The implementation of amazon-ebs
builder states that "-force" flag for packer build
command should imitate the behavior of the setting force_register = true
.
However, that doesn't happen:
$ packer build \
-var='ami_name=my-existing-ami' \
-force \
-debug \
./
Debug mode enabled. Builds will not be parallelized.
amazon-ebs: output will be in this color.
==> amazon-ebs: Prevalidating any provided VPC information
==> amazon-ebs: Prevalidating AMI Name: my-existing-ami
==> amazon-ebs: Error: AMI Name: 'my-existing-ami' is used by an existing AMI: ami-02453ab91773d7bd8
Build 'amazon-ebs' errored: Error: AMI Name: 'my-existing-ami' is used by an existing AMI: ami-02453ab91773d7bd8
==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: Error: AMI Name: 'my-existing-ami' is used by an existing AMI: ami-02453ab91773d7bd8
==> Builds finished but no artifacts were created.
It works only if I set force_register = true
in my config (but then -force
flag is not needed at all)
I reproduce it with the simpliest config based on HCL2 syntax:
source "amazon-ebs" "main" {
profile = var.aws_profile
instance_type = var.instance_type
region = var.region
ssh_username = var.ssh_username
ssh_interface = "public_ip"
source_ami = var.source_ami
ami_name = var.ami_name
}
build {
sources = [
"source.amazon-ebs.main"
]
}
Packer v1.5.6
See the snippets above
macOS 10.15.4
$ env PACKER_LOG=1 packer build \
-var='ami_name=my-existing-ami' \
-force \
-debug \
./
2020/05/07 12:04:21 [INFO] Packer version: 1.5.6 [go1.14.2 darwin amd64]
2020/05/07 12:04:21 Checking 'PACKER_CONFIG' for a config file path
2020/05/07 12:04:21 'PACKER_CONFIG' not set; checking the default config file path
2020/05/07 12:04:21 Attempting to open config file: /Users/legal/.packerconfig
2020/05/07 12:04:21 [WARN] Config file doesn't exist: /Users/legal/.packerconfig
2020/05/07 12:04:21 Setting cache directory: /Users/legal/Workspace/my-project/deployment/packer/packer_cache
2020/05/07 12:04:21 Creating plugin client for path: /usr/local/bin/packer
2020/05/07 12:04:21 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-builder-amazon-ebs"}
2020/05/07 12:04:21 Waiting for RPC address for: /usr/local/bin/packer
2020/05/07 12:04:21 packer-builder-amazon-ebs plugin: [INFO] Packer version: 1.5.6 [go1.14.2 darwin amd64]
2020/05/07 12:04:21 packer-builder-amazon-ebs plugin: Checking 'PACKER_CONFIG' for a config file path
2020/05/07 12:04:21 packer-builder-amazon-ebs plugin: 'PACKER_CONFIG' not set; checking the default config file path
2020/05/07 12:04:21 packer-builder-amazon-ebs plugin: Attempting to open config file: /Users/legal/.packerconfig
2020/05/07 12:04:21 packer-builder-amazon-ebs plugin: [WARN] Config file doesn't exist: /Users/legal/.packerconfig
2020/05/07 12:04:21 packer-builder-amazon-ebs plugin: Setting cache directory: /Users/legal/Workspace/my-project/deployment/packer/packer_cache
2020/05/07 12:04:21 packer-builder-amazon-ebs plugin: args: []string{"packer-builder-amazon-ebs"}
2020/05/07 12:04:21 packer-builder-amazon-ebs plugin: Plugin address: unix /var/folders/r_/04n660m11yb684259lnb0jnc0000gq/T/packer-plugin615871852
2020/05/07 12:04:21 packer-builder-amazon-ebs plugin: Waiting for connection...
2020/05/07 12:04:21 Received unix RPC address for /usr/local/bin/packer: addr is /var/folders/r_/04n660m11yb684259lnb0jnc0000gq/T/packer-plugin615871852
2020/05/07 12:04:21 packer-builder-amazon-ebs plugin: Serving a plugin connection...
2020/05/07 12:04:21 Build debug mode: true
2020/05/07 12:04:21 Force build: true
2020/05/07 12:04:21 On error:
Debug mode enabled. Builds will not be parallelized.
2020/05/07 12:04:21 Preparing build: amazon-ebs
2020/05/07 12:04:21 Debug enabled, so waiting for build to finish: amazon-ebs
amazon-ebs: output will be in this color.
2020/05/07 12:04:21 Starting build run: amazon-ebs
2020/05/07 12:04:21 Running builder:
2020/05/07 12:04:21 [INFO] (telemetry) Starting builder
2020/05/07 12:04:21 packer-builder-amazon-ebs plugin: Found region eu-central-1
2020/05/07 12:04:22 packer-builder-amazon-ebs plugin: [INFO] AWS Auth provider used: "AssumeRoleProvider"
2020/05/07 12:04:22 packer-builder-amazon-ebs plugin: [INFO] (aws): No AWS timeout and polling overrides have been set. Packer will default to waiter-specific delays and timeouts. If you would like to customize the length of time between retries and max number of retries you may do so by setting the environment variables AWS_POLL_DELAY_SECONDS and AWS_MAX_ATTEMPTS to your desired values.
==> amazon-ebs: Prevalidating any provided VPC information
==> amazon-ebs: Prevalidating AMI Name: my-existing-ami
==> amazon-ebs: Error: AMI Name: 'my-existing-ami' is used by an existing AMI: ami-02453ab91773d7bd8
2020/05/07 12:04:24 [INFO] (telemetry) ending
2020/05/07 12:04:24 Waiting on builds to complete...
2020/05/07 12:04:24 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2020/05/07 12:04:24 machine readable: amazon-ebs,error []string{"Error: AMI Name: 'my-existing-ami' is used by an existing AMI: ami-02453ab91773d7bd8"}
==> Builds finished but no artifacts were created.
Build 'amazon-ebs' errored: Error: AMI Name: 'my-existing-ami' is used by an existing AMI: ami-02453ab91773d7bd8
2020/05/07 12:04:24 [INFO] (telemetry) Finalizing.
==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: Error: AMI Name: 'my-existing-ami' is used by an existing AMI: ami-02453ab91773d7bd8
==> Builds finished but no artifacts were created.
2020/05/07 12:04:25 waiting for all plugin processes to complete...
2020/05/07 12:04:25 /usr/local/bin/packer: plugin process exited
Thanks for opening; we'll try to take a look as soon as we can.
To give more context on this. For JSON this happens here :
You can see all these common fields from cli and such be set on that map and the applied after the user config. We need to pass that same struct down after #9139 is merged (to avoid conflicts). This needs to happen here:
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.