AWS Dynamic Provider Credentials
Requirements
The dynamic provider credential setup in AWS can be done with the Terrraform code available in the following link:
https://github.com/terrakube-io/terrakube/tree/main/dynamic-credential-setup/aws
Make sure to mount your public and private key to the API container as explained here
Validate the following terrakube api endpoints are working:
Set terraform variables using: "variables.auto.tfvars"
terrakube_token = "TERRAKUBE_PERSONAL_ACCESS_TOKEN"
terrakube_api_hostname = "TERRAKUBE-API.MYCLUSTER.COM"
terrakube_federated_credentials_audience="aws.workload.identity"
terrakube_organization_name="simple"
terrakube_workspace_name = "dynamic-workspace-aws"
aws_region = "us-east-1"Run Terraform apply to create all the federated credential setup in AWS and a sample workspace in terrakube for testing
To test the following terraform code can be used:


Session tags (ABAC)
The AWS web identity token Terrakube issues can also carry AWS session tags, so IAM roles can be scoped with aws:PrincipalTag (attribute-based access control) instead of creating one role per workspace.
Session tags are opt-in: set the workspace environment variable ENABLE_AWS_SESSION_TAGS to true to enable them. This requires sts:TagSession in the role's trust policy — without it, AssumeRoleWithWebIdentity fails. Workspaces that don't set this variable are unaffected.
Three tags are sent as transitive principal tags:
terrakube:org
Organization name
terrakube:workspace
Workspace name
terrakube:project
Project name (only set when the workspace belongs to a project)
The role trust policy needs two additions: allow sts:TagSession alongside sts:AssumeRoleWithWebIdentity, and restrict accepted tag keys with a ForAllValues:StringEquals condition on aws:TagKeys so Terrakube can't set any tag key beyond the ones you expect:
Session tags let the role's permissions scope access to the calling workspace, for example restricting an S3 prefix to its name:
You can further restrict accepted tag values (not just keys) with aws:RequestTag/<key> in the trust policy, to pin a role to a specific organization or workspace.
Workspace trust boundary
The 2.34.0 setup example trusts the exact workspace subject using StringEquals. Use your organization and workspace names in the example above. An organization-wide workspace:* pattern requires StringLike and intentionally lets any matching workspace assume the role; choose it only when that broader trust is required.
Upgrading Terrakube does not update existing IAM trust policies. Review roles created with earlier setup examples and apply the narrower trust policy yourself.
Last updated
Was this helpful?