hcp_service_principal_key (Resource)

The service principal key resource manages a service principal key.

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

Example Usage: Creating a new key

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

resource "hcp_service_principal_key" "key" {
  service_principal = hcp_service_principal.example.resource_name
}

Example Usage: Creating and regularly rotating a key

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

# Note this requires the Terraform to be run regularly
resource "time_rotating" "key_rotation" {
  rotation_days = 14
}

resource "hcp_service_principal_key" "key" {
  service_principal = hcp_service_principal.example.resource_name
  rotation_triggers {
    rotation_time = time_rotating.key_rotation.rotation_rfc3339
  }
}

Schema

Required

Optional

Read-Only