File tree Expand file tree Collapse file tree 5 files changed +37
-9
lines changed
modules/github_actions_assumable_role Expand file tree Collapse file tree 5 files changed +37
-9
lines changed Original file line number Diff line number Diff line change 11locals {
22 org_defaults = {
3- role_name = " githubActions-iamRole"
4- allowed_branches = [" master" ]
3+ role_name = " githubActions-iamRole"
4+ allowed_branches = [" main" ]
5+ allowed_tags = []
6+ allowed_environments = []
7+ pull_requests = false
58 repositories = {
69 " *" = {}
710 }
@@ -36,9 +39,13 @@ locals {
3639 for org_name , org_data in local . github_orgs_with_repos : [
3740 for repo_name , repo_data in org_data [" repositories" ] : {
3841 role_name : repo_data [" role_name" ]
39- github_subs : [
40- for branch in repo_data [" allowed_branches" ] : " repo:${ org_name } /${ repo_name } :ref:refs/heads/${ branch } "
41- ] }
42+ github_subs : flatten ([
43+ [for branch in repo_data [" allowed_branches" ] : " repo:${ org_name } /${ repo_name } :ref:refs/heads/${ branch } " ],
44+ [for tag in repo_data [" allowed_tags" ] : " repo:${ org_name } /${ repo_name } :ref:refs/tags/${ tag } " ],
45+ [for env in repo_data [" allowed_environments" ] : " repo:${ org_name } /${ repo_name } :environment:${ env } " ],
46+ [for dummy in [" DUMMY" ] : " repo:${ org_name } /${ repo_name } :pull_request" if repo_data [" pull_requests" ] == true ]
47+ ])
48+ }
4249 ]
4350 ])
4451
Original file line number Diff line number Diff line change @@ -11,11 +11,15 @@ resource "aws_iam_openid_connect_provider" "github_actions" {
1111 " sts.amazonaws.com" ,
1212 ]
1313 thumbprint_list = [
14- " 6938fd4d98bab03faadb97b34396831e3780aea1 "
14+ data . tls_certificate . this . certificates [ 0 ] . sha1_fingerprint
1515 ]
1616 url = " https://token.actions.githubusercontent.com"
1717}
1818
19+ data "tls_certificate" "this" {
20+ url = " https://token.actions.githubusercontent.com"
21+ }
22+
1923module "github_actions_assumable_role" {
2024 source = " ./modules/github_actions_assumable_role"
2125 for_each = var. create_iam_roles ? local. github_subs_by_role : {}
Original file line number Diff line number Diff line change 66terraform {
77 required_version = " >= 0.13.0"
88 required_providers {
9- aws = " > 3.0, ~> 4.0"
9+ aws = " ~> 4.0"
1010 }
1111}
1212
@@ -28,5 +28,15 @@ data "aws_iam_policy_document" "this" {
2828 values = var. github_subs
2929 variable = " token.actions.githubusercontent.com:sub"
3030 }
31+ condition {
32+ test = " ForAllValues:StringEquals"
33+ values = [" sts.amazonaws.com" ]
34+ variable = " token.actions.githubusercontent.com:aud"
35+ }
36+ condition {
37+ test = " ForAllValues:StringEquals"
38+ values = [" https://token.actions.githubusercontent.com" ]
39+ variable = " token.actions.githubusercontent.com:iss"
40+ }
3141 }
3242}
Original file line number Diff line number Diff line change 11terraform {
22 required_version = " >= 0.13.0"
33 required_providers {
4- aws = " > 3.0, ~> 4.0"
4+ aws = {
5+ source = " hashicorp/aws"
6+ version = " ~> 4.0"
7+ }
8+ tls = {
9+ source = " hashicorp/tls"
10+ version = " ~> 4.0"
11+ }
512 }
613}
Original file line number Diff line number Diff line change 66
77plugin "aws" {
88 enabled = true
9- version = " 0.11 .0"
9+ version = " 0.30 .0"
1010 source = " github.com/terraform-linters/tflint-ruleset-aws"
1111}
1212
You can’t perform that action at this time.
0 commit comments