InfoGrab DocsInfoGrab Docs

조직 내 모든 계정의 AWS 리소스 검색 예시

요약

이 페이지는 teleport-discovery-aws Terraform 모듈의 사용 예시인 organization의 구성 필드를 나열합니다. 이 디렉터리의 구성은 Teleport가 동일한 조직(Organization) 아래의 여러 AWS 계정에 있는 리소스를 검색하는 데 필요한 AWS 및 Teleport 리소스를 생성합니다.

이 페이지는 teleport-discovery-aws Terraform 모듈의 사용 예시인 organization의 구성 필드를 나열합니다.

Teleport AWS 조직 검색 예시#

이 디렉터리의 구성은 Teleport가 동일한 조직(Organization) 아래의 여러 AWS 계정에 있는 리소스를 검색하는 데 필요한 AWS 및 Teleport 리소스를 생성합니다.

현재 조직 전체 검색에서는 EC2 검색만 지원됩니다.

AWS 조직 관리 계정 또는 위임된 관리자 계정의 자격 증명으로 Terraform을 실행합니다. Discovery Service와 Auth 서비스는 필요한 AWS Organizations API를 호출하기 위해 이 계정 중 하나의 자격 증명을 사용해야 합니다.

적용 후에는 terraform output을 실행해 얻을 수 있는 aws_child_account_iam_role_template 출력에 제공된 세부 정보를 사용하여 각 대상 계정에 IAM 역할을 수동으로 생성해야 합니다. 루트 또는 *가 포함된 경우 관리 계정 또는 위임된 관리자 계정도 여기에 포함됩니다.

terraform output에서 얻은 다음 템플릿을 사용하여 각 대상 계정에 IAM 역할을 생성합니다.

{
  "aws_child_account_iam_role_template" = {
    "assume_role_policy" = <<-EOT
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": "sts:AssumeRole",
          "Principal": {
            "AWS": "arn:aws:iam::<aws-root-account-id>:role/teleport-discovery-<timestamp>"
          },
          "Condition": {
            "StringEquals": {
              "aws:PrincipalOrgID": "<aws-organization-id>"
            }
          }
        }
      ]
    }
    EOT
    "policy" = <<-EOT
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "ssm:SendCommand",
            "ssm:ListCommandInvocations",
            "ssm:GetCommandInvocation",
            "ssm:DescribeInstanceInformation",
            "ec2:DescribeInstances",
            "account:ListRegions"
          ],
          "Resource": "*"
        }
      ]
    }
    EOT
    "role_name" = "teleport-organization-discovery-child-account-role"
  }
  # ...
}

AWS OIDC 연동을 사용하지 않는 경우에는 관리 계정 또는 위임된 관리자 계정에 IAM 역할을 두 개 더 생성해야 합니다.

  • teleport_organization_account_enumeration_iam_role_template: Discovery Service에서 접근할 수 있어야 하며, 조직 아래의 모든 계정을 열거하고 각 대상 계정에 생성된 역할을 맡는 데 사용됩니다.
  • teleport_organization_join_validation_iam_role_template: Auth 서비스에서 접근할 수 있어야 하며, 대상 EC2 인스턴스의 조인 시도를 수락하는 데 사용됩니다.

또한 aws_organization_discovery_iam_principal_arn을 Discovery Service가 사용하는 AWS IAM 프린시펄의 ARN으로 설정해야 합니다. 하위 계정 IAM 역할 템플릿은 이 ARN을 신뢰 정책에 사용합니다.

terraform output을 실행하면 역할 세부 정보를 확인할 수 있습니다.

요구 사항#

이름 버전
terraform >= 1.5.7
aws >= 5.0
teleport >= 18.8.3
tls >= 4.0

공급자 (Providers)#

공급자 없음.

모듈 (Modules)#

이름 소스 버전
aws_discovery ../.. n/a

리소스 (Resources)#

리소스 없음.

입력 (Inputs)#

입력 없음.

출력 (Outputs)#

이름 설명
aws_discovery n/a

소스 코드#

GitHub에서 teleport-discovery-aws 모듈의 organization 예시 소스 코드 보기.

################################################################################
# teleport/discovery/aws/examples/organization/main.tf
################################################################################

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

  teleport_proxy_public_addr    = "example.teleport.sh:443"
  teleport_discovery_group_name = "cloud-discovery-group"

  # Enroll resources from all AWS Accounts in the Organization
  # Only EC2 resource discovery is supported for organization-wide discovery.
  aws_organization_discovery = {
    organizational_units = {
      # Include accounts under any Organizational Unit.
      # At least one organizational unit must be included. You can use the root ID or the `*` to include the entire organization.
      include = ["*"]
      # Exclude the Organizational Unit's accounts and all their descendants.
      # Takes precedence over the include rule, so accounts under this OU will not be enrolled even if the include rule matches them.
      # Only exact matches are supported for exclusion, wildcards are not allowed.
      exclude = ["ou-1234-abcdwxyz"]
    }
  }

  # Each child account in the organization must have an IAM role with this name.
  # This role is assumed by the discovery service to enroll resources from that account.
  # The required trust relationship and permissions for this role can be found in the module outputs and documentation.
  aws_child_account_iam_role_name = "teleport-organization-discovery-child-account-role"

  # Discover EC2 instances using matching rules.
  # Accepts "*" to discover across all enabled regions.
  # The module adds account:ListRegions to the IAM policy automatically when "*" is used.
  aws_matchers = [
    {
      types = ["ec2"]
      # EC2 discovery supports a wildcard to find instances in all regions.
      regions = ["*"]
      tags = {
        env = ["prod"]
      }
    }
  ]

  # Apply the additional Teleport label "origin=example" to all Teleport resources created by this module
  apply_teleport_resource_labels = { origin = "example" }
  # Apply the additional AWS tag "origin=example" to all AWS resources created by this module
  apply_aws_tags = { origin = "example" }
}

################################################################################
# teleport/discovery/aws/examples/organization/outputs.tf
################################################################################

output "aws_discovery" {
  value = module.aws_discovery
}

################################################################################
# teleport/discovery/aws/examples/organization/versions.tf
################################################################################

terraform {
  required_version = ">= 1.5.7"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.0"
    }
    tls = {
      source  = "hashicorp/tls"
      version = ">= 4.0"
    }
    teleport = {
      source  = "terraform.releases.teleport.dev/gravitational/teleport"
      version = ">= 18.8.3"
    }
  }
}

조직 내 모든 계정의 AWS 리소스 검색 예시

Teleport v18.11
원문 보기

요약

이 페이지는 teleport-discovery-aws Terraform 모듈의 사용 예시인 organization의 구성 필드를 나열합니다. 이 디렉터리의 구성은 Teleport가 동일한 조직(Organization) 아래의 여러 AWS 계정에 있는 리소스를 검색하는 데 필요한 AWS 및 Teleport 리소스를 생성합니다.

이 페이지는 teleport-discovery-aws Terraform 모듈의 사용 예시인 organization의 구성 필드를 나열합니다.

Teleport AWS 조직 검색 예시#

이 디렉터리의 구성은 Teleport가 동일한 조직(Organization) 아래의 여러 AWS 계정에 있는 리소스를 검색하는 데 필요한 AWS 및 Teleport 리소스를 생성합니다.

현재 조직 전체 검색에서는 EC2 검색만 지원됩니다.

AWS 조직 관리 계정 또는 위임된 관리자 계정의 자격 증명으로 Terraform을 실행합니다. Discovery Service와 Auth 서비스는 필요한 AWS Organizations API를 호출하기 위해 이 계정 중 하나의 자격 증명을 사용해야 합니다.

적용 후에는 terraform output을 실행해 얻을 수 있는 aws_child_account_iam_role_template 출력에 제공된 세부 정보를 사용하여 각 대상 계정에 IAM 역할을 수동으로 생성해야 합니다. 루트 또는 *가 포함된 경우 관리 계정 또는 위임된 관리자 계정도 여기에 포함됩니다.

terraform output에서 얻은 다음 템플릿을 사용하여 각 대상 계정에 IAM 역할을 생성합니다.

{
  "aws_child_account_iam_role_template" = {
    "assume_role_policy" = <<-EOT
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": "sts:AssumeRole",
          "Principal": {
            "AWS": "arn:aws:iam::<aws-root-account-id>:role/teleport-discovery-<timestamp>"
          },
          "Condition": {
            "StringEquals": {
              "aws:PrincipalOrgID": "<aws-organization-id>"
            }
          }
        }
      ]
    }
    EOT
    "policy" = <<-EOT
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "ssm:SendCommand",
            "ssm:ListCommandInvocations",
            "ssm:GetCommandInvocation",
            "ssm:DescribeInstanceInformation",
            "ec2:DescribeInstances",
            "account:ListRegions"
          ],
          "Resource": "*"
        }
      ]
    }
    EOT
    "role_name" = "teleport-organization-discovery-child-account-role"
  }
  # ...
}

AWS OIDC 연동을 사용하지 않는 경우에는 관리 계정 또는 위임된 관리자 계정에 IAM 역할을 두 개 더 생성해야 합니다.

  • teleport_organization_account_enumeration_iam_role_template: Discovery Service에서 접근할 수 있어야 하며, 조직 아래의 모든 계정을 열거하고 각 대상 계정에 생성된 역할을 맡는 데 사용됩니다.
  • teleport_organization_join_validation_iam_role_template: Auth 서비스에서 접근할 수 있어야 하며, 대상 EC2 인스턴스의 조인 시도를 수락하는 데 사용됩니다.

또한 aws_organization_discovery_iam_principal_arn을 Discovery Service가 사용하는 AWS IAM 프린시펄의 ARN으로 설정해야 합니다. 하위 계정 IAM 역할 템플릿은 이 ARN을 신뢰 정책에 사용합니다.

terraform output을 실행하면 역할 세부 정보를 확인할 수 있습니다.

요구 사항#

이름 버전
terraform >= 1.5.7
aws >= 5.0
teleport >= 18.8.3
tls >= 4.0

공급자 (Providers)#

공급자 없음.

모듈 (Modules)#

이름 소스 버전
aws_discovery ../.. n/a

리소스 (Resources)#

리소스 없음.

입력 (Inputs)#

입력 없음.

출력 (Outputs)#

이름 설명
aws_discovery n/a

소스 코드#

GitHub에서 teleport-discovery-aws 모듈의 organization 예시 소스 코드 보기.

################################################################################
# teleport/discovery/aws/examples/organization/main.tf
################################################################################

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

  teleport_proxy_public_addr    = "example.teleport.sh:443"
  teleport_discovery_group_name = "cloud-discovery-group"

  # Enroll resources from all AWS Accounts in the Organization
  # Only EC2 resource discovery is supported for organization-wide discovery.
  aws_organization_discovery = {
    organizational_units = {
      # Include accounts under any Organizational Unit.
      # At least one organizational unit must be included. You can use the root ID or the `*` to include the entire organization.
      include = ["*"]
      # Exclude the Organizational Unit's accounts and all their descendants.
      # Takes precedence over the include rule, so accounts under this OU will not be enrolled even if the include rule matches them.
      # Only exact matches are supported for exclusion, wildcards are not allowed.
      exclude = ["ou-1234-abcdwxyz"]
    }
  }

  # Each child account in the organization must have an IAM role with this name.
  # This role is assumed by the discovery service to enroll resources from that account.
  # The required trust relationship and permissions for this role can be found in the module outputs and documentation.
  aws_child_account_iam_role_name = "teleport-organization-discovery-child-account-role"

  # Discover EC2 instances using matching rules.
  # Accepts "*" to discover across all enabled regions.
  # The module adds account:ListRegions to the IAM policy automatically when "*" is used.
  aws_matchers = [
    {
      types = ["ec2"]
      # EC2 discovery supports a wildcard to find instances in all regions.
      regions = ["*"]
      tags = {
        env = ["prod"]
      }
    }
  ]

  # Apply the additional Teleport label "origin=example" to all Teleport resources created by this module
  apply_teleport_resource_labels = { origin = "example" }
  # Apply the additional AWS tag "origin=example" to all AWS resources created by this module
  apply_aws_tags = { origin = "example" }
}

################################################################################
# teleport/discovery/aws/examples/organization/outputs.tf
################################################################################

output "aws_discovery" {
  value = module.aws_discovery
}

################################################################################
# teleport/discovery/aws/examples/organization/versions.tf
################################################################################

terraform {
  required_version = ">= 1.5.7"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.0"
    }
    tls = {
      source  = "hashicorp/tls"
      version = ">= 4.0"
    }
    teleport = {
      source  = "terraform.releases.teleport.dev/gravitational/teleport"
      version = ">= 18.8.3"
    }
  }
}