From c25c27b6b6e7ef5ed838546c0db7f026e530167c Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Tue, 7 Sep 2021 10:26:57 -0700 Subject: [PATCH] add docs pages for new data sources --- .../docs/datasources/hcp-packer-image.mdx | 85 +++++++++++++++++++ .../docs/datasources/hcp-packer-iteration.mdx | 83 ++++++++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 website/content/docs/datasources/hcp-packer-image.mdx create mode 100644 website/content/docs/datasources/hcp-packer-iteration.mdx diff --git a/website/content/docs/datasources/hcp-packer-image.mdx b/website/content/docs/datasources/hcp-packer-image.mdx new file mode 100644 index 000000000..ba90a00eb --- /dev/null +++ b/website/content/docs/datasources/hcp-packer-image.mdx @@ -0,0 +1,85 @@ +--- +description: | + 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. +page_title: HCP Packer Image - Data Sources +--- + +# HCP Packer Image Data Source + +Type: `hcp-packer-image` + +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. + +Please note: The HCP Packer registry is in development, and is not yet available +for public use. For more information about HCP Packer, see https://www.hashicorp.com/blog/announcing-hcp-packer + +## 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/RunConfig-required.mdx' + +There are currently no optional fields for this datasource, though we intend +to add filtering fields in the future. + +### Output Fields: + +@include 'datasource/hcp-packer-image/DatasourceOutput.mdx' \ No newline at end of file diff --git a/website/content/docs/datasources/hcp-packer-iteration.mdx b/website/content/docs/datasources/hcp-packer-iteration.mdx new file mode 100644 index 000000000..388542b81 --- /dev/null +++ b/website/content/docs/datasources/hcp-packer-iteration.mdx @@ -0,0 +1,83 @@ +--- +description: | + The HCP Packer Iteration Data Source retrieves information about an + iteration from the HCP Packer registry. This information can be used to + query HCP for a source image for various Packer builders. +page_title: HCP Packer Iteration - Data Sources +--- + +# HCP Packer Iteration Data Source + +Type: `hcp-packer-iteration` + +The `HCP Packer Iteration` Data Source retrieves information about an +iteration from the HCP Packer registry. This information can be used to query +HCP for a source image for various Packer builders. + +Please note: The HCP Packer registry is in development, and is not yet available +for public use. For more information about HCP Packer, see https://www.hashicorp.com/blog/announcing-hcp-packer + +## Basic Example + +Below is a fully functioning example. It stores information about an image +iteration, which can then be accessed as a variable. + +```hcl +data "hcp-packer-iteration" "hardened-source" { + bucket_name = "hardened-ubuntu-16-04" + channel = "packer-test" +} +``` + +## Full Example + +This data source can be used in conjunction with the hcp-packer-image +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 inside 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-iteration/RunConfig-required.mdx' + +There are currently no optional fields for this datasource, though we intend +to add filtering fields in the future. + +### Output Fields: + +@include 'datasource/hcp-packer-iteration/DatasourceOutput.mdx' \ No newline at end of file