Skip to content

Files

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Latest commit

416226e · Nov 2, 2023

History

History
72 lines (54 loc) · 2 KB
·

project_iam_policy.md

File metadata and controls

72 lines (54 loc) · 2 KB
·
page_title subcategory description
Resource hcp_project_iam_policy - terraform-provider-hcp
Cloud Platform
Sets the project's IAM policy and replaces any existing policy.

hcp_project_iam_policy (Resource)

!> Be Careful! You can accidentally lock yourself out of your project using this resource. Deleting a hcp_project_iam_policy removes access from anyone without organization-level access to the project. It is not recommended to use hcp_project_iam_policy with your provider project to avoid locking yourself out, and it should generally only be used with projects fully managed by Terraform. If you are trying to additively give permissions to the project, prefer using hcp_project_iam_binding. If you do use this resource, it is recommended to import the policy before applying the change.

Sets the project's IAM policy and replaces any existing policy.

~> Note: hcp_project_iam_policy can not be used in conjunction with hcp_project_iam_binding.

Example Usage

data "hcp_iam_policy" "example" {
  bindings = [
    {
      role = "roles/contributor"
      principals = [
        "example-user-id-1",
        "example-group-id-1",
        "example-sp-1"
      ]
    },
  ]
}

resource "hcp_project" "my_project" {
  name = "example"
}

resource "hcp_project_iam_policy" "project_policy" {
  project_id  = hcp_project.my_project.resource_id
  policy_data = data.hcp_iam_policy.example.policy_data
}

Schema

Required

  • policy_data (String) The policy to apply.

Optional

  • project_id (String) The ID of the HCP project to apply the IAM Policy to. If unspecified, the project configured on the provider is used.

Read-Only

  • etag (String) The etag captures the existing state of the policy.

Import

Import is supported using the following syntax:

# Project IAM Policy can be imported by specifying the project id
terraform import hcp_project_iam_policy.example 840e3701-55b6-4f86-8c17-b1fe397303c5