Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions terraform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Terraform directory structure
| [aws_iam_group.project_leads](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_group) | resource |
| [aws_iam_group_policy_attachment.admin](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_group_policy_attachment) | resource |
| [aws_iam_group_policy_attachment.manageAccessKeys](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_group_policy_attachment) | resource |
| [aws_iam_openid_connect_provider.entra](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_openid_connect_provider) | resource |
| [aws_iam_policy.food_oasis_local_dev](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_policy.manage_access_keys](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_role.incubator_tf_apply](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
Expand Down Expand Up @@ -128,5 +129,6 @@ Terraform directory structure

| Name | Description |
|------|-------------|
| <a name="output_entra_oidc_provider_arn"></a> [entra\_oidc\_provider\_arn](#output\_entra\_oidc\_provider\_arn) | ARN of the IAM OIDC provider for Hack for LA's Entra tenant, for roles assumed by apps on Azure. Null when iam\_only is true. |
| <a name="output_incubator_azure_ci_client_ids"></a> [incubator\_azure\_ci\_client\_ids](#output\_incubator\_azure\_ci\_client\_ids) | Client IDs of incubator's Azure CI identities, keyed plan/apply. |
<!-- END_TF_DOCS -->
32 changes: 32 additions & 0 deletions terraform/aws-entra-oidc-provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Lets AWS trust tokens issued by Hack for LA's Entra tenant ("CIVIC TECH STRUCTURE"),
// so incubator apps running on Azure can assume AWS roles. Each app's credential sidecar
// (hackforla/incubator#312) exchanges its managed identity token for AWS credentials with
// sts:AssumeRoleWithWebIdentity. The per-project roles that trust this provider are
// created in hackforla/incubator, next to each project (hackforla/incubator#313).
// See hackforla/devops-security#236.
//
// Skipped unless var.iam_only is false, like cloudtrail.tf and azure-ci-identities.tf: it
// trusts Hack for LA's tenant, so it means nothing in a contributor's own AWS account.

resource "aws_iam_openid_connect_provider" "entra" {
count = var.iam_only ? 0 : 1

// Must equal the managed identity token's `iss` claim exactly, trailing slash
// included, or AWS rejects the token. Recorded from a live token in
// hackforla/incubator#307. Managed identity tokens are v1, issued by sts.windows.net.
url = "https://sts.windows.net/8d4de52f-0fe7-43d5-a950-f268f4a09ead/"

// The audience the sidecars request: the client ID of the app registration
// `incubator-aws-credential-audience`, which hackforla/incubator creates (its root
// output azure_aws_credential_audience_client_id). Hard-coded because this repo can't
// read incubator's state. If that registration is ever recreated, its client ID
// changes and this must follow.
client_id_list = ["bb422364-5f6c-4950-bc83-170463db0a53"]

// No thumbprint_list: AWS no longer needs one for this issuer and fills it in itself.
}

output "entra_oidc_provider_arn" {
description = "ARN of the IAM OIDC provider for Hack for LA's Entra tenant, for roles assumed by apps on Azure. Null when iam_only is true."
value = one(aws_iam_openid_connect_provider.entra[*].arn)
}