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.
[Do not merge] Add
hcp_packer_bucket
, `hcp_packer_bucket_iam_bindin…
- Loading branch information
1 parent
a99d1a0
commit d3ec11f
Showing
25 changed files
with
989 additions
and
3 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,5 @@ | ||
```release-note:feature | ||
New resource: Add `hcp_packer_bucket` resource for managing HCP Packer buckets | ||
New Resource: Add `hcp_packer_bucket_iam_policy` resource for assigning a list of policy bindings to multiple principals for a HCP Packer Bucket | ||
New resource: Add `hcp_packer_bucket_iam_binding` resource for assigning a single role to a principal for a HCP Packer Bucket | ||
``` |
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,55 @@ | ||
--- | ||
subcategory: "" | ||
page_title: "Managing HCP Packer Bucket IAM Policies" | ||
description: |- | ||
A guide to using HCP Packer bucket resource along with binding or policy resource to manage bucket level access. | ||
--- | ||
|
||
# Managing HCP Packer Bucket IAM Policies | ||
|
||
You can grant specific users, service principals, or groups contributor or admin level access to a specific HCP Packer bucket using either a `hcp_packer_bucket_iam_binding` or `hcp_packer_bucket_iam_policy` resource. Whenever a user is invited to a project they will have read level access to all resources, but you can restrict which of the principals in your project can maintain specific buckets. | ||
|
||
A resource's policy is a list of bindings to assign roles to multiple users, groups, or service principals. The `hcp_packer_bucket_iam_policy` resource sets the Bucket IAM policy and replaces any existing policy. | ||
|
||
The following example assigns the role `contributor` to a user principal and a service principal for the `production` bucket. | ||
|
||
```terraform | ||
data "hcp_iam_policy" "mypolicy" { | ||
bindings = [ | ||
{ | ||
role = "roles/contributor" | ||
principals = [ | ||
"user-principal-id-1", | ||
"service-principal-id-1", | ||
] | ||
}, | ||
] | ||
} | ||
resource "hcp_packer_bucket" "production" { | ||
name = "production" | ||
} | ||
resource "hcp_packer_bucket_iam_policy" "example" { | ||
resource_name = hcp_packer_bucket.production.resource_name | ||
policy_data = data.hcp_iam_policy.mypolicy.policy_data | ||
} | ||
``` | ||
|
||
The following example assigns role contriubtor for a service principal to the production bucket, and also preserves existing bindings. | ||
|
||
```terraform | ||
resource "hcp_service_principal" "my-sp" { | ||
name = "my-sp" | ||
} | ||
resource "hcp_packer_bucket" "production" { | ||
name = "production" | ||
} | ||
resource "hcp_packer_bucket_iam_binding" "example" { | ||
resource_name = hcp_packer_bucket.production.resource_name | ||
principal_id = hcp_service_principal.my-sp.resource_id | ||
role = "roles/contributor" | ||
} | ||
``` |
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,46 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "hcp_packer_bucket Resource - terraform-provider-hcp" | ||
subcategory: "" | ||
description: |- | ||
The Packer Bucket resource allows you to manage a bucket within an active HCP Packer Registry. | ||
--- | ||
|
||
# hcp_packer_bucket (Resource) | ||
|
||
The Packer Bucket resource allows you to manage a bucket within an active HCP Packer Registry. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "hcp_packer_bucket" "staging" { | ||
name = "alpine" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) The bucket's name. | ||
|
||
### Optional | ||
|
||
- `project_id` (String) The ID of the project to create the bucket under. If unspecified, the bucket will be created in the project the provider is configured with. | ||
|
||
### Read-Only | ||
|
||
- `created_at` (String) The creation time of this bucket | ||
- `organization_id` (String) The ID of the HCP organization where this bucket is located. | ||
- `resource_name` (String) The buckets's HCP resource name in the format `packer/project/<project_id>/packer/<name>`. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# Using a HCP Packer Bucket Resource Name | ||
# packer/project/{project_id}/bucket/{bucket_name} | ||
terraform import hcp_packer_bucket.alpine packer/project/f709ec73-55d4-46d8-897d-816ebba28778/bucket/alpine | ||
``` |
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,38 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "hcp_packer_bucket_iam_binding Resource - terraform-provider-hcp" | ||
subcategory: "" | ||
description: |- | ||
Updates the HCP Packer Bucket IAM policy to bind a role to a new member. Existing bindings are preserved. | ||
--- | ||
|
||
# hcp_packer_bucket_iam_binding (Resource) | ||
|
||
Updates the HCP Packer Bucket IAM policy to bind a role to a new member. Existing bindings are preserved. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "hcp_service_principal" "my-sp" { | ||
name = "my-sp" | ||
} | ||
resource "hcp_packer_bucket" "production" { | ||
name = "production" | ||
} | ||
resource "hcp_packer_bucket_iam_binding" "example" { | ||
resource_name = hcp_packer_bucket.production.resource_name | ||
principal_id = hcp_service_principal.my-sp.resource_id | ||
role = "roles/contributor" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `principal_id` (String) The principal to bind to the given role. | ||
- `resource_name` (String) The bucket's resource name in the format packer/project/<project ID>/bucket/<bucket name>. | ||
- `role` (String) The role name to bind to the given principal. |
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,58 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "hcp_packer_bucket_iam_policy Resource - terraform-provider-hcp" | ||
subcategory: "" | ||
description: |- | ||
Sets the HCP Packer Bucket IAM policy and replaces any existing policy. | ||
--- | ||
|
||
# hcp_packer_bucket_iam_policy (Resource) | ||
|
||
Sets the HCP Packer Bucket IAM policy and replaces any existing policy. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "hcp_iam_policy" "mypolicy" { | ||
bindings = [ | ||
{ | ||
role = "roles/contributor" | ||
principals = [ | ||
"user-principal-id-1", | ||
"service-principal-id-1", | ||
] | ||
}, | ||
] | ||
} | ||
resource "hcp_packer_bucket" "production" { | ||
name = "production" | ||
} | ||
resource "hcp_packer_bucket_iam_policy" "example" { | ||
resource_name = hcp_packer_bucket.production.resource_name | ||
policy_data = data.hcp_iam_policy.mypolicy.policy_data | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `policy_data` (String) The policy to apply. | ||
- `resource_name` (String) The bucket's resource name in the format packer/project/<project ID>/bucket/<bucket name>. | ||
|
||
### Read-Only | ||
|
||
- `etag` (String) The etag captures the existing state of the policy. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# Using a HCP Packer Bucket Resource Name | ||
# packer/project/{project_id}/bucket/{bucket_name} | ||
terraform import hcp_packer_bucket.alpine packer/project/f709ec73-55d4-46d8-897d-816ebba28778/bucket/alpine | ||
``` |
13 changes: 13 additions & 0 deletions
13
examples/guides/packer_bucket_rbac/iam_binding_resource.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,13 @@ | ||
resource "hcp_service_principal" "my-sp" { | ||
name = "my-sp" | ||
} | ||
|
||
resource "hcp_packer_bucket" "production" { | ||
name = "production" | ||
} | ||
|
||
resource "hcp_packer_bucket_iam_binding" "example" { | ||
resource_name = hcp_packer_bucket.production.resource_name | ||
principal_id = hcp_service_principal.my-sp.resource_id | ||
role = "roles/contributor" | ||
} |
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,20 @@ | ||
data "hcp_iam_policy" "mypolicy" { | ||
bindings = [ | ||
{ | ||
role = "roles/contributor" | ||
principals = [ | ||
"user-principal-id-1", | ||
"service-principal-id-1", | ||
] | ||
}, | ||
] | ||
} | ||
|
||
resource "hcp_packer_bucket" "production" { | ||
name = "production" | ||
} | ||
|
||
resource "hcp_packer_bucket_iam_policy" "example" { | ||
resource_name = hcp_packer_bucket.production.resource_name | ||
policy_data = data.hcp_iam_policy.mypolicy.policy_data | ||
} |
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 @@ | ||
# Using a HCP Packer Bucket Resource Name | ||
# packer/project/{project_id}/bucket/{bucket_name} | ||
terraform import hcp_packer_bucket.alpine packer/project/f709ec73-55d4-46d8-897d-816ebba28778/bucket/alpine | ||
|
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,3 @@ | ||
resource "hcp_packer_bucket" "staging" { | ||
name = "alpine" | ||
} |
13 changes: 13 additions & 0 deletions
13
examples/resources/hcp_packer_bucket_iam_binding/resource.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,13 @@ | ||
resource "hcp_service_principal" "my-sp" { | ||
name = "my-sp" | ||
} | ||
|
||
resource "hcp_packer_bucket" "production" { | ||
name = "production" | ||
} | ||
|
||
resource "hcp_packer_bucket_iam_binding" "example" { | ||
resource_name = hcp_packer_bucket.production.resource_name | ||
principal_id = hcp_service_principal.my-sp.resource_id | ||
role = "roles/contributor" | ||
} |
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 @@ | ||
# Using a HCP Packer Bucket Resource Name | ||
# packer/project/{project_id}/bucket/{bucket_name} | ||
terraform import hcp_packer_bucket.alpine packer/project/f709ec73-55d4-46d8-897d-816ebba28778/bucket/alpine | ||
|
20 changes: 20 additions & 0 deletions
20
examples/resources/hcp_packer_bucket_iam_policy/resource.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,20 @@ | ||
data "hcp_iam_policy" "mypolicy" { | ||
bindings = [ | ||
{ | ||
role = "roles/contributor" | ||
principals = [ | ||
"user-principal-id-1", | ||
"service-principal-id-1", | ||
] | ||
}, | ||
] | ||
} | ||
|
||
resource "hcp_packer_bucket" "production" { | ||
name = "production" | ||
} | ||
|
||
resource "hcp_packer_bucket_iam_policy" "example" { | ||
resource_name = hcp_packer_bucket.production.resource_name | ||
policy_data = data.hcp_iam_policy.mypolicy.policy_data | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.