Skip to content

Commit

Permalink
Merge pull request #111 from hashicorp/sync-public-and-internal-provider
Browse files Browse the repository at this point in the history
[auto] Sync with Public Provider
  • Loading branch information
aidan-mundy authored Jun 29, 2023
2 parents 7b517a0 + 8c66aad commit 73a8ff6
Show file tree
Hide file tree
Showing 34 changed files with 2,125 additions and 818 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## v0.63.0 (June 29, 2023)

FEATURES:

* Adds `hcp_packer_channel_assignment` resource. [[GH-531](https://github.com/hashicorp/terraform-provider-hcp/pull/531)]

IMPROVEMENTS:

* Adds read-only `restricted` field to `hcp_packer_channel` resource. [[GH-531](https://github.com/hashicorp/terraform-provider-hcp/pull/531)]

DEPRECATIONS:

* Setting the `iteration` block on `hcp_packer_channel` is now deprecated in
favor of `hcp_packer_channel_assignment`. [[GH-531](https://github.com/hashicorp/terraform-provider-hcp/pull/531)]
## v0.62.0 (June 23, 2023)

IMPROVEMENTS:
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/packer_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ output "packer-registry-ubuntu-west-1" {

### Required

- `bucket_name` (String) The slug of the HCP Packer Registry image bucket to pull from.
- `bucket_name` (String) The slug of the HCP Packer Registry bucket to pull from.
- `cloud_provider` (String) Name of the cloud provider this image is stored-in.
- `region` (String) Region this image is stored in, if any.

Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/packer_image_iteration.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ data "hcp_packer_image_iteration" "alpine" {

### Required

- `bucket_name` (String) The slug of the HCP Packer Registry image bucket to pull from.
- `bucket_name` (String) The slug of the HCP Packer Registry bucket to pull from.
- `channel` (String) The channel that points to the version of the image you want.

### Optional
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/packer_iteration.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data "hcp_packer_iteration" "hardened-source" {

### Required

- `bucket_name` (String) The slug of the HCP Packer Registry image bucket to pull from.
- `bucket_name` (String) The slug of the HCP Packer Registry bucket to pull from.
- `channel` (String) The channel that points to the version of the image you want.

### Optional
Expand Down
51 changes: 51 additions & 0 deletions docs/guides/packer-channel-management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
subcategory: ""
page_title: "Advanced Packer Channel Management - HCP Provider"
description: |-
A guide to integreting HCP Packer resources and data sources for more advanced channel management.
---

# Advanced Packer Channel Management

You can integrate multiple HCP Packer resources and data sources to perform advanced channel management tasks.

## Setting the channel assignment on a Terraform-managed channel

```terraform
resource "hcp_packer_channel" "advanced" {
name = "advanced"
bucket_name = "alpine"
}
resource "hcp_packer_channel_assignment" "advanced" {
bucket_name = hcp_packer_channel.advanced.bucket_name
channel_name = hcp_packer_channel.advanced.name
# Exactly one of version, id, or fingerprint must be set:
iteration_version = 12
# iteration_id = "01H1SF9NWAK8AP25PAWDBGZ1YD"
# iteration_fingerprint = "01H1ZMW0Q2W6FT4FK27FQJCFG7"
}
```

## Setting the channel assignment to the latest complete iteration

```terraform
data "hcp_packer_iteration" "alpine_latest" {
bucket_name = "alpine"
channel = "latest"
}
resource "hcp_packer_channel" "alpine_advanced" {
name = "advanced"
bucket_name = data.hcp_packer_iteration.alpine_latest.bucket_name
}
resource "hcp_packer_channel_assignment" "alpine_advanced" {
bucket_name = hcp_packer_channel.alpine_advanced.bucket_name
channel_name = hcp_packer_channel.alpine_advanced.name
iteration_version = data.hcp_packer_iteration.alpine_latest.incremental_version
}
```

2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ terraform {
required_providers {
hcp = {
source = "hashicorp/hcp"
version = "~> 0.62.0"
version = "~> 0.63.0"
}
}
}
Expand Down
61 changes: 9 additions & 52 deletions docs/resources/packer_channel.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,36 @@
---
page_title: "Resource hcp_packer_channel - terraform-provider-hcp"
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "hcp_packer_channel Resource - terraform-provider-hcp"
subcategory: ""
description: |-
The Packer Channel resource allows you to manage image bucket channels within an active HCP Packer Registry.
The Packer Channel resource allows you to manage a bucket channel within an active HCP Packer Registry.
---

# hcp_packer_channel (Resource)

The Packer Channel resource allows you to manage image bucket channels within an active HCP Packer Registry.
The Packer Channel resource allows you to manage a bucket channel within an active HCP Packer Registry.

## Example Usage

To create a channel.
```terraform
resource "hcp_packer_channel" "staging" {
name = "staging"
bucket_name = "alpine"
}
```

To create a channel with iteration assignment managed by Terraform.
```terraform
resource "hcp_packer_channel" "staging" {
name = "staging"
bucket_name = "alpine"
iteration {
# Exactly one of `id`, `fingerprint` or `incremental_version` must be passed
id = "01H1SF9NWAK8AP25PAWDBGZ1YD"
# fingerprint = "01H1ZMW0Q2W6FT4FK27FQJCFG7"
# incremental_version = 1
}
}
# To configure a channel to have no assigned iteration, use a "zero value".
# The zero value for `id` and `fingerprint` is `""`; for `incremental_version`, it is `0`
resource "hcp_packer_channel" "staging" {
name = "staging"
bucket_name = "alpine"
iteration {
# Exactly one of `id`, `fingerprint` or `incremental_version` must be passed
id = ""
# fingerprint = ""
# incremental_version = 0
}
}
```

Using the latest channel to create a new channel with the latest complete iteration assigned.
```terraform
data "hcp_packer_image_iteration" "latest" {
bucket_name = "alpine"
channel = "latest"
}
resource "hcp_packer_channel" "staging" {
name = staging
bucket_name = alpine
iteration {
id = data.hcp_packer_image_iteration.latest.id
}
}
```


<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `bucket_name` (String) The slug of the HCP Packer Registry image bucket where the channel should be created in.
- `bucket_name` (String) The slug of the HCP Packer Registry bucket where the channel should be created.
- `name` (String) The name of the channel being managed.

### Optional

- `iteration` (Block List, Max: 1) The iteration assigned to the channel. (see [below for nested schema](#nestedblock--iteration))
- `project_id` (String) The ID of the HCP project where this channel is located in.
- `iteration` (Block List, Max: 1, Deprecated) The iteration assigned to the channel. This block is deprecated. Please use `hcp_packer_channel_assignment` instead. (see [below for nested schema](#nestedblock--iteration))
- `project_id` (String) The ID of the HCP project where this channel is located.
If not specified, the project specified in the HCP Provider config block will be used, if configured.
If a project is not configured in the HCP Provider config block, the oldest project in the organization will be used.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
Expand All @@ -84,7 +40,8 @@ If a project is not configured in the HCP Provider config block, the oldest proj
- `author_id` (String) The author of this channel.
- `created_at` (String) The creation time of this channel.
- `id` (String) The ID of this resource.
- `organization_id` (String) The ID of the HCP organization where this channel is located in.
- `organization_id` (String) The ID of the HCP organization where this channel is located.
- `restricted` (Boolean) If true, the channel is only visible to users with permission to create and manage it. Otherwise the channel is visible to every member of the organization.
- `updated_at` (String) The time this channel was last updated.

<a id="nestedblock--iteration"></a>
Expand Down
82 changes: 82 additions & 0 deletions docs/resources/packer_channel_assignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "hcp_packer_channel_assignment Resource - terraform-provider-hcp"
subcategory: ""
description: |-
The Packer Channel Assignment resource allows you to manage the iteration assigned to a bucket channel in an active HCP Packer Registry.
---

# hcp_packer_channel_assignment (Resource)

The Packer Channel Assignment resource allows you to manage the iteration assigned to a bucket channel in an active HCP Packer Registry.

## Example Usage

```terraform
resource "hcp_packer_channel_assignment" "staging" {
bucket_name = "alpine"
channel_name = "staging"
# Exactly one of version, id, or fingerprint must be set:
iteration_version = 12
# iteration_id = "01H1SF9NWAK8AP25PAWDBGZ1YD"
# iteration_fingerprint = "01H1ZMW0Q2W6FT4FK27FQJCFG7"
}
# To set the channel to have no assignment, use one of the iteration attributes with their zero value.
# The two string-typed iteration attributes, id and fingerprint, use "none" as their zero value.
resource "hcp_packer_channel_assignment" "staging" {
bucket_name = "alpine"
channel_name = "staging"
iteration_version = 0
# iteration_id = "none"
# iteration_fingerprint = "none"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `bucket_name` (String) The slug of the HCP Packer Registry bucket where the channel is located.
- `channel_name` (String) The name of the HCP Packer channel being managed.

### Optional

- `iteration_fingerprint` (String) The fingerprint of the iteration assigned to the channel.
- `iteration_id` (String) The ID of the iteration assigned to the channel.
- `iteration_version` (Number) The incremental version of the iteration assigned to the channel.
- `project_id` (String) The ID of the HCP project where the channel is located.
If not specified, the project specified in the HCP Provider config block will be used, if configured.
If a project is not configured in the HCP Provider config block, the oldest project in the organization will be used.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-Only

- `id` (String) The ID of this resource.
- `organization_id` (String) The ID of the HCP organization where this channel is located. Always the same as the associated channel.

<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- `create` (String)
- `default` (String)
- `delete` (String)
- `update` (String)

## Import

Import is supported using the following syntax:

```shell
# Using an explicit project ID, the import ID is:
# {project_id}:{bucket_name}:{channel_name}
terraform import hcp_packer_channel_assignment.staging f709ec73-55d4-46d8-897d-816ebba28778:alpine:staging
# Using the provider-default project ID, the import ID is:
# {bucket_name}:{channel_name}
terraform import hcp_packer_channel_assignment.staging alpine:staging
```
16 changes: 16 additions & 0 deletions examples/guides/packer_channel_management/assign_latest.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
data "hcp_packer_iteration" "alpine_latest" {
bucket_name = "alpine"
channel = "latest"
}

resource "hcp_packer_channel" "alpine_advanced" {
name = "advanced"
bucket_name = data.hcp_packer_iteration.alpine_latest.bucket_name
}

resource "hcp_packer_channel_assignment" "alpine_advanced" {
bucket_name = hcp_packer_channel.alpine_advanced.bucket_name
channel_name = hcp_packer_channel.alpine_advanced.name

iteration_version = data.hcp_packer_iteration.alpine_latest.incremental_version
}
14 changes: 14 additions & 0 deletions examples/guides/packer_channel_management/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resource "hcp_packer_channel" "advanced" {
name = "advanced"
bucket_name = "alpine"
}

resource "hcp_packer_channel_assignment" "advanced" {
bucket_name = hcp_packer_channel.advanced.bucket_name
channel_name = hcp_packer_channel.advanced.name

# Exactly one of version, id, or fingerprint must be set:
iteration_version = 12
# iteration_id = "01H1SF9NWAK8AP25PAWDBGZ1YD"
# iteration_fingerprint = "01H1ZMW0Q2W6FT4FK27FQJCFG7"
}
2 changes: 1 addition & 1 deletion examples/provider/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ terraform {
required_providers {
hcp = {
source = "hashicorp/hcp"
version = "~> 0.62.0"
version = "~> 0.63.0"
}
}
}
Expand Down
23 changes: 0 additions & 23 deletions examples/resources/hcp_packer_channel/resource_assignment.tf

This file was deleted.

This file was deleted.

6 changes: 6 additions & 0 deletions examples/resources/hcp_packer_channel_assignment/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Using an explicit project ID, the import ID is:
# {project_id}:{bucket_name}:{channel_name}
terraform import hcp_packer_channel_assignment.staging f709ec73-55d4-46d8-897d-816ebba28778:alpine:staging
# Using the provider-default project ID, the import ID is:
# {bucket_name}:{channel_name}
terraform import hcp_packer_channel_assignment.staging alpine:staging
20 changes: 20 additions & 0 deletions examples/resources/hcp_packer_channel_assignment/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resource "hcp_packer_channel_assignment" "staging" {
bucket_name = "alpine"
channel_name = "staging"

# Exactly one of version, id, or fingerprint must be set:
iteration_version = 12
# iteration_id = "01H1SF9NWAK8AP25PAWDBGZ1YD"
# iteration_fingerprint = "01H1ZMW0Q2W6FT4FK27FQJCFG7"
}

# To set the channel to have no assignment, use one of the iteration attributes with their zero value.
# The two string-typed iteration attributes, id and fingerprint, use "none" as their zero value.
resource "hcp_packer_channel_assignment" "staging" {
bucket_name = "alpine"
channel_name = "staging"

iteration_version = 0
# iteration_id = "none"
# iteration_fingerprint = "none"
}
Loading

0 comments on commit 73a8ff6

Please sign in to comment.