github.com/hashicorp/packer@v1.14.3/website/content/docs/datasources/hcp/hcp-packer-image.mdx (about) 1 --- 2 description: | 3 The `hcp-packer-image` data source retrieves information about an image from the HCP Packer registry. This data source is deprecated, use the `hcp-packer-artifact` data source instead. 4 page_title: hcp-packer-image data source reference 5 --- 6 7 <BadgesHeader> 8 <PluginBadge type="official" /> 9 </BadgesHeader> 10 11 # `hcp-packer-image` 12 13 ~> **This data source is deprecated**. Use the [`hcp-packer-artifact`](/packer/docs/datasources/hcp/hcp-packer-artifact) data source instead. 14 15 The `hcp-packer-image` data source retrieves information about an 16 image from the HCP Packer registry. This information can be used to 17 provide a source image to various Packer builders. 18 19 To get started with HCP Packer, refer to the [HCP Packer documentation](/hcp/docs/packer) or try the [Get Started with HCP Packer tutorials](/packer/tutorials/hcp-get-started). 20 21 ~> **Note:** You will receive an error if you try to reference metadata from a deactivated or deleted registry. An administrator can manually deactivate or delete a registry, and HCP Packer automatically deactivates registries with billing issues. Contact [HashiCorp Support](https://support.hashicorp.com/) with questions. 22 23 ## Revoked Iterations 24 25 If an iteration is revoked, the `hcp-packer-iteration` data source will fail and Packer won't proceed with the build. Building new images from a revoked image is not compliant. 26 Iterations that are scheduled to be revoked will still be considered valid until the revocation date. 27 28 ## Basic Example 29 30 Below is a fully functioning example. It stores information about an image, 31 which can then be parsed and accessed as a variable. 32 33 ```hcl 34 data "hcp-packer-image" "example" { 35 bucket_name = "hardened-ubuntu-16-04" 36 iteration_id = "${data.hcp-packer-iteration.hardened-source.id}" 37 cloud_provider = "aws" 38 region = "us-east-1" 39 } 40 ``` 41 42 ## Full Example 43 44 This data source can be used in conjunction with the hcp-packer-iteration 45 data source to retrieve an image ID using a channel. You provide the channel 46 name to the iteration data source, then use the iteration source in the image 47 data source, then use the image data source inside your source block. 48 49 ```hcl 50 # Retrieves information about the HCP Packer "iteration"; an "iteration" can be 51 # thought of as all the metadata created by a single call of `packer build`. 52 data "hcp-packer-iteration" "hardened-source" { 53 bucket_name = "hardened-ubuntu-16-04" 54 channel = "packer-test" 55 } 56 57 # Retrieves information about the HCP Packer "image"; an image can be thought 58 # of as all the metadata (including the artifact names) created by a single 59 # "source" builder; this can include multiple images so we provide a cloud 60 # region to disambiguate. 61 data "hcp-packer-image" "foo" { 62 bucket_name = "hardened-ubuntu-16-04" 63 iteration_id = data.hcp-packer-iteration.hardened-source.id 64 cloud_provider = "aws" 65 region = "us-east-1" 66 } 67 68 # This source uses the output from a previous Packer build. By using the 69 # HCP Packer registry in this way, you can easily create build pipelines where 70 # a single base image can be customized in multiple secondary layers. 71 source "amazon-ebs" "packer-secondary" { 72 source_ami = data.hcp-packer-image.foo.id 73 # ... 74 } 75 ``` 76 77 ## Configuration Reference 78 79 Configuration options are organized below into two categories: required and 80 optional. Within each category, the available options are alphabetized and 81 described. 82 83 ### Required: 84 85 @include 'datasource/hcp-packer-image/Config-required.mdx' 86 87 ### Optional: 88 89 ~> **Note:** This data source only returns the first found image's metadata filtered by the given options, from the returned list of images associated with the specified iteration. Therefore, if multiple images exist in the same region, it will only pick one of them. In this case, you can filter images by a source build name (Ex: `amazon-ebs.example`) using the `component_type` option. 90 91 @include 'datasource/hcp-packer-image/Config-not-required.mdx' 92 93 ### Output Fields: 94 95 @include 'datasource/hcp-packer-image/DatasourceOutput.mdx'