Skip to content

How do I import an existing resource directly into a nested CloudFormation stack?

2 minute read
0

I want to import an existing AWS resource into a nested stack on AWS CloudFormation.

Resolution

CloudFormation can import resources directly into nested stacks and retain their parent stack. You can't import a stack into a child stack or import a stack that has children.

To import an existing resource into a nested stack, complete the following steps:

  1. Open the CloudFormation console.
  2. Select the nested stack.
  3. Update the stack template with the resource definition of the existing resource that you want to import in the stack template.
  4. Make sure that the DeletionPolicy is set to Retain on the AWS::CloudFormation::Stack resource.
    Note: Existing resource properties of the resource must match the current resource configuration.
  5. Choose Stack actions on the nested stack, and then choose Import resources into stack.
  6. Upload the updated template that includes the resource to import, and then choose Next.
  7. Import the existing resource into the stack resource and provide the resource identifier, and then choose Next.
  8. On the Review stack-name page, review the resources to import changeset, and then choose Import resources.
  9. In the Stack resources section, verify that the resource has successfully imported and that the nested stack manages the resource.
  10. Make sure that the nested stack template in the Amazon Simple Storage Service (Amazon S3) bucket that the root stack uses during update operations and the current template in the nested stack are identical.

Related Information

Resource type support

Import AWS resources into a CloudFormation stack

AWS OFFICIALUpdated 4 months ago