InfoGrab Docs

전용 서버에서 Teleport Terraform 프로바이더 실행하기

요약

이 가이드에서는 영구적인 Linux 또는 macOS 서버에서 Teleport용 Terraform 프로바이더를 설정하는 방법을 설명합니다. 이 가이드는 Terraform 프로바이더를 로컬에서 실행하거나, CI/CD 및 단기간 클라우드 VM 같은 임시 환경에서 실행하는 방법은 다루지 않습니다.

이 가이드에서는 영구적인 Linux 또는 macOS 서버에서 Teleport용 Terraform 프로바이더를 설정하는 방법을 설명합니다.

이 가이드는 Terraform 프로바이더를 로컬에서 실행하거나, CI/CD 및 단기간 클라우드 VM 같은 임시 환경에서 실행하는 방법은 다루지 않습니다. 해당 경우에는 전용 가이드를 참조하세요:

이 가이드에서는 서버에 Teleport 머신 및 워크로드 아이덴티티를 설정합니다. 머신 및 워크로드 아이덴티티는 사람 사용자가 아닌 머신 및 서비스에 ID를 제공합니다.

동작 방식#

이 설정은 머신 및 워크로드 아이덴티티 데몬(tbot)이 Teleport 클러스터에 참여하여 Terraform 프로바이더에 필요한 자격 증명을 획득하고 갱신하는 방식으로 동작합니다. 데몬은 디스크에 ID를 저장하고 일반적으로 30분마다 Terraform 자격 증명을 갱신합니다.

사전 요구 사항#

  • A running Teleport cluster. If you want to get started with Teleport, sign up for a free trial or set up a demo environment.

  • The tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Determine the version of your Teleport cluster. The tctl and tsh clients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at /v1/webapi/find and use a JSON query tool to obtain your cluster version. Replace with the web address of your Teleport Proxy Service:

      $ TELEPORT_DOMAIN=
      $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')"
      
    2. Follow the instructions for your platform to install tctl and tsh clients:

To check that you can connect to your Teleport cluster, sign in with tsh login, then verify that you can run tctl commands using your current credentials.

For example, run the following command, assigning to the domain name of the Teleport Proxy Service in your cluster and to your Teleport username:

$ tsh login --proxy= --user=
$ tctl status
# Cluster  (=teleport.url=)
# Version  (=teleport.version=)
# CA pin   (=presets.ca_pin=)

If you can connect to the cluster and run the tctl status command, you can use your current credentials to run subsequent tctl commands from your workstation. If you host your own Teleport cluster, you can also run tctl commands on the computer that hosts the Teleport Auth Service for full permissions.

  • Teleport Terraform 프로바이더를 실행하려는 Linux 호스트.

  • Terraform 및 tbot을 실행할 해당 호스트의 Linux 사용자.

1/4단계. 서버에 tbot 설치하기#

tbot을 설치하고 Teleport 클러스터에 참여시켜야 합니다. 이를 위해 3단계까지 Linux용 tbot 배포 가이드를 따르세요.

2/4단계. RBAC 구성하기#

이 시점에서 tbot은 Terraform을 실행할 머신에 설치 및 구성되어 있습니다.

Starting with 16.2, Teleport comes with a built-in role for the Terraform provider: terraform-provider.

RBAC for versions before v16.2 On older version you will need to create the Terraform role yourself. Write the following `role.yaml` manifest:
```yaml
kind: role
version: v7
metadata:
  name: terraform-provider
spec:
  allow:
    db_labels:
      '*': '*'
    app_labels:
      '*': '*'
    node_labels:
      '*': '*'
    rules:
      - resources:
        - app
        - cluster_auth_preference
        - cluster_networking_config
        - db
        - device
        - github
        - login_rule
        - oidc
        - okta_import_rule
        - role
        - saml
        - session_recording_config
        - token
        - trusted_cluster
        - user
        - access_list
        - node
        verbs: ['list','create','read','update','delete']
```

Use `tctl create -f ./role.yaml` to create the role.

tctl bots update 명령을 사용하여 Bot에 역할을 추가합니다. example을 배포 가이드에서 생성한 Bot의 이름으로 교체하세요.

$ tctl bots update example --add-roles terraform-provider

3/4단계. tbot 출력 구성하기#

이제 tbot에 Terraform 프로바이더에 필요한 자격 증명을 생성하는 출력을 구성해야 합니다. Terraform 프로바이더가 Teleport API에 접근할 것이므로, 사용할 올바른 출력 유형은 identity입니다.

이 가이드에서는 directory 대상을 사용합니다. 이렇게 하면 자격 증명이 디스크의 특정 디렉터리에 기록됩니다. tbot이 실행되는 Linux 사용자가 이 디렉터리에 쓸 수 있고, Terraform이 실행되는 Linux 사용자가 읽을 수 있도록 하세요.

tbot 구성을 수정하여 identity 출력을 추가하세요:

services:
- type: identity
  destination:
    type: directory
    # 이 가이드에서는 /opt/machine-id를 대상 디렉터리로 사용합니다.
    # 이를 사용자 정의할 수 있습니다. 여러 출력이 같은
    # 대상을 공유할 수 없습니다.
    path: /opt/machine-id

tbot을 백그라운드 서비스로 운영하는 경우 재시작합니다. tbot을 원샷 모드(백그라운드 프로세스를 실행하지 않고 자격 증명을 생성하고 프로세스를 종료하는 방식)로 실행하는 경우, 나중에 Terraform 플랜을 실행하기 전에 먼저 실행해야 합니다.

이제 /opt/machine-id 아래에 identity 파일이 생성됩니다. 이 파일에는 Terraform 프로바이더가 Teleport Auth Service로 인증하는 데 필요한 개인 키와 서명된 인증서가 포함되어 있습니다.

4/4단계. Terraform 실행하기#

새 Terraform 작업 디렉터리를 생성하는 것부터 시작합니다:

$ mkdir ./my-terraform && cd ./my-terraform
$ terraform init

머신 및 워크로드 아이덴티티가 출력하는 자격 증명을 사용하도록 Teleport Terraform 프로바이더를 구성하려면 identity_file_path 옵션을 사용합니다.

이 디렉터리에 main.tf를 생성합니다:

terraform {
  required_providers {
    teleport = {
      version = "(=teleport.version=)"
      source  = "terraform.releases.teleport.dev/gravitational/teleport"
    }
  }
}

provider "teleport" {
  # Teleport 프록시 또는 Auth Service의 주소로 교체하세요.
  addr               = "teleport.example.com:443"
  # 이전 단계의 identity 출력에서 구성된 디렉터리로 교체하세요.
  identity_file_path = "/opt/machine-id/identity"
}

# 테스트 역할을 생성해야 합니다. 리소스를 선언하지 않으면 Terraform이
# Teleport에 연결을 시도하지 않아 설정을 검증할 수 없습니다.
resource "teleport_role" "terraform-test" {
  version = "v7"
  metadata = {
    name        = "terraform-test"
    description = "Example role created by Terraform"
  }

  spec = {
    # 이것은 예제 역할이므로 아무것도 하지 않습니다.
    allow = {}
  }
}

teleport.example.com:443을 Teleport 프록시 서비스 또는 Auth Service 주소로 교체하세요. /opt/machine-id에서 대상 디렉터리를 변경했다면 이 부분도 교체해야 합니다.

이제 구성을 테스트하기 위해 Terraform을 실행합니다:

$ terraform init
$ terraform plan
$ terraform apply

Teleport 클러스터를 확인하여 역할이 생성되었는지 확인합니다:

$ tctl get role/terraform-test

다음 단계#

전용 서버에서 Teleport Terraform 프로바이더 실행하기

원문 보기
요약

이 가이드에서는 영구적인 Linux 또는 macOS 서버에서 Teleport용 Terraform 프로바이더를 설정하는 방법을 설명합니다. 이 가이드는 Terraform 프로바이더를 로컬에서 실행하거나, CI/CD 및 단기간 클라우드 VM 같은 임시 환경에서 실행하는 방법은 다루지 않습니다.

이 가이드에서는 영구적인 Linux 또는 macOS 서버에서 Teleport용 Terraform 프로바이더를 설정하는 방법을 설명합니다.

이 가이드는 Terraform 프로바이더를 로컬에서 실행하거나, CI/CD 및 단기간 클라우드 VM 같은 임시 환경에서 실행하는 방법은 다루지 않습니다. 해당 경우에는 전용 가이드를 참조하세요:

이 가이드에서는 서버에 Teleport 머신 및 워크로드 아이덴티티를 설정합니다. 머신 및 워크로드 아이덴티티는 사람 사용자가 아닌 머신 및 서비스에 ID를 제공합니다.

동작 방식#

이 설정은 머신 및 워크로드 아이덴티티 데몬(tbot)이 Teleport 클러스터에 참여하여 Terraform 프로바이더에 필요한 자격 증명을 획득하고 갱신하는 방식으로 동작합니다. 데몬은 디스크에 ID를 저장하고 일반적으로 30분마다 Terraform 자격 증명을 갱신합니다.

사전 요구 사항#

  • A running Teleport cluster. If you want to get started with Teleport, sign up for a free trial or set up a demo environment.

  • The tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Determine the version of your Teleport cluster. The tctl and tsh clients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at /v1/webapi/find and use a JSON query tool to obtain your cluster version. Replace with the web address of your Teleport Proxy Service:

      $ TELEPORT_DOMAIN=
      $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')"
      
    2. Follow the instructions for your platform to install tctl and tsh clients:

To check that you can connect to your Teleport cluster, sign in with tsh login, then verify that you can run tctl commands using your current credentials.

For example, run the following command, assigning to the domain name of the Teleport Proxy Service in your cluster and to your Teleport username:

$ tsh login --proxy= --user=
$ tctl status
# Cluster  (=teleport.url=)
# Version  (=teleport.version=)
# CA pin   (=presets.ca_pin=)

If you can connect to the cluster and run the tctl status command, you can use your current credentials to run subsequent tctl commands from your workstation. If you host your own Teleport cluster, you can also run tctl commands on the computer that hosts the Teleport Auth Service for full permissions.

  • Teleport Terraform 프로바이더를 실행하려는 Linux 호스트.

  • Terraform 및 tbot을 실행할 해당 호스트의 Linux 사용자.

1/4단계. 서버에 tbot 설치하기#

tbot을 설치하고 Teleport 클러스터에 참여시켜야 합니다. 이를 위해 3단계까지 Linux용 tbot 배포 가이드를 따르세요.

2/4단계. RBAC 구성하기#

이 시점에서 tbot은 Terraform을 실행할 머신에 설치 및 구성되어 있습니다.

Starting with 16.2, Teleport comes with a built-in role for the Terraform provider: terraform-provider.

RBAC for versions before v16.2 On older version you will need to create the Terraform role yourself. Write the following `role.yaml` manifest:
```yaml
kind: role
version: v7
metadata:
  name: terraform-provider
spec:
  allow:
    db_labels:
      '*': '*'
    app_labels:
      '*': '*'
    node_labels:
      '*': '*'
    rules:
      - resources:
        - app
        - cluster_auth_preference
        - cluster_networking_config
        - db
        - device
        - github
        - login_rule
        - oidc
        - okta_import_rule
        - role
        - saml
        - session_recording_config
        - token
        - trusted_cluster
        - user
        - access_list
        - node
        verbs: ['list','create','read','update','delete']
```

Use `tctl create -f ./role.yaml` to create the role.

tctl bots update 명령을 사용하여 Bot에 역할을 추가합니다. example을 배포 가이드에서 생성한 Bot의 이름으로 교체하세요.

$ tctl bots update example --add-roles terraform-provider

3/4단계. tbot 출력 구성하기#

이제 tbot에 Terraform 프로바이더에 필요한 자격 증명을 생성하는 출력을 구성해야 합니다. Terraform 프로바이더가 Teleport API에 접근할 것이므로, 사용할 올바른 출력 유형은 identity입니다.

이 가이드에서는 directory 대상을 사용합니다. 이렇게 하면 자격 증명이 디스크의 특정 디렉터리에 기록됩니다. tbot이 실행되는 Linux 사용자가 이 디렉터리에 쓸 수 있고, Terraform이 실행되는 Linux 사용자가 읽을 수 있도록 하세요.

tbot 구성을 수정하여 identity 출력을 추가하세요:

services:
- type: identity
  destination:
    type: directory
    # 이 가이드에서는 /opt/machine-id를 대상 디렉터리로 사용합니다.
    # 이를 사용자 정의할 수 있습니다. 여러 출력이 같은
    # 대상을 공유할 수 없습니다.
    path: /opt/machine-id

tbot을 백그라운드 서비스로 운영하는 경우 재시작합니다. tbot을 원샷 모드(백그라운드 프로세스를 실행하지 않고 자격 증명을 생성하고 프로세스를 종료하는 방식)로 실행하는 경우, 나중에 Terraform 플랜을 실행하기 전에 먼저 실행해야 합니다.

이제 /opt/machine-id 아래에 identity 파일이 생성됩니다. 이 파일에는 Terraform 프로바이더가 Teleport Auth Service로 인증하는 데 필요한 개인 키와 서명된 인증서가 포함되어 있습니다.

4/4단계. Terraform 실행하기#

새 Terraform 작업 디렉터리를 생성하는 것부터 시작합니다:

$ mkdir ./my-terraform && cd ./my-terraform
$ terraform init

머신 및 워크로드 아이덴티티가 출력하는 자격 증명을 사용하도록 Teleport Terraform 프로바이더를 구성하려면 identity_file_path 옵션을 사용합니다.

이 디렉터리에 main.tf를 생성합니다:

terraform {
  required_providers {
    teleport = {
      version = "(=teleport.version=)"
      source  = "terraform.releases.teleport.dev/gravitational/teleport"
    }
  }
}

provider "teleport" {
  # Teleport 프록시 또는 Auth Service의 주소로 교체하세요.
  addr               = "teleport.example.com:443"
  # 이전 단계의 identity 출력에서 구성된 디렉터리로 교체하세요.
  identity_file_path = "/opt/machine-id/identity"
}

# 테스트 역할을 생성해야 합니다. 리소스를 선언하지 않으면 Terraform이
# Teleport에 연결을 시도하지 않아 설정을 검증할 수 없습니다.
resource "teleport_role" "terraform-test" {
  version = "v7"
  metadata = {
    name        = "terraform-test"
    description = "Example role created by Terraform"
  }

  spec = {
    # 이것은 예제 역할이므로 아무것도 하지 않습니다.
    allow = {}
  }
}

teleport.example.com:443을 Teleport 프록시 서비스 또는 Auth Service 주소로 교체하세요. /opt/machine-id에서 대상 디렉터리를 변경했다면 이 부분도 교체해야 합니다.

이제 구성을 테스트하기 위해 Terraform을 실행합니다:

$ terraform init
$ terraform plan
$ terraform apply

Teleport 클러스터를 확인하여 역할이 생성되었는지 확인합니다:

$ tctl get role/terraform-test

다음 단계#