Importing Resources

Importing Existing Resources into a Stack

An import is a change set of type IMPORT that adopts existing resources into a stack. You supply a template for the whole stack, where each adopted resource has a DeletionPolicy (infra/wishlist.yaml declares the table booknest-wishlist with Retain), and a JSON list in infra/import/wishlist.json that maps the logical ID WishlistTable to its identifier, {"TableName": "booknest-wishlist"}.

Creating the table by hand, then trying to import itShell
aws dynamodb create-table --table-name booknest-wishlist --billing-mode PAY_PER_REQUEST \
  --attribute-definitions AttributeName=userId,AttributeType=S \
  --key-schema AttributeName=userId,KeyType=HASH --query TableDescription.TableStatus
aws cloudformation create-change-set --stack-name booknest-wishlist --change-set-name adopt \
  --change-set-type IMPORT --resources-to-import file://import/wishlist.json \
  --template-body file://wishlist.yaml 2>&1 | fold -s -w 90
Output
"ACTIVE"
aws: [ERROR]: An error occurred (ValidationError) when calling the CreateChangeSet
operation: Stack 'booknest-wishlist' does not exist.

LocalStack 4.13.1 63,725 rejects an IMPORT for a new stack as if the stack had to exist, and an import into an existing stack fails with InternalFailure, "not supported by this version of LocalStack". On AWS 24 (not run here), the stack goes through IMPORT_IN_PROGRESS to IMPORT_COMPLETE with the table untouched. An import may not change anything else, and CloudFormation 24 does not check that your template matches the resource, so check drift right after.