-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into disk-full-alert-docsrs
- Loading branch information
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Docs: https://aws.amazon.com/blogs/security/use-iam-roles-to-connect-github-actions-to-actions-in-aws/ | ||
resource "aws_iam_openid_connect_provider" "github_actions_provider" { | ||
url = "https://token.actions.githubusercontent.com" | ||
|
||
client_id_list = ["sts.amazonaws.com"] | ||
|
||
// unused | ||
thumbprint_list = ["1c58a3a8518e8759bf075b76b750d4f2df264fcd"] | ||
} | ||
|
||
resource "aws_iam_role" "github_actions_ci_role" { | ||
name = "ci--rust-lang--aws-runners-test" | ||
assume_role_policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Effect = "Allow" | ||
Action = [ | ||
"sts:AssumeRoleWithWebIdentity", | ||
] | ||
Principal = { | ||
Federated = aws_iam_openid_connect_provider.github_actions_provider.arn | ||
} | ||
Condition = { | ||
// StringLike is used with a wildcard operator (*) to allow any branch, pull request merge branch | ||
// of the repository to assume a role in AWS | ||
StringLike : { | ||
"token.actions.githubusercontent.com:sub" : "repo:rust-lang/aws-runners-test:ref:*" | ||
}, | ||
StringEquals : { | ||
"token.actions.githubusercontent.com:aud" : "sts.amazonaws.com" | ||
} | ||
} | ||
} | ||
] | ||
}) | ||
} | ||
|
||
# Allow GitHub Actions to authenticate to AWS ECR Public Gallery | ||
resource "aws_iam_role_policy" "github_actions_ecr_policy" { | ||
name = "ecr-auth-policy" | ||
role = aws_iam_role.github_actions_ci_role.id | ||
|
||
policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Effect = "Allow" | ||
Action = [ | ||
"ecr-public:GetAuthorizationToken", | ||
"sts:GetServiceBearerToken" | ||
] | ||
Resource = "*" | ||
} | ||
] | ||
}) | ||
} |