Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions awscli/examples/cloudformation/create-generated-template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
**To create a generated template from scanned resources**

The following ``create-generated-template`` example creates a generated template named ``MyTemplate`` from scanned resources. ::

aws cloudformation create-generated-template \
--generated-template-name MyTemplate \
--resources file://resources.json

Contents of ``resources.json``::

[
{
"ResourceType": "AWS::EKS::Cluster",
"LogicalResourceId":"MyCluster",
"ResourceIdentifier": {
"ClusterName": "MyAppClusterName"
}
},
{
"ResourceType": "AWS::AutoScaling::AutoScalingGroup",
"LogicalResourceId":"MyASG",
"ResourceIdentifier": {
"AutoScalingGroupName": "MyAppASGName"
}
},
{
"ResourceType": "AWS::EKS::Nodegroup",
"LogicalResourceId":"MyNodegroup",
"ResourceIdentifier": {
"NodegroupName": "MyAppNodegroupName"
}
},
{
"ResourceType": "AWS::IAM::Role",
"LogicalResourceId":"MyRole",
"ResourceIdentifier": {
"RoleId": "arn:aws::iam::123456789012:role/MyAppIAMRole"
}
}
]

Output::

{
"Arn":
"arn:aws:cloudformation:us-east-1:123456789012:generatedtemplate/7fc8512c-d8cb-4e02-b266-d39c48344e48",
"Name": "MyTemplate"
}

For more information, see `Create a CloudFormation template from resources scanned with IaC generator <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/iac-generator-create-template-from-scanned-resources.html>`__ in the *AWS CloudFormation User Guide*.
16 changes: 16 additions & 0 deletions awscli/examples/cloudformation/create-stack-refactor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**To create the stack definition for a stack refactor operation**

The following ``create-stack-refactor`` example creates the stack definition for stack refactoring. ::

aws cloudformation create-stack-refactor \
--stack-definitions \
StackName=Stack1,TemplateBody@=file://template1-updated.yaml \
StackName=Stack2,TemplateBody@=file://template2-updated.yaml

Output::

{
"StackRefactorId": "9c384f70-4e07-4ed7-a65d-fee5eb430841"
}

For more information, see `Stack refactoring <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stack-refactoring.html>`__ in the *AWS CloudFormation User Guide*.
10 changes: 10 additions & 0 deletions awscli/examples/cloudformation/delete-generated-template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**To delete a generated template**

The following ``delete-generated-template`` example deletes the specified template. ::

aws cloudformation delete-generated-template \
--generated-template-name MyTemplate

This command produces no output.

For more information, see `Generating templates from existing resources <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html>`__ in the *AWS CloudFormation User Guide*.
62 changes: 62 additions & 0 deletions awscli/examples/cloudformation/describe-generated-template.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
**To describe a generated template**

The following ``describe-generated-template`` example describes the specified template. ::

aws cloudformation describe-generated-template \
--generated-template-name MyTemplate

Output::

{
"GeneratedTemplateId": "arn:aws:cloudformation:us-east-1:123456789012:generatedTemplate/7d881acf-f307-4ded-910e-f8fb49b96894",
"GeneratedTemplateName": "MyTemplate",
"Resources": [
{
"ResourceType": "AWS::EC2::SecurityGroup",
"LogicalResourceId": "EC2SecurityGroup",
"ResourceIdentifier": {
"Id": "sg-1234567890abcdef0"
},
"ResourceStatus": "COMPLETE",
"ResourceStatusReason": "Resource Template complete",
"Warnings": []
},
{
"ResourceType": "AWS::EC2::Instance",
"LogicalResourceId": "EC2Instance",
"ResourceIdentifier": {
"InstanceId": "i-1234567890abcdef0"
},
"ResourceStatus": "COMPLETE",
"ResourceStatusReason": "Resource Template complete",
"Warnings": []
},
{
"ResourceType": "AWS::EC2::KeyPair",
"LogicalResourceId": "EC2KeyPairSshkeypair",
"ResourceIdentifier": {
"KeyName": "sshkeypair"
},
"ResourceStatus": "COMPLETE",
"ResourceStatusReason": "Resource Template complete",
"Warnings": []
}
],
"Status": "COMPLETE",
"StatusReason": "All resources complete",
"CreationTime": "2025-09-23T19:38:06.435000+00:00",
"LastUpdatedTime": "2025-09-23T19:38:10.798000+00:00",
"Progress": {
"ResourcesSucceeded": 3,
"ResourcesFailed": 0,
"ResourcesProcessing": 0,
"ResourcesPending": 0
},
"TemplateConfiguration": {
"DeletionPolicy": "RETAIN",
"UpdateReplacePolicy": "RETAIN"
},
"TotalWarnings": 0
}

For more information, see `Generating templates from existing resources <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html>`__ in the *AWS CloudFormation User Guide*.
38 changes: 38 additions & 0 deletions awscli/examples/cloudformation/describe-resource-scan.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
**To describe a resource scan**

The following ``describe-resource-scan`` example describes the resource scan with the specified scan ID. ::

aws cloudformation describe-resource-scan --region \
--resource-scan-id arn:aws:cloudformation:us-east-1:123456789012:resourceScan/0a699f15-489c-43ca-a3ef-3e6ecfa5da60

Output::

{
"ResourceScanId": "arn:aws:cloudformation:us-east-1:123456789012:resourceScan/0a699f15-489c-43ca-a3ef-3e6ecfa5da60",
"Status": "COMPLETE",
"StartTime": "2025-08-21T03:10:38.485000+00:00",
"EndTime": "2025-08-21T03:20:28.485000+00:00",
"PercentageCompleted": 100.0,
"ResourceTypes": [
"AWS::CloudFront::CachePolicy",
"AWS::CloudFront::OriginRequestPolicy",
"AWS::EC2::DHCPOptions",
"AWS::EC2::InternetGateway",
"AWS::EC2::KeyPair",
"AWS::EC2::NetworkAcl",
"AWS::EC2::NetworkInsightsPath",
"AWS::EC2::NetworkInterface",
"AWS::EC2::PlacementGroup",
"AWS::EC2::Route",
"AWS::EC2::RouteTable",
"AWS::EC2::SecurityGroup",
"AWS::EC2::Subnet",
"AWS::EC2::SubnetCidrBlock",
"AWS::EC2::SubnetNetworkAclAssociation",
"AWS::EC2::SubnetRouteTableAssociation",
...
],
"ResourcesRead": 676
}

For more information, see `Generating templates from existing resources <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html>`__ in the *AWS CloudFormation User Guide*.
20 changes: 20 additions & 0 deletions awscli/examples/cloudformation/describe-stack-refactor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
**To describe a stack refactor operation**

The following ``describe-stack-refactor`` example describes the stack refactor operation with the specified stack refactor ID. ::

aws cloudformation describe-stack-refactor \
--stack-refactor-id 9c384f70-4e07-4ed7-a65d-fee5eb430841

Output::

{
"StackRefactorId": "9c384f70-4e07-4ed7-a65d-fee5eb430841",
"StackIds": [
"arn:aws:cloudformation:us-east-1:123456789012:stack/Stack1/3e6a1ff0-94b1-11f0-aa6f-0a88d2e03acf",
"arn:aws:cloudformation:us-east-1:123456789012:stack/Stack2/5da91650-94b1-11f0-81cf-0a23500e151b"
],
"ExecutionStatus": "AVAILABLE",
"Status": "CREATE_COMPLETE"
}

For more information, see `Stack refactoring <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stack-refactoring.html>`__ in the *AWS CloudFormation User Guide*.
10 changes: 10 additions & 0 deletions awscli/examples/cloudformation/execute-stack-refactor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**To complete a stack refactor operation**

The following ``execute-stack-refactor`` example completes the stack refactor operation with the specified stack refactor ID. ::

aws cloudformation execute-stack-refactor \
--stack-refactor-id 9c384f70-4e07-4ed7-a65d-fee5eb430841

This command produces no output.

For more information, see `Stack refactoring <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stack-refactoring.html>`__ in the *AWS CloudFormation User Guide*.
41 changes: 41 additions & 0 deletions awscli/examples/cloudformation/list-generated-templates.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
**To list generated templates**

The following ``list-generated-templates`` example lists all generated templates. ::

aws cloudformation list-generated-templates

Output::

{
"Summaries": [
{
"GeneratedTemplateId": "arn:aws:cloudformation:us-east-1:123456789012:generatedtemplate/7fc8512c-d8cb-4e02-b266-d39c48344e48",
"GeneratedTemplateName": "MyTemplate",
"Status": "COMPLETE",
"StatusReason": "All resources complete",
"CreationTime": "2025-09-23T20:13:24.283000+00:00",
"LastUpdatedTime": "2025-09-23T20:13:28.610000+00:00",
"NumberOfResources": 4
},
{
"GeneratedTemplateId": "arn:aws:cloudformation:us-east-1:123456789012:generatedTemplate/f10dd1c4-edc6-4823-8153-ab6112b8d051",
"GeneratedTemplateName": "MyEC2InstanceTemplate",
"Status": "COMPLETE",
"StatusReason": "All resources complete",
"CreationTime": "2024-08-08T19:35:49.790000+00:00",
"LastUpdatedTime": "2024-08-08T19:35:52.207000+00:00",
"NumberOfResources": 3
},
{
"GeneratedTemplateId": "arn:aws:cloudformation:us-east-1:123456789012:generatedTemplate/e5a1c89f-7ce2-41bd-9bdf-75b7c852e3ca",
"GeneratedTemplateName": "MyEKSNodeGroupTemplate",
"Status": "COMPLETE",
"StatusReason": "All resources complete",
"CreationTime": "2024-07-16T20:39:27.883000+00:00",
"LastUpdatedTime": "2024-07-16T20:39:35.766000+00:00",
"NumberOfResources": 4
}
]
}

For more information, see `Generating templates from existing resources <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/generate-IaC.html>`__ in the *AWS CloudFormation User Guide*.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
**To list related resources from a resource scan**

The following ``list-resource-scan-related-resources`` example lists resources from the specified resource scan that are related to resources in ``resources.json``. ::

aws cloudformation list-resource-scan-related-resources \
--resource-scan-id arn:aws:cloudformation:us-east-1:123456789012:resourceScan/0a699f15-489c-43ca-a3ef-3e6ecfa5da60 \
--resources file://resources.json

Contents of ``resources.json``::

[
{
"ResourceType": "AWS::EKS::Cluster",
"ResourceIdentifier": {
"ClusterName": "MyAppClusterName"
}
},
{
"ResourceType": "AWS::AutoScaling::AutoScalingGroup",
"ResourceIdentifier": {
"AutoScalingGroupName": "MyAppASGName"
}
}
]

Output::

{
"RelatedResources": [
{
"ResourceType": "AWS::EKS::Nodegroup",
"ResourceIdentifier": {
"NodegroupName": "MyAppNodegroupName"
},
"ManagedByStack": false
},
{
"ResourceType": "AWS::IAM::Role",
"ResourceIdentifier": {
"RoleId": "arn:aws::iam::123456789012:role/MyAppIAMRole"
},
"ManagedByStack": false
}
]
}

For more information, see `Create a CloudFormation template from resources scanned with IaC generator <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/iac-generator-create-template-from-scanned-resources.html>`__ in the *AWS CloudFormation User Guide*.
30 changes: 30 additions & 0 deletions awscli/examples/cloudformation/list-resource-scan-resources.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
**To list resources from a resource scan**

The following ``list-resource-scan-resources`` example lists resources from the specified resource scan, filtered by resource identifier. ::

aws cloudformation list-resource-scan-resources \
--resource-scan-id arn:aws:cloudformation:us-east-1:123456789012:resourceScan/0a699f15-489c-43ca-a3ef-3e6ecfa5da60 \
--resource-identifier MyApp

Output::

{
"Resources": [
{
"ResourceType": "AWS::EKS::Cluster",
"ResourceIdentifier": {
"ClusterName": "MyAppClusterName"
},
"ManagedByStack": false
},
{
"ResourceType": "AWS::AutoScaling::AutoScalingGroup",
"ResourceIdentifier": {
"AutoScalingGroupName": "MyAppASGName"
},
"ManagedByStack": false
}
]
}

For more information, see `Create a CloudFormation template from resources scanned with IaC generator <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/iac-generator-create-template-from-scanned-resources.html>`__ in the *AWS CloudFormation User Guide*.
Loading