hashicorp / hashicorp/packer-plugin-amazon

AMI tag not persisting after build

Open
#41 4 comments 1 reaction 0 assignees View on GitHub
builder/amazon upstream-bug
Dominant language
Go
Stars
91
Forks
141
Avg merge
2d 18h
Merged PRs (30d)
3

Description

_This issue was originally opened by @RixhersAjazi as hashicorp/packer#10132. It was migrated here as a result of the [Packer plugin split](https://github.com/hashicorp/packer/issues/8610#issuecomment-770034737). The original body of the issue is below._


#### Overview of the Issue

When I set `tags` on `amazon-ebs` builder I see the tags being applied in packer log output during the running of packer. However I do not see the final tag in AWS console when I go and check on my AMI's.

#### Reproduction Steps

- Use this amazon-ebs builder defintion:

```
{
"name": "t3a.micro",
"profile": "{{user `profile`}}",
"region": "{{user `aws_region`}}",
"type": "amazon-ebs",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20200609",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": false
},
"ami_users": ["320176959135", "351145466100", "485438916218"],
"instance_type": "t3a.micro",
"ssh_username": "ubuntu",
"ami_name": "foooo-{{timestamp}}",
"subnet_filter": {
"filters": {
"tag:Group": "meta-new",
"tag:Name": "meta-new-private-*"
},
"most_free": true,
"random": false
},
"ssh_interface": "private_ip",
"ami_regions": ["us-east-2", "ap-southeast-2"],
"tags": {
"Release": "{{user `release_tag`}}"
},
"run_tags":{
"Release": "{{user `release_tag`}}"
}
}
```

- Run packer
- Go to AWS CLI and see that the AMI that was generated and subsequently copied to the other regions doesn't have the tag defined:
Screen Shot 2020-10-20 at 1 09 24 PM

### Packer version

```
rixhersajazi@hostyhost packer-dev (ticketT-7772)*$ packer --version
1.6.0
```

### Packer build output

```
==> t3a.micro: Waiting for the instance to stop...
==> t3a.micro: Creating AMI fooooo-1603212597 from instance i-06aa58418cfc94449
t3a.micro: AMI: ami-00275c4502a4e0dba
==> t3a.micro: Waiting for AMI to become ready...
==> t3a.micro: Copying/Encrypting AMI (ami-00275c4502a4e0dba) to other regions...
t3a.micro: Copying to: us-east-2
t3a.micro: Copying to: ap-southeast-2
t3a.micro: Waiting for all copies to complete...
==> t3a.micro: Modifying attributes on AMI (ami-0b2881c5cba17e5b0)...
t3a.micro: Modifying: users
==> t3a.micro: Modifying attributes on AMI (ami-00275c4502a4e0dba)...
t3a.micro: Modifying: users
==> t3a.micro: Modifying attributes on AMI (ami-0752628f480d59636)...
t3a.micro: Modifying: users
==> t3a.micro: Modifying attributes on snapshot (snap-04a99f316e19fced0)...
==> t3a.micro: Modifying attributes on snapshot (snap-032d3d88e4844f1dd)...
==> t3a.micro: Modifying attributes on snapshot (snap-0bd7cae46477fc6ca)...
==> t3a.micro: Adding tags to AMI (ami-00275c4502a4e0dba)...
==> t3a.micro: Tagging snapshot: snap-04a99f316e19fced0
==> t3a.micro: Creating AMI tags
t3a.micro: Adding tag: "Release": "FEATURE_BRANCH_QA_ONLY"
==> t3a.micro: Creating snapshot tags
==> t3a.micro: Adding tags to AMI (ami-0752628f480d59636)...
==> t3a.micro: Tagging snapshot: snap-032d3d88e4844f1dd
==> t3a.micro: Creating AMI tags
t3a.micro: Adding tag: "Release": "FEATURE_BRANCH_QA_ONLY"
==> t3a.micro: Creating snapshot tags
==> t3a.micro: Adding tags to AMI (ami-0b2881c5cba17e5b0)...
==> t3a.micro: Tagging snapshot: snap-0bd7cae46477fc6ca
==> t3a.micro: Creating AMI tags
t3a.micro: Adding tag: "Release": "FEATURE_BRANCH_QA_ONLY"
==> t3a.micro: Creating snapshot tags
==> t3a.micro: Terminating the source AWS instance...
==> t3a.micro: Cleaning up any extra volumes...
==> t3a.micro: No volumes to clean up, skipping
==> t3a.micro: Deleting temporary security group...
==> t3a.micro: Deleting temporary keypair...
Build 't3a.micro' finished.

==> Builds finished. The artifacts of successful builds are:
--> t3a.micro: AMIs were created:
ap-southeast-2: ami-0752628f480d59636
us-east-2: ami-0b2881c5cba17e5b0
us-west-2: ami-00275c4502a4e0dba

```

Notice there are lines saying:

```
==> t3a.micro: Creating AMI tags
t3a.micro: Adding tag: "Release": "FEATURE_BRANCH_QA_ONLY"
```

### Operating system and Environment details

MacOS Catalina - 10.15.7

### Log Fragments and crash.log files

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.