Skip to content

Commit fe0b680

Browse files
authored
Scope down execution and logging role assume role policy (#860)
1 parent bc68113 commit fe0b680

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/rpdk/core/data/managed-upload-infrastructure.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ Resources:
9191
Service:
9292
- resources.cloudformation.amazonaws.com
9393
Action: sts:AssumeRole
94+
Condition:
95+
StringEquals:
96+
aws:SourceAccount:
97+
Ref: AWS::AccountId
9498
Path: "/"
9599
Policies:
96100
- PolicyName: LogAndMetricsDeliveryRolePolicy

src/rpdk/core/project.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ def type_name(self, value):
160160
def hypenated_name(self):
161161
return "-".join(self.type_info).lower()
162162

163+
@property
164+
def hyphenated_name_case_sensitive(self):
165+
return "-".join(self.type_info)
166+
163167
@property
164168
def schema_filename(self):
165169
return f"{self.hypenated_name}.json"
@@ -428,7 +432,7 @@ def generate(self):
428432
permission = "Deny"
429433

430434
contents = template.render(
431-
type_name=self.hypenated_name,
435+
type_name=self.hyphenated_name_case_sensitive,
432436
actions=sorted(actions),
433437
permission=permission,
434438
role_session_timeout=role_session_timeout,

src/rpdk/core/templates/resource-role.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ Resources:
1515
Principal:
1616
Service: resources.cloudformation.amazonaws.com
1717
Action: sts:AssumeRole
18+
Condition:
19+
StringEquals:
20+
aws:SourceAccount:
21+
Ref: AWS::AccountId
22+
StringLike:
23+
aws:SourceArn:
24+
Fn::Sub: arn:${AWS::Partition}:cloudformation:${AWS::Region}:${AWS::AccountId}:type/resource/{{ type_name }}/*
1825
Path: "/"
1926
Policies:
2027
- PolicyName: ResourceTypePolicy

0 commit comments

Comments
 (0)