Skip to content

Commit 85fb0b4

Browse files
committed
Adding deployment role parameter and restricting s3:GetObject to the deployment role
1 parent 77bb165 commit 85fb0b4

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

extras/aws-control-tower/prerequisites/prereq-lambda-s3-bucket.yaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ Parameters:
1010
Default: lambda-zips
1111
Description: S3 bucket name prefix for the Lambda zip files. The account and region are added to the prefix.
1212
Type: String
13-
13+
14+
pDeploymentRoleName:
15+
AllowedPattern: '^[\w+=,.@-]{1,64}$'
16+
ConstraintDescription: Max 64 alphanumeric characters. Also special characters supported [+, =, ., @, -]
17+
Default: AWSControlTowerExecution
18+
Description: Role used to deploy resources within accounts and requires s3:GetObject access
19+
Type: String
20+
1421
pOrganizationId:
1522
AllowedPattern: '^o-[a-z0-9]{10,32}$'
1623
ConstraintDescription: >
@@ -61,18 +68,20 @@ Resources:
6168
Condition:
6269
StringEquals:
6370
aws:PrincipalOrgID: !Ref pOrganizationId
71+
ArnLike:
72+
aws:PrincipalArn: !Sub arn:${AWS::Partition}:iam::*:${pDeploymentRoleName}
6473
Effect: Allow
6574
Principal: "*"
6675
Resource: !Sub arn:${AWS::Partition}:s3:::${rLambdaS3Bucket}/*
6776
Sid: AllowOrgGetObject
68-
77+
6978
- Action: "s3:*"
7079
Condition:
7180
StringNotEquals:
7281
aws:PrincipalOrgID: !Ref pOrganizationId
7382
Effect: Deny
7483
Principal: "*"
75-
Resource:
84+
Resource:
7685
- !Sub arn:${AWS::Partition}:s3:::${rLambdaS3Bucket}
7786
- !Sub arn:${AWS::Partition}:s3:::${rLambdaS3Bucket}/*
7887
Sid: DenyExternalPrincipals
@@ -83,18 +92,18 @@ Resources:
8392
"aws:SecureTransport": "false"
8493
Effect: Deny
8594
Principal: "*"
86-
Resource:
95+
Resource:
8796
- !Sub arn:${AWS::Partition}:s3:::${rLambdaS3Bucket}
8897
- !Sub arn:${AWS::Partition}:s3:::${rLambdaS3Bucket}/*
8998
Sid: SecureTransport
9099

91100

92101
rS3BucketSSMParameter:
93-
Type: AWS::SSM::Parameter
102+
Type: AWS::SSM::Parameter
94103
Properties:
95104
Description: Lambda zip file bucket
96105
Name: !Sub /org/primary/lambda_zips_bucket/${AWS::Region}
97106
Tags:
98107
cfct: managed-by-cfct
99108
Type: String
100-
Value: !Ref rLambdaS3Bucket
109+
Value: !Ref rLambdaS3Bucket

extras/lambda-s3-buckets.yaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ Metadata:
1515
default: Bucket Attributes
1616
Parameters:
1717
- pBucketNamePrefix
18+
- pDeploymentRoleName
1819
- pOrganizationId
1920

2021
ParameterLabels:
2122
pBucketNamePrefix:
2223
default: Bucket Name Prefix
24+
pDeploymentRoleName:
25+
default: Deployment Role Name
2326
pOrganizationId:
2427
default: AWS Organization ID
2528

@@ -33,6 +36,13 @@ Parameters:
3336
Description: S3 bucket name prefix for the Lambda zip files
3437
Type: String
3538

39+
pDeploymentRoleName:
40+
AllowedPattern: '^[\w+=,.@-]{1,64}$'
41+
ConstraintDescription: Max 64 alphanumeric characters. Also special characters supported [+, =, ., @, -]
42+
Default: AWSControlTowerExecution
43+
Description: Role used to deploy resources within accounts and requires s3:GetObject access
44+
Type: String
45+
3646
pOrganizationId:
3747
AllowedPattern: '^o-[a-z0-9]{10,32}$'
3848
ConstraintDescription: >
@@ -86,6 +96,8 @@ Resources:
8696
Condition:
8797
StringEquals:
8898
aws:PrincipalOrgID: !Ref pOrganizationId
99+
ArnLike:
100+
aws:PrincipalArn: !Sub arn:${AWS::Partition}:iam::*:${pDeploymentRoleName}
89101
Effect: Allow
90102
Principal: "*"
91103
Resource: !Sub arn:${AWS::Partition}:s3:::${rLambdaS3Bucket}/*
@@ -124,9 +136,8 @@ Resources:
124136
# ######################################################################
125137
# Commented out to allow for modifications before deployment.
126138
# CloudFormation doesn't allow dynamic tag keys here.
127-
# Examples:
128-
# aws-landing-zone: managed-by-aws-landing-zone
139+
# Example:
129140
# cfct: managed-by-cfct
130141
# #######################################################################
131-
# Tags:
132-
# aws-landing-zone: managed-by-aws-landing-zone
142+
Tags:
143+
cfct: managed-by-cfct

0 commit comments

Comments
 (0)