Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HCP_PACKER_BUCKET_NAME env var doesn't make bucket_name optional on hcp_packer_registry block #13194

Closed
othmane399 opened this issue Oct 29, 2024 · 2 comments · Fixed by #13210
Labels

Comments

@othmane399
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction 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

Overview of the Issue

using hcp_packer_registry block require bucket_name variable even if HCP_PACKER_BUCKET_NAME env var is set and will override the bucket_name at the end

Reproduction Steps

define a packer template with the hcp_packer_registry without bucket_name var

...
build {
  hcp_packer_registry {
  }
...

build your template

export HCP_PACKER_BUCKET_NAME="base"
packer build --debug .
Error: hcp_packer_registry.bucket_name can only contain between 3 and 36 ASCII letters, numbers and hyphens

  on base.pkr.hcl line 61:
  (source code not available)

Packer version

Packer v1.11.2

Simplified Packer Template

source "amazon-ebs" "ubuntu-lts" {
  region = "us-west-1"
  source_ami_filter {
    filters = {
      virtualization-type = "hvm"
      name                = "ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"
      root-device-type    = "ebs"
    }
    owners      = ["099720109477"]
    most_recent = true
  }
  instance_type  = "t2.small"
  ssh_username   = "ubuntu"
  ssh_agent_auth = false

  ami_name    = "hashicups_{{timestamp}}"
  ami_regions = ["us-west-1"]
}

build {
  # HCP Packer settings
  hcp_packer_registry {
  }

  sources = [
    "source.amazon-ebs.ubuntu-lts",
  ]
}

Operating system and Environment details

Not needed

Log Fragments and crash.log files

packer build --debug .  
2024/10/29 17:38:52 [INFO] Packer version: 1.11.2 [go1.21.12 darwin arm64]
2024/10/29 17:38:52 Detected xdg config directory from env var: /Users/otch
2024/10/29 17:38:52 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2024/10/29 17:38:52 [INFO] PACKER_CONFIG env var set; attempting to open config file: /Users/otch/.packerconfig
2024/10/29 17:38:52 [WARN] Config file doesn't exist: /Users/otch/.packerconfig
2024/10/29 17:38:52 Detected xdg config directory from env var: /Users/otch
2024/10/29 17:38:52 [INFO] Setting cache directory: /Users/otch/.cache/packer
2024/10/29 17:38:52 Detected xdg config directory from env var: /Users/otch
2024/10/29 17:38:52 [TRACE] listing potential installations for <nil> that match "". plugingetter.ListInstallationsOptions{PluginDirectory:"/Users/otch/packer/plugins", BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"darwin", ARCH:"arm64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0x1400079a700)}}, ReleasesOnly:false}}
2024/10/29 17:38:52 found external [-packer-default-plugin-name- local] provisioner from ansible plugin
2024/10/29 17:38:52 [INFO] found external [chroot ebs ebssurrogate ebsvolume instance] builders from amazon plugin
2024/10/29 17:38:52 [INFO] found external [import] post-processors from amazon plugin
2024/10/29 17:38:52 found external [ami parameterstore secretsmanager] datasource from amazon plugin
2024/10/29 17:38:52 [TRACE] validateValue: not active for region, so skipping

  on base.pkr.hcl line 61:
  (source code not available)

2024/10/29 17:38:52 [INFO] (telemetry) Finalizing.
Error: hcp_packer_registry.bucket_name can only contain between 3 and 36 ASCII letters, numbers and hyphens

  on base.pkr.hcl line 61:
  (source code not available)


2024/10/29 17:38:53 waiting for all plugin processes to complete...
@lbajolet-hashicorp
Copy link
Contributor

Hey @othmane399,

Thanks for the issue, that's a good catch. The fix is quite simple fortunately, I've already opened the PR on Packer core, assuming it gets approved, this will be merged in a not too distant future, and will be part of the 1.12.0 release!

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants