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