liveBook · Manning

Identity provider

As explained in Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu

An identity provider is a system that authenticates identities and issues identity assertions or tokens to relying systems.

An identity provider (IdP) lets a platform such as GitHub Actions or Spacelift prove its identity to a vendor or cloud account. Registering the provider establishes authentication; it does not yet grant permissions. section 8.5.1

OpenID Connect uses a provider URL and identity token to identify a user or machine. Authorization follows separately: AWS maps the identity to an assumable IAM role, while Azure maps it to a service principal. section 8.5.1

Listing 8.13 Registering an OIDC provider with AWS
locals {
  gh_actions_token_url = "https://token.actions.githubusercontent.com" #1
}
 
data "tls_certificate" "gh_actions" {
  url = local.gh_actions_token_url                                     #2
}
 
resource "aws_iam_openid_connect_provider" "github" {                  #3
  url             = local.gh_actions_token_url                         #4
  thumbprint_list = data.tls_certificate.gh_actions.certificates[*].
sha1_fingerprint                                                     #5
  client_id_list  = ["sts.amazonaws.com"]                              #6
}
#1 This is the URL for the GitHub Actions OIDC token service.
#2 OIDC uses the TLS certificate to verify the identity of the service.
#3 This resource should only be called once per account per url.
#4 These values comes from the GitHub Actions documentation.
#5 This is the SHA1 fingerprint of the certificates attached to the GitHub OIDC service.
#6 For AWS, you will almost always use the security token service as the client.

Register a GitHub Actions OIDC provider in AWS with Terraform, deriving the certificate fingerprint and configuring the STS client ID. Create this provider once per account and URL. section 8.5.1

Restricting workflow access

A GitHub Actions workflow requests an OIDC token, then uses an AWS credentials action to assume a repository-specific role. The role trust relationship should restrict which repository and workflows may use it. section 8.5.1

How Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu covers it

How deep it goes
Explains provider registration, authentication versus authorization, identity mapping, and trust restrictions through Terraform and workflow listings.
Examples
Uses GitHub Actions and Spacelift integrations, AWS provider registration, certificate fingerprints, IAM roles, and workflow permissions.
What it assumes
Assumes familiarity with cloud identity systems and Terraform while distinguishing authentication from authorization explicitly.
What you can do after
Configure an OIDC provider and connect external workflows to restricted AWS roles or Azure service principals.
How it connects
Links OpenID Connect with authentication, authorization, IAM roles, service principals, Terraform, GitHub Actions, and Spacelift.

Also explained in

Compare how 12 books explain identity provider →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu. The section links point to the parts of the book it draws on.