hashicorp / hashicorp/packer-plugin-amazon
Build of an AMI with HCP Packer Registry integration and with skip_create_ami = true ends up in creating an incomplete Iteration in HCP Packer Registry
- Dominant language
- Go
- Stars
- 91
- Forks
- 141
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 3
Description
When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.
#### Overview of the Issue
Build of an AMI with HCP Packer Registry integration and with skip_create_ami = true ends up in creating an incomplete Iteration in HCP Packer Registry.
#### Reproduction Steps
1/ Export the HCP_CLIENT_SECRET and the HCP_CLIENT_ID locally as per : https://developer.hashicorp.com/packer/tutorials/hcp-get-started/hcp-push-image-metadata#create-hcp-service-principal-and-set-to-environment-variable
2/ Run the following:
```hcl
packer {
required_plugins {
amazon = {
version = ">= 1.0.1"
source = "github.com/hashicorp/amazon"
}
}
}
source "amazon-ebs" "basic-example-east" {
region = "us-east-2"
source_ami_filter {
filters = {
virtualization-type = "hvm"
name = "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*"
root-device-type = "ebs"
}
owners = ["099720109477"]
most_recent = true
}
skip_create_ami = true
instance_type = "t2.small"
ssh_username = "ubuntu"
ssh_agent_auth = false
ami_name = "packer_AWS_{{timestamp}}"
}
build {
name = "example-amazon-ebs"
sources = [ "source.amazon-ebs.basic-example-east"]
hcp_packer_registry {
bucket_name = "example-amazon-ebs-custom"
description = "Golden image for Amazon-backed applications"
bucket_labels = {
"team" = "amazon-development",
"os" = "Ubuntu"
}
build_labels = {
"python-version" = "3.9",
"ubuntu-version" = "Xenial 16.04"
"build-time" = timestamp()
}
}
}
```
### Plugin and Packer version
Packer v1.9.4
### Simplified Packer Buildfile
See above
### Operating system and Environment details
N/A
### Log Fragments and crash.log files
```sh
> packer build .
Tracking build on HCP Packer with fingerprint "XXXXX"
example-amazon-ebs.amazon-ebs.basic-example-east: output will be in this color.
==> example-amazon-ebs.amazon-ebs.basic-example-east: Prevalidating any provided VPC information
==> example-amazon-ebs.amazon-ebs.basic-example-east: Prevalidating AMI Name: packer_AWS_1695295551
example-amazon-ebs.amazon-ebs.basic-example-east: Found Image ID: ami-yyyyyyyyy
==> example-amazon-ebs.amazon-ebs.basic-example-east: Creating temporary keypair: packer_650c283f-65c4-5efe-ad79-4ee744651510
==> example-amazon-ebs.amazon-ebs.basic-example-east: Creating temporary security group for this instance: packer_650c2846-a87f-58d6-c7bf-af9608fc299c
==> example-amazon-ebs.amazon-ebs.basic-example-east: Authorizing access to port 22 from [0.0.0.0/0] in the temporary security groups...
==> example-amazon-ebs.amazon-ebs.basic-example-east: Launching a source AWS instance...
example-amazon-ebs.amazon-ebs.basic-example-east: Instance ID: i-qsdqsdqsdqsdqsd
==> example-amazon-ebs.amazon-ebs.basic-example-east: Waiting for instance (i-qsdqsdqsdqsdqsd) to become ready...
==> example-amazon-ebs.amazon-ebs.basic-example-east: Using SSH communicator to connect: 1.1.1.1
==> example-amazon-ebs.amazon-ebs.basic-example-east: Waiting for SSH to become available...
==> example-amazon-ebs.amazon-ebs.basic-example-east: Connected to SSH!
==> example-amazon-ebs.amazon-ebs.basic-example-east: Stopping the source instance...
example-amazon-ebs.amazon-ebs.basic-example-east: Stopping instance
==> example-amazon-ebs.amazon-ebs.basic-example-east: Waiting for the instance to stop...
==> example-amazon-ebs.amazon-ebs.basic-example-east: Skipping AMI creation...
==> example-amazon-ebs.amazon-ebs.basic-example-east: Skipping AMI region copy...
==> example-amazon-ebs.amazon-ebs.basic-example-east: Skipping Enable AMI deprecation...
==> example-amazon-ebs.amazon-ebs.basic-example-east: Skipping AMI modify attributes...
==> example-amazon-ebs.amazon-ebs.basic-example-east: Skipping AMI create tags...
==> example-amazon-ebs.amazon-ebs.basic-example-east: Terminating the source AWS instance...
==> example-amazon-ebs.amazon-ebs.basic-example-east: Cleaning up any extra volumes...
==> example-amazon-ebs.amazon-ebs.basic-example-east: No volumes to clean up, skipping
==> example-amazon-ebs.amazon-ebs.basic-example-east: Deleting temporary security group...
==> example-amazon-ebs.amazon-ebs.basic-example-east: Deleting temporary keypair...
Error: failed to complete HCP-enabled build "example-amazon-ebs.amazon-ebs.basic-example-east"
failed to update Packer registry with image artifacts for
"amazon-ebs.basic-example-east": setting a build to DONE with no published
images is not currently supported.
Build 'example-amazon-ebs.amazon-ebs.basic-example-east' finished after 1 minute 46 seconds.
==> Wait completed after 1 minute 46 seconds
==> Builds finished but no artifacts were created.
Iteration "XXXXX" is not complete, the following builds are not done:
* "amazon-ebs.basic-example-east": RUNNING
You may resume work on this iteration in further Packer builds by defining the following variable in your environment:
HCP_PACKER_BUILD_FINGERPRINT="XXXXX"
```
Ideally, HCP Packer Registry push should be ignored by Packer since this is a test build and no AMI will be created upon the packer process.
Hope this makes sense.
Thanks a lot for your help.
Bests.
Contributor guide
Assessment
This issue has not been assessed yet.