Skip to content

Commit 14d275e

Browse files
committed
[ELI-731] creating a new role and adding a trust policy for the regression repo
1 parent ae9e403 commit 14d275e

3 files changed

Lines changed: 51 additions & 0 deletions

File tree

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,34 @@ data "aws_iam_policy_document" "github_actions_assume_role" {
721721
}
722722
}
723723

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+
724752
resource "aws_iam_policy" "stream_management" {
725753
name = "stream-management"
726754
description = "Allow GitHub Actions to manage project Firehose delivery streams and Kinesis streams"

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,20 @@ data "aws_iam_policy_document" "github_actions_iam_bootstrap_assume_role" {
107107
}
108108
}
109109
}
110+
111+
resource "aws_iam_role" "regression_test_role" {
112+
name = "Eligibility-Signposting-API-E2E-Regression-Tests"
113+
description = "Role for regression testing"
114+
permissions_boundary = aws_iam_policy.permissions_boundary.arn
115+
path = "/service-roles/"
116+
117+
# Trust policy allowing GitHub Actions to assume the role
118+
assume_role_policy = data.aws_iam_policy_document.regression_repo_assume_role.json
119+
120+
tags = merge(
121+
local.tags,
122+
{
123+
Name = "Eligibility-Signposting-API-E2E-Regression-Tests"
124+
}
125+
)
126+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ variable "github_repo" {
99
description = "GitHub repository"
1010
type = string
1111
}
12+
13+
variable "regression_repo" {
14+
default = "eligibility-signposting-api-regression-tests"
15+
description = "GitHub repository"
16+
type = string
17+
}

0 commit comments

Comments
 (0)