File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
src/lib/custom-resources/cdk-s3-update-logarchive-bucket-policy Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ export interface LogArchiveReadAccessProps {
2626 aesLogBucket : s3 . IBucket ;
2727 removalPolicy ?: cdk . RemovalPolicy ;
2828 acceleratorPrefix : string ;
29+ forceUpdate ?: boolean ;
2930}
3031
3132/**
@@ -54,6 +55,12 @@ export class S3UpdateLogArchivePolicy extends cdk.Construct {
5455 aesLogBucketName : this . props . aesLogBucket . bucketName ,
5556 } ;
5657
58+ const forceUpdate = this . props . forceUpdate ?? true ;
59+ if ( forceUpdate ) {
60+ // Add a dummy value that is a random number to update the resource every time
61+ handlerProperties . forceUpdate = Math . round ( Math . random ( ) * 1000000 ) ;
62+ }
63+
5764 this . resource = new cdk . CustomResource ( this , 'Resource' , {
5865 resourceType,
5966 serviceToken : this . lambdaFunction . functionArn ,
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ export interface HandlerProperties {
2828 logBucketKmsKeyArn : string | undefined ;
2929 aesLogBucketArn : string ;
3030 aesLogBucketName : string ;
31+ forceUpdate ?: number ;
3132}
3233
3334export const handler = errorHandler ( onEvent ) ;
@@ -215,7 +216,14 @@ async function onCreate(event: CloudFormationCustomResourceCreateEvent) {
215216
216217async function onUpdate ( event : CloudFormationCustomResourceUpdateEvent ) {
217218 const props = getPropertiesFromEvent ( event ) ;
218- await createOrUpdateBucketPolicy ( props ) ;
219+
220+ if ( props . forceUpdate !== undefined ) {
221+ console . log ( 'onUpdate forceUpdate true' ) ;
222+ await createOrUpdateBucketPolicy ( props ) ;
223+ } else {
224+ console . log ( 'onUpdate skipped' ) ;
225+ }
226+
219227 return { physicalResourceId : event . PhysicalResourceId } ;
220228}
221229
You can’t perform that action at this time.
0 commit comments