> For the complete documentation index, see [llms.txt](https://docs.panther.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.panther.com/ko/panther/terraform/cloud-accounts.md).

# Terraform을 사용한 AWS 클라우드 계정 관리

## 개요

Panther를 사용하여 Terraform에서 AWS Cloud Account 통합을 정의할 수 있습니다 [Terraform 제공자](https://registry.terraform.io/providers/panther-labs/panther/latest). AWS Cloud Accounts는 Panther의 [클라우드 보안 스캐닝](/ko/cloud-scanning.md) 기능을 통해 보안 컴플라이언스 준수를 위해 클라우드 리소스 구성을 모니터링합니다.

AWS Cloud Account 통합을 생성하는 다른 방법으로는 [Panther REST API를 직접 사용하는 것](/ko/panther/api/rest/cloud-accounts.md) 직접 사용 및 [Panther Console에서 수동으로 생성하는 방법이 있습니다](/ko/cloud-scanning.md#onboarding-a-cloud-account-in-the-panther-console).

## Terraform에서 AWS Cloud Account를 정의하는 방법

다음 섹션에서는 HashiCorp Configuration Language(HCL)에서 AWS Cloud Account 통합을 정의하는 방법을 설명합니다.

### 사전 요구 사항

* 시작하기 전에 다음이 준비되어 있는지 확인하세요:
  * 다음 권한이 있는 API URL과 토큰: `Cloud Security Sources 관리` 권한. 이는 완료하는 데 필요합니다 [2단계](#step-2-provide-values-for-the-defined-variables).
    * 필요한 경우 다음을 따르세요 [Panther Console에서 API 토큰을 생성하는 지침](/ko/panther/api.md#how-to-create-a-panther-api-token).
  * AWS 계정에 배포된 IAM 감사 역할입니다. Panther가 생성한 CloudFormation 템플릿(**클라우드 계정** > **계정 연결**)를 사용해 해당 역할을 프로비저닝한 다음, Terraform 구성에서 해당 ARN을 사용하세요.

### 1단계: 변수 정의

* 다음을 정의하세요: `variables.tf` 아래 코드 블록에 표시된 Panther 변수가 포함된 파일.

```hcl
variable "panther_api_token" {
  description = "Panther API 토큰"
  type        = string
  sensitive   = true
}

variable "panther_api_url" {
  description = "Panther API URL"
  type        = string
}

variable "integration_label" {
  description = "AWS Cloud Account 통합의 표시 이름."
  type        = string
}

variable "aws_account_id" {
  description = "12자리 AWS 계정 ID."
  type        = string
}

variable "audit_role" {
  description = "Panther가 AWS 계정을 스캔할 때 사용하는 IAM 역할 ARN."
  type        = string
}

// (선택 사항) 스캔에서 제외할 리전, 리소스 유형 및 ARN 정규식 패턴.
variable "region_ignore_list" {
  description = "스캔에서 제외할 AWS 리전."
  type        = list(string)
  default     = []
}

variable "resource_type_ignore_list" {
  description = "스캔에서 제외할 리소스 유형(예: AWS.S3.Bucket)."
  type        = list(string)
  default     = []
}

variable "resource_regex_ignore_list" {
  description = "스캔에서 제외할 리소스 ARN과 일치하는 정규식 패턴."
  type        = list(string)
  default     = []
}
```

### 2단계: 정의된 변수에 값을 제공하세요

* 다음을 추가하세요: `*.tfvars` 1단계에서 정의한 변수에 값을 할당하는 파일입니다. 이 섹션을 완료하려면 다음에 설명된 API URL과 토큰이 필요합니다: [필수 조건 섹션](#prerequisites).
  * 여기에 입력하는 `panther_api_url` 값은 루트 API URL이어야 합니다. 즉, 다음 중 하나입니다:
    * A [GraphQL API URL](/ko/panther/api/graphql.md#step-1-identify-your-panther-graphql-api-url) 다음 없이 `/public/graphql` 접미사
    * A [REST API URL](/ko/panther/api/rest.md#step-1-identify-your-panther-rest-api-url) 그대로 사용합니다(REST URL은 루트 URL 뒤에 접미사가 없습니다)

```hcl
panther_api_token          = "XXXXXXXXXX"
panther_api_url            = "https://your-panther-url/v1"
integration_label          = "production-aws"
aws_account_id             = "123456789012"
audit_role                 = "arn:aws:iam::123456789012:role/PantherAuditRole"
region_ignore_list         = ["us-west-1"]
resource_type_ignore_list  = ["AWS.KMS.Key"]
resource_regex_ignore_list = [".*-test-.*"]
```

### 3단계: Terraform 제공자 정의

* 다음을 [Panther](https://registry.terraform.io/providers/panther-labs/panther/latest) Terraform 제공자.

```hcl
terraform {
  required_providers {
    panther = {
      source  = "panther-labs/panther"
      version = "~> 0.2.11"
    }
  }
}
```

### 4단계: Panther AWS Cloud Account 리소스 정의

다음 HCL 구성은 Panther에서 AWS Cloud Account 통합을 정의합니다.

```hcl
provider "panther" {
  token = var.panther_api_token
  url   = var.panther_api_url
}

resource "panther_aws_cloud_account" "example" {
  integration_label = var.integration_label
  aws_account_id    = var.aws_account_id

  aws_scan_config = {
    audit_role = var.audit_role
  }

  region_ignore_list         = var.region_ignore_list
  resource_type_ignore_list  = var.resource_type_ignore_list
  resource_regex_ignore_list = var.resource_regex_ignore_list
}
```

{% hint style="info" %}
`aws_account_id` 변경할 수 없습니다. 생성 후 변경하면 Terraform이 리소스를 삭제한 뒤 다시 생성합니다.
{% endhint %}

## 리소스 참조

### `panther_aws_cloud_account`

#### 인수

| 이름                           | 유형           | 필수 | 설명                                                                     |
| ---------------------------- | ------------ | -- | ---------------------------------------------------------------------- |
| `integration_label`          | 문자열          | ✓  | 통합의 표시 이름(영숫자, 공백, 하이픈만 허용, 최대 36자).                                   |
| `aws_account_id`             | 문자열          | ✓  | 12자리 AWS 계정 ID입니다. 변경할 수 없으며, 이 값을 변경하면 리소스가 교체됩니다.                    |
| `aws_scan_config`            | 객체           | ✓  | AWS 스캔 구성. 다음을 참조하세요: [aws\_scan\_config](#aws_scan_config) 아래를 참조하세요. |
| `region_ignore_list`         | list(string) | —  | 스캔에서 제외할 AWS 리전. 기본값: `[]`.                                            |
| `resource_type_ignore_list`  | list(string) | —  | 스캔에서 제외할 리소스 유형(예: `AWS.S3.Bucket`). 기본값: `[]`.                        |
| `resource_regex_ignore_list` | list(string) | —  | 스캔에서 제외할 리소스 ARN과 일치하는 정규식 패턴. 기본값: `[]`.                              |

#### `aws_scan_config`

| 이름           | 유형  | 필수 | 설명                                         |
| ------------ | --- | -- | ------------------------------------------ |
| `audit_role` | 문자열 | ✓  | Panther가 AWS 계정을 스캔할 때 사용하는 IAM 역할 ARN입니다. |

#### 속성

| 이름   | 유형  | 설명                                      |
| ---- | --- | --------------------------------------- |
| `id` | 문자열 | AWS Cloud Account의 Panther 통합 ID(UUID). |

## 기존 AWS Cloud Account 가져오기

Terraform으로 관리하려는 기존 Panther의 AWS Cloud Account가 있다면 다음을 사용하세요: `terraform import` 통합 ID를 사용합니다. 통합 ID는 Cloud Account를 볼 때 Panther Console URL에서 확인할 수 있는 UUID입니다(**클라우드 계정**).

```shell
terraform import panther_aws_cloud_account.example 12345678-1234-1234-1234-123456789012
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.panther.com/ko/panther/terraform/cloud-accounts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
