-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cloudfront): add grantCreateInvalidation to Distribution #22575
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as iam from '@aws-cdk/aws-iam'; | ||
import { Stack } from '@aws-cdk/core'; | ||
import { Construct } from 'constructs'; | ||
import { IDistribution } from '..'; | ||
|
||
/** | ||
* Format distribution ARN from stack and distribution ID. | ||
*/ | ||
export function formatDistributionArn(scope: Construct, distributionId: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not seeing the benefit of creating this file instead of just putting these in the distribution file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These functions are shared by |
||
return Stack.of(scope).formatArn({ | ||
service: 'cloudfront', | ||
region: '', | ||
resource: 'distribution', | ||
resourceName: distributionId, | ||
}); | ||
} | ||
|
||
export function grantCreateInvalidation(distribution: IDistribution, grantee: iam.IGrantable) { | ||
return iam.Grant.addToPrincipal({ | ||
grantee, | ||
actions: ['cloudfront:CreateInvalidation'], | ||
resourceArns: [distribution.distributionArn], | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"version":"20.0.0"} | ||
{"version":"21.0.0"} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
{ | ||
"version": "20.0.0", | ||
"version": "21.0.0", | ||
"testCases": { | ||
"integ.distribution-basic": { | ||
"integ-distribution-basic/distribution-basic-test/DefaultTest": { | ||
"stacks": [ | ||
"integ-distribution-basic" | ||
], | ||
"diffAssets": false, | ||
"stackUpdateWorkflow": true | ||
"assertionStack": "integ-distribution-basic/distribution-basic-test/DefaultTest/DeployAssert", | ||
"assertionStackName": "integdistributionbasicdistributionbasictestDefaultTestDeployAssert2D53EBF0" | ||
} | ||
}, | ||
"synthContext": {}, | ||
"enableLookups": false | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "21.0.0", | ||
"files": { | ||
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { | ||
"source": { | ||
"path": "integdistributionbasicdistributionbasictestDefaultTestDeployAssert2D53EBF0.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I get why this is being added in this context. It's not included in
Fn::GetAtt
in the resource per https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudfront-distribution.html. How is this being used?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's useful when grant other than
CreateInvalidation
:Can be removed if it's excessive.