Skip to content

Commit

Permalink
feat: allow github actions to attach more assume role policies
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeyheath committed Oct 30, 2023
1 parent a2d7c4a commit 2e33003
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions aws-iam-role-github-action/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,24 @@ locals {

// https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services#adding-the-identity-provider-to-aws
data "aws_iam_policy_document" "assume_role" {
dynamic "statement" {
for_each = var.authorized_aws_accounts

content {
sid = "AllowAssumeRoleFrom${statement.key}"
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${statement.value}:root"]
}
actions = ["sts:AssumeRole", "sts:TagSession"]
effect = "Allow"
}
}
dynamic "statement" {
for_each = var.authorized_github_repos

content {
sid = "AllowGithubActionsToAssumeRole"
principals {
type = "Federated"
identifiers = [local.idp_arn]
Expand Down
6 changes: 6 additions & 0 deletions aws-iam-role-github-action/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ variable "tags" {

description = "Standard tagging."
}

variable "authorized_aws_accounts" {
type = map(string)
description = "The map of authorized AWS accounts to assume the created role."
default = {}
}

0 comments on commit 2e33003

Please sign in to comment.