Exporting Values with Outputs

An output becomes an export when it has an Export: {Name: ...}, as TableName and BucketName do in infra/booknest-data.yaml (Outputs and Exports). The name must be unique in the account and region, and it may use parameters and pseudo parameters but not Ref or GetAtt of a resource, since the name must be known before anything is created. Prefix export names with the stack's purpose and stage, as BookNest does, so two stages can coexist in one account:

Deploying the data stack and listing the region's exportsShell
cd ~/v5-ch7/booknest/infra
aws cloudformation deploy --stack-name booknest-data-dev --template-file booknest-data.yaml
aws cloudformation list-exports --output text --query 'Exports[].[Name,Value]'
Output
Waiting for changeset to be created..
Waiting for stack create/update to complete
Successfully created/updated stack - booknest-data-dev
booknest-dev-bucket   booknest-data-dev-frontendbucket-bff970a7
booknest-dev-table-name   booknest-dev-books

Once another stack imports an export, AWS 24 will not let you change or delete it (The Export Deletion Trap), so export only stable identifiers that consumers need, such as a table name or a subnet ID.