Skip to content

Commit

Permalink
fix(cloudtrail): Invalid arn partition for GovCloud (#8248)
Browse files Browse the repository at this point in the history
Use partition ref for lambda and s3 data events

Closes #8247


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
cmckni3 authored Jun 14, 2020
1 parent 86d84e6 commit 5189170
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-cloudtrail/lib/cloudtrail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export class Trail extends Resource {
* @default false
*/
public logAllLambdaDataEvents(options: AddEventSelectorOptions = {}) {
return this.addEventSelector(DataResourceType.LAMBDA_FUNCTION, [ 'arn:aws:lambda' ], options);
return this.addEventSelector(DataResourceType.LAMBDA_FUNCTION, [ `arn:${this.stack.partition}:lambda` ], options);
}

/**
Expand All @@ -372,7 +372,7 @@ export class Trail extends Resource {
* @default false
*/
public logAllS3DataEvents(options: AddEventSelectorOptions = {}) {
return this.addEventSelector(DataResourceType.S3_OBJECT, [ 'arn:aws:s3:::' ], options);
return this.addEventSelector(DataResourceType.S3_OBJECT, [ `arn:${this.stack.partition}:s3:::` ], options);
}

/**
Expand Down
45 changes: 42 additions & 3 deletions packages/@aws-cdk/aws-cloudtrail/test/cloudtrail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,20 @@ describe('cloudtrail', () => {
{
DataResources: [{
Type: 'AWS::S3::Object',
Values: [ 'arn:aws:s3:::' ],
Values: [
{
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':s3:::',
],
],
},
],
}],
IncludeManagementEvents: ABSENT,
ReadWriteType: ABSENT,
Expand Down Expand Up @@ -331,7 +344,20 @@ describe('cloudtrail', () => {
{
DataResources: [{
Type: 'AWS::S3::Object',
Values: [ 'arn:aws:s3:::' ],
Values: [
{
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':s3:::',
],
],
},
],
}],
IncludeManagementEvents: false,
ReadWriteType: 'ReadOnly',
Expand Down Expand Up @@ -391,7 +417,20 @@ describe('cloudtrail', () => {
{
DataResources: [{
Type: 'AWS::Lambda::Function',
Values: [ 'arn:aws:lambda' ],
Values: [
{
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':lambda',
],
],
},
],
}],
},
],
Expand Down

0 comments on commit 5189170

Please sign in to comment.