Search code examples
amazon-web-servicesaws-cloudformationaws-cli

Use AWS CLI to import existing resources into CloudFormation


I have a collection of CloudFormation templates that I'm using to create new resources but I also have a small percentage of AWS resources that were created outside of CF that I now want to import into CF. I know how to import existing resources into CF via the AWS dashboard but I want to do it with the CLI instead.

This is the documentation I thought would help but it appears to be out of date as I don't have a "--resources-to-import" option when I run aws cloudformation create-stack help. An up-to-date example would be very helpful if this is even possible via the command-line.


Solution

  • In CLI documentation step 4, it's actually calling create-change-set instead of create-stack:

    aws cloudformation create-change-set --change-set-type IMPORT --resources-to-import