Chain the Packer-built AMI id into Terraform without hardcoding
Tag the AMI at build time with something stable like a version number or timestamp, then use the aws_ami data source in Terraform with most_recent set and a filter on that tag to resolve the id at plan time.
Tag the AMI at build time with something stable like a version number or timestamp, then use the awsami data source in Terraform with mostrecent set and a filter on that tag to resolve the id at plan time. This removes the hand-off step entirely: Packer just builds and tags, Terraform always finds the latest matching AMI. The same pattern works for any consumer that needs the newest image without a manual lookup.
Context: Stack Overflow #37357618 (accepted answer, 25 votes): the asker builds an AMI with Packer and deploys infrastructure with Terraform, and wants the AMI id to flow into Terraform automatically instead of being pasted in by hand. The accepted answer flips the dependency: do not push the id from Packer, have Terraform look it up.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.