tharsis_managed_identity
Defines and manages a managed identity.
Example Usage​
resource "tharsis_managed_identity" "aws" {
name = "my-aws-identity"
description = "Federated AWS identity."
type = "aws_federated"
group_id = tharsis_group.top_level.id
aws_role = "arn:aws:iam::123456789012:role/my-role"
}
# Azure and Tharsis identities use their own attributes instead of aws_role:
#
# resource "tharsis_managed_identity" "azure" {
# name = "my-azure-identity"
# type = "azure_federated"
# group_id = tharsis_group.top_level.id
# azure_client_id = "<client_id>"
# azure_tenant_id = "<tenant_id>"
# }
#
# resource "tharsis_managed_identity" "tharsis" {
# name = "my-tharsis-identity"
# type = "tharsis_federated"
# group_id = tharsis_group.top_level.id
# tharsis_service_account_path = "my-group/my-service-account"
# }
# A kubernetes_federated managed identity, used to give a Tharsis run short-lived
# access to a Kubernetes cluster. The audience must match the client_id on the
# cluster's OIDC identity provider configuration.
resource "tharsis_managed_identity" "kubernetes" {
type = "kubernetes_federated"
name = "eks-cluster-access"
description = "Gives each run short-lived access to the EKS cluster."
group_id = tharsis_group.top_level.id
audience = "my-cluster"
}
Behavior​
- A managed identity assumes cloud provider credentials through OIDC federation, so no credentials are stored.
- The
typedetermines which other attributes are required:aws_federatedrequiresaws_role.azure_federatedrequiresazure_client_idandazure_tenant_id.tharsis_federatedrequirestharsis_service_account_path.kubernetes_federatedrequiresaudience.
- A managed identity is created in a group and inherited by its child groups. Inheritance does not assign it: each workspace must be assigned the identity, for example with
tharsis_assigned_managed_identity. - By default, anyone with deployer access to the identity can assume it. Use
tharsis_managed_identity_access_ruleto restrict this. - A name cannot be changed after creation. Only the description and provider configuration can be edited.
Permissions​
Only the owner role can create, update, or delete managed identities.
Schema​
Required​
name(String) The name of the managed identity.type(String) Type of managed identity: aws_federated, azure_federated, tharsis_federated, or kubernetes_federated.
Optional​
audience(String) Audience for a kubernetes_federated managed identity. Must match the client_id on the cluster's OIDC identity provider configuration.aws_role(String) AWS roleazure_client_id(String) Azure client IDazure_tenant_id(String) Azure tenant IDdescription(String) A description of the managed identity.group_id(String) The ID or TRN of the parent group.group_path(String, Deprecated) Full path of the parent group.tharsis_service_account_path(String) Tharsis service account path
Read-Only​
id(String) String identifier of the managed identity.last_updated(String) Timestamp when this managed identity was most recently updated by Terraform.resource_path(String, Deprecated) The path of the parent group plus the name of the managed identity.subject(String) subject string for AWS, Azure, and Tharsis
Import​
Import is supported using the following syntax:
In Terraform v1.5.0 and later, the import block can be used with the id attribute, for example:
# A managed identity can be imported by its TRN, which is "trn:managed_identity:"
# followed by the group path and the identity name.
import {
to = tharsis_managed_identity.aws
id = "trn:managed_identity:my-group/my-aws-identity"
}
# The identity's ID also works as the id, shown by the "id" attribute or in the
# Tharsis UI.