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

Add component_type optional field #11872

Conversation

smaeda-ks
Copy link
Contributor

@smaeda-ks smaeda-ks commented Jul 11, 2022

to support specifying the exact build image when multiple images exist in the same provider and region for a given iteration.

Porting over from:
hashicorp/terraform-provider-hcp#347

tests

Select the most recent one (fallback to the current behavior):

data "hcp-packer-iteration" "ubuntu" {
  bucket_name = "learn-packer-ubuntu"
  channel     = "development"
}

data "hcp-packer-image" "ubuntu-west" {
  bucket_name    = "learn-packer-ubuntu"
  iteration_id   = data.hcp-packer-iteration.ubuntu.id
  cloud_provider = "aws"
  region         = "us-west-1"
}

locals {
  image = data.hcp-packer-image.ubuntu-west
}

Select the exact image:

data "hcp-packer-iteration" "ubuntu" {
  bucket_name = "learn-packer-ubuntu"
  channel     = "development"
}

data "hcp-packer-image" "ubuntu-west" {
  bucket_name    = "learn-packer-ubuntu"
  iteration_id   = data.hcp-packer-iteration.ubuntu.id
  cloud_provider = "aws"
  region         = "us-west-1"
  component_type = "amazon-ebs.basic-example-west" // provide an optional field
}

locals {
  image = data.hcp-packer-image.ubuntu-west
}

Error if the specified component_type is not found:

data "hcp-packer-iteration" "ubuntu" {
  bucket_name = "learn-packer-ubuntu"
  channel     = "development"
}

data "hcp-packer-image" "ubuntu-west" {
  bucket_name    = "learn-packer-ubuntu"
  iteration_id   = data.hcp-packer-iteration.ubuntu.id
  cloud_provider = "aws"
  region         = "us-west-1"
  component_type = "foo-bar" // provide an optional field
}

locals {
  image = data.hcp-packer-image.ubuntu-west
}

to support specifying the exact build image when multiple images exist in the same provider and region for a given iteration
@smaeda-ks smaeda-ks changed the title [WIP] Add component_type optional field Add component_type optional field Jul 11, 2022
@smaeda-ks smaeda-ks marked this pull request as ready for review July 11, 2022 11:29
@smaeda-ks smaeda-ks requested a review from a team as a code owner July 11, 2022 11:29
Copy link
Member

@sylviamoss sylviamoss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this PR! Looking good. 🎉
I added a comment about the docs and it is not being rendered.

Copy link
Collaborator

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JenGoldstrich JenGoldstrich merged commit 9f28ced into hashicorp:main Jul 14, 2022
@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, 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 Aug 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants