{{timestamp}} doesn't remain constant in post processor manifest
- Dominant language
- Go
- Stars
- 15.8k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
#### Community Note
* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment
When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.
#### Overview of the Issue
We have a locals to create tags on the AMI which in turn is used to write to manifest.
```
locals {
tstamp = "{{timestamp}}"
tags = {
Name = "${var.ami_prefix}-${local.tstamp}"
....
}
```
These tags are applied fine on the AMI.
We also have a post processor section.
```
post-processors {
post-processor "manifest" {
...
custom_data = {
....
ami_name = local.tags.Name
}
}
}
```
The ami_name in manifest file should be the same as AMI name of the AMI. But, on certain occasions, it is a few seconds out i.e. it does not match the actual AMI Name. The problem is very random.
#### Reproduction Steps
The problem is very random. It is not reproducible every time.
### Packer version
Any including latest
### Operating system and Environment details
Redhat Linux 9.6
### Logs
```
$ packer build -machine-readable packer/images-ebs/ | tee packer.out
1761565722,,ui,say,==> amazon-ebs.base: Prevalidating any provided VPC information
1761565722,,ui,say,==> amazon-ebs.base: Prevalidating AMI Name:MYAMI-v9.6-v26.4.2-1761565720
1761565722,,ui,say,==> amazon-ebs.base: Found Image ID: __hidden__
1761565722,,ui,say,==> amazon-ebs.base: Found VPC ID: __hidden__
1761565722,,ui,say,==> amazon-ebs.base: Found Subnet ID: __hidden__
1761565722,,ui,say,==> amazon-ebs.base: Creating temporary keypair: __hidden__
1761565723,,ui,say,==> amazon-ebs.base: Found Security Group(s): __hidden__
1761565723,,ui,say,==> amazon-ebs.base: Launching a source AWS instance...
1761565723,,ui,say,==> amazon-ebs.base: Adding tag: "Base_AMI_Name": "__hidden__"
1761565723,,ui,say,==> amazon-ebs.base: Adding tag: "Component": "packer"
1761565723,,ui,say,==> amazon-ebs.base: Adding tag: "Name": "MYAMI-v9.6-v26.4.2-1761565720"
...
...
1761565723,,ui,say,==> amazon-ebs.base: Adding tag: "Name": "MYAMI-v9.6-v26.4.2-1761565720"
...
1761565742,,ui,say,==> amazon-ebs.base: Using SSH communicator to connect: 10.195.13.37
1761565742,,ui,say,==> amazon-ebs.base: Waiting for SSH to become available...
1761565775,,ui,say,==> amazon-ebs.base: Connected to SSH!
...
...snip to end..
...
1761566241,,ui,say,==> amazon-ebs.base: Adding tag: "Name": "MYAMI-v9.6-v26.4.2-1761565720"
1761566259,,ui,say,==> amazon-ebs.base: Running post-processor: (type manifest)
1761566259,,ui,say,Build 'amazon-ebs.base' finished after 8 minutes 58 seconds.
1761566259,amazon-ebs.base,artifact,1,end
1761566259,,ui,say,--> amazon-ebs.base: AMIs were created:\neu-west-2: ami-__hidden_\n
```
Contents of manifest.json
```
{
"builds": [
{
"name": "base",
"builder_type": "amazon-ebs",
"build_time": 1761566259,
"files": null,
"artifact_id": "eu-west-2:ami-__hidden__",
"packer_run_uuid": "27ef8979-e7eb-088d-31eb-cc3d9cc974e9",
"custom_data": {
"ami_name": "MYAMI-v9.6-v26.4.2-1761565721",
"ami_source_id": "ami-__hidden__",
"ami_source_name": "__hidden__",
"ami_version": "v26.4.2",
"baseline": "__hidden__",
"instance_id": "__hidden__",
"os_major_version": "9",
"os_version": "9.6"
}
}
],
"last_run_uuid": "27ef8979-e7eb-088d-31eb-cc3d9cc974e9"
}
```
In the above logs, you can see that timestamp has shifted by 1.
**Actual AMI Name**: MYAMI-v9.6-v26.4.2-1761565720
**AMI Name recorded in manifest**: MYAMI-v9.6-v26.4.2-1761565721
**Note**: We use {{timestamp}} because there's no built in method to get time since epoch.
Contributor guide
Research direction
Start with the manifest post-processor and the {{timestamp}} expansion path, comparing them with the amazon-ebs AMI naming path shown in the logs. Reproduce the one-second mismatch if possible and verify completion when manifest custom_data.ami_name consistently matches the actual AMI name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, go
- Domain
- cloud, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100