mirror of https://github.com/hashicorp/packer
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
4.5 KiB
101 lines
4.5 KiB
---
|
|
description: |
|
|
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.
|
|
page_title: hcp-packer-image data source reference
|
|
---
|
|
|
|
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
|
|
> [!IMPORTANT]
|
|
> **Documentation Update:** Product documentation previously located in `/website` has moved to the [`hashicorp/web-unified-docs`](https://github.com/hashicorp/web-unified-docs) repository, where all product documentation is now centralized. Please make contributions directly to `web-unified-docs`, since changes to `/website` in this repository will not appear on developer.hashicorp.com.
|
|
⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️
|
|
|
|
<BadgesHeader>
|
|
<PluginBadge type="official" />
|
|
</BadgesHeader>
|
|
|
|
# `hcp-packer-image`
|
|
|
|
~> **This data source is deprecated**. Use the [`hcp-packer-artifact`](/packer/docs/datasources/hcp/hcp-packer-artifact) data source instead.
|
|
|
|
The `hcp-packer-image` data source retrieves information about an
|
|
image from the HCP Packer registry. This information can be used to
|
|
provide a source image to various Packer builders.
|
|
|
|
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).
|
|
|
|
~> **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.
|
|
|
|
## Revoked Iterations
|
|
|
|
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.
|
|
Iterations that are scheduled to be revoked will still be considered valid until the revocation date.
|
|
|
|
## Basic Example
|
|
|
|
Below is a fully functioning example. It stores information about an image,
|
|
which can then be parsed and accessed as a variable.
|
|
|
|
```hcl
|
|
data "hcp-packer-image" "example" {
|
|
bucket_name = "hardened-ubuntu-16-04"
|
|
iteration_id = "${data.hcp-packer-iteration.hardened-source.id}"
|
|
cloud_provider = "aws"
|
|
region = "us-east-1"
|
|
}
|
|
```
|
|
|
|
## Full Example
|
|
|
|
This data source can be used in conjunction with the hcp-packer-iteration
|
|
data source to retrieve an image ID using a channel. You provide the channel
|
|
name to the iteration data source, then use the iteration source in the image
|
|
data source, then use the image data source inside your source block.
|
|
|
|
```hcl
|
|
# Retrieves information about the HCP Packer "iteration"; an "iteration" can be
|
|
# thought of as all the metadata created by a single call of `packer build`.
|
|
data "hcp-packer-iteration" "hardened-source" {
|
|
bucket_name = "hardened-ubuntu-16-04"
|
|
channel = "packer-test"
|
|
}
|
|
|
|
# Retrieves information about the HCP Packer "image"; an image can be thought
|
|
# of as all the metadata (including the artifact names) created by a single
|
|
# "source" builder; this can include multiple images so we provide a cloud
|
|
# region to disambiguate.
|
|
data "hcp-packer-image" "foo" {
|
|
bucket_name = "hardened-ubuntu-16-04"
|
|
iteration_id = data.hcp-packer-iteration.hardened-source.id
|
|
cloud_provider = "aws"
|
|
region = "us-east-1"
|
|
}
|
|
|
|
# This source uses the output from a previous Packer build. By using the
|
|
# HCP Packer registry in this way, you can easily create build pipelines where
|
|
# a single base image can be customized in multiple secondary layers.
|
|
source "amazon-ebs" "packer-secondary" {
|
|
source_ami = data.hcp-packer-image.foo.id
|
|
# ...
|
|
}
|
|
```
|
|
|
|
## Configuration Reference
|
|
|
|
Configuration options are organized below into two categories: required and
|
|
optional. Within each category, the available options are alphabetized and
|
|
described.
|
|
|
|
### Required:
|
|
|
|
@include 'datasource/hcp-packer-image/Config-required.mdx'
|
|
|
|
### Optional:
|
|
|
|
~> **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.
|
|
|
|
@include 'datasource/hcp-packer-image/Config-not-required.mdx'
|
|
|
|
### Output Fields:
|
|
|
|
@include 'datasource/hcp-packer-image/DatasourceOutput.mdx'
|