Unable to build: "Request has expired" after less than a second

I am working on some real-world applications where I need to build some AMIs. I’ve been getting the same problem since I started using Packer (it’s been a little while, haven’t used it until now at my current job), and I’ve been slowly backing up to less and less complex scenarios to troubleshoot to the point where I’m trying to execute the build straight from the tutorial and having the same problem. I am currently using an account I set up specifically to troubleshoot this issue that has full access to EC2 and AWS Marketplace.

When I run packer build sample.pkr.hcl (which is a direct copy of the setup found in the tutorial) I get the following output:

learn-packer.amazon-ebs.ubuntu: output will be in this color.

Build 'learn-packer.amazon-ebs.ubuntu' errored after 51 seconds 238 milliseconds: error validating regions: RequestExpired: Request has expired.
	status code: 400, request id: d2e28866-49d1-42a3-be58-8609deafb36d

==> Wait completed after 51 seconds 238 milliseconds

==> Some builds didn't complete successfully and had errors:
--> learn-packer.amazon-ebs.ubuntu: error validating regions: RequestExpired: Request has expired.
	status code: 400, request id: d2e28866-49d1-42a3-be58-8609deafb36d

==> Builds finished but no artifacts were created.

I got hung up on the “error validating regions” thing for a while, but then I added skip_region_validation = true to the same build. When I run that build, I get this:

learn-packer.amazon-ebs.ubuntu: output will be in this color.

==> learn-packer.amazon-ebs.ubuntu: Prevalidating any provided VPC information
==> learn-packer.amazon-ebs.ubuntu: Prevalidating AMI Name: learn-packer-linux-aws
==> learn-packer.amazon-ebs.ubuntu: Error querying AMI: RequestExpired: Request has expired.
==> learn-packer.amazon-ebs.ubuntu: 	status code: 400, request id: d82f3fae-81bf-44b3-9f66-9b400835deba
Build 'learn-packer.amazon-ebs.ubuntu' errored after 308 milliseconds 566 microseconds: Error querying AMI: RequestExpired: Request has expired.
	status code: 400, request id: d82f3fae-81bf-44b3-9f66-9b400835deba

==> Wait completed after 308 milliseconds 801 microseconds

==> Some builds didn't complete successfully and had errors:
--> learn-packer.amazon-ebs.ubuntu: Error querying AMI: RequestExpired: Request has expired.
	status code: 400, request id: d82f3fae-81bf-44b3-9f66-9b400835deba

==> Builds finished but no artifacts were created.

Now it’s failing in less than a second, and I have no idea why. There isn’t much else available in the logfile, but I’ll post it here anyway:

packerlog.txt (6.8 KB)

Any suggestions?

UPDATE: In case anyone is as dumb as me (unlikely), this issue is due to the fact that while my ~/.aws files were clear of older references, I still had an expired token sitting in my declared variables. Use unset AWS_SESSION_TOKEN to remove, possibly also your access key ID and secret key if those are also stale. Thank you.