> 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 클라우드 계정 통합을 정의할 수 있습니다 [Terraform 공급자](https://registry.terraform.io/providers/panther-labs/panther/latest). AWS 클라우드 계정은 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과 토큰: `클라우드 보안 소스 관리` 권한이 있어야 합니다. 이는 다음을 완료하는 데 필요합니다 [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 템플릿(**구성** > **클라우드 계정** > **계정 연결**)를 사용해 역할을 프로비저닝한 다음, 해당 ARN을 Terraform 구성에서 사용하세요.

### 1단계: 변수 정의

* 다음 파일을 정의하세요 `다음 AWS 및 Panther 변수가 포함된 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`          | string       | ✓  | 통합의 표시 이름(영숫자, 공백, 하이픈만 허용; 최대 36자).                            |
| `aws_account_id`             | string       | ✓  | 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` | string | ✓  | Panther가 AWS 계정을 스캔할 때 가정하는 IAM 역할 ARN. |

#### 속성

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

## 기존 AWS Cloud Account 가져오기

Terraform으로 관리하고 싶은 기존 AWS Cloud Account가 Panther에 있다면 다음을 사용하세요: `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.
