

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 코드 리포지토리를 AWS Service Catalog 사용하여에서 Terraform 제품 프로비저닝
<a name="provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository"></a>

*Dr. Rahul Sharad Gaikwad and Tamilselvan P, Amazon Web Services*

## 요약
<a name="provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository-summary"></a>

AWS Service Catalog 는 [HashiCorp Terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started) 구성에 대한 거버넌스를 통한 셀프 서비스 프로비저닝을 지원합니다. Terraform을 사용하는 경우 Service Catalog를 단일 도구로 사용하여 AWS 에서 Terraform 구성을 대규모로 구성, 관리 및 배포할 수 있습니다. 표준화되고 사전 승인된 코드형 인프라(IaC) 템플릿의 카탈로그 작성, 액세스 제어, 최소 권한 액세스를 통한 클라우드 리소스 프로비저닝, 버전 관리, 수천 개의에 대한 공유 AWS 계정, 태그 지정 등 Service Catalog 주요 기능에 액세스할 수 있습니다. 엔지니어, 데이터베이스 관리자, 데이터 과학자와 같은 최종 사용자는 액세스할 수 있는 제품 및 버전 목록을 보고 단일 작업을 통해 배포할 수 있습니다.

이 패턴은 Terraform 코드를 사용하여 AWS 리소스를 배포하는 데 도움이 됩니다. GitHub 리포지토리의 Terraform 코드는 Service Catalog를 통해 액세스됩니다. 또는 제품을 기존 Terraform 워크플로와 통합할 수 있습니다. 관리자는 Service Catalog 포트폴리오를 생성하고 Terraform을 사용하여 포트폴리오에 AWS Launch Wizard 제품을 추가할 수 있습니다.

이 접근 방식은 다음과 같은 이점이 있습니다.
+ Service Catalog의 롤백 기능으로 인해 배포 중에 문제가 발생하면 제품을 이전 버전으로 되돌릴 수 있습니다.
+ 제품 버전 간의 차이점을 쉽게 식별할 수 있습니다. 이렇게 하면 배포 중에 문제를 해결하는 데 도움이 됩니다.
+ Service Catalog에서 GitHub 또는 GitLab GitLab과 같은 리포지토리 연결을 구성할 수 있습니다. 리포지토리를 통해 직접 제품을 변경할 수 있습니다.

의 전반적인 이점에 대한 자세한 내용은 [서비스 카탈로그란 무엇입니까](https://docs.aws.amazon.com/servicecatalog/latest/adminguide/introduction.html)?를 AWS Service Catalog참조하십시오.

## 사전 조건 및 제한 사항
<a name="provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository-prereqs"></a>

**사전 조건 **
+ 활성. AWS 계정
+ ZIP 형식의 Terraform 구성 파일이 포함된 GitHub, BitBucket 또는 기타 리포지토리입니다.
+ AWS Serverless Application Model 명령줄 인터페이스(AWS SAM CLI), [설치](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html)됨.
+ AWS Command Line Interface (AWS CLI), [설치](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) 및 [구성](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html)됨.
+ Go, [설치](https://go.dev/doc/install)됨.
+ Python 버전 3.9 , [설치](https://www.python.org/downloads/release/python-3913/)됨. AWS SAM CLI에는이 버전의 Python이 필요합니다.
+ Service Catalog 제품 및 포트폴리오에 액세스하고 관리할 수 있는 AWS Lambda 함수 및 권한을 작성하고 실행할 수 있는 권한.

## 아키텍처
<a name="provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository-architecture"></a>

![\[코드 리포지토리에서 Service Catalog에 Terraform 제품을 프로비저닝하는 아키텍처 다이어그램\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/images/pattern-img/7d0d76e8-9485-4b3f-915f-481b6a7cdcd9/images/e83fa44a-4ca6-4438-a0d1-99f09a3541bb.png)


이 다이어그램은 다음 워크플로를 보여줍니다.

1. Terraform 구성이 준비되면 개발자는 모든 Terraform 코드가 포함된 .zip 파일을 생성합니다. 개발자는 Service Catalog에 연결된 코드 리포지토리에 .zip 파일을 업로드합니다.

1. 관리자가 Terraform 제품을 Service Catalog의 포트폴리오에 연결합니다. 또한 관리자는 최종 사용자가 제품을 프로비저닝할 수 있도록 허용하는 시작 제약 조건을 생성합니다.

1. Service Catalog에서 최종 사용자는 Terraform 구성을 사용하여 AWS 리소스를 시작합니다. 배포할 제품 버전을 선택할 수 있습니다.

## 도구
<a name="provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository-tools"></a>

**AWS 서비스**
+ [AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html)는 서버를 프로비저닝하거나 관리할 필요 없이 코드를 실행하는 데 도움이 되는 컴퓨팅 서비스입니다. 필요할 때만 코드를 실행하며 자동으로 확장이 가능하므로 사용한 컴퓨팅 시간만큼만 비용을 지불합니다.
+ [AWS Service Catalog](https://docs.aws.amazon.com/servicecatalog/latest/adminguide/introduction.html)는 승인된 IT 서비스의 카탈로그를 중앙에서 관리할 수 있도록 지원합니다 AWS. 최종 사용자는 조직에서 규정한 제약에 따라, 필요에 따라 승인된 IT 서비스만 신속하게 배포할 수 있습니다.

**기타 서비스**
+ [Go](https://go.dev/doc/install)는 Google이 지원하는 오픈 소스 프로그래밍 언어입니다.
+ [Python](https://www.python.org/)은 범용 컴퓨터 프로그래밍 언어입니다.

**코드 리포지토리**

Service Catalog를 통해 배포할 수 있는 샘플 Terraform 구성이 필요한 경우 GitHub [Amazon Macie Organization Setup Using Terraform](https://github.com/aws-samples/aws-macie-customization-terraform-samples) 리포지토리의 구성을 사용할 수 있습니다. 이 리포지토리에서 코드 샘플을 사용할 필요는 없습니다.

## 모범 사례
<a name="provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository-best-practices"></a>
+ Service Catalog를 통해 제품을 시작할 때 Terraform 구성 파일(`terraform.tfvars`)에 변수 값을 제공하는 대신 변수 값을 구성합니다.
+ 포트폴리오에 대한 액세스 권한을 특정 사용자 또는 관리자에게만 부여합니다.
+ 최소 권한 원칙을 따르고 작업을 수행하는 데 필요한 최소 권한을 부여하세요. 자세한 내용은 AWS Identity and Access Management (IAM) 설명서의 [최소 권한 부여](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#grant-least-priv) 및 [보안 모범 사례를](https://docs.aws.amazon.com/IAM/latest/UserGuide/IAMBestPracticesAndUseCases.html) 참조하세요.

## 에픽
<a name="provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository-epics"></a>

### 로컬 워크스테이션 설정
<a name="set-up-your-local-workstation"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| (선택 사항) Docker 설치 | 개발 환경에서 AWS Lambda 함수를 실행하려면 Docker를 설치합니다. 자세한 내용은 도커 설명서의 [도커 엔진 설치](https://docs.docker.com/engine/install/) 단원을 참조하세요. | DevOps 엔지니어 | 
| Terraform용 AWS Service Catalog 엔진을 설치합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html) | AWS 관리자, DevOps 엔지니어 | 

### GitHub 리포지토리.
<a name="connect-the-github-repository"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| GitHub 리포지토리에 대한 연결을 생성할 수 없음 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html) | 관리자 | 

### 3단계: Service Catalog에서 제품 생성
<a name="create-a-terraform-product-in-service-catalog"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| Service Catalog 제품에서 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html) | 관리자 | 
| 포트폴리오를 생성합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html) | 관리자 | 
| 포트폴리오에 Terraform 제품을 추가합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html) | 관리자 | 
| 액세스 정책을 생성합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html) | 관리자 | 
| 사용자 지정 정책 생성 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html) | 관리자 | 
| Service Catalog 제품에 시작 제약 조건을 추가합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html) | 관리자 | 
| 제품에 대한 액세스 권한을 부여합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html) | 관리자 | 
| 제품을 시작하려면 | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html) | DevOps 엔지니어 | 

### 배포 확인
<a name="verify-the-deployment"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 배포를 검증합니다. | Service Catalog 프로비저닝 워크플로에는 두 가지 AWS Step Functions 상태 시스템이 있습니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html)`ManageProvisionedProductStateMachine` 상태 시스템의 로그를 확인하여 제품이 프로비저닝되었는지 확인합니다.[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html) | DevOps 엔지니어 | 

### 인프라 정리
<a name="clean-up-infrastructure"></a>


| 작업 | 설명 | 필요한 기술 | 
| --- | --- | --- | 
| 프로비저닝된 제품을 삭제합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html) | DevOps 엔지니어 | 
| Terraform용 AWS Service Catalog 엔진을 제거합니다. | [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/prescriptive-guidance/latest/patterns/provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository.html) | 관리자 | 

## 관련 리소스
<a name="provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository-resources"></a>

**AWS 설명서**
+ [Terraform 제품 시작하기](https://docs.aws.amazon.com/servicecatalog/latest/adminguide/getstarted-Terraform.html)

**Terraform 설명서**
+ [Terraform 설치](https://learn.hashicorp.com/tutorials/terraform/install-cli)
+ [Terraform 백엔드 구성](https://developer.hashicorp.com/terraform/language/backend)
+ [Terraform AWS 공급자 설명서](https://registry.terraform.io/providers/hashicorp/aws/latest/docs)

## 추가 정보
<a name="provision-a-terraform-product-in-aws-service-catalog-by-using-a-code-repository-additional"></a>

**액세스 정책**

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "s3:GetObject",
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "s3:ExistingObjectTag/servicecatalog:provisioning": "true"
                }
            }
        },
        {
            "Action": [
                "s3:CreateBucket*",
                "s3:DeleteBucket*",
                "s3:Get*",
                "s3:List*",
                "s3:PutBucketTagging"
            ],
            "Resource": "arn:aws:s3:::*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "resource-groups:CreateGroup",
                "resource-groups:ListGroupResources",
                "resource-groups:DeleteGroup",
                "resource-groups:Tag"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "tag:GetResources",
                "tag:GetTagKeys",
                "tag:GetTagValues",
                "tag:TagResources",
                "tag:UntagResources"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}
```

**신뢰 정책**

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "GivePermissionsToServiceCatalog",
            "Effect": "Allow",
            "Principal": {
                "Service": "servicecatalog.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        },
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::account_id:root"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringLike": {
                    "aws:PrincipalArn": [
                        "arn:aws:iam::accounti_id:role/TerraformEngine/TerraformExecutionRole*",
                        "arn:aws:iam::accounti_id:role/TerraformEngine/ServiceCatalogExternalParameterParserRole*",
                        "arn:aws:iam::accounti_id:role/TerraformEngine/ServiceCatalogTerraformOSParameterParserRole*"
                    ]
                }
            }
        }
    ]
}
```