Error: Unknown region on packer validate (region newer than Packer)
Fixes packer validate failing with 'Unknown region' for newer AWS regions. For engineers whose templates target regions added after their Packer version, the fix is upgrading Packer or the amazon plugin.
Error: Unknown region: ap-northeast-2 (packer validate)
TL;DR
Your Packer version predates the AWS region you are targeting. Upgrade Packer (and the amazon plugin) to a release that knows the region, then re-validate.
The error
Build 'amazon-ebs' prepare failure: 1 error(s) occurred:
* Unknown region: ap-northeast-2Fix it
- Check your Packer version:
packer version. If it predates the region's launch, that is the problem.
- Success check: you have a version number to compare against the region launch date.
- Upgrade Packer to current, and upgrade the amazon plugin:
packer plugins install github.com/hashicorp/amazon.
- Success check:
packer versionshows the new release.
- Re-run
packer validate.
- Success check: the region is accepted.
- If you cannot upgrade, verify the region string is spelled correctly (
ap-northeast-2, notap-north-east-2) as a sanity check.
- Success check: the spelling matches the AWS region list.
When to use this
You hit this on packer validate with a region that AWS launched after your Packer release.
When NOT to use this
Do not use this for error validating regions: MissingEndpoint. That is an endpoint configuration problem, not an unknown region.
Compatibility
Older Packer 1.x and the amazon plugin. Current releases know all commercial regions.
Variants
Unknown region: [any newer region](af-south-1, eu-south-1, me-south-1, etc. on old builds)- The same error from
packer buildat prepare time, not just validate
Root cause
Packer validated regions against a baked-in list. New AWS regions launched after the release were rejected as unknown until the list was updated upstream.
Edge cases
- GovCloud and China regions have always needed explicit endpoint configuration; they fail differently.
- A typo'd region fails the same way on any version. Rule out typos before upgrading.
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.