diff --git a/awscli/examples/cloudformation/create-generated-template.rst b/awscli/examples/cloudformation/create-generated-template.rst new file mode 100644 index 000000000000..9f321fcba5c1 --- /dev/null +++ b/awscli/examples/cloudformation/create-generated-template.rst @@ -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 `__ in the *AWS CloudFormation User Guide*. diff --git a/awscli/examples/cloudformation/create-stack-refactor.rst b/awscli/examples/cloudformation/create-stack-refactor.rst new file mode 100644 index 000000000000..0e2d974df7d6 --- /dev/null +++ b/awscli/examples/cloudformation/create-stack-refactor.rst @@ -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 `__ in the *AWS CloudFormation User Guide*. diff --git a/awscli/examples/cloudformation/delete-generated-template.rst b/awscli/examples/cloudformation/delete-generated-template.rst new file mode 100644 index 000000000000..817305663b49 --- /dev/null +++ b/awscli/examples/cloudformation/delete-generated-template.rst @@ -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 `__ in the *AWS CloudFormation User Guide*. diff --git a/awscli/examples/cloudformation/describe-generated-template.rst b/awscli/examples/cloudformation/describe-generated-template.rst new file mode 100644 index 000000000000..e66305302b62 --- /dev/null +++ b/awscli/examples/cloudformation/describe-generated-template.rst @@ -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 `__ in the *AWS CloudFormation User Guide*. diff --git a/awscli/examples/cloudformation/describe-resource-scan.rst b/awscli/examples/cloudformation/describe-resource-scan.rst new file mode 100644 index 000000000000..bda035638add --- /dev/null +++ b/awscli/examples/cloudformation/describe-resource-scan.rst @@ -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 `__ in the *AWS CloudFormation User Guide*. diff --git a/awscli/examples/cloudformation/describe-stack-refactor.rst b/awscli/examples/cloudformation/describe-stack-refactor.rst new file mode 100644 index 000000000000..fa3612dd6982 --- /dev/null +++ b/awscli/examples/cloudformation/describe-stack-refactor.rst @@ -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 `__ in the *AWS CloudFormation User Guide*. diff --git a/awscli/examples/cloudformation/execute-stack-refactor.rst b/awscli/examples/cloudformation/execute-stack-refactor.rst new file mode 100644 index 000000000000..e083bd3b913e --- /dev/null +++ b/awscli/examples/cloudformation/execute-stack-refactor.rst @@ -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 `__ in the *AWS CloudFormation User Guide*. diff --git a/awscli/examples/cloudformation/list-generated-templates.rst b/awscli/examples/cloudformation/list-generated-templates.rst new file mode 100644 index 000000000000..30ae27d0d65d --- /dev/null +++ b/awscli/examples/cloudformation/list-generated-templates.rst @@ -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 `__ in the *AWS CloudFormation User Guide*. diff --git a/awscli/examples/cloudformation/list-resource-scan-related-resources.rst b/awscli/examples/cloudformation/list-resource-scan-related-resources.rst new file mode 100644 index 000000000000..1150d4799d30 --- /dev/null +++ b/awscli/examples/cloudformation/list-resource-scan-related-resources.rst @@ -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 `__ in the *AWS CloudFormation User Guide*. diff --git a/awscli/examples/cloudformation/list-resource-scan-resources.rst b/awscli/examples/cloudformation/list-resource-scan-resources.rst new file mode 100644 index 000000000000..1b072381806a --- /dev/null +++ b/awscli/examples/cloudformation/list-resource-scan-resources.rst @@ -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 `__ in the *AWS CloudFormation User Guide*. diff --git a/awscli/examples/cloudformation/list-stack-refactor-actions.rst b/awscli/examples/cloudformation/list-stack-refactor-actions.rst new file mode 100644 index 000000000000..1e0c4e06ae16 --- /dev/null +++ b/awscli/examples/cloudformation/list-stack-refactor-actions.rst @@ -0,0 +1,71 @@ +**To list actions for a stack refactor operation** + +The following ``list-stack-refactor-actions`` example lists actions for the stack refactor operation with the specified stack refactor ID. :: + + aws cloudformation list-stack-refactor-actions \ + --stack-refactor-id 9c384f70-4e07-4ed7-a65d-fee5eb430841 + +Output:: + + { + "StackRefactorActions": [ + { + "Action": "MOVE", + "Entity": "RESOURCE", + "PhysicalResourceId": "MyTestLambdaRole", + "Description": "No configuration changes detected.", + "Detection": "AUTO", + "TagResources": [], + "UntagResources": [], + "ResourceMapping": { + "Source": { + "StackName": "arn:aws:cloudformation:us-east-1:123456789012:stack/Stack1/3e6a1ff0-94b1-11f0-aa6f-0a88d2e03acf", + "LogicalResourceId": "MyLambdaRole" + }, + "Destination": { + "StackName": "arn:aws:cloudformation:us-east-1:123456789012:stack/Stack2/5da91650-94b1-11f0-81cf-0a23500e151b", + "LogicalResourceId": "MyLambdaRole" + } + } + }, + { + "Action": "MOVE", + "Entity": "RESOURCE", + "PhysicalResourceId": "MyTestFunction", + "Description": "Resource configuration changes will be validated during refactor execution.", + "Detection": "AUTO", + "TagResources": [ + { + "Key": "aws:cloudformation:stack-name", + "Value": "Stack2" + }, + { + "Key": "aws:cloudformation:logical-id", + "Value": "MyFunction" + }, + { + "Key": "aws:cloudformation:stack-id", + "Value": "arn:aws:cloudformation:us-east-1:123456789012:stack/Stack2/5da91650-94b1-11f0-81cf-0a23500e151b" + } + ], + "UntagResources": [ + "aws:cloudformation:stack-name", + "aws:cloudformation:logical-id", + "aws:cloudformation:stack-id" + ], + "ResourceMapping": { + "Source": { + "StackName": "arn:aws:cloudformation:us-east-1:123456789012:stack/Stack1/3e6a1ff0-94b1-11f0-aa6f-0a88d2e03acf", + "LogicalResourceId": "MyFunction" + }, + "Destination": { + "StackName": "arn:aws:cloudformation:us-east-1:123456789012:stack/Stack2/5da91650-94b1-11f0-81cf-0a23500e151b", + "LogicalResourceId": "MyFunction" + } + } + } + ] + } + + +For more information, see `Stack refactoring `__ in the *AWS CloudFormation User Guide*. diff --git a/awscli/examples/cloudformation/start-resource-scan.rst b/awscli/examples/cloudformation/start-resource-scan.rst new file mode 100644 index 000000000000..5b26692dd015 --- /dev/null +++ b/awscli/examples/cloudformation/start-resource-scan.rst @@ -0,0 +1,14 @@ +**To start a resource scan** + +The following ``start-resource-scan`` example starts a resource scan that scans all existing resources in the current account and Region. :: + + aws cloudformation start-resource-scan + +Output:: + + { + "ResourceScanId": + "arn:aws:cloudformation:us-east-1:123456789012:resourceScan/0a699f15-489c-43ca-a3ef-3e6ecfa5da60" + } + +For more information, see `Start a resource scan with CloudFormation IaC generator `__ in the *AWS CloudFormation User Guide*.