AWS CloudFormation 예제 사용 AWS CLI - AWS Command Line Interface

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

AWS CloudFormation 예제 사용 AWS CLI

다음 코드 예제는 with를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여줍니다 AWS CloudFormation. AWS Command Line Interface

작업은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접적으로 호출하는 방법을 보여주며 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

각 예제에는 전체 소스 코드에 대한 링크가 포함되어 있으며, 여기에서 상황에 맞게 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있습니다.

주제

작업

다음 코드 예시에서는 activate-type을 사용하는 방법을 보여 줍니다.

AWS CLI

유형을 활성화하려면

다음 activate-type 예제는 타사 공용 확장을 활성화하여 스택 템플릿에서 사용할 수 있도록 합니다.

aws cloudformation activate-type \ --region us-west-2 \ --type RESOURCE \ --type-name Example::Test::1234567890abcdef0 \ --type-name-alias Example::Test::Alias

출력:

{ "Arn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/Example-Test-Alias" }

자세한 내용은 사용 설명서의 AWS CloudFormation 레지스트리 사용을 참조하십시오.AWS CloudFormation

  • 자세한 API 내용은 AWS CLI 명령 ActivateType참조를 참조하십시오.

다음 코드 예시에서는 batch-describe-type-configurations을 사용하는 방법을 보여 줍니다.

AWS CLI

유형 구성을 일괄 설명하려면

다음 batch-describe-type-configurations 예제에서는 유형에 대한 데이터를 구성합니다.

aws cloudformation batch-describe-type-configurations \ --region us-west-2 \ --type-configuration-identifiers TypeArn="arn:aws:cloudformation:us-west-2:123456789012:type/resource/Example-Test-Type,TypeConfigurationAlias=MyConfiguration"

출력:

{ "Errors": [], "UnprocessedTypeConfigurations": [], "TypeConfigurations": [ { "Arn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/Example-Test-Type", "Alias": "MyConfiguration", "Configuration": "{\n \"Example\": {\n \"ApiKey\": \"examplekey\",\n \"ApplicationKey\": \"examplekey1\",\n \"ApiURL\": \"exampleurl\"\n }\n}", "LastUpdated": "2021-10-01T15:25:46.210000+00:00", "TypeArn": "arn:aws:cloudformation:us-east-1:123456789012:type/resource/Example-Test-Type" } ] }

자세한 내용은 사용 AWS CloudFormation 설명서의 AWS CloudFormation 레지스트리 사용을 참조하십시오.

다음 코드 예시에서는 cancel-update-stack을 사용하는 방법을 보여 줍니다.

AWS CLI

진행 중인 스택 업데이트를 취소하려면

다음 cancel-update-stack 명령은 myteststack 스택의 스택 업데이트를 취소합니다.

aws cloudformation cancel-update-stack --stack-name myteststack
  • 자세한 API 내용은 AWS CLI 명령 CancelUpdateStack참조를 참조하십시오.

다음 코드 예시에서는 continue-update-rollback을 사용하는 방법을 보여 줍니다.

AWS CLI

업데이트 롤백을 재시도하려면

다음 continue-update-rollback 예제는 이전에 실패한 스택 업데이트에서 롤백 작업을 재개합니다.

aws cloudformation continue-update-rollback \ --stack-name my-stack

이 명령은 출력을 생성하지 않습니다.

다음 코드 예시에서는 create-change-set을 사용하는 방법을 보여 줍니다.

AWS CLI

변경 세트를 만들려면

다음 create-change-set 예제에서는 CAPABILITY_IAM 기능이 포함된 변경 세트를 만듭니다. 파일은 template.yaml IAM 리소스가 포함된 스택을 정의하는 현재 폴더의 AWS CloudFormation 템플릿입니다.

aws cloudformation create-change-set \ --stack-name my-application \ --change-set-name my-change-set \ --template-body file://template.yaml \ --capabilities CAPABILITY_IAM

출력:

{ "Id": "arn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/bc9555ba-a949-xmpl-bfb8-f41d04ec5784", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-application/d0a825a0-e4cd-xmpl-b9fb-061c69e99204" }
  • 자세한 API 내용은 AWS CLI 명령 CreateChangeSet참조를 참조하십시오.

다음 코드 예시에서는 create-stack-instances을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 인스턴스를 만들려면

다음 create-stack-instances 예시에서는 두 개의 계정과 네 개의 지역에 스택 세트의 인스턴스를 만듭니다. 내결함성 설정을 통해 일부 스택을 생성할 수 없는 경우에도 모든 계정과 지역에서 업데이트를 시도할 수 있습니다.

aws cloudformation create-stack-instances \ --stack-set-name my-stack-set \ --accounts 123456789012 223456789012 \ --regions us-east-1 us-east-2 us-west-1 us-west-2 \ --operation-preferences FailureToleranceCount=7

출력:

{ "OperationId": "d7995c31-83c2-xmpl-a3d4-e9ca2811563f" }

스택 세트를 생성하려면 create-stack-set 명령을 사용합니다.

다음 코드 예시에서는 create-stack-set을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 세트를 만들려면

다음 create-stack-set 예제에서는 지정된 YAML 파일 템플릿을 사용하여 스택 세트를 만듭니다. template.yaml스택을 정의하는 현재 폴더의 AWS CloudFormation 템플릿입니다.

aws cloudformation create-stack-set \ --stack-set-name my-stack-set \ --template-body file://template.yaml \ --description "SNS topic"

출력:

{ "StackSetId": "my-stack-set:8d0f160b-d157-xmpl-a8e6-c0ce8e5d8cc1" }

스택 세트에 스택 인스턴스를 추가하려면 create-stack-instances 명령을 사용합니다.

  • 자세한 API 내용은 AWS CLI 명령 CreateStackSet참조를 참조하십시오.

다음 코드 예시에서는 create-stack을 사용하는 방법을 보여 줍니다.

AWS CLI

AWS CloudFormation 스택을 만들려면

다음 create-stacks 명령에서는 sampletemplate.json 템플릿을 사용하여 이름이 myteststack인 스택을 생성합니다.

aws cloudformation create-stack --stack-name myteststack --template-body file://sampletemplate.json --parameters ParameterKey=KeyPairName,ParameterValue=TestKey ParameterKey=SubnetIDs,ParameterValue=SubnetID1\\,SubnetID2

출력:

{ "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/myteststack/466df9e0-0dff-08e3-8e2f-5088487c4896" }

자세한 내용은 AWS CloudFormation 사용 설명서의 스택을 참조하십시오.

  • 자세한 API 내용은 AWS CLI 명령 CreateStack참조를 참조하십시오.

다음 코드 예시에서는 deactivate-type을 사용하는 방법을 보여 줍니다.

AWS CLI

유형을 비활성화하려면

다음 deactivate-type 예시는 이전에 이 계정 및 지역에서 활성화된 공개 확장 프로그램을 비활성화합니다.

aws cloudformation deactivate-type \ --region us-west-2 \ --type MODULE \ --type-name Example::Test::Type::MODULE

이 명령은 출력을 생성하지 않습니다.

자세한 내용은 사용 AWS CloudFormation 설명서의 AWS CloudFormation 레지스트리 사용을 참조하십시오.

  • 자세한 API 내용은 AWS CLI 명령 DeactivateType참조를 참조하십시오.

다음 코드 예시에서는 delete-change-set을 사용하는 방법을 보여 줍니다.

AWS CLI

변경 세트를 삭제하려면

다음 delete-change-set 예제에서는 변경 세트 이름과 스택 이름을 지정하여 변경 세트를 삭제합니다.

aws cloudformation delete-change-set \ --stack-name my-stack \ --change-set-name my-change-set

이 명령은 출력을 생성하지 않습니다.

다음 delete-change-set 예제에서는 변경 세트 전체를 지정하여 변경 ARN 세트를 삭제합니다.

aws cloudformation delete-change-set \ --change-set-name arn:aws:cloudformation:us-east-2:123456789012:changeSet/my-change-set/4eca1a01-e285-xmpl-8026-9a1967bfb4b0

이 명령은 출력을 생성하지 않습니다.

  • 자세한 API 내용은 AWS CLI 명령 DeleteChangeSet참조를 참조하십시오.

다음 코드 예시에서는 delete-stack-instances을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 인스턴스를 삭제하려면

다음 delete-stack-instances 예시에서는 두 지역의 두 계정에 설정된 스택의 인스턴스를 삭제하고 스택을 종료합니다.

aws cloudformation delete-stack-instances \ --stack-set-name my-stack-set \ --accounts 123456789012 567890123456 \ --regions us-east-1 us-west-1 \ --no-retain-stacks

출력:

{ "OperationId": "ad49f10c-fd1d-413f-a20a-8de6e2fa8f27" }

빈 스택 세트를 삭제하려면 명령어를 사용합니다. delete-stack-set

다음 코드 예시에서는 delete-stack-set을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 세트를 삭제하려면

다음 명령은 지정된 빈 스택 세트를 삭제합니다. 스택 세트는 비어 있어야 합니다.

aws cloudformation delete-stack-set \ --stack-set-name my-stack-set

이 명령은 출력을 생성하지 않습니다.

스택 세트에서 인스턴스를 삭제하려면 delete-stack-instances 명령을 사용합니다.

  • 자세한 API 내용은 AWS CLI 명령 DeleteStackSet참조를 참조하십시오.

다음 코드 예시에서는 delete-stack을 사용하는 방법을 보여 줍니다.

AWS CLI

스택을 삭제하려면

다음 delete-stack 예제에서는 지정된 스택을 삭제합니다.

aws cloudformation delete-stack \ --stack-name my-stack

이 명령은 출력을 생성하지 않습니다.

  • 자세한 API 내용은 AWS CLI 명령 DeleteStack참조를 참조하십시오.

다음 코드 예시에서는 deploy을 사용하는 방법을 보여 줍니다.

AWS CLI

다음 명령은 이름이 지정된 템플릿을 이름이 지정된 template.json 스택에 배포합니다. my-new-stack

aws cloudformation deploy --template-file /path_to_template/template.json --stack-name my-new-stack --parameter-overrides Key1=Value1 Key2=Value2 --tags Key1=Value1 Key2=Value2
  • 자세한 API 내용은 AWS CLI 명령 참조의 배포를 참조하십시오.

다음 코드 예시에서는 deregister-type을 사용하는 방법을 보여 줍니다.

AWS CLI

타입 버전 등록을 취소하려면

다음 deregister-type 예제에서는 지정된 유형 버전을 CloudFormation 레지스트리에서 적극적으로 사용하지 않도록 제거하여 더 이상 CloudFormation 작업에 사용할 수 없도록 합니다.

aws cloudformation deregister-type \ --type RESOURCE \ --type-name My::Logs::LogGroup \ --version-id 00000002

이 명령은 출력을 생성하지 않습니다.

자세한 내용은 사용 설명서의 CloudFormation 레지스트리 사용을AWS CloudFormation 참조하십시오.

  • 자세한 API 내용은 AWS CLI 명령 DeregisterType참조를 참조하십시오.

다음 코드 예시에서는 describe-account-limits을 사용하는 방법을 보여 줍니다.

AWS CLI

계정 한도에 대한 정보를 얻으려면

다음 명령은 현재 계정의 지역 한도 목록을 검색합니다.

aws cloudformation describe-account-limits

출력:

{ "AccountLimits": [ { "Name": "StackLimit", "Value": 200 }, { "Name": "StackOutputsLimit", "Value": 60 }, { "Name": "ConcurrentResourcesLimit", "Value": 2500 } ] }

다음 코드 예시에서는 describe-change-set을 사용하는 방법을 보여 줍니다.

AWS CLI

변경 세트에 대한 정보를 가져오려면

다음 describe-change-set 예제는 변경 세트 이름 및 스택 이름으로 지정된 변경 세트의 세부 정보를 표시합니다.

aws cloudformation describe-change-set \ --change-set-name my-change-set \ --stack-name my-stack

다음 describe-change-set 예제에서는 전체 ARN 변경 세트로 지정된 변경 세트의 세부 정보를 표시합니다.

aws cloudformation describe-change-set \ --change-set-name arn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/bc9555ba-a949-xmpl-bfb8-f41d04ec5784

출력:

{ "Changes": [ { "Type": "Resource", "ResourceChange": { "Action": "Modify", "LogicalResourceId": "function", "PhysicalResourceId": "my-function-SEZV4XMPL4S5", "ResourceType": "AWS::Lambda::Function", "Replacement": "False", "Scope": [ "Properties" ], "Details": [ { "Target": { "Attribute": "Properties", "Name": "Timeout", "RequiresRecreation": "Never" }, "Evaluation": "Static", "ChangeSource": "DirectModification" } ] } } ], "ChangeSetName": "my-change-set", "ChangeSetId": "arn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/4eca1a01-e285-xmpl-8026-9a1967bfb4b0", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "StackName": "my-stack", "Description": null, "Parameters": null, "CreationTime": "2019-10-02T05:20:56.651Z", "ExecutionStatus": "AVAILABLE", "Status": "CREATE_COMPLETE", "StatusReason": null, "NotificationARNs": [], "RollbackConfiguration": {}, "Capabilities": [ "CAPABILITY_IAM" ], "Tags": null }
  • 자세한 API 내용은 AWS CLI 명령 DescribeChangeSet참조를 참조하십시오.

다음 코드 예시에서는 describe-publisher을 사용하는 방법을 보여 줍니다.

AWS CLI

퍼블리셔를 설명하려면

다음 describe-publisher 예제는 게시자에 대한 정보를 구성합니다.

aws cloudformation describe-publisher \ --region us-west-2 \ --publisher-id 000q6TfUovXsEMmgKowxDZLlwqr2QUsh

출력:

{ "PublisherId": "000q6TfUovXsEMmgKowxDZLlwqr2QUshd2e75c8c", "PublisherStatus": "VERIFIED", "IdentityProvider": "AWS_Marketplace", "PublisherProfile": "https://aws.amazon.com/marketplace/seller-profile?id=2c5dc1f0-17cd-4259-8e46-822a83gdtegd" }

자세한 내용은 사용 설명서의 AWS CloudFormation 레지스트리 사용을 참조하십시오.AWS CloudFormation

  • 자세한 API 내용은 AWS CLI 명령 DescribePublisher참조를 참조하십시오.

다음 코드 예시에서는 describe-stack-drift-detection-status을 사용하는 방법을 보여 줍니다.

AWS CLI

드리프트 감지 작업 상태를 확인하려면

다음 describe-stack-drift-detection-status 예제는 드리프트 감지 작업의 상태를 표시합니다. detect-stack-drift명령을 실행하여 ID별로 가져옵니다.

aws cloudformation describe-stack-drift-detection-status \ --stack-drift-detection-id 1a229160-e4d9-xmpl-ab67-0a4f93df83d4

출력:

{ "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "StackDriftDetectionId": "1a229160-e4d9-xmpl-ab67-0a4f93df83d4", "StackDriftStatus": "DRIFTED", "DetectionStatus": "DETECTION_COMPLETE", "DriftedStackResourceCount": 1, "Timestamp": "2019-10-02T05:54:30.902Z" }

다음 코드 예시에서는 describe-stack-events을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 이벤트를 설명하려면

다음 describe-stack-events 예제에서는 지정된 스택의 가장 최근 이벤트 2개를 표시합니다.

aws cloudformation describe-stack-events \ --stack-name my-stack \ --max-items 2 { "StackEvents": [ { "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "EventId": "4e1516d0-e4d6-xmpl-b94f-0a51958a168c", "StackName": "my-stack", "LogicalResourceId": "my-stack", "PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "ResourceType": "AWS::CloudFormation::Stack", "Timestamp": "2019-10-02T05:34:29.556Z", "ResourceStatus": "UPDATE_COMPLETE" }, { "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "EventId": "4dd3c810-e4d6-xmpl-bade-0aaf8b31ab7a", "StackName": "my-stack", "LogicalResourceId": "my-stack", "PhysicalResourceId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "ResourceType": "AWS::CloudFormation::Stack", "Timestamp": "2019-10-02T05:34:29.127Z", "ResourceStatus": "UPDATE_COMPLETE_CLEANUP_IN_PROGRESS" } ], "NextToken": "eyJOZXh0VG9XMPLiOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAyfQ==" }

다음 코드 예시에서는 describe-stack-instance을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 인스턴스 설명하기

다음 명령은 지정된 계정 및 지역에 설정된 지정된 스택의 인스턴스를 설명합니다. 스택 세트는 현재 리전 및 계정에 있고 인스턴스는 계정 내 us-west-2 리전에 123456789012 있습니다. :

aws cloudformation describe-stack-instance \ --stack-set-name my-stack-set \ --stack-instance-account 123456789012 \ --stack-instance-region us-west-2

출력:

{ "StackInstance": { "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743", "Region": "us-west-2", "Account": "123456789012", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/StackSet-enable-config-e6cac20f-xmpl-46e9-8314-53e0d4591532/4287f9a0-e615-xmpl-894a-12b31d3117be", "ParameterOverrides": [], "Status": "OUTDATED", "StatusReason": "ResourceLogicalId:ConfigBucket, ResourceType:AWS::S3::Bucket, ResourceStatusReason:You have attempted to create more buckets than allowed (Service: Amazon S3; Status Code: 400; Error Code: TooManyBuckets; Request ID: F7F21CXMPL580224; S3 Extended Request ID: egd/Fdt89BXMPLyiqbMNljVk55Yqqvi3NYW2nKLUVWhUGEhNfCmZdyj967lhriaG/dWMobSO40o=)." } }

다음 코드 예시에서는 describe-stack-resource-drifts을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 정의에서 벗어난 리소스에 대한 정보를 가져오려면

다음 명령은 지정된 스택의 드리프트된 리소스에 대한 정보를 표시합니다. 드리프트 감지를 시작하려면 명령을 사용합니다. detect-stack-drift :

aws cloudformation describe-stack-resource-drifts \ --stack-name my-stack

출력에는 수정된 AWS Lambda 함수가 표시됩니다. out-of-band

{ "StackResourceDrifts": [ { "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "LogicalResourceId": "function", "PhysicalResourceId": "my-function-SEZV4XMPL4S5", "ResourceType": "AWS::Lambda::Function", "ExpectedProperties": "{\"Description\":\"Write a file to S3.\",\"Environment\":{\"Variables\":{\"bucket\":\"my-stack-bucket-1vc62xmplgguf\"}},\"Handler\":\"index.handler\",\"MemorySize\":128,\"Role\":\"arn:aws:iam::123456789012:role/my-functionRole-HIZXMPLEOM9E\",\"Runtime\":\"nodejs10.x\",\"Tags\":[{\"Key\":\"lambda:createdBy\",\"Value\":\"SAM\"}],\"Timeout\":900,\"TracingConfig\":{\"Mode\":\"Active\"}}", "ActualProperties": "{\"Description\":\"Write a file to S3.\",\"Environment\":{\"Variables\":{\"bucket\":\"my-stack-bucket-1vc62xmplgguf\"}},\"Handler\":\"index.handler\",\"MemorySize\":256,\"Role\":\"arn:aws:iam::123456789012:role/my-functionRole-HIZXMPLEOM9E\",\"Runtime\":\"nodejs10.x\",\"Tags\":[{\"Key\":\"lambda:createdBy\",\"Value\":\"SAM\"}],\"Timeout\":22,\"TracingConfig\":{\"Mode\":\"Active\"}}", "PropertyDifferences": [ { "PropertyPath": "/MemorySize", "ExpectedValue": "128", "ActualValue": "256", "DifferenceType": "NOT_EQUAL" }, { "PropertyPath": "/Timeout", "ExpectedValue": "900", "ActualValue": "22", "DifferenceType": "NOT_EQUAL" } ], "StackResourceDriftStatus": "MODIFIED", "Timestamp": "2019-10-02T05:54:44.064Z" } ] }

다음 코드 예시에서는 describe-stack-resource을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 리소스에 대한 정보를 가져오려면

다음 describe-stack-resource 예제에서는 지정된 스택의 이름이 MyFunction인 리소스에 대한 세부 정보를 표시합니다.

aws cloudformation describe-stack-resource \ --stack-name MyStack \ --logical-resource-id MyFunction

출력:

{ "StackResourceDetail": { "StackName": "MyStack", "StackId": "arn:aws:cloudformation:us-east-2:123456789012:stack/MyStack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "LogicalResourceId": "MyFunction", "PhysicalResourceId": "my-function-SEZV4XMPL4S5", "ResourceType": "AWS::Lambda::Function", "LastUpdatedTimestamp": "2019-10-02T05:34:27.989Z", "ResourceStatus": "UPDATE_COMPLETE", "Metadata": "{}", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } } }

다음 코드 예시에서는 describe-stack-resources을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 리소스에 대한 정보를 가져오려면

다음 describe-stack-resources 예제에서는 지정된 스택의 리소스에 대한 세부 정보를 표시합니다.

aws cloudformation describe-stack-resources \ --stack-name my-stack

출력:

{ "StackResources": [ { "StackName": "my-stack", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "LogicalResourceId": "bucket", "PhysicalResourceId": "my-stack-bucket-1vc62xmplgguf", "ResourceType": "AWS::S3::Bucket", "Timestamp": "2019-10-02T04:34:11.345Z", "ResourceStatus": "CREATE_COMPLETE", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } }, { "StackName": "my-stack", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "LogicalResourceId": "function", "PhysicalResourceId": "my-function-SEZV4XMPL4S5", "ResourceType": "AWS::Lambda::Function", "Timestamp": "2019-10-02T05:34:27.989Z", "ResourceStatus": "UPDATE_COMPLETE", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } }, { "StackName": "my-stack", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "LogicalResourceId": "functionRole", "PhysicalResourceId": "my-functionRole-HIZXMPLEOM9E", "ResourceType": "AWS::IAM::Role", "Timestamp": "2019-10-02T04:34:06.350Z", "ResourceStatus": "CREATE_COMPLETE", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } } ] }

다음 코드 예시에서는 describe-stack-set-operation을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 세트 작업에 대한 정보를 가져오려면

다음 describe-stack-set-operation `예제는 지정된 스택 세트의 업데이트 작업에 대한 세부 정보를 표시합니다.

aws cloudformation describe-stack-set-operation \ --stack-set-name enable-config \ --operation-id 35d45ebc-ed88-xmpl-ab59-0197a1fc83a0

출력:

{ "StackSetOperation": { "OperationId": "35d45ebc-ed88-xmpl-ab59-0197a1fc83a0", "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743", "Action": "UPDATE", "Status": "SUCCEEDED", "OperationPreferences": { "RegionOrder": [ "us-east-1", "us-west-2", "eu-west-1", "us-west-1" ], "FailureToleranceCount": 7, "MaxConcurrentCount": 2 }, "AdministrationRoleARN": "arn:aws:iam::123456789012:role/AWSCloudFormationStackSetAdministrationRole", "ExecutionRoleName": "AWSCloudFormationStackSetExecutionRole", "CreationTimestamp": "2019-10-03T16:28:44.377Z", "EndTimestamp": "2019-10-03T16:42:08.607Z" } }

다음 코드 예시에서는 describe-stack-set을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 세트에 대한 정보를 가져오려면

다음 describe-stack-set `예제는 지정된 스택 세트에 대한 세부 정보를 표시합니다.

aws cloudformation describe-stack-set \ --stack-set-name my-stack-set

출력:

{ "StackSet": { "StackSetName": "my-stack-set", "StackSetId": "my-stack-set:296a3360-xmpl-40af-be78-9341e95bf743", "Description": "Create an Amazon SNS topic", "Status": "ACTIVE", "TemplateBody": "AWSTemplateFormatVersion: '2010-09-09'\nDescription: An AWS SNS topic\nResources:\n topic:\n Type: AWS::SNS::Topic", "Parameters": [], "Capabilities": [], "Tags": [], "StackSetARN": "arn:aws:cloudformation:us-west-2:123456789012:stackset/enable-config:296a3360-xmpl-40af-be78-9341e95bf743", "AdministrationRoleARN": "arn:aws:iam::123456789012:role/AWSCloudFormationStackSetAdministrationRole", "ExecutionRoleName": "AWSCloudFormationStackSetExecutionRole" } }
  • 자세한 API 내용은 AWS CLI 명령 DescribeStackSet참조를 참조하십시오.

다음 코드 예시에서는 describe-stacks을 사용하는 방법을 보여 줍니다.

AWS CLI

AWS CloudFormation 스택을 설명하려면

다음 describe-stacks 명령에서는 myteststack 스택에 대한 요약 정보를 보여줍니다.

aws cloudformation describe-stacks --stack-name myteststack

출력:

{ "Stacks": [ { "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/myteststack/466df9e0-0dff-08e3-8e2f-5088487c4896", "Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.", "Tags": [], "Outputs": [ { "Description": "Name of S3 bucket to hold website content", "OutputKey": "BucketName", "OutputValue": "myteststack-s3bucket-jssofi1zie2w" } ], "StackStatusReason": null, "CreationTime": "2013-08-23T01:02:15.422Z", "Capabilities": [], "StackName": "myteststack", "StackStatus": "CREATE_COMPLETE", "DisableRollback": false } ] }

자세한 내용은 AWS CloudFormation 사용 설명서의 스택을 참조하십시오.

  • 자세한 API 내용은 AWS CLI 명령 DescribeStacks참조를 참조하십시오.

다음 코드 예시에서는 describe-type-registration을 사용하는 방법을 보여 줍니다.

AWS CLI

유형 등록 정보를 표시하려면

다음 describe-type-registration 예제는 유형의 현재 상태, 유형 및 버전을 포함하여 지정된 유형 등록에 대한 정보를 표시합니다.

aws cloudformation describe-type-registration \ --registration-token a1b2c3d4-5678-90ab-cdef-EXAMPLE11111

출력:

{ "ProgressStatus": "COMPLETE", "TypeArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Logs-LogGroup", "Description": "Deployment is currently in DEPLOY_STAGE of status COMPLETED; ", "TypeVersionArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Logs-LogGroup/00000001" }

자세한 내용은 사용 설명서의 CloudFormation 레지스트리 사용을AWS CloudFormation 참조하십시오.

다음 코드 예시에서는 describe-type을 사용하는 방법을 보여 줍니다.

AWS CLI

유형 정보를 표시하려면

다음 describe-type 예제에서는 지정된 유형에 대한 정보를 표시합니다.

aws cloudformation describe-type \ --type-name My::Logs::LogGroup \ --type RESOURCE

출력:

{ "SourceUrl": "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-logs.git", "Description": "Customized resource derived from AWS::Logs::LogGroup", "TimeCreated": "2019-12-03T23:29:33.321Z", "Visibility": "PRIVATE", "TypeName": "My::Logs::LogGroup", "LastUpdated": "2019-12-03T23:29:33.321Z", "DeprecatedStatus": "LIVE", "ProvisioningType": "FULLY_MUTABLE", "Type": "RESOURCE", "Arn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Logs-LogGroup/00000001", "Schema": "[details omitted]" }

자세한 내용은 사용 설명서의 CloudFormation 레지스트리 사용을AWS CloudFormation 참조하십시오.

  • 자세한 API 내용은 AWS CLI 명령 DescribeType참조를 참조하십시오.

다음 코드 예시에서는 detect-stack-drift을 사용하는 방법을 보여 줍니다.

AWS CLI

드리프트된 리소스를 탐지하려면

다음 detect-stack-drift 예제에서는 지정된 스택에 대한 드리프트 감지를 시작합니다.

aws cloudformation detect-stack-drift \ --stack-name my-stack

출력:

{ "StackDriftDetectionId": "1a229160-e4d9-xmpl-ab67-0a4f93df83d4" }

그런 다음 이 ID를 describe-stack-resource-drifts 명령과 함께 사용하여 드리프트된 리소스를 설명할 수 있습니다.

  • 자세한 API 내용은 AWS CLI 명령 DetectStackDrift참조를 참조하십시오.

다음 코드 예시에서는 detect-stack-resource-drift을 사용하는 방법을 보여 줍니다.

AWS CLI

리소스의 드리프트를 감지하려면

다음 detect-stack-resource-drift 예제에서는 drift라는 이름의 MyFunction MyStack 스택에서 이름이 지정된 리소스를 확인합니다.

aws cloudformation detect-stack-resource-drift \ --stack-name MyStack \ --logical-resource-id MyFunction

출력에는 수정된 AWS Lambda 함수가 표시됩니다. out-of-band

{ "StackResourceDrift": { "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/MyStack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "LogicalResourceId": "MyFunction", "PhysicalResourceId": "my-function-SEZV4XMPL4S5", "ResourceType": "AWS::Lambda::Function", "ExpectedProperties": "{\"Description\":\"Write a file to S3.\",\"Environment\":{\"Variables\":{\"bucket\":\"my-stack-bucket-1vc62xmplgguf\"}},\"Handler\":\"index.handler\",\"MemorySize\":128,\"Role\":\"arn:aws:iam::123456789012:role/my-functionRole-HIZXMPLEOM9E\",\"Runtime\":\"nodejs10.x\",\"Tags\":[{\"Key\":\"lambda:createdBy\",\"Value\":\"SAM\"}],\"Timeout\":900,\"TracingConfig\":{\"Mode\":\"Active\"}}", "ActualProperties": "{\"Description\":\"Write a file to S3.\",\"Environment\":{\"Variables\":{\"bucket\":\"my-stack-bucket-1vc62xmplgguf\"}},\"Handler\":\"index.handler\",\"MemorySize\":256,\"Role\":\"arn:aws:iam::123456789012:role/my-functionRole-HIZXMPLEOM9E\",\"Runtime\":\"nodejs10.x\",\"Tags\":[{\"Key\":\"lambda:createdBy\",\"Value\":\"SAM\"}],\"Timeout\":22,\"TracingConfig\":{\"Mode\":\"Active\"}}", "PropertyDifferences": [ { "PropertyPath": "/MemorySize", "ExpectedValue": "128", "ActualValue": "256", "DifferenceType": "NOT_EQUAL" }, { "PropertyPath": "/Timeout", "ExpectedValue": "900", "ActualValue": "22", "DifferenceType": "NOT_EQUAL" } ], "StackResourceDriftStatus": "MODIFIED", "Timestamp": "2019-10-02T05:58:47.433Z" } }

다음 코드 예시에서는 detect-stack-set-drift을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 세트 및 모든 관련 스택 인스턴스에서 드리프트를 감지하려면

다음 detect-stack-set-drift 예제는 해당 스택 세트와 연결된 모든 스택 인스턴스를 포함하여 지정된 스택 세트에서 드리프트 감지 작업을 시작하고 드리프트 작업 상태를 추적하는 데 사용할 수 있는 작업 ID를 반환합니다.

aws cloudformation detect-stack-set-drift \ --stack-set-name stack-set-drift-example

출력:

{ "OperationId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" }

자세한 내용은 사용 설명서의 스택 세트의 관리되지 않는 구성 변경 감지를 참조하십시오.AWS CloudFormation

다음 코드 예시에서는 estimate-template-cost을 사용하는 방법을 보여 줍니다.

AWS CLI

템플릿 비용을 추정하려면

다음 estimate-template-cost 예제에서는 현재 폴더에서 이름이 template.yaml인 템플릿에 대한 예상 비용을 생성합니다.

aws cloudformation estimate-template-cost \ --template-body file://template.yaml

출력:

{ "Url": "http://calculator.s3.amazonaws.com/calc5.html?key=cloudformation/7870825a-xmpl-4def-92e7-c4f8dd360cca" }

다음 코드 예시에서는 execute-change-set을 사용하는 방법을 보여 줍니다.

AWS CLI

변경 세트를 실행하려면

다음 execute-change-set 예제에서는 변경 세트 이름과 스택 이름으로 지정된 변경 세트를 실행합니다.

aws cloudformation execute-change-set \ --change-set-name my-change-set \ --stack-name my-stack

다음 execute-change-set 예제에서는 전체 ARN 변경 세트로 지정된 변경 세트를 실행합니다.

aws cloudformation execute-change-set \ --change-set-name arn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/bc9555ba-a949-xmpl-bfb8-f41d04ec5784
  • 자세한 API 내용은 AWS CLI 명령 ExecuteChangeSet참조를 참조하십시오.

다음 코드 예시에서는 get-stack-policy을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 정책을 보려면

다음 get-stack-policy 예제는 지정된 스택의 스택 정책을 표시합니다. 정책을 스택에 연결하려면 set-stack-policy 명령을 사용합니다.

aws cloudformation get-stack-policy \ --stack-name my-stack

출력:

{ "StackPolicyBody": "{\n \"Statement\" : [\n {\n \"Effect\" : \"Allow\",\n \"Action\" : \"Update:*\",\n \"Principal\": \"*\",\n \"Resource\" : \"*\"\n },\n {\n \"Effect\" : \"Deny\",\n \"Action\" : \"Update:*\",\n \"Principal\": \"*\",\n \"Resource\" : \"LogicalResourceId/bucket\"\n }\n ]\n}\n" }
  • 자세한 API 내용은 AWS CLI 명령 GetStackPolicy참조를 참조하십시오.

다음 코드 예시에서는 get-template-summary을 사용하는 방법을 보여 줍니다.

AWS CLI

템플릿 요약을 표시하려면

다음 명령은 지정된 템플릿 파일의 리소스 및 메타데이터에 대한 요약 정보를 표시합니다.

aws cloudformation get-template-summary \ --template-body file://template.yaml

출력:

{ "Parameters": [], "Description": "A VPC and subnets.", "ResourceTypes": [ "AWS::EC2::VPC", "AWS::EC2::Subnet", "AWS::EC2::Subnet", "AWS::EC2::RouteTable", "AWS::EC2::VPCEndpoint", "AWS::EC2::SubnetRouteTableAssociation", "AWS::EC2::SubnetRouteTableAssociation", "AWS::EC2::VPCEndpoint" ], "Version": "2010-09-09" }

다음 코드 예시에서는 get-template을 사용하는 방법을 보여 줍니다.

AWS CLI

AWS CloudFormation 스택의 템플릿 본문을 보려면

다음 get-template 명령에서는 myteststack 스택에 대한 템플릿을 보여줍니다.

aws cloudformation get-template --stack-name myteststack

출력:

{ "TemplateBody": { "AWSTemplateFormatVersion": "2010-09-09", "Outputs": { "BucketName": { "Description": "Name of S3 bucket to hold website content", "Value": { "Ref": "S3Bucket" } } }, "Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.", "Resources": { "S3Bucket": { "Type": "AWS::S3::Bucket", "Properties": { "AccessControl": "PublicRead" } } } } }
  • 자세한 API 내용은 AWS CLI 명령 GetTemplate참조를 참조하십시오.

다음 코드 예시에서는 list-change-sets을 사용하는 방법을 보여 줍니다.

AWS CLI

변경 세트를 나열하려면

다음 list-change-sets 예제는 지정된 스택에 대해 보류 중인 변경 세트 목록을 표시합니다.

aws cloudformation list-change-sets \ --stack-name my-stack

출력:

{ "Summaries": [ { "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204", "StackName": "my-stack", "ChangeSetId": "arn:aws:cloudformation:us-west-2:123456789012:changeSet/my-change-set/70160340-7914-xmpl-bcbf-128a1fa78b5d", "ChangeSetName": "my-change-set", "ExecutionStatus": "AVAILABLE", "Status": "CREATE_COMPLETE", "CreationTime": "2019-10-02T05:38:54.297Z" } ] }
  • 자세한 API 내용은 AWS CLI 명령 ListChangeSets참조를 참조하십시오.

다음 코드 예시에서는 list-exports을 사용하는 방법을 보여 줍니다.

AWS CLI

익스포트를 나열하려면

다음 list-exports 예제는 현재 지역의 스택에서 내보낸 목록을 표시합니다.

aws cloudformation list-exports

출력:

{ "Exports": [ { "ExportingStackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/private-vpc/99764070-b56c-xmpl-bee8-062a88d1d800", "Name": "private-vpc-subnet-a", "Value": "subnet-07b410xmplddcfa03" }, { "ExportingStackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/private-vpc/99764070-b56c-xmpl-bee8-062a88d1d800", "Name": "private-vpc-subnet-b", "Value": "subnet-075ed3xmplebd2fb1" }, { "ExportingStackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/private-vpc/99764070-b56c-xmpl-bee8-062a88d1d800", "Name": "private-vpc-vpcid", "Value": "vpc-011d7xmpl100e9841" } ] }
  • 자세한 API 내용은 AWS CLI 명령 ListExports참조를 참조하십시오.

다음 코드 예시에서는 list-imports을 사용하는 방법을 보여 줍니다.

AWS CLI

임포트를 나열하려면

다음 list-imports 예제는 지정된 익스포트를 가져오는 스택을 나열합니다. 사용 가능한 내보내기 목록을 가져오려면 list-exports 명령을 사용합니다.

aws cloudformation list-imports \ --export-name private-vpc-vpcid

출력:

{ "Imports": [ "my-database-stack" ] }
  • 자세한 API 내용은 AWS CLI 명령 ListImports참조를 참조하십시오.

다음 코드 예시에서는 list-stack-instances을 사용하는 방법을 보여 줍니다.

AWS CLI

스택의 인스턴스를 나열하려면

다음 list-stack-instances 예제는 지정된 스택 세트에서 생성된 인스턴스를 나열합니다.

aws cloudformation list-stack-instances \ --stack-set-name enable-config

예제 출력에는 오류로 인해 업데이트에 실패한 스택에 대한 세부 정보가 포함됩니다.

{ "Summaries": [ { "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743", "Region": "us-west-2", "Account": "123456789012", "StackId": "arn:aws:cloudformation:ap-northeast-1:123456789012:stack/StackSet-enable-config-35a6ac50-d9f8-4084-86e4-7da34d5de4c4/a1631cd0-e5fb-xmpl-b474-0aa20f14f06e", "Status": "CURRENT" }, { "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743", "Region": "us-west-2", "Account": "123456789012", "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/StackSet-enable-config-e6cac20f-xmpl-46e9-8314-53e0d4591532/eab53680-e5fa-xmpl-ba14-0a522351f81e", "Status": "OUTDATED", "StatusReason": "ResourceLogicalId:ConfigDeliveryChannel, ResourceType:AWS::Config::DeliveryChannel, ResourceStatusReason:Failed to put delivery channel 'StackSet-enable-config-e6cac20f-xmpl-46e9-8314-53e0d4591532-ConfigDeliveryChannel-1OJWJ7XD59WR0' because the maximum number of delivery channels: 1 is reached. (Service: AmazonConfig; Status Code: 400; Error Code: MaxNumberOfDeliveryChannelsExceededException; Request ID: d14b34a0-ef7c-xmpl-acf8-8a864370ae56)." } ] }

다음 코드 예시에서는 list-stack-resources을 사용하는 방법을 보여 줍니다.

AWS CLI

스택의 리소스를 나열하려면

다음 명령은 지정된 스택의 리소스 목록을 표시합니다.

aws cloudformation list-stack-resources \ --stack-name my-stack

출력:

{ "StackResourceSummaries": [ { "LogicalResourceId": "bucket", "PhysicalResourceId": "my-stack-bucket-1vc62xmplgguf", "ResourceType": "AWS::S3::Bucket", "LastUpdatedTimestamp": "2019-10-02T04:34:11.345Z", "ResourceStatus": "CREATE_COMPLETE", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } }, { "LogicalResourceId": "function", "PhysicalResourceId": "my-function-SEZV4XMPL4S5", "ResourceType": "AWS::Lambda::Function", "LastUpdatedTimestamp": "2019-10-02T05:34:27.989Z", "ResourceStatus": "UPDATE_COMPLETE", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } }, { "LogicalResourceId": "functionRole", "PhysicalResourceId": "my-functionRole-HIZXMPLEOM9E", "ResourceType": "AWS::IAM::Role", "LastUpdatedTimestamp": "2019-10-02T04:34:06.350Z", "ResourceStatus": "CREATE_COMPLETE", "DriftInformation": { "StackResourceDriftStatus": "IN_SYNC" } } ] }

다음 코드 예시에서는 list-stack-set-operation-results을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 세트 작업 결과를 나열하려면

다음 명령은 지정된 스택 세트의 인스턴스에 대한 업데이트 작업 결과를 표시합니다.

aws cloudformation list-stack-set-operation-results \ --stack-set-name enable-config \ --operation-id 35d45ebc-ed88-xmpl-ab59-0197a1fc83a0

출력:

{ "Summaries": [ { "Account": "223456789012", "Region": "us-west-2", "Status": "SUCCEEDED", "AccountGateResult": { "Status": "SKIPPED", "StatusReason": "Function not found: arn:aws:lambda:eu-west-1:223456789012:function:AWSCloudFormationStackSetAccountGate" } }, { "Account": "223456789012", "Region": "ap-south-1", "Status": "CANCELLED", "StatusReason": "Cancelled since failure tolerance has exceeded" } ] }

참고: 계정 게이트 함수를 생성하지 않는 한 작업이 성공하려면 의 SKIPPED 상태가 표시될 것으로 예상됩니다. AccountGateResult

다음 코드 예시에서는 list-stack-set-operations을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 세트 작업을 나열하려면

다음 list-stack-set-operations 예제는 지정된 스택 세트의 가장 최근 작업 목록을 표시합니다.

aws cloudformation list-stack-set-operations \ --stack-set-name my-stack-set

출력:

{ "Summaries": [ { "OperationId": "35d45ebc-ed88-xmpl-ab59-0197a1fc83a0", "Action": "UPDATE", "Status": "SUCCEEDED", "CreationTimestamp": "2019-10-03T16:28:44.377Z", "EndTimestamp": "2019-10-03T16:42:08.607Z" }, { "OperationId": "891aa98f-7118-xmpl-00b2-00954d1dd0d6", "Action": "UPDATE", "Status": "FAILED", "CreationTimestamp": "2019-10-03T15:43:53.916Z", "EndTimestamp": "2019-10-03T15:45:58.925Z" } ] }

다음 코드 예시에서는 list-stack-sets을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 세트를 나열하려면

다음 list-stack-sets 예제는 현재 지역 및 계정의 스택 세트 목록을 표시합니다.

aws cloudformation list-stack-sets

출력:

{ "Summaries": [ { "StackSetName": "enable-config", "StackSetId": "enable-config:296a3360-xmpl-40af-be78-9341e95bf743", "Description": "Enable AWS Config", "Status": "ACTIVE" } ] }
  • 자세한 API 내용은 AWS CLI 명령 ListStackSets참조를 참조하십시오.

다음 코드 예시에서는 list-stacks을 사용하는 방법을 보여 줍니다.

AWS CLI

AWS CloudFormation 스택을 나열하려면

다음 list-stacks 명령에서는 상태가 CREATE_COMPLETE인 모든 스택에 대한 요약 내용을 보여줍니다.

aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETE

출력:

[ { "StackId": "arn:aws:cloudformation:us-east-1:123456789012:stack/myteststack/466df9e0-0dff-08e3-8e2f-5088487c4896", "TemplateDescription": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.", "StackStatusReason": null, "CreationTime": "2013-08-26T03:27:10.190Z", "StackName": "myteststack", "StackStatus": "CREATE_COMPLETE" } ]
  • 자세한 API 내용은 AWS CLI 명령 ListStacks참조를 참조하십시오.

다음 코드 예시에서는 list-type-registrations을 사용하는 방법을 보여 줍니다.

AWS CLI

완료된 유형의 등록을 나열하려면

다음 list-type-registrations 예제는 지정된 유형에 대해 완료된 유형 등록 목록을 표시합니다.

aws cloudformation list-type-registrations \ --type RESOURCE \ --type-name My::Logs::LogGroup \ --registration-status-filter COMPLETE

출력:

{ "RegistrationTokenList": [ "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222", "a1b2c3d4-5678-90ab-cdef-EXAMPLE33333" ] }

자세한 내용은 사용 설명서의 CloudFormation 레지스트리 사용을 참조하십시오.AWS CloudFormation

다음 코드 예시에서는 list-type-versions을 사용하는 방법을 보여 줍니다.

AWS CLI

확장 프로그램 버전을 나열하려면

다음 list-type-versions 예제는 확장 버전에 대한 요약 정보를 반환합니다.

aws cloudformation list-type-versions \ --endpoint https://example.com \ --region us-west-2 \ --type RESOURCE \ --type-name My::Resource::Example \ --publisher-id 123456789012

이 명령은 출력을 생성하지 않습니다.

자세한 내용은 사용 AWS CloudFormation 설명서의 AWS CloudFormation 레지스트리 사용을 참조하십시오.

  • 자세한 API 내용은 AWS CLI 명령 ListTypeVersions참조를 참조하십시오.

다음 코드 예시에서는 list-types을 사용하는 방법을 보여 줍니다.

AWS CLI

계정의 비공개 리소스 유형을 나열하려면

다음 list-types 예제는 현재 AWS 계정에 현재 등록된 개인 자원 유형의 목록을 표시합니다.

aws cloudformation list-types

출력:

{ "TypeSummaries": [ { "Description": "WordPress blog resource for internal use", "LastUpdated": "2019-12-04T18:28:15.059Z", "TypeName": "My::WordPress::BlogExample", "TypeArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-WordPress-BlogExample", "DefaultVersionId": "00000005", "Type": "RESOURCE" }, { "Description": "Customized resource derived from AWS::Logs::LogGroup", "LastUpdated": "2019-12-04T18:28:15.059Z", "TypeName": "My::Logs::LogGroup", "TypeArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/My-Logs-LogGroup", "DefaultVersionId": "00000003", "Type": "RESOURCE" } ] }

자세한 내용은 사용 설명서의 CloudFormation 레지스트리 사용을AWS CloudFormation 참조하십시오.

  • 자세한 API 내용은 AWS CLI 명령 ListTypes참조를 참조하십시오.

다음 코드 예시에서는 package을 사용하는 방법을 보여 줍니다.

AWS CLI

다음 명령은 로컬 아티팩트를 S3 template.json bucket-name 버킷에 업로드하여 이름이 지정된 템플릿을 내보내고 내보낸 템플릿을 다음 위치에 씁니다. packaged-template.json

aws cloudformation package --template-file /path_to_template/template.json --s3-bucket bucket-name --output-template-file packaged-template.json --use-json
  • 자세한 API 내용은 AWS CLI 명령 참조의 Package를 참조하십시오.

다음 코드 예시에서는 publish-type을 사용하는 방법을 보여 줍니다.

AWS CLI

확장 프로그램 게시하기

다음 publish-type 예제는 지정된 확장을 이 지역의 공개 확장으로 CloudFormation 레지스트리에 게시합니다.

aws cloudformation publish-type \ --region us-west-2 \ --type RESOURCE \ --type-name Example::Test::1234567890abcdef0

출력:

{ "PublicTypeArn":"arn:aws:cloudformation:us-west-2::type/resource/000q6TfUovXsEMmgKowxDZLlwqr2QUshd2e75c8c/Example-Test-1234567890abcdef0/1.0.0" }

자세한 내용은 사용 설명서의 AWS CloudFormation 레지스트리 사용을 참조하십시오.AWS CloudFormation

  • 자세한 API 내용은 AWS CLI 명령 PublishType참조를 참조하십시오.

다음 코드 예시에서는 register-publisher을 사용하는 방법을 보여 줍니다.

AWS CLI

퍼블리셔를 등록하려면

다음 register-publisher 예제에서는 게시자를 등록하고 이용 약관 매개변수를 수락합니다.

aws cloudformation register-publisher \ --region us-west-2 \ --accept-terms-and-conditions

출력:

{ "PublisherId": "000q6TfUovXsEMmgKowxDZLlwqr2QUshd2e75c8c" }

자세한 내용은 사용 AWS CloudFormation 설명서의 AWS CloudFormation 레지스트리 사용을 참조하십시오.

  • 자세한 API 내용은 AWS CLI 명령 RegisterPublisher참조를 참조하십시오.

다음 코드 예시에서는 register-type을 사용하는 방법을 보여 줍니다.

AWS CLI

리소스 유형을 등록하려면

다음 register-type 예제에서는 지정된 자원 유형을 사용자 계정의 개인 자원 유형으로 등록합니다.

aws cloudformation register-type \ --type-name My::Organization::ResourceName \ --schema-handler-package s3://bucket_name/my-organization-resource_name.zip \ --type RESOURCE

출력:

{ "RegistrationToken": "f5525280-104e-4d35-bef5-8f1f1example" }

자세한 내용은 유형 개발을 위한 CloudFormation 명령줄 인터페이스 사용 설명서의 리소스 공급자 등록을 참조하십시오.

  • 자세한 API 내용은 AWS CLI 명령 RegisterType참조를 참조하십시오.

다음 코드 예시에서는 set-stack-policy을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 정책을 적용하려면

다음 set-stack-policy 예제에서는 지정된 스택의 지정된 리소스에 대한 업데이트를 비활성화합니다. stack-policy.json스택의 리소스에 허용되는 작업을 정의하는 JSON 문서입니다.

aws cloudformation set-stack-policy \ --stack-name my-stack \ --stack-policy-body file://stack-policy.json

출력:

{ "Statement" : [ { "Effect" : "Allow", "Action" : "Update:*", "Principal": "*", "Resource" : "*" }, { "Effect" : "Deny", "Action" : "Update:*", "Principal": "*", "Resource" : "LogicalResourceId/bucket" } ] }
  • 자세한 API 내용은 AWS CLI 명령 SetStackPolicy참조를 참조하십시오.

다음 코드 예시에서는 set-type-configuration을 사용하는 방법을 보여 줍니다.

AWS CLI

데이터를 구성하려면

다음 set-type-configuration 예에서는 지정된 계정 및 지역에서 등록된 CloudFormation 확장 프로그램의 구성 데이터를 지정합니다.

aws cloudformation set-type-configuration \ --region us-west-2 \ --type RESOURCE \ --type-name Example::Test::Type \ --configuration-alias default \ --configuration "{\"CredentialKey\": \"testUserCredential\"}"

출력:

{ "ConfigurationArn": "arn:aws:cloudformation:us-west-2:123456789012:type-configuration/resource/Example-Test-Type/default" }

자세한 내용은 사용 AWS CloudFormation 설명서의 AWS CloudFormation 레지스트리 사용을 참조하십시오.

다음 코드 예시에서는 set-type-default-version을 사용하는 방법을 보여 줍니다.

AWS CLI

유형의 기본 버전을 설정하려면

다음 set-type-default-version 예제에서는 지정된 유형 버전을 이 유형의 기본값으로 사용하도록 설정합니다.

aws cloudformation set-type-default-version \ --type RESOURCE \ --type-name My::Logs::LogGroup \ --version-id 00000003

이 명령은 출력을 생성하지 않습니다.

자세한 내용은 사용 설명서의 CloudFormation 레지스트리 사용을AWS CloudFormation 참조하십시오.

다음 코드 예시에서는 signal-resource을 사용하는 방법을 보여 줍니다.

AWS CLI

리소스에 신호를 보내려면

다음 signal-resource 예제는 이름이 지정된 MyWaitCondition 스택에 지정된 대기 조건을 success 충족하라는 신호를 보냅니다my-stack.

aws cloudformation signal-resource \ --stack-name my-stack \ --logical-resource-id MyWaitCondition \ --unique-id 1234 \ --status SUCCESS

이 명령은 출력을 생성하지 않습니다.

  • 자세한 API 내용은 AWS CLI 명령 SignalResource참조를 참조하십시오.

다음 코드 예시에서는 stop-stack-set-operation을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 세트 작업을 중지하려면

다음 stop-stack-set-operation 예제에서는 지정된 스택 세트에서 진행 중인 업데이트 작업을 중지합니다.

aws cloudformation stop-stack-set-operation \ --stack-set-name my-stack-set \ --operation-id 1261cd27-490b-xmpl-ab42-793a896c69e6

이 명령은 출력을 생성하지 않습니다.

다음 코드 예시에서는 test-type을 사용하는 방법을 보여 줍니다.

AWS CLI

확장 프로그램을 테스트하려면

다음 test-type 예제는 등록된 확장을 테스트하여 CloudFormation 레지스트리에 게시하는 데 필요한 모든 요구 사항을 충족하는지 확인합니다.

aws cloudformation test-type \ --arn arn:aws:cloudformation:us-west-2:123456789012:type/resource/Sample-Test-Resource123/00000001

출력:

{ "TypeVersionArn": "arn:aws:cloudformation:us-west-2:123456789012:type/resource/Sample-Test-Resource123/00000001" }

자세한 내용은 사용 AWS CloudFormation 설명서의 AWS CloudFormation 레지스트리 사용을 참조하십시오.

  • 자세한 API 내용은 AWS CLI 명령 TestType참조를 참조하십시오.

다음 코드 예시에서는 update-stack-instances을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 인스턴스를 업데이트하려면

다음 update-stack-instances 예시에서는 두 지역의 두 계정에 있는 스택 인스턴스에 대한 업데이트를 가장 최근 설정으로 재시도합니다. 지정된 내결함성 설정을 통해 일부 스택을 업데이트할 수 없는 경우에도 모든 계정과 지역에서 업데이트를 시도할 수 있습니다.

aws cloudformation update-stack-instances \ --stack-set-name my-stack-set \ --accounts 123456789012 567890123456 \ --regions us-east-1 us-west-2 \ --operation-preferences FailureToleranceCount=3

출력:

{ "OperationId": "103ebdf2-21ea-xmpl-8892-de5e30733132" }

다음 코드 예시에서는 update-stack-set을 사용하는 방법을 보여 줍니다.

AWS CLI

스택 세트를 업데이트하려면

다음 update-stack-set 예제에서는 키 Owner 이름과 값이 1인 태그를 지정된 스택 세트의 스택 인스턴스에 추가합니다. IT

aws cloudformation update-stack-set \ --stack-set-name my-stack-set \ --use-previous-template \ --tags Key=Owner,Value=IT

출력:

{ "OperationId": "e2b60321-6cab-xmpl-bde7-530c6f47950e" }
  • 자세한 API 내용은 AWS CLI 명령 UpdateStackSet참조를 참조하십시오.

다음 코드 예시에서는 update-stack을 사용하는 방법을 보여 줍니다.

AWS CLI

AWS CloudFormation 스택을 업데이트하려면

다음 update-stack 명령에서는 mystack 스택의 템플릿 및 입력 파라미터를 업데이트합니다.

aws cloudformation update-stack --stack-name mystack --template-url https://s3.amazonaws.com/sample/updated.template --parameters ParameterKey=KeyPairName,ParameterValue=SampleKeyPair ParameterKey=SubnetIDs,ParameterValue=SampleSubnetID1\\,SampleSubnetID2

다음 update-stack 명령에서는 mystack 스택의 SubnetIDs 파라미터값만 업데이트합니다. 파라미터값을 지정하지 않으면 템플릿에 지정된 기본값이 사용됩니다.

aws cloudformation update-stack --stack-name mystack --template-url https://s3.amazonaws.com/sample/updated.template --parameters ParameterKey=KeyPairName,UsePreviousValue=true ParameterKey=SubnetIDs,ParameterValue=SampleSubnetID1\\,UpdatedSampleSubnetID2

다음 update-stack 명령에서는 mystack 스택에 스택 알림 주제 2개를 추가합니다.

aws cloudformation update-stack --stack-name mystack --use-previous-template --notification-arns "arn:aws:sns:use-east-1:123456789012:mytopic1" "arn:aws:sns:us-east-1:123456789012:mytopic2"

자세한 내용은 AWS CloudFormation 사용 설명서의AWS CloudFormation 스택 업데이트를 참조하십시오.

  • 자세한 API 내용은 AWS CLI 명령 UpdateStack참조를 참조하십시오.

다음 코드 예시에서는 update-termination-protection을 사용하는 방법을 보여 줍니다.

AWS CLI

종료 방지 기능을 활성화하려면

다음 update-termination-protection 예시에서는 지정된 스택에서 종료 보호를 활성화합니다.

aws cloudformation update-termination-protection \ --stack-name my-stack \ --enable-termination-protection

출력:

{ "StackId": "arn:aws:cloudformation:us-west-2:123456789012:stack/my-stack/d0a825a0-e4cd-xmpl-b9fb-061c69e99204" }

다음 코드 예시에서는 validate-template을 사용하는 방법을 보여 줍니다.

AWS CLI

AWS CloudFormation 템플릿을 검증하려면

다음 validate-template 명령은 sampletemplate.json 템플릿의 유효성을 확인합니다.

aws cloudformation validate-template --template-body file://sampletemplate.json

출력:

{ "Description": "AWS CloudFormation Sample Template S3_Bucket: Sample template showing how to create a publicly accessible S3 bucket. **WARNING** This template creates an S3 bucket. You will be billed for the AWS resources used if you create a stack from this template.", "Parameters": [], "Capabilities": [] }

자세한 내용은 AWS CloudFormation 사용 설명서의 AWS CloudFormation 템플릿 작업을 참조하십시오.

  • 자세한 API 내용은 AWS CLI 명령 ValidateTemplate참조를 참조하십시오.