generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HPR-1514: Packer Nomenclature Version Data Source (#140)
Co-authored-by: Sylvia Moss <[email protected]> Co-authored-by: Jenna Goldstrich <[email protected]> Co-authored-by: Devashish <[email protected]>
- Loading branch information
1 parent
afacc47
commit f447f03
Showing
77 changed files
with
3,544 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:deprecation | ||
`data.hcp_packer_iteration`: This data source will be removed in a future release, and is superseded by `data.hcp_packer_version` | ||
``` | ||
|
||
```release-note:feature | ||
`data.hcp_packer_version`: Added the `hcp_packer_version` data source, which replaces `data.hcp_packer_iteration` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:deprecation | ||
`data.hcp_packer_image`: This data source will be removed in a future release, and is superseded by `data.hcp_packer_artifact` | ||
``` | ||
|
||
```release-note:feature | ||
`data.hcp_packer_artifact`: Added the `hcp_packer_artifact` data source, which replaces `data.hcp_packer_image` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
--- | ||
page_title: "Data Source hcp_packer_artifact - terraform-provider-hcp" | ||
subcategory: "HCP Packer" | ||
description: |- | ||
The HCP Packer Artifact data source retrieves information about an Artifact. | ||
--- | ||
|
||
# hcp_packer_artifact (Data Source) | ||
|
||
The HCP Packer Artifact data source retrieves information about an Artifact. | ||
|
||
## Example Usage | ||
|
||
### Single artifact sourcing | ||
|
||
```terraform | ||
data "hcp_packer_artifact" "ubuntu-east" { | ||
bucket_name = "hardened-ubuntu-16-04" | ||
channel_name = "production" | ||
platform = "aws" | ||
region = "us-east-1" | ||
} | ||
output "packer-registry-ubuntu-east-1" { | ||
value = data.hcp_packer_artifact.ubuntu-east.external_identifier | ||
} | ||
``` | ||
|
||
~> **Note:** The `channel` attribute in this data source may incur a billable request to HCP Packer. This attribute is intended for convenience when using a single artifact. When sourcing multiple artifacts from a single version, the `hcp_packer_version` data source is the alternative for querying a channel just once. | ||
|
||
### Multiple artifact sourcing from a single version | ||
|
||
```terraform | ||
data "hcp_packer_version" "hardened-source" { | ||
bucket_name = "hardened-ubuntu-16-04" | ||
channel_name = "production" | ||
} | ||
data "hcp_packer_artifact" "ubuntu-east" { | ||
bucket_name = "hardened-ubuntu-16-04" | ||
version_fingerprint = data.hcp_packer_version.hardened-source.fingerprint | ||
platform = "aws" | ||
region = "us-east-1" | ||
} | ||
data "hcp_packer_artifact" "ubuntu-west" { | ||
bucket_name = "hardened-ubuntu-16-04" | ||
version_fingerprint = data.hcp_packer_version.hardened-source.fingerprint | ||
platform = "aws" | ||
region = "us-west-1" | ||
} | ||
output "packer-registry-ubuntu-east-1" { | ||
value = data.hcp_packer_artifact.ubuntu-east.external_identifier | ||
} | ||
output "packer-registry-ubuntu-west-1" { | ||
value = data.hcp_packer_artifact.ubuntu-west.external_identifier | ||
} | ||
``` | ||
|
||
~> **Note:** This data source only returns the first found artifact's metadata filtered by the given arguments, from the returned list of artifacts associated with the specified version. Therefore, if multiple artifacts exist in the same region, it will only pick one of them. In this case, you can filter artifacts by a source build name (Ex: `amazon-ebs.example`) using the `component_type` optional argument. | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `bucket_name` (String) The name of the HCP Packer Bucket where the Artifact is located. | ||
- `platform` (String) Name of the platform where the HCP Packer Artifact is stored. (i.e. aws, gce, azure) | ||
- `region` (String) The Region where the HCP Packer Artifact is stored, if any. | ||
|
||
### Optional | ||
|
||
- `channel_name` (String) The name of the HCP Packer Channel the Version containing this Artifact is assigned to. | ||
The Version currently assigned to the Channel will be fetched. | ||
Exactly one of `channel_name` or `version_fingerprint` must be provided. | ||
- `component_type` (String) Name of the Packer builder that built this Artifact. Ex: `amazon-ebs.example`. | ||
- `project_id` (String) The ID of the HCP Organization where the Artifact is located | ||
- `version_fingerprint` (String) The fingerprint of the HCP Packer Version where the Artifact is located. | ||
If provided in the config, it is used to fetch the Version. | ||
Exactly one of `channel_name` or `version_fingerprint` must be provided. | ||
|
||
### Read-Only | ||
|
||
- `build_id` (String) The ULID of the HCP Packer Build where the Artifact is located. | ||
- `created_at` (String) The creation time of this HCP Packer Artifact. | ||
- `external_identifier` (String) An external identifier for the HCP Packer Artifact. | ||
- `id` (String) The ULID of the HCP Packer Artifact. | ||
- `labels` (Map of String) Labels associated with the build containing this image. | ||
- `organization_id` (String) The ID of the HCP Organization where the Artifact is located | ||
- `packer_run_uuid` (String) The UUID of the build containing this image. | ||
- `revoke_at` (String) The revocation time of the HCP Packer Version containing this Artifact. This field will be null for any Version that has not been revoked or scheduled for revocation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
page_title: "hcp_packer_version Data Source - terraform-provider-hcp" | ||
subcategory: "HCP Packer" | ||
description: |- | ||
The HCP Packer Version data source retrieves information about a Version. | ||
--- | ||
|
||
# hcp_packer_version (Data Source) | ||
|
||
The HCP Packer Version data source retrieves information about a Version. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "hcp_packer_version" "hardened-source" { | ||
bucket_name = "hardened-ubuntu-16-04" | ||
channel_name = "dev" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `bucket_name` (String) The name of the HCP Packer Bucket where the Version is located | ||
- `channel_name` (String) The name of the HCP Packer Channel the Version is assigned to. | ||
The version currently assigned to the Channel will be fetched. | ||
|
||
### Optional | ||
|
||
- `project_id` (String) The ID of the HCP Organization where the Version is located | ||
|
||
### Read-Only | ||
|
||
- `author_id` (String) The name of the person who created this HCP Packer Version | ||
- `created_at` (String) The creation time of this HCP Packer Version | ||
- `fingerprint` (String) The fingerprint of the HCP Packer Version | ||
- `id` (String) The ULID of the HCP Packer Version | ||
- `name` (String) The name of the HCP Packer Version | ||
- `organization_id` (String) The ID of the HCP Organization where the Version is located | ||
- `revoke_at` (String) The revocation time of this HCP Packer Version. This field will be null for any Version that has not been revoked or scheduled for revocation | ||
- `updated_at` (String) The last time this HCP Packer Version was updated |
10 changes: 10 additions & 0 deletions
10
examples/data-sources/hcp_packer_artifact/data-source-alt.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
data "hcp_packer_artifact" "ubuntu-east" { | ||
bucket_name = "hardened-ubuntu-16-04" | ||
channel_name = "production" | ||
platform = "aws" | ||
region = "us-east-1" | ||
} | ||
|
||
output "packer-registry-ubuntu-east-1" { | ||
value = data.hcp_packer_artifact.ubuntu-east.external_identifier | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
data "hcp_packer_version" "hardened-source" { | ||
bucket_name = "hardened-ubuntu-16-04" | ||
channel_name = "production" | ||
} | ||
|
||
data "hcp_packer_artifact" "ubuntu-east" { | ||
bucket_name = "hardened-ubuntu-16-04" | ||
version_fingerprint = data.hcp_packer_version.hardened-source.fingerprint | ||
platform = "aws" | ||
region = "us-east-1" | ||
} | ||
|
||
data "hcp_packer_artifact" "ubuntu-west" { | ||
bucket_name = "hardened-ubuntu-16-04" | ||
version_fingerprint = data.hcp_packer_version.hardened-source.fingerprint | ||
platform = "aws" | ||
region = "us-west-1" | ||
} | ||
|
||
output "packer-registry-ubuntu-east-1" { | ||
value = data.hcp_packer_artifact.ubuntu-east.external_identifier | ||
} | ||
|
||
output "packer-registry-ubuntu-west-1" { | ||
value = data.hcp_packer_artifact.ubuntu-west.external_identifier | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
examples/data-sources/hcp_packer_image_iteration/data-source.tf
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
data "hcp_packer_version" "hardened-source" { | ||
bucket_name = "hardened-ubuntu-16-04" | ||
channel_name = "dev" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,35 @@ module github.com/hashicorp/terraform-provider-hcp | |
|
||
go 1.21 | ||
|
||
// TODO: FOR_EXTERNAL: Remove this replace directive once the HCP Packer v2 API is | ||
// in the public SDK. Look for other `TODO: FOR_EXTERNAL:` comments in the code | ||
// for a non-exhaustive list of other places that need to be updated for some | ||
// reason. | ||
// | ||
// This replace directive assumes that this `terraform-provider-hcp` directory | ||
// is a sibling of the `hcp-sdk-go` directory, containing your local clone of | ||
// the HCP SDK. If you have the SDK cloned elsewhere, you'll need to adjust it | ||
// to be in this location for the other import changes to work, or update those | ||
// as well. Ideally, both packages will be located in `~/go/src/github.com/hashicorp/` | ||
// as `~/go/src/github.com/hashicorp/hcp-sdk-go` and `~/go/src/github.com/hashicorp/terraform-provider-hcp`. | ||
// | ||
// If you are using a branch from the `hcp-sdk-go-internal` repo, you'll need | ||
// to add it as another remote of `hcp-sdk-go` in `~/go/src/github.com/hashicorp/hcp-sdk-go` | ||
// and then checkout the branch/commit you want to use. | ||
// For example: | ||
// ``` | ||
// cd ~/go/src/github.com/hashicorp/hcp-sdk-go | ||
// git remote add internal [email protected]:hashicorp/hcp-sdk-go-internal.git | ||
// git fetch --all | ||
// git checkout internal/main | ||
// ``` | ||
// Just be careful not to leak the internal repo history to the public repo as | ||
// the `hcp-sdk-go-internal` repo git tree is not the same as the `hcp-sdk-go` | ||
// repo git tree, but some branches on `hcp-sdk-go-internal` may have been | ||
// branched from `hcp-sdk-go` branches instead. You might want to check the | ||
// commit history to see which remote your branch is based on. | ||
replace github.com/hashicorp/hcp-sdk-go => ../hcp-sdk-go-internal | ||
|
||
require ( | ||
github.com/cenkalti/backoff v2.2.1+incompatible | ||
github.com/go-openapi/runtime v0.26.2 | ||
|
@@ -78,7 +107,7 @@ require ( | |
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/mitchellh/reflectwalk v1.0.2 // indirect | ||
github.com/oklog/run v1.1.0 // indirect | ||
github.com/oklog/ulid v1.3.1 // indirect | ||
github.com/oklog/ulid v1.3.1 | ||
github.com/opentracing/opentracing-go v1.2.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | ||
github.com/posener/complete v1.2.3 // indirect | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.