Skip to content

Commit

Permalink
Scope down execution and logging role assume role policy (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
sungkkim committed Jan 28, 2022
1 parent bc68113 commit fe0b680
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/rpdk/core/data/managed-upload-infrastructure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ Resources:
Service:
- resources.cloudformation.amazonaws.com
Action: sts:AssumeRole
Condition:
StringEquals:
aws:SourceAccount:
Ref: AWS::AccountId
Path: "/"
Policies:
- PolicyName: LogAndMetricsDeliveryRolePolicy
Expand Down
6 changes: 5 additions & 1 deletion src/rpdk/core/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ def type_name(self, value):
def hypenated_name(self):
return "-".join(self.type_info).lower()

@property
def hyphenated_name_case_sensitive(self):
return "-".join(self.type_info)

@property
def schema_filename(self):
return f"{self.hypenated_name}.json"
Expand Down Expand Up @@ -428,7 +432,7 @@ def generate(self):
permission = "Deny"

contents = template.render(
type_name=self.hypenated_name,
type_name=self.hyphenated_name_case_sensitive,
actions=sorted(actions),
permission=permission,
role_session_timeout=role_session_timeout,
Expand Down
7 changes: 7 additions & 0 deletions src/rpdk/core/templates/resource-role.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ Resources:
Principal:
Service: resources.cloudformation.amazonaws.com
Action: sts:AssumeRole
Condition:
StringEquals:
aws:SourceAccount:
Ref: AWS::AccountId
StringLike:
aws:SourceArn:
Fn::Sub: arn:${AWS::Partition}:cloudformation:${AWS::Region}:${AWS::AccountId}:type/resource/{{ type_name }}/*
Path: "/"
Policies:
- PolicyName: ResourceTypePolicy
Expand Down

0 comments on commit fe0b680

Please sign in to comment.