File tree 2 files changed +23
-6
lines changed
2 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ module "cloudfront" {
28
28
29
29
create_origin_access_control = true
30
30
origin_access_control = {
31
- s3_oac = {
31
+ (var . example_env ) = {
32
32
description = " CloudFront access to S3"
33
33
origin_type = " s3"
34
34
signing_behavior = " always"
@@ -76,7 +76,7 @@ module "cloudfront" {
76
76
77
77
s3_oac = { # with origin access control settings (recommended)
78
78
domain_name = module.s3_one.s3_bucket_bucket_regional_domain_name
79
- origin_access_control = " s3_oac " # key in `origin_access_control`
79
+ origin_access_control = var.example_env # key in `origin_access_control`
80
80
# origin_access_control_id = "E345SXM82MIOSU" # external OAС resource
81
81
}
82
82
}
@@ -349,7 +349,7 @@ resource "aws_cloudfront_distribution" "s3_distribution" {
349
349
}
350
350
351
351
resource "aws_cloudfront_response_headers_policy" "headers-policy" {
352
- name = " baseline"
352
+ name = " baseline- ${ var . example_env } "
353
353
comment = " This controls which headers are cached for baseline applications. This includes headers that are safe to cache"
354
354
355
355
cors_config {
Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ resource "aws_iam_role" "deploy_role" {
63
63
managed_policy_arns = [aws_iam_policy . state_access . arn , " arn:aws:iam::aws:policy/AdministratorAccess" ]
64
64
assume_role_policy = jsonencode ({
65
65
Version = " 2012-10-17"
66
- Statement = [
66
+ # Ensure that there is a valid federated principal, even on the non-default environments
67
+ Statement = var.example_env == " terraform-example" ? [
67
68
{
68
69
Sid = " AllowGithubOIDC" ,
69
70
Effect = " Allow" ,
@@ -84,8 +85,7 @@ resource "aws_iam_role" "deploy_role" {
84
85
Sid = " AllowTerraformOIDC" ,
85
86
Effect = " Allow" ,
86
87
Principal = {
87
- # Ensure that there is a valid federated principal, even on the non default environments
88
- Federated = var.example_env == " terraform-example" ? aws_iam_openid_connect_provider.tfc_provider[0 ].arn : " arn:aws:iam::${ local . account_id } :oidc-provider/token.actions.githubusercontent.com"
88
+ Federated = aws_iam_openid_connect_provider.tfc_provider[0 ].arn
89
89
},
90
90
Action = " sts:AssumeRoleWithWebIdentity"
91
91
Condition = {
@@ -97,6 +97,23 @@ resource "aws_iam_role" "deploy_role" {
97
97
}
98
98
}
99
99
}
100
+ ] : [
101
+ {
102
+ Sid = " AllowGithubOIDC" ,
103
+ Effect = " Allow" ,
104
+ Principal = {
105
+ Federated = " arn:aws:iam::${ local . account_id } :oidc-provider/token.actions.githubusercontent.com"
106
+ },
107
+ Action = " sts:AssumeRoleWithWebIdentity"
108
+ Condition = {
109
+ StringLike = {
110
+ " token.actions.githubusercontent.com:sub" = " repo:overmindtech/terraform-example:*"
111
+ },
112
+ StringEquals = {
113
+ " token.actions.githubusercontent.com:aud" = " sts.amazonaws.com"
114
+ }
115
+ }
116
+ }
100
117
]
101
118
})
102
119
}
You can’t perform that action at this time.
0 commit comments