InfoGrab DocsInfoGrab Docs

Terraform EC2 자동 검색 구성

요약

이 가이드는 Terraform을 사용하여 클러스터에서 EC2 인스턴스를 자동으로 등록하도록 Teleport와 AWS를 구성하는 방법을 설명합니다. teleport-discovery-aws Terraform 모듈은 Teleport EC2 자동 검색을 활성화하기 위해 Teleport 클러스터와 AWS 계정에 리소스를 생성합니다.

이 가이드는 Terraform을 사용하여 클러스터에서 EC2 인스턴스를 자동으로 등록하도록 Teleport와 AWS를 구성하는 방법을 설명합니다.

작동 방식#

teleport-discovery-aws Terraform 모듈은 Teleport EC2 자동 검색을 활성화하기 위해 Teleport 클러스터와 AWS 계정에 리소스를 생성합니다.

Teleport Discovery Service는 AWS API를 쿼리하여 계정 내 EC2 인스턴스 목록을 가져옵니다. Discovery Service는 검색된 각 EC2 인스턴스에 대해 AWS Systems Manager(SSM)를 사용하여 해당 인스턴스에 Teleport를 설치하고 이를 Teleport가 보호하는 서버로 클러스터에 조인시킵니다.

사전 요구사항#

  • 실행 중인 Teleport 클러스터. Teleport를 시작하려면 무료 체험판에 가입하거나 데모 환경을 구성하세요.

  • tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Teleport 클러스터의 버전을 확인합니다. tctl and tsh clients는 Teleport 클러스터 버전보다 최대 한 개의 메이저 버전까지만 뒤처질 수 있습니다. Proxy Service의 /v1/webapi/find로 GET 요청을 보내고 JSON 쿼리 도구를 사용하여 클러스터 버전을 확인합니다. teleport.example.com:443를 Teleport Proxy Service의 웹 주소로 바꿉니다:

      $ TELEPORT_DOMAIN=teleport.example.com:443
      $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')"
      
    2. 사용 중인 플랫폼에 대한 지침에 따라 tctl and tsh clients를 설치합니다:

Mac

     `tctl` and `tsh` clients가 포함된, 서명된 Teleport macOS .pkg 설치 프로그램을 다운로드합니다:
 
     ```code
     $ curl -O https://cdn.teleport.dev/teleport-${TELEPORT_VERSION?}.pkg
     ```

     Finder에서 `pkg` 파일을 더블 클릭하여 설치를 시작합니다.
 
     
Warning
       Homebrew를 사용하여 Teleport를 설치하는 것은 지원되지 않습니다. Homebrew의
       Teleport 패키지는 Teleport에서 유지 관리하지 않으므로 신뢰성이나 보안을
       보장할 수 없습니다.
     

Windows - Powershell

     ```code
     $ curl.exe -O https://cdn.teleport.dev/teleport-v${TELEPORT_VERSION?}-windows-amd64-bin.zip
     # Unzip the archive and move the `tctl` and `tsh` clients to your %PATH%
     # NOTE: Do not place the `tctl` and `tsh` clients in the System32 directory, as this can cause issues when using WinSCP.
     # Use %SystemRoot% (C:\Windows) or %USERPROFILE% (C:\Users\<username>) instead.
     ```
 
   

 
   

Linux

     Linux 설치판의 모든 Teleport 바이너리에는 `tctl` and `tsh` clients가 포함되어 있습니다.  RPM/DEB
     패키지 및 i386/ARM/ARM64용 다운로드를 포함한 더 많은 옵션은
     [설치 페이지](../installation/installation.mdx)를 참조하세요.
 
     ```code
     $ curl -O https://cdn.teleport.dev/teleport-v${TELEPORT_VERSION?}-linux-amd64-bin.tar.gz
     $ tar -xzf teleport-v${TELEPORT_VERSION?}-linux-amd64-bin.tar.gz
     $ cd teleport
     $ sudo ./install
     # Teleport binaries have been copied to /usr/local/bin
     ```
   

 
  • Ubuntu/Debian/RHEL/Amazon Linux 2/Amazon Linux 2023을 실행하는 EC2 인스턴스와 SSM Agent 버전 3.1 이상

Teleport cluster에 연결할 수 있는지 확인하려면 tsh login으로 로그인한 다음, 현재 자격 증명으로 tctl 명령을 실행할 수 있는지 확인합니다.

예를 들어, teleport.example.com에 cluster 내 Teleport Proxy Service의 도메인 이름을, email@example.com에 Teleport 사용자 이름을 지정하여 다음 명령을 실행합니다:

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

cluster에 연결하여 tctl status 명령을 실행할 수 있다면, 현재 자격 증명을 사용하여 워크스테이션에서 이후의 tctl 명령을 실행할 수 있습니다. 자체 Teleport cluster를 호스팅하는 경우, 전체 권한을 얻기 위해 Teleport Auth Service를 호스팅하는 컴퓨터에서 tctl 명령을 실행할 수도 있습니다.

Note

Discovery Service에 의해 Teleport 클러스터에 추가된 모든 EC2 인스턴스는 Discovery Service로부터 명령을 수신하기 위해 AmazonSSMManagedInstanceCore IAM 정책을 반드시 포함해야 합니다. 해당 정책에 포함된 권한 목록은 AWS 문서를 참조하세요.

Discovery Service를 실행할 Teleport 설치#

Tip

이미 실행 중인 Discovery Service 인스턴스가 있다면, 해당 인스턴스의 discovery_groupdiscovery-group-name에 할당하고 teleport-discovery-aws Terraform 모듈 사용하기로 진행하세요.

모든 Teleport Cloud 클러스터는 Discovery Service를 사용자를 대신하여 실행하므로, Teleport Cloud 구독자는 이 설치 단계를 모두 건너뛸 수 있습니다.

1/3단계. Teleport 설치#

Discovery Service를 다른 Teleport 서비스(예: Auth 또는 Proxy)가 이미 실행 중인 동일한 호스트에서 실행할 계획이라면 이 단계는 건너뛰어도 됩니다.

Discovery Service를 실행할 호스트 인스턴스에 Teleport를 설치합니다.

Linux 서버에 Teleport Agent를 설치하려면:

권장 설치 방법은 클러스터 설치 스크립트입니다. 이 스크립트는 클러스터에 맞는 올바른 버전, 에디션, 설치 모드를 선택합니다.

  1. teleport.example.com:443에 Teleport 클러스터의 호스트명과 포트를 할당하되, 스킴(https://)은 포함하지 마십시오.

  2. 클러스터의 설치 스크립트를 실행하십시오:

    $ curl "https://teleport.example.com:443/scripts/install.sh" | sudo bash
    

2/3단계. Discovery Service 구성#

Discovery Service를 자체 호스트에서 실행하는 경우, 해당 서비스는 클러스터에 연결하기 위한 유효한 초대 토큰이 필요합니다. Teleport Auth Service를 대상으로 다음 명령을 실행하여 토큰을 생성합니다.

$ tctl tokens add --type=discovery

생성된 토큰을 Discovery Service를 실행할 노드(EC2 인스턴스)의 /tmp/token에 저장합니다.

Warning

Discovery Service는 검색된 리소스를 서로 다른 집합으로 그룹화할 수 있게 하는 구성 파라미터 discovery_service.discovery_group을 제공합니다. 이 파라미터는 서로 다른 클라우드 리소스 집합을 감시하는 Discovery Agent들이 서로 충돌하여 다른 서비스가 생성한 리소스를 삭제하는 것을 방지하는 데 사용됩니다.

여러 개의 Discovery Service를 실행할 때, 동일한 클라우드 리소스를 감시하는 경우에는 각 서비스가 동일한 discovery_group 값으로 구성되어 있는지 확인해야 하며, 서로 다른 클라우드 리소스를 감시하는 경우에는 서로 다른 값으로 구성해야 합니다.

동일한 Teleport 클러스터에서 구성을 혼합하여 실행할 수 있습니다. 즉 일부 Discovery Service는 동일한 클라우드 리소스를 감시하도록 구성하고 다른 서비스는 서로 다른 리소스를 감시하도록 구성할 수 있습니다. 예를 들어, 서로 다른 두 개의 클라우드 계정에서 데이터를 분석하는 4개 에이전트 고가용성 구성은 다음과 같은 구성으로 실행됩니다.

  • Production 계정에서 데이터를 폴링하는 discovery_group: "prod"로 구성된 Discovery Service 2개.
  • Staging 계정에서 데이터를 폴링하는 discovery_group: "staging"로 구성된 Discovery Service 2개.

teleport.example.com:443를 클러스터 내 Teleport Proxy Service의 호스트 및 포트로 할당하고, discovery-group-name을 등록할 리소스 그룹을 식별하는 이름으로 할당합니다.

# teleport.yaml
version: v3
teleport:
  join_params:
    # token_name can be a literal token string or a path to a file.
    # File path is preferable to avoid including a secret in the config file.
    token_name: "/tmp/token"
    method: token
  proxy_server: "teleport.example.com:443"
auth_service:
  enabled: false
proxy_service:
  enabled: false
ssh_service:
  enabled: false
discovery_service:
  enabled: true
  discovery_group: "discovery-group-name"

3/3단계. Teleport 시작#

the Discovery Service이(가) AWS에 인증하는 데 사용할 수 있는 자격 증명에 대한 접근 권한을 부여합니다.

  • the Discovery Service을(를) EC2 인스턴스에서 실행하는 경우 EC2 Instance Metadata Service 방식을 사용할 수 있습니다
  • the Discovery Service을(를) Kubernetes에서 실행하는 경우 IAM Roles for Service Accounts (IRSA)를 사용할 수 있습니다
  • 그 외의 경우에는 환경 변수를 사용해야 합니다

Instance Metadata Service

Teleport는 EC2 인스턴스에서 실행 중일 때를 감지하고 Instance Metadata Service를 사용하여 자격 증명을 가져옵니다.

EC2 인스턴스는 EC2 인스턴스 프로파일을 사용하도록 구성되어야 합니다. 자세한 내용은 Using Instance Profiles를 참고하세요.

Kubernetes IRSA

AWS에서 OIDC provider를 설정하고 pod의 서비스 계정이 role을 assume할 수 있도록 허용하는 AWS IAM role을 구성하려면 IAM Roles for Service Accounts (IRSA)를 참고하세요.

Environment Variables

Teleport의 내장 AWS 클라이언트는 다음 환경 변수에서 자격 증명을 읽습니다:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_DEFAULT_REGION

the Discovery Service을(를) 시작하면 서비스는 /etc/default/teleport 경로의 파일에서 환경 변수를 읽습니다. 이러한 자격 증명은 조직에서 얻으세요. 각 변수의 값을 교체하여 /etc/default/teleport가 다음 내용을 담도록 하세요:

AWS_ACCESS_KEY_ID=00000000000000000000
AWS_SECRET_ACCESS_KEY=0000000000000000000000000000000000000000
AWS_DEFAULT_REGION=
AWS 자격 증명 소스가 여러 개인가요?

Teleport의 AWS 클라이언트는 다음 순서로 여러 소스에서 자격 증명을 로드합니다:

  • 환경 변수
  • 공유 자격 증명 파일
  • 공유 구성 파일 (Teleport는 항상 공유 구성을 활성화합니다)
  • EC2 Instance Metadata (자격 증명만)

공유 자격 증명 파일이나 공유 구성 파일을 통해 AWS 자격 증명을 제공할 수 있지만, 원하는 프로파일의 이름을 AWS_PROFILE 환경 변수에 할당하여 the Discovery Service을(를) 실행해야 합니다.

위의 지침이 다루지 않는 특정 사용 사례가 있다면, 자격 증명 로딩 동작에 대한 자세한 설명은 AWS SDK for Go 문서를 참고하세요.

systemd 서비스를 생성하여 호스트가 부팅될 때 the Discovery Service이 자동으로 시작되도록 구성합니다. 지침은 the Discovery Service을 어떻게 설치했는지에 따라 다릅니다.

Package Manager

the Discovery Service을 실행할 호스트에서 Teleport를 활성화하고 시작합니다:

$ sudo systemctl enable teleport
$ sudo systemctl start teleport

TAR Archive

the Discovery Service을 실행할 호스트에서 Teleport용 systemd 서비스 구성을 생성하고, Teleport 서비스를 활성화한 후 Teleport를 시작합니다:

$ sudo teleport install systemd -o /etc/systemd/system/teleport.service
$ sudo systemctl enable teleport
$ sudo systemctl start teleport

systemctl status teleport로 the Discovery Service의 상태를 확인하고 journalctl -fu teleport로 로그를 볼 수 있습니다.

teleport-discovery-aws Terraform 모듈 사용하기#

1/5단계. AWS Terraform 공급자 구성#

Terraform이 AWS 리소스를 관리할 수 있도록 AWS Terraform 공급자와 AWS IAM 권한을 구성합니다.

AWS Terraform 공급자에 필요한 AWS IAM 권한

AWS Terraform 공급자가 teleport-discovery-aws 모듈에서 생성한 AWS 리소스를 관리하려면 다음과 같은 AWS IAM 권한이 필요합니다.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "TerraformIdentity",
      "Effect": "Allow",
      "Action": "sts:GetCallerIdentity",
      "Resource": "*"
    },
    {
      "Sid": "ManageIamRole",
      "Effect": "Allow",
      "Action": [
        "iam:CreateRole",
        "iam:DeleteRole",
        "iam:GetRole",
        "iam:ListInstanceProfilesForRole",
        "iam:ListRolePolicies",
        "iam:ListRoles",
        "iam:ListRoleTags",
        "iam:TagRole",
        "iam:UntagRole",
        "iam:UpdateAssumeRolePolicy"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ManageIamPolicy",
      "Effect": "Allow",
      "Action": [
        "iam:CreatePolicy",
        "iam:CreatePolicyVersion",
        "iam:DeletePolicy",
        "iam:DeletePolicyVersion",
        "iam:GetPolicy",
        "iam:GetPolicyVersion",
        "iam:ListPolicies",
        "iam:ListPolicyTags",
        "iam:ListPolicyVersions",
        "iam:TagPolicy",
        "iam:UntagPolicy"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ManageRolePolicyAttachments",
      "Effect": "Allow",
      "Action": [
        "iam:AttachRolePolicy",
        "iam:DetachRolePolicy",
        "iam:ListAttachedRolePolicies"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ManageOidcProvider",
      "Effect": "Allow",
      "Action": [
        "iam:CreateOpenIDConnectProvider",
        "iam:DeleteOpenIDConnectProvider",
        "iam:GetOpenIDConnectProvider",
        "iam:ListOpenIDConnectProviders",
        "iam:TagOpenIDConnectProvider",
        "iam:UntagOpenIDConnectProvider",
        "iam:UpdateOpenIDConnectProviderThumbprint"
      ],
      "Resource": "*"
    }
  ]
}

2/5단계. Teleport Terraform 공급자 구성#

Terraform을 실행하려는 방식(예: CI, Spacelift, 또는 다른 원격 환경)에 따라 Teleport Terraform 공급자를 구성하는 여러 방법이 있지만, 빠르게 시작하려면 로컬 데모 가이드를 참조하세요.

로컬 데모 가이드에서는 로컬 Teleport 자격 증명을 사용하여 Teleport Terraform 공급자를 구성하는 방법을 안내하는데, 이는 일반적으로 tsh로 로그인한 다음 terraform 명령을 실행할 셸에서 tctl 명령을 실행하는 것만큼 간단합니다.

$ tsh login
$ eval "$(tctl terraform env)"

클라우드 VM, 온프레미스 서버, CI/CD 파이프라인과 같은 원격 환경에서 Terraform을 실행하는 경우, 사용 사례에 적합한 가이드를 찾으려면 Teleport Terraform 공급자 사용하기를 참조하세요.

3/5단계. Terraform 모듈 입력값 구성#

Terraform 구성에 teleport-discovery-aws 모듈을 추가합니다.

module "aws_discovery" {
  source = "terraform.releases.teleport.dev/teleport/discovery/aws"
  version = "~> (=cloud.major_version=).0"

  # Required inputs:
  # Assign example.teleport.sh:443 to your Teleport cluster's proxy public address in host:port form.
  teleport_proxy_public_addr = "https://example.teleport.sh:443"
  # teleport_discovery_group_name must match the discovery group name in your Discovery Service config file.
  # Teleport Cloud clusters run the Discovery Service in the group name "cloud-discovery-group".
  # Do not modify this input unless you intend to run your own Discovery Service.
  teleport_discovery_group_name = "cloud-discovery-group"
  # Discover EC2 instances
  match_aws_resource_types = ["ec2"]

  # Optional inputs:
  # Apply the additional AWS tag "origin=example" to all AWS resources created by this module
  apply_aws_tags = { origin = "example" }
  # Apply the additional Teleport label "origin=example" to all Teleport resources created by this module
  apply_teleport_resource_labels = { origin = "example" }
  # match_aws_regions is a list of regions in which the Discovery Service will match and discover EC2 instances.
  # The wildcard "*" is the default and matches all regions.
  match_aws_regions = ["*"]
  # match_aws_tags are AWS tags to match when discovering EC2 instances.
  # Only EC2 instances with matching tags will be discovered.
  # The wildcard {"*" : ["*"]} is the default and matches all tags.
  match_aws_tags = { "*" : ["*"] }
}
module "aws_discovery" {
  source = "terraform.releases.teleport.dev/teleport/discovery/aws"
  version = "~> (=teleport.major_version=).0"

  # Required inputs:
  # Edit this input to the host and port of the Teleport Proxy Service in your cluster
  teleport_proxy_public_addr    = "https://teleport.example.com:443"
  # Edit this input to match the discovery group name in your Discovery Service config file
  teleport_discovery_group_name = "discovery-group-name"
  # Discover EC2 instances
  match_aws_resource_types = ["ec2"]

  # Optional inputs:
  # Apply the additional AWS tag "origin=example" to all AWS resources created by this module
  apply_aws_tags = { origin = "example" }
  # Apply the additional Teleport label "origin=example" to all Teleport resources created by this module
  apply_teleport_resource_labels = { origin = "example" }
  # match_aws_regions is a list of regions in which the Discovery Service will match and discover EC2 instances.
  # The wildcard "*" is the default and matches all regions.
  match_aws_regions = ["*"]
  # match_aws_tags are AWS tags to match when discovering EC2 instances.
  # Only EC2 instances with matching tags will be discovered.
  # The wildcard {"*" : ["*"]} is the default and matches all tags.
  match_aws_tags = { "*" : ["*"] }
}

모듈에 Terraform 출력값을 추가하여 Terraform이 해당 출력값을 표시하도록 합니다.

output "aws_discovery" {
  value = module.aws_discovery
}

모듈 입력값 및 출력값에 대한 전체 설명은 teleport-discovery-aws 참조를 참조하세요.

4/5단계. Terraform 모듈 적용#

$ terraform init
$ terraform apply

Terraform은 다음 리소스를 생성하도록 계획을 세워야 합니다.

  • Teleport Discovery Service가 위임(assume)할 AWS IAM 역할
  • Teleport가 AWS에서 리소스를 검색하는 데 필요한 AWS 권한을 부여하는 AWS IAM 정책
  • IAM 정책을 Discovery Service IAM 역할에 연결하는 AWS IAM 정책 연결
  • Teleport Discovery Service가 OIDC를 사용하여 IAM 역할을 위임(assume)할 수 있도록 하는 AWS OIDC 공급자
  • AWS 리소스 검색을 위해 Teleport를 구성하는 Teleport discovery_config 클러스터 리소스
  • AWS OIDC용 Teleport integration 클러스터 리소스
  • Teleport 노드가 AWS IAM 자격 증명을 사용하여 클러스터에 조인할 수 있도록 하는 Teleport token 클러스터 리소스

Terraform 계획을 검토하고 계획 작업을 확인합니다.

Terraform이 계획 적용을 마치면 모듈 출력값을 표시해야 합니다.

aws_discovery = {
  "aws_oidc_provider_arn" = "arn:aws:iam::123456789012:oidc-provider/example.teleport.sh"
  "teleport_discovery_config_name" = "discovery-aws-account-123456789012"
  "teleport_discovery_service_iam_policy_arn" = "arn:aws:iam::123456789012:policy/teleport-discovery-<timestamp>"
  "teleport_discovery_service_iam_role_arn" = "arn:aws:iam::123456789012:role/teleport-discovery-<timestamp>"
  "teleport_integration_name" = "discovery-aws-account-123456789012"
  "teleport_provision_token_name" = "discovery-aws-account-123456789012"
}

AWS 리소스에는 다음 태그가 있어야 합니다.

  • origin=example
  • teleport.dev/cluster=<cluster-name>
  • teleport.dev/integration=discovery-aws-account-<account-id>
  • teleport.dev/iac-tool=terraform

Teleport 리소스에는 다음 라벨이 있어야 합니다.

  • origin=example
  • teleport.dev/iac-tool=terraform

5/5단계. 검색 상태 확인#

Terraform 모듈을 적용한 후, Teleport Discovery Service는 AWS 계정 내 EC2 인스턴스를 검색하여 보호된 리소스로 클러스터에 등록하기 시작해야 합니다.

Note

EC2 인스턴스가 검색되어 등록되기까지 몇 분 정도 걸릴 수 있습니다.

Teleport Web UI로 이동하여 Zero Trust Access > Integrations를 선택합니다. 기본적으로 teleport-discovery-aws Terraform 모듈에 의해 생성된 통합은 discovery-aws-account-<aws-account-id>라는 이름을 갖습니다.

AWS 계정에 대한 통합을 클릭하여 검색 상태를 검토합니다.

통합 페이지는 검색된 EC2 인스턴스 수와 검색 과정에서 발생한 문제에 대한 개요를 제공합니다.

비정상 상태의 검색 통합 개요

위 예시에서는 인스턴스의 AWS SSM 에이전트에 문제가 있었음을 확인할 수 있습니다.

"issues" 탭으로 이동하여 "Details"를 클릭하면 해당 문제에 대한 자세한 정보를 확인할 수 있습니다.

SSM 설치 문제

이 경우 문제는 EC2 인스턴스에 AmazonSSMManagedInstanceCore IAM 정책이 연결된 IAM 역할이 없어서 인스턴스가 SSM 명령을 수신할 수 없다는 것입니다.

이 문제는 AmazonSSMManagedInstanceCore IAM 정책을 EC2 인스턴스의 역할에 연결하고 Discovery Service가 SSM을 사용한 설치를 재시도할 때까지 기다리면 해결할 수 있습니다. 다음 검색 스캔이 실행되어 인스턴스에 Teleport를 설치하기까지 몇 분 정도 걸릴 수 있습니다.

검색된 모든 EC2 인스턴스가 Teleport 클러스터에 성공적으로 조인되면 개요 페이지에는 정상 상태가 표시됩니다.

정상 상태의 검색 통합 개요

모듈 구성 업데이트#

모듈 입력값을 변경하고 다시 적용하여 AWS 검색 통합을 조정할 수 있습니다.

예를 들어, 이전에 (모든 리전에 대한 와일드카드 기본값 대신) 특정 AWS 리전을 사용했다면, match_aws_regions를 조정하여 EC2 검색을 위한 리전을 추가하고 모듈을 다시 적용하여 해당 리전에서도 인스턴스를 등록하기 시작할 수 있습니다.

-match_aws_regions = ["us-west-1"]
+match_aws_regions = ["us-west-1", "us-east-1"]

Terraform을 다시 적용합니다.

$ terraform apply

변경 사항을 확인하기 전에 Terraform 계획을 검토하세요.

Terraform이 계획 적용을 마치면 Discovery Service는 동적 discovery_config의 변경 사항을 반영하여 us-east-1에서도 EC2 인스턴스를 등록하기 시작합니다.

문제 해결#

설치가 실패로 표시되거나 인스턴스가 나타나지 않는 경우, AWS System Manager -> Node Management -> Run Command에서 Command 이력을 확인하십시오. Target의 instance-id를 선택하여 오류를 검토하십시오.

cannot unmarshal object into Go struct field#

다음과 유사한 오류가 발생하는 경우:

invalid format in plugin properties map[destinationPath:/tmp/installTeleport.sh sourceInfo:map[url:[https://example.teleport.sh:443/webapi/scripts/installer/preprod-installer](https://example.teleport.sh/webapi/scripts/installer/preprod-installer)] sourceType:HTTP];
error json: cannot unmarshal object into Go struct field DownloadContentPlugin.sourceInfo of type string

이는 오래된 버전의 SSM agent를 실행하고 있을 가능성이 높습니다. 이 문제를 해결하려면 SSM agent 버전 3.1 이상으로 업그레이드하십시오.

InvalidInstanceId: Instances [[i-123]] not in a valid state for account 456#

다음과 같은 문제로 인해 이 오류가 발생할 수 있습니다:

  • Discovery Service에 관리 노드에 접근할 권한이 없습니다.
  • AWS Systems Manager Agent(SSM Agent)가 실행되고 있지 않습니다. SSM Agent가 실행 중인지 확인하십시오.
  • SSM Agent가 SSM 엔드포인트에 등록되어 있지 않습니다. SSM Agent를 재설치해 보십시오.
  • 발견된 인스턴스에 SSM 명령을 수신할 권한이 없습니다. 인스턴스에 AmazonSSMManagedInstanceCore IAM 정책이 포함되어 있는지 확인하십시오.

자세한 내용은 AWS 문서의 SSM RunCommand 오류 코드 및 문제 해결 정보를 참조하십시오:

다음 단계#

Terraform EC2 자동 검색 구성

Teleport v18.9
원문 보기
요약

이 가이드는 Terraform을 사용하여 클러스터에서 EC2 인스턴스를 자동으로 등록하도록 Teleport와 AWS를 구성하는 방법을 설명합니다. teleport-discovery-aws Terraform 모듈은 Teleport EC2 자동 검색을 활성화하기 위해 Teleport 클러스터와 AWS 계정에 리소스를 생성합니다.

이 가이드는 Terraform을 사용하여 클러스터에서 EC2 인스턴스를 자동으로 등록하도록 Teleport와 AWS를 구성하는 방법을 설명합니다.

작동 방식#

teleport-discovery-aws Terraform 모듈은 Teleport EC2 자동 검색을 활성화하기 위해 Teleport 클러스터와 AWS 계정에 리소스를 생성합니다.

Teleport Discovery Service는 AWS API를 쿼리하여 계정 내 EC2 인스턴스 목록을 가져옵니다. Discovery Service는 검색된 각 EC2 인스턴스에 대해 AWS Systems Manager(SSM)를 사용하여 해당 인스턴스에 Teleport를 설치하고 이를 Teleport가 보호하는 서버로 클러스터에 조인시킵니다.

사전 요구사항#

  • 실행 중인 Teleport 클러스터. Teleport를 시작하려면 무료 체험판에 가입하거나 데모 환경을 구성하세요.

  • tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Teleport 클러스터의 버전을 확인합니다. tctl and tsh clients는 Teleport 클러스터 버전보다 최대 한 개의 메이저 버전까지만 뒤처질 수 있습니다. Proxy Service의 /v1/webapi/find로 GET 요청을 보내고 JSON 쿼리 도구를 사용하여 클러스터 버전을 확인합니다. teleport.example.com:443를 Teleport Proxy Service의 웹 주소로 바꿉니다:

      $ TELEPORT_DOMAIN=teleport.example.com:443
      $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')"
      
    2. 사용 중인 플랫폼에 대한 지침에 따라 tctl and tsh clients를 설치합니다:

Mac

     `tctl` and `tsh` clients가 포함된, 서명된 Teleport macOS .pkg 설치 프로그램을 다운로드합니다:
 
     ```code
     $ curl -O https://cdn.teleport.dev/teleport-${TELEPORT_VERSION?}.pkg
     ```

     Finder에서 `pkg` 파일을 더블 클릭하여 설치를 시작합니다.
 
     
Warning
       Homebrew를 사용하여 Teleport를 설치하는 것은 지원되지 않습니다. Homebrew의
       Teleport 패키지는 Teleport에서 유지 관리하지 않으므로 신뢰성이나 보안을
       보장할 수 없습니다.
     

Windows - Powershell

     ```code
     $ curl.exe -O https://cdn.teleport.dev/teleport-v${TELEPORT_VERSION?}-windows-amd64-bin.zip
     # Unzip the archive and move the `tctl` and `tsh` clients to your %PATH%
     # NOTE: Do not place the `tctl` and `tsh` clients in the System32 directory, as this can cause issues when using WinSCP.
     # Use %SystemRoot% (C:\Windows) or %USERPROFILE% (C:\Users\<username>) instead.
     ```
 
   

 
   

Linux

     Linux 설치판의 모든 Teleport 바이너리에는 `tctl` and `tsh` clients가 포함되어 있습니다.  RPM/DEB
     패키지 및 i386/ARM/ARM64용 다운로드를 포함한 더 많은 옵션은
     [설치 페이지](../installation/installation.mdx)를 참조하세요.
 
     ```code
     $ curl -O https://cdn.teleport.dev/teleport-v${TELEPORT_VERSION?}-linux-amd64-bin.tar.gz
     $ tar -xzf teleport-v${TELEPORT_VERSION?}-linux-amd64-bin.tar.gz
     $ cd teleport
     $ sudo ./install
     # Teleport binaries have been copied to /usr/local/bin
     ```
   

 
  • Ubuntu/Debian/RHEL/Amazon Linux 2/Amazon Linux 2023을 실행하는 EC2 인스턴스와 SSM Agent 버전 3.1 이상

Teleport cluster에 연결할 수 있는지 확인하려면 tsh login으로 로그인한 다음, 현재 자격 증명으로 tctl 명령을 실행할 수 있는지 확인합니다.

예를 들어, teleport.example.com에 cluster 내 Teleport Proxy Service의 도메인 이름을, email@example.com에 Teleport 사용자 이름을 지정하여 다음 명령을 실행합니다:

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

cluster에 연결하여 tctl status 명령을 실행할 수 있다면, 현재 자격 증명을 사용하여 워크스테이션에서 이후의 tctl 명령을 실행할 수 있습니다. 자체 Teleport cluster를 호스팅하는 경우, 전체 권한을 얻기 위해 Teleport Auth Service를 호스팅하는 컴퓨터에서 tctl 명령을 실행할 수도 있습니다.

Note

Discovery Service에 의해 Teleport 클러스터에 추가된 모든 EC2 인스턴스는 Discovery Service로부터 명령을 수신하기 위해 AmazonSSMManagedInstanceCore IAM 정책을 반드시 포함해야 합니다. 해당 정책에 포함된 권한 목록은 AWS 문서를 참조하세요.

Discovery Service를 실행할 Teleport 설치#

Tip

이미 실행 중인 Discovery Service 인스턴스가 있다면, 해당 인스턴스의 discovery_groupdiscovery-group-name에 할당하고 teleport-discovery-aws Terraform 모듈 사용하기로 진행하세요.

모든 Teleport Cloud 클러스터는 Discovery Service를 사용자를 대신하여 실행하므로, Teleport Cloud 구독자는 이 설치 단계를 모두 건너뛸 수 있습니다.

1/3단계. Teleport 설치#

Discovery Service를 다른 Teleport 서비스(예: Auth 또는 Proxy)가 이미 실행 중인 동일한 호스트에서 실행할 계획이라면 이 단계는 건너뛰어도 됩니다.

Discovery Service를 실행할 호스트 인스턴스에 Teleport를 설치합니다.

Linux 서버에 Teleport Agent를 설치하려면:

권장 설치 방법은 클러스터 설치 스크립트입니다. 이 스크립트는 클러스터에 맞는 올바른 버전, 에디션, 설치 모드를 선택합니다.

  1. teleport.example.com:443에 Teleport 클러스터의 호스트명과 포트를 할당하되, 스킴(https://)은 포함하지 마십시오.

  2. 클러스터의 설치 스크립트를 실행하십시오:

    $ curl "https://teleport.example.com:443/scripts/install.sh" | sudo bash
    

2/3단계. Discovery Service 구성#

Discovery Service를 자체 호스트에서 실행하는 경우, 해당 서비스는 클러스터에 연결하기 위한 유효한 초대 토큰이 필요합니다. Teleport Auth Service를 대상으로 다음 명령을 실행하여 토큰을 생성합니다.

$ tctl tokens add --type=discovery

생성된 토큰을 Discovery Service를 실행할 노드(EC2 인스턴스)의 /tmp/token에 저장합니다.

Warning

Discovery Service는 검색된 리소스를 서로 다른 집합으로 그룹화할 수 있게 하는 구성 파라미터 discovery_service.discovery_group을 제공합니다. 이 파라미터는 서로 다른 클라우드 리소스 집합을 감시하는 Discovery Agent들이 서로 충돌하여 다른 서비스가 생성한 리소스를 삭제하는 것을 방지하는 데 사용됩니다.

여러 개의 Discovery Service를 실행할 때, 동일한 클라우드 리소스를 감시하는 경우에는 각 서비스가 동일한 discovery_group 값으로 구성되어 있는지 확인해야 하며, 서로 다른 클라우드 리소스를 감시하는 경우에는 서로 다른 값으로 구성해야 합니다.

동일한 Teleport 클러스터에서 구성을 혼합하여 실행할 수 있습니다. 즉 일부 Discovery Service는 동일한 클라우드 리소스를 감시하도록 구성하고 다른 서비스는 서로 다른 리소스를 감시하도록 구성할 수 있습니다. 예를 들어, 서로 다른 두 개의 클라우드 계정에서 데이터를 분석하는 4개 에이전트 고가용성 구성은 다음과 같은 구성으로 실행됩니다.

  • Production 계정에서 데이터를 폴링하는 discovery_group: "prod"로 구성된 Discovery Service 2개.
  • Staging 계정에서 데이터를 폴링하는 discovery_group: "staging"로 구성된 Discovery Service 2개.

teleport.example.com:443를 클러스터 내 Teleport Proxy Service의 호스트 및 포트로 할당하고, discovery-group-name을 등록할 리소스 그룹을 식별하는 이름으로 할당합니다.

# teleport.yaml
version: v3
teleport:
  join_params:
    # token_name can be a literal token string or a path to a file.
    # File path is preferable to avoid including a secret in the config file.
    token_name: "/tmp/token"
    method: token
  proxy_server: "teleport.example.com:443"
auth_service:
  enabled: false
proxy_service:
  enabled: false
ssh_service:
  enabled: false
discovery_service:
  enabled: true
  discovery_group: "discovery-group-name"

3/3단계. Teleport 시작#

the Discovery Service이(가) AWS에 인증하는 데 사용할 수 있는 자격 증명에 대한 접근 권한을 부여합니다.

  • the Discovery Service을(를) EC2 인스턴스에서 실행하는 경우 EC2 Instance Metadata Service 방식을 사용할 수 있습니다
  • the Discovery Service을(를) Kubernetes에서 실행하는 경우 IAM Roles for Service Accounts (IRSA)를 사용할 수 있습니다
  • 그 외의 경우에는 환경 변수를 사용해야 합니다

Instance Metadata Service

Teleport는 EC2 인스턴스에서 실행 중일 때를 감지하고 Instance Metadata Service를 사용하여 자격 증명을 가져옵니다.

EC2 인스턴스는 EC2 인스턴스 프로파일을 사용하도록 구성되어야 합니다. 자세한 내용은 Using Instance Profiles를 참고하세요.

Kubernetes IRSA

AWS에서 OIDC provider를 설정하고 pod의 서비스 계정이 role을 assume할 수 있도록 허용하는 AWS IAM role을 구성하려면 IAM Roles for Service Accounts (IRSA)를 참고하세요.

Environment Variables

Teleport의 내장 AWS 클라이언트는 다음 환경 변수에서 자격 증명을 읽습니다:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_DEFAULT_REGION

the Discovery Service을(를) 시작하면 서비스는 /etc/default/teleport 경로의 파일에서 환경 변수를 읽습니다. 이러한 자격 증명은 조직에서 얻으세요. 각 변수의 값을 교체하여 /etc/default/teleport가 다음 내용을 담도록 하세요:

AWS_ACCESS_KEY_ID=00000000000000000000
AWS_SECRET_ACCESS_KEY=0000000000000000000000000000000000000000
AWS_DEFAULT_REGION=
AWS 자격 증명 소스가 여러 개인가요?

Teleport의 AWS 클라이언트는 다음 순서로 여러 소스에서 자격 증명을 로드합니다:

  • 환경 변수
  • 공유 자격 증명 파일
  • 공유 구성 파일 (Teleport는 항상 공유 구성을 활성화합니다)
  • EC2 Instance Metadata (자격 증명만)

공유 자격 증명 파일이나 공유 구성 파일을 통해 AWS 자격 증명을 제공할 수 있지만, 원하는 프로파일의 이름을 AWS_PROFILE 환경 변수에 할당하여 the Discovery Service을(를) 실행해야 합니다.

위의 지침이 다루지 않는 특정 사용 사례가 있다면, 자격 증명 로딩 동작에 대한 자세한 설명은 AWS SDK for Go 문서를 참고하세요.

systemd 서비스를 생성하여 호스트가 부팅될 때 the Discovery Service이 자동으로 시작되도록 구성합니다. 지침은 the Discovery Service을 어떻게 설치했는지에 따라 다릅니다.

Package Manager

the Discovery Service을 실행할 호스트에서 Teleport를 활성화하고 시작합니다:

$ sudo systemctl enable teleport
$ sudo systemctl start teleport

TAR Archive

the Discovery Service을 실행할 호스트에서 Teleport용 systemd 서비스 구성을 생성하고, Teleport 서비스를 활성화한 후 Teleport를 시작합니다:

$ sudo teleport install systemd -o /etc/systemd/system/teleport.service
$ sudo systemctl enable teleport
$ sudo systemctl start teleport

systemctl status teleport로 the Discovery Service의 상태를 확인하고 journalctl -fu teleport로 로그를 볼 수 있습니다.

teleport-discovery-aws Terraform 모듈 사용하기#

1/5단계. AWS Terraform 공급자 구성#

Terraform이 AWS 리소스를 관리할 수 있도록 AWS Terraform 공급자와 AWS IAM 권한을 구성합니다.

AWS Terraform 공급자에 필요한 AWS IAM 권한

AWS Terraform 공급자가 teleport-discovery-aws 모듈에서 생성한 AWS 리소스를 관리하려면 다음과 같은 AWS IAM 권한이 필요합니다.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "TerraformIdentity",
      "Effect": "Allow",
      "Action": "sts:GetCallerIdentity",
      "Resource": "*"
    },
    {
      "Sid": "ManageIamRole",
      "Effect": "Allow",
      "Action": [
        "iam:CreateRole",
        "iam:DeleteRole",
        "iam:GetRole",
        "iam:ListInstanceProfilesForRole",
        "iam:ListRolePolicies",
        "iam:ListRoles",
        "iam:ListRoleTags",
        "iam:TagRole",
        "iam:UntagRole",
        "iam:UpdateAssumeRolePolicy"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ManageIamPolicy",
      "Effect": "Allow",
      "Action": [
        "iam:CreatePolicy",
        "iam:CreatePolicyVersion",
        "iam:DeletePolicy",
        "iam:DeletePolicyVersion",
        "iam:GetPolicy",
        "iam:GetPolicyVersion",
        "iam:ListPolicies",
        "iam:ListPolicyTags",
        "iam:ListPolicyVersions",
        "iam:TagPolicy",
        "iam:UntagPolicy"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ManageRolePolicyAttachments",
      "Effect": "Allow",
      "Action": [
        "iam:AttachRolePolicy",
        "iam:DetachRolePolicy",
        "iam:ListAttachedRolePolicies"
      ],
      "Resource": "*"
    },
    {
      "Sid": "ManageOidcProvider",
      "Effect": "Allow",
      "Action": [
        "iam:CreateOpenIDConnectProvider",
        "iam:DeleteOpenIDConnectProvider",
        "iam:GetOpenIDConnectProvider",
        "iam:ListOpenIDConnectProviders",
        "iam:TagOpenIDConnectProvider",
        "iam:UntagOpenIDConnectProvider",
        "iam:UpdateOpenIDConnectProviderThumbprint"
      ],
      "Resource": "*"
    }
  ]
}

2/5단계. Teleport Terraform 공급자 구성#

Terraform을 실행하려는 방식(예: CI, Spacelift, 또는 다른 원격 환경)에 따라 Teleport Terraform 공급자를 구성하는 여러 방법이 있지만, 빠르게 시작하려면 로컬 데모 가이드를 참조하세요.

로컬 데모 가이드에서는 로컬 Teleport 자격 증명을 사용하여 Teleport Terraform 공급자를 구성하는 방법을 안내하는데, 이는 일반적으로 tsh로 로그인한 다음 terraform 명령을 실행할 셸에서 tctl 명령을 실행하는 것만큼 간단합니다.

$ tsh login
$ eval "$(tctl terraform env)"

클라우드 VM, 온프레미스 서버, CI/CD 파이프라인과 같은 원격 환경에서 Terraform을 실행하는 경우, 사용 사례에 적합한 가이드를 찾으려면 Teleport Terraform 공급자 사용하기를 참조하세요.

3/5단계. Terraform 모듈 입력값 구성#

Terraform 구성에 teleport-discovery-aws 모듈을 추가합니다.

module "aws_discovery" {
  source = "terraform.releases.teleport.dev/teleport/discovery/aws"
  version = "~> (=cloud.major_version=).0"

  # Required inputs:
  # Assign example.teleport.sh:443 to your Teleport cluster's proxy public address in host:port form.
  teleport_proxy_public_addr = "https://example.teleport.sh:443"
  # teleport_discovery_group_name must match the discovery group name in your Discovery Service config file.
  # Teleport Cloud clusters run the Discovery Service in the group name "cloud-discovery-group".
  # Do not modify this input unless you intend to run your own Discovery Service.
  teleport_discovery_group_name = "cloud-discovery-group"
  # Discover EC2 instances
  match_aws_resource_types = ["ec2"]

  # Optional inputs:
  # Apply the additional AWS tag "origin=example" to all AWS resources created by this module
  apply_aws_tags = { origin = "example" }
  # Apply the additional Teleport label "origin=example" to all Teleport resources created by this module
  apply_teleport_resource_labels = { origin = "example" }
  # match_aws_regions is a list of regions in which the Discovery Service will match and discover EC2 instances.
  # The wildcard "*" is the default and matches all regions.
  match_aws_regions = ["*"]
  # match_aws_tags are AWS tags to match when discovering EC2 instances.
  # Only EC2 instances with matching tags will be discovered.
  # The wildcard {"*" : ["*"]} is the default and matches all tags.
  match_aws_tags = { "*" : ["*"] }
}
module "aws_discovery" {
  source = "terraform.releases.teleport.dev/teleport/discovery/aws"
  version = "~> (=teleport.major_version=).0"

  # Required inputs:
  # Edit this input to the host and port of the Teleport Proxy Service in your cluster
  teleport_proxy_public_addr    = "https://teleport.example.com:443"
  # Edit this input to match the discovery group name in your Discovery Service config file
  teleport_discovery_group_name = "discovery-group-name"
  # Discover EC2 instances
  match_aws_resource_types = ["ec2"]

  # Optional inputs:
  # Apply the additional AWS tag "origin=example" to all AWS resources created by this module
  apply_aws_tags = { origin = "example" }
  # Apply the additional Teleport label "origin=example" to all Teleport resources created by this module
  apply_teleport_resource_labels = { origin = "example" }
  # match_aws_regions is a list of regions in which the Discovery Service will match and discover EC2 instances.
  # The wildcard "*" is the default and matches all regions.
  match_aws_regions = ["*"]
  # match_aws_tags are AWS tags to match when discovering EC2 instances.
  # Only EC2 instances with matching tags will be discovered.
  # The wildcard {"*" : ["*"]} is the default and matches all tags.
  match_aws_tags = { "*" : ["*"] }
}

모듈에 Terraform 출력값을 추가하여 Terraform이 해당 출력값을 표시하도록 합니다.

output "aws_discovery" {
  value = module.aws_discovery
}

모듈 입력값 및 출력값에 대한 전체 설명은 teleport-discovery-aws 참조를 참조하세요.

4/5단계. Terraform 모듈 적용#

$ terraform init
$ terraform apply

Terraform은 다음 리소스를 생성하도록 계획을 세워야 합니다.

  • Teleport Discovery Service가 위임(assume)할 AWS IAM 역할
  • Teleport가 AWS에서 리소스를 검색하는 데 필요한 AWS 권한을 부여하는 AWS IAM 정책
  • IAM 정책을 Discovery Service IAM 역할에 연결하는 AWS IAM 정책 연결
  • Teleport Discovery Service가 OIDC를 사용하여 IAM 역할을 위임(assume)할 수 있도록 하는 AWS OIDC 공급자
  • AWS 리소스 검색을 위해 Teleport를 구성하는 Teleport discovery_config 클러스터 리소스
  • AWS OIDC용 Teleport integration 클러스터 리소스
  • Teleport 노드가 AWS IAM 자격 증명을 사용하여 클러스터에 조인할 수 있도록 하는 Teleport token 클러스터 리소스

Terraform 계획을 검토하고 계획 작업을 확인합니다.

Terraform이 계획 적용을 마치면 모듈 출력값을 표시해야 합니다.

aws_discovery = {
  "aws_oidc_provider_arn" = "arn:aws:iam::123456789012:oidc-provider/example.teleport.sh"
  "teleport_discovery_config_name" = "discovery-aws-account-123456789012"
  "teleport_discovery_service_iam_policy_arn" = "arn:aws:iam::123456789012:policy/teleport-discovery-<timestamp>"
  "teleport_discovery_service_iam_role_arn" = "arn:aws:iam::123456789012:role/teleport-discovery-<timestamp>"
  "teleport_integration_name" = "discovery-aws-account-123456789012"
  "teleport_provision_token_name" = "discovery-aws-account-123456789012"
}

AWS 리소스에는 다음 태그가 있어야 합니다.

  • origin=example
  • teleport.dev/cluster=<cluster-name>
  • teleport.dev/integration=discovery-aws-account-<account-id>
  • teleport.dev/iac-tool=terraform

Teleport 리소스에는 다음 라벨이 있어야 합니다.

  • origin=example
  • teleport.dev/iac-tool=terraform

5/5단계. 검색 상태 확인#

Terraform 모듈을 적용한 후, Teleport Discovery Service는 AWS 계정 내 EC2 인스턴스를 검색하여 보호된 리소스로 클러스터에 등록하기 시작해야 합니다.

Note

EC2 인스턴스가 검색되어 등록되기까지 몇 분 정도 걸릴 수 있습니다.

Teleport Web UI로 이동하여 Zero Trust Access > Integrations를 선택합니다. 기본적으로 teleport-discovery-aws Terraform 모듈에 의해 생성된 통합은 discovery-aws-account-<aws-account-id>라는 이름을 갖습니다.

AWS 계정에 대한 통합을 클릭하여 검색 상태를 검토합니다.

통합 페이지는 검색된 EC2 인스턴스 수와 검색 과정에서 발생한 문제에 대한 개요를 제공합니다.

비정상 상태의 검색 통합 개요

위 예시에서는 인스턴스의 AWS SSM 에이전트에 문제가 있었음을 확인할 수 있습니다.

"issues" 탭으로 이동하여 "Details"를 클릭하면 해당 문제에 대한 자세한 정보를 확인할 수 있습니다.

SSM 설치 문제

이 경우 문제는 EC2 인스턴스에 AmazonSSMManagedInstanceCore IAM 정책이 연결된 IAM 역할이 없어서 인스턴스가 SSM 명령을 수신할 수 없다는 것입니다.

이 문제는 AmazonSSMManagedInstanceCore IAM 정책을 EC2 인스턴스의 역할에 연결하고 Discovery Service가 SSM을 사용한 설치를 재시도할 때까지 기다리면 해결할 수 있습니다. 다음 검색 스캔이 실행되어 인스턴스에 Teleport를 설치하기까지 몇 분 정도 걸릴 수 있습니다.

검색된 모든 EC2 인스턴스가 Teleport 클러스터에 성공적으로 조인되면 개요 페이지에는 정상 상태가 표시됩니다.

정상 상태의 검색 통합 개요

모듈 구성 업데이트#

모듈 입력값을 변경하고 다시 적용하여 AWS 검색 통합을 조정할 수 있습니다.

예를 들어, 이전에 (모든 리전에 대한 와일드카드 기본값 대신) 특정 AWS 리전을 사용했다면, match_aws_regions를 조정하여 EC2 검색을 위한 리전을 추가하고 모듈을 다시 적용하여 해당 리전에서도 인스턴스를 등록하기 시작할 수 있습니다.

-match_aws_regions = ["us-west-1"]
+match_aws_regions = ["us-west-1", "us-east-1"]

Terraform을 다시 적용합니다.

$ terraform apply

변경 사항을 확인하기 전에 Terraform 계획을 검토하세요.

Terraform이 계획 적용을 마치면 Discovery Service는 동적 discovery_config의 변경 사항을 반영하여 us-east-1에서도 EC2 인스턴스를 등록하기 시작합니다.

문제 해결#

설치가 실패로 표시되거나 인스턴스가 나타나지 않는 경우, AWS System Manager -> Node Management -> Run Command에서 Command 이력을 확인하십시오. Target의 instance-id를 선택하여 오류를 검토하십시오.

cannot unmarshal object into Go struct field#

다음과 유사한 오류가 발생하는 경우:

invalid format in plugin properties map[destinationPath:/tmp/installTeleport.sh sourceInfo:map[url:[https://example.teleport.sh:443/webapi/scripts/installer/preprod-installer](https://example.teleport.sh/webapi/scripts/installer/preprod-installer)] sourceType:HTTP];
error json: cannot unmarshal object into Go struct field DownloadContentPlugin.sourceInfo of type string

이는 오래된 버전의 SSM agent를 실행하고 있을 가능성이 높습니다. 이 문제를 해결하려면 SSM agent 버전 3.1 이상으로 업그레이드하십시오.

InvalidInstanceId: Instances [[i-123]] not in a valid state for account 456#

다음과 같은 문제로 인해 이 오류가 발생할 수 있습니다:

  • Discovery Service에 관리 노드에 접근할 권한이 없습니다.
  • AWS Systems Manager Agent(SSM Agent)가 실행되고 있지 않습니다. SSM Agent가 실행 중인지 확인하십시오.
  • SSM Agent가 SSM 엔드포인트에 등록되어 있지 않습니다. SSM Agent를 재설치해 보십시오.
  • 발견된 인스턴스에 SSM 명령을 수신할 권한이 없습니다. 인스턴스에 AmazonSSMManagedInstanceCore IAM 정책이 포함되어 있는지 확인하십시오.

자세한 내용은 AWS 문서의 SSM RunCommand 오류 코드 및 문제 해결 정보를 참조하십시오:

다음 단계#