hcp_service_principal (Resource)

The service principal resource manages a HCP Service Principal.

The user or service account that is running Terraform when creating a hcp_service_principal resource must have roles/admin on the parent resource; either the project or organization.

Example Usage: Create in provider configured project

resource "hcp_service_principal" "example" {
  name = "example-sp"
}

Example Usage: Create in new project

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

resource "hcp_service_principal" "example" {
  name   = "example-sp"
  parent = hcp_project.my_proj.resource_name
}

Example Usage: Create organization service principal

data "hcp_organization" "my_org" {
}

resource "hcp_service_principal" "example" {
  name   = "example-sp"
  parent = data.hcp_organization.my_org.resource_name
}

Schema

Required

Optional

Read-Only

Import

Import is supported using the following syntax:

# Service Principals can be imported by specifying the resource name
terraform import hcp_service_principal.example iam/project/840e3701-55b6-4f86-8c17-b1fe397303c5/service-principal/my-sp