Skip to content

Commit 271901b

Browse files
committed
[ELI-731] swapping things around into a logical order
1 parent 14d275e commit 271901b

1 file changed

Lines changed: 71 additions & 71 deletions

File tree

infrastructure/stacks/iams-developer-roles/github_actions_policies.tf

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -678,77 +678,6 @@ resource "aws_iam_policy" "iam_management" {
678678
tags = merge(local.tags, { Name = "iam-management" })
679679
}
680680

681-
# Assume role policy document for GitHub Actions
682-
data "aws_iam_policy_document" "github_actions_assume_role" {
683-
statement {
684-
sid = "OidcAssumeRoleWithWebIdentity"
685-
effect = "Allow"
686-
actions = ["sts:AssumeRoleWithWebIdentity"]
687-
688-
principals {
689-
type = "Federated"
690-
identifiers = [
691-
aws_iam_openid_connect_provider.github.arn
692-
]
693-
}
694-
695-
condition {
696-
test = "StringLike"
697-
variable = "token.actions.githubusercontent.com:sub"
698-
values = ["repo:${var.github_org}/${var.github_repo}:*"]
699-
}
700-
701-
condition {
702-
test = "StringEquals"
703-
variable = "token.actions.githubusercontent.com:aud"
704-
values = ["sts.amazonaws.com"]
705-
}
706-
}
707-
dynamic "statement" {
708-
for_each = var.environment == "dev" ? [1] : []
709-
content {
710-
sid = "AllowDevSSORoleToAssumeIamBootstrap"
711-
effect = "Allow"
712-
actions = ["sts:AssumeRole"]
713-
714-
principals {
715-
type = "AWS"
716-
identifiers = [
717-
local.dev_role_arn
718-
]
719-
}
720-
}
721-
}
722-
}
723-
724-
# Assume role policy document for GitHub Actions
725-
data "aws_iam_policy_document" "regression_repo_assume_role" {
726-
statement {
727-
sid = "OidcAssumeRoleWithWebIdentity"
728-
effect = "Allow"
729-
actions = ["sts:AssumeRoleWithWebIdentity"]
730-
731-
principals {
732-
type = "Federated"
733-
identifiers = [
734-
aws_iam_openid_connect_provider.github.arn
735-
]
736-
}
737-
738-
condition {
739-
test = "StringLike"
740-
variable = "token.actions.githubusercontent.com:sub"
741-
values = ["repo:${var.github_org}/${var.regression_repo}:*"]
742-
}
743-
744-
condition {
745-
test = "StringEquals"
746-
variable = "token.actions.githubusercontent.com:aud"
747-
values = ["sts.amazonaws.com"]
748-
}
749-
}
750-
}
751-
752681
resource "aws_iam_policy" "stream_management" {
753682
name = "stream-management"
754683
description = "Allow GitHub Actions to manage project Firehose delivery streams and Kinesis streams"
@@ -873,6 +802,77 @@ resource "aws_iam_policy" "cloudwatch_management" {
873802
tags = merge(local.tags, { Name = "cloudwatch-management" })
874803
}
875804

805+
# Assume role policy document for GitHub Actions
806+
data "aws_iam_policy_document" "github_actions_assume_role" {
807+
statement {
808+
sid = "OidcAssumeRoleWithWebIdentity"
809+
effect = "Allow"
810+
actions = ["sts:AssumeRoleWithWebIdentity"]
811+
812+
principals {
813+
type = "Federated"
814+
identifiers = [
815+
aws_iam_openid_connect_provider.github.arn
816+
]
817+
}
818+
819+
condition {
820+
test = "StringLike"
821+
variable = "token.actions.githubusercontent.com:sub"
822+
values = ["repo:${var.github_org}/${var.github_repo}:*"]
823+
}
824+
825+
condition {
826+
test = "StringEquals"
827+
variable = "token.actions.githubusercontent.com:aud"
828+
values = ["sts.amazonaws.com"]
829+
}
830+
}
831+
dynamic "statement" {
832+
for_each = var.environment == "dev" ? [1] : []
833+
content {
834+
sid = "AllowDevSSORoleToAssumeIamBootstrap"
835+
effect = "Allow"
836+
actions = ["sts:AssumeRole"]
837+
838+
principals {
839+
type = "AWS"
840+
identifiers = [
841+
local.dev_role_arn
842+
]
843+
}
844+
}
845+
}
846+
}
847+
848+
# Assume role policy document for GitHub Actions
849+
data "aws_iam_policy_document" "regression_repo_assume_role" {
850+
statement {
851+
sid = "OidcAssumeRoleWithWebIdentity"
852+
effect = "Allow"
853+
actions = ["sts:AssumeRoleWithWebIdentity"]
854+
855+
principals {
856+
type = "Federated"
857+
identifiers = [
858+
aws_iam_openid_connect_provider.github.arn
859+
]
860+
}
861+
862+
condition {
863+
test = "StringLike"
864+
variable = "token.actions.githubusercontent.com:sub"
865+
values = ["repo:${var.github_org}/${var.regression_repo}:*"]
866+
}
867+
868+
condition {
869+
test = "StringEquals"
870+
variable = "token.actions.githubusercontent.com:aud"
871+
values = ["sts.amazonaws.com"]
872+
}
873+
}
874+
}
875+
876876
# Attach the policies to the role
877877
resource "aws_iam_role_policy_attachment" "api_infrastructure" {
878878
role = aws_iam_role.github_actions.name

0 commit comments

Comments
 (0)