diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.2ec8ad9e91dcd6e7ad6a5c84ffc6c9c05c408aca3b26ceb2816d81043e6c4dc3/index.js b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.2ec8ad9e91dcd6e7ad6a5c84ffc6c9c05c408aca3b26ceb2816d81043e6c4dc3/index.js
new file mode 100644
index 0000000000000..9d841e15260d7
--- /dev/null
+++ b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.2ec8ad9e91dcd6e7ad6a5c84ffc6c9c05c408aca3b26ceb2816d81043e6c4dc3/index.js
@@ -0,0 +1 @@
+"use strict";var C=Object.create;var i=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var L=(e,t)=>{for(var o in t)i(e,o,{get:t[o],enumerable:!0})},d=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of w(t))!A.call(e,s)&&s!==o&&i(e,s,{get:()=>t[s],enumerable:!(r=I(t,s))||r.enumerable});return e};var l=(e,t,o)=>(o=e!=null?C(P(e)):{},d(t||!e||!e.__esModule?i(o,"default",{value:e,enumerable:!0}):o,e)),k=e=>d(i({},"__esModule",{value:!0}),e);var U={};L(U,{autoDeleteHandler:()=>S,handler:()=>_});module.exports=k(U);var h=require("@aws-sdk/client-s3");var y=l(require("https")),m=l(require("url")),a={sendHttpRequest:T,log:b,includeStackTraces:!0,userHandlerIndex:"./index"},p="AWSCDK::CustomResourceProviderFramework::CREATE_FAILED",B="AWSCDK::CustomResourceProviderFramework::MISSING_PHYSICAL_ID";function R(e){return async(t,o)=>{let r={...t,ResponseURL:"..."};if(a.log(JSON.stringify(r,void 0,2)),t.RequestType==="Delete"&&t.PhysicalResourceId===p){a.log("ignoring DELETE event caused by a failed CREATE event"),await u("SUCCESS",t);return}try{let s=await e(r,o),n=D(t,s);await u("SUCCESS",n)}catch(s){let n={...t,Reason:a.includeStackTraces?s.stack:s.message};n.PhysicalResourceId||(t.RequestType==="Create"?(a.log("CREATE failed, responding with a marker physical resource id so that the subsequent DELETE will be ignored"),n.PhysicalResourceId=p):a.log(`ERROR: Malformed event. "PhysicalResourceId" is required: ${JSON.stringify(t)}`)),await u("FAILED",n)}}}function D(e,t={}){let o=t.PhysicalResourceId??e.PhysicalResourceId??e.RequestId;if(e.RequestType==="Delete"&&o!==e.PhysicalResourceId)throw new Error(`DELETE: cannot change the physical resource ID from "${e.PhysicalResourceId}" to "${t.PhysicalResourceId}" during deletion`);return{...e,...t,PhysicalResourceId:o}}async function u(e,t){let o={Status:e,Reason:t.Reason??e,StackId:t.StackId,RequestId:t.RequestId,PhysicalResourceId:t.PhysicalResourceId||B,LogicalResourceId:t.LogicalResourceId,NoEcho:t.NoEcho,Data:t.Data};a.log("submit response to cloudformation",o);let r=JSON.stringify(o),s=m.parse(t.ResponseURL),n={hostname:s.hostname,path:s.path,method:"PUT",headers:{"content-type":"","content-length":Buffer.byteLength(r,"utf8")}};await O({attempts:5,sleep:1e3},a.sendHttpRequest)(n,r)}async function T(e,t){return new Promise((o,r)=>{try{let s=y.request(e,n=>o());s.on("error",r),s.write(t),s.end()}catch(s){r(s)}})}function b(e,...t){console.log(e,...t)}function O(e,t){return async(...o)=>{let r=e.attempts,s=e.sleep;for(;;)try{return await t(...o)}catch(n){if(r--<=0)throw n;await x(Math.floor(Math.random()*s)),s*=2}}}async function x(e){return new Promise(t=>setTimeout(t,e))}var g="aws-cdk:auto-delete-objects",H=JSON.stringify({Version:"2012-10-17",Statement:[]}),c=new h.S3({}),_=R(S);async function S(e){switch(e.RequestType){case"Create":return;case"Update":return F(e);case"Delete":return f(e.ResourceProperties?.BucketName)}}async function F(e){let t=e,o=t.OldResourceProperties?.BucketName,r=t.ResourceProperties?.BucketName;if(r!=null&&o!=null&&r!==o)return f(o)}async function N(e){try{let t=(await c.getBucketPolicy({Bucket:e}))?.Policy??H,o=JSON.parse(t);o.Statement.push({Principal:"*",Effect:"Deny",Action:["s3:PutObject"],Resource:[`arn:aws:s3:::${e}/*`]}),await c.putBucketPolicy({Bucket:e,Policy:JSON.stringify(o)})}catch(t){if(t.name==="NoSuchBucket")throw t;console.log(`Could not set new object deny policy on bucket '${e}' prior to deletion.`)}}async function E(e){let t=await c.listObjectVersions({Bucket:e}),o=[...t.Versions??[],...t.DeleteMarkers??[]];if(o.length===0)return;let r=o.map(s=>({Key:s.Key,VersionId:s.VersionId}));await c.deleteObjects({Bucket:e,Delete:{Objects:r}}),t?.IsTruncated&&await E(e)}async function f(e){if(!e)throw new Error("No BucketName was provided.");try{if(!await W(e)){console.log(`Bucket does not have '${g}' tag, skipping cleaning.`);return}await N(e),await E(e)}catch(t){if(t.name==="NoSuchBucket"){console.log(`Bucket '${e}' does not exist.`);return}throw t}}async function W(e){return(await c.getBucketTagging({Bucket:e})).TagSet?.some(o=>o.Key===g&&o.Value==="true")}0&&(module.exports={autoDeleteHandler,handler});
diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.3fb6287214999ddeafa7cd0e3e58bc5144c8678bb720f3b5e45e8fd32f333eb3.zip b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.3fb6287214999ddeafa7cd0e3e58bc5144c8678bb720f3b5e45e8fd32f333eb3.zip
new file mode 100644
index 0000000000000..75300b2710dfd
Binary files /dev/null and b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.3fb6287214999ddeafa7cd0e3e58bc5144c8678bb720f3b5e45e8fd32f333eb3.zip differ
diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.e976a796f036a5efbf44b99e44cfb5a961df08d8dbf7cd37e60bf216fb982a00/index.py b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.e976a796f036a5efbf44b99e44cfb5a961df08d8dbf7cd37e60bf216fb982a00/index.py
new file mode 100644
index 0000000000000..4015927d9c843
--- /dev/null
+++ b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.e976a796f036a5efbf44b99e44cfb5a961df08d8dbf7cd37e60bf216fb982a00/index.py
@@ -0,0 +1,320 @@
+import contextlib
+import json
+import logging
+import os
+import shutil
+import subprocess
+import tempfile
+from urllib.request import Request, urlopen
+from uuid import uuid4
+from zipfile import ZipFile
+
+import boto3
+
+logger = logging.getLogger()
+logger.setLevel(logging.INFO)
+
+cloudfront = boto3.client('cloudfront')
+s3 = boto3.client('s3')
+
+CFN_SUCCESS = "SUCCESS"
+CFN_FAILED = "FAILED"
+ENV_KEY_MOUNT_PATH = "MOUNT_PATH"
+ENV_KEY_SKIP_CLEANUP = "SKIP_CLEANUP"
+
+AWS_CLI_CONFIG_FILE = "/tmp/aws_cli_config"
+CUSTOM_RESOURCE_OWNER_TAG = "aws-cdk:cr-owned"
+
+os.putenv('AWS_CONFIG_FILE', AWS_CLI_CONFIG_FILE)
+
+def handler(event, context):
+
+ def cfn_error(message=None):
+ logger.error("| cfn_error: %s" % message)
+ cfn_send(event, context, CFN_FAILED, reason=message, physicalResourceId=event.get('PhysicalResourceId', None))
+
+
+ try:
+ # We are not logging ResponseURL as this is a pre-signed S3 URL, and could be used to tamper
+ # with the response CloudFormation sees from this Custom Resource execution.
+ logger.info({ key:value for (key, value) in event.items() if key != 'ResponseURL'})
+
+ # cloudformation request type (create/update/delete)
+ request_type = event['RequestType']
+
+ # extract resource properties
+ props = event['ResourceProperties']
+ old_props = event.get('OldResourceProperties', {})
+ physical_id = event.get('PhysicalResourceId', None)
+
+ try:
+ source_bucket_names = props['SourceBucketNames']
+ source_object_keys = props['SourceObjectKeys']
+ source_markers = props.get('SourceMarkers', None)
+ dest_bucket_name = props['DestinationBucketName']
+ dest_bucket_prefix = props.get('DestinationBucketKeyPrefix', '')
+ extract = props.get('Extract', 'true') == 'true'
+ retain_on_delete = props.get('RetainOnDelete', "true") == "true"
+ distribution_id = props.get('DistributionId', '')
+ user_metadata = props.get('UserMetadata', {})
+ system_metadata = props.get('SystemMetadata', {})
+ prune = props.get('Prune', 'true').lower() == 'true'
+ exclude = props.get('Exclude', [])
+ include = props.get('Include', [])
+ sign_content = props.get('SignContent', 'false').lower() == 'true'
+
+ # backwards compatibility - if "SourceMarkers" is not specified,
+ # assume all sources have an empty market map
+ if source_markers is None:
+ source_markers = [{} for i in range(len(source_bucket_names))]
+
+ default_distribution_path = dest_bucket_prefix
+ if not default_distribution_path.endswith("/"):
+ default_distribution_path += "/"
+ if not default_distribution_path.startswith("/"):
+ default_distribution_path = "/" + default_distribution_path
+ default_distribution_path += "*"
+
+ distribution_paths = props.get('DistributionPaths', [default_distribution_path])
+ except KeyError as e:
+ cfn_error("missing request resource property %s. props: %s" % (str(e), props))
+ return
+
+ # configure aws cli options after resetting back to the defaults for each request
+ if os.path.exists(AWS_CLI_CONFIG_FILE):
+ os.remove(AWS_CLI_CONFIG_FILE)
+ if sign_content:
+ aws_command("configure", "set", "default.s3.payload_signing_enabled", "true")
+
+ # treat "/" as if no prefix was specified
+ if dest_bucket_prefix == "/":
+ dest_bucket_prefix = ""
+
+ s3_source_zips = list(map(lambda name, key: "s3://%s/%s" % (name, key), source_bucket_names, source_object_keys))
+ s3_dest = "s3://%s/%s" % (dest_bucket_name, dest_bucket_prefix)
+ old_s3_dest = "s3://%s/%s" % (old_props.get("DestinationBucketName", ""), old_props.get("DestinationBucketKeyPrefix", ""))
+
+
+ # obviously this is not
+ if old_s3_dest == "s3:///":
+ old_s3_dest = None
+
+ logger.info("| s3_dest: %s" % s3_dest)
+ logger.info("| old_s3_dest: %s" % old_s3_dest)
+
+ # if we are creating a new resource, allocate a physical id for it
+ # otherwise, we expect physical id to be relayed by cloudformation
+ if request_type == "Create":
+ physical_id = "aws.cdk.s3deployment.%s" % str(uuid4())
+ else:
+ if not physical_id:
+ cfn_error("invalid request: request type is '%s' but 'PhysicalResourceId' is not defined" % {request_type})
+ return
+
+ # delete or create/update (only if "retain_on_delete" is false)
+ if request_type == "Delete" and not retain_on_delete:
+ if not bucket_owned(dest_bucket_name, dest_bucket_prefix):
+ aws_command("s3", "rm", s3_dest, "--recursive")
+
+ # if we are updating without retention and the destination changed, delete first
+ if request_type == "Update" and not retain_on_delete and old_s3_dest != s3_dest:
+ if not old_s3_dest:
+ logger.warn("cannot delete old resource without old resource properties")
+ return
+
+ aws_command("s3", "rm", old_s3_dest, "--recursive")
+
+ if request_type == "Update" or request_type == "Create":
+ s3_deploy(s3_source_zips, s3_dest, user_metadata, system_metadata, prune, exclude, include, source_markers, extract)
+
+ if distribution_id:
+ cloudfront_invalidate(distribution_id, distribution_paths)
+
+ cfn_send(event, context, CFN_SUCCESS, physicalResourceId=physical_id, responseData={
+ # Passing through the ARN sequences dependencees on the deployment
+ 'DestinationBucketArn': props.get('DestinationBucketArn'),
+ 'SourceObjectKeys': props.get('SourceObjectKeys'),
+ })
+ except KeyError as e:
+ cfn_error("invalid request. Missing key %s" % str(e))
+ except Exception as e:
+ logger.exception(e)
+ cfn_error(str(e))
+
+#---------------------------------------------------------------------------------------------------
+# populate all files from s3_source_zips to a destination bucket
+def s3_deploy(s3_source_zips, s3_dest, user_metadata, system_metadata, prune, exclude, include, source_markers, extract):
+ # list lengths are equal
+ if len(s3_source_zips) != len(source_markers):
+ raise Exception("'source_markers' and 's3_source_zips' must be the same length")
+
+ # create a temporary working directory in /tmp or if enabled an attached efs volume
+ if ENV_KEY_MOUNT_PATH in os.environ:
+ workdir = os.getenv(ENV_KEY_MOUNT_PATH) + "/" + str(uuid4())
+ os.mkdir(workdir)
+ else:
+ workdir = tempfile.mkdtemp()
+
+ logger.info("| workdir: %s" % workdir)
+
+ # create a directory into which we extract the contents of the zip file
+ contents_dir=os.path.join(workdir, 'contents')
+ os.mkdir(contents_dir)
+
+ try:
+ # download the archive from the source and extract to "contents"
+ for i in range(len(s3_source_zips)):
+ s3_source_zip = s3_source_zips[i]
+ markers = source_markers[i]
+
+ if extract:
+ archive=os.path.join(workdir, str(uuid4()))
+ logger.info("archive: %s" % archive)
+ aws_command("s3", "cp", s3_source_zip, archive)
+ logger.info("| extracting archive to: %s\n" % contents_dir)
+ logger.info("| markers: %s" % markers)
+ extract_and_replace_markers(archive, contents_dir, markers)
+ else:
+ logger.info("| copying archive to: %s\n" % contents_dir)
+ aws_command("s3", "cp", s3_source_zip, contents_dir)
+
+ # sync from "contents" to destination
+
+ s3_command = ["s3", "sync"]
+
+ if prune:
+ s3_command.append("--delete")
+
+ if exclude:
+ for filter in exclude:
+ s3_command.extend(["--exclude", filter])
+
+ if include:
+ for filter in include:
+ s3_command.extend(["--include", filter])
+
+ s3_command.extend([contents_dir, s3_dest])
+ s3_command.extend(create_metadata_args(user_metadata, system_metadata))
+ aws_command(*s3_command)
+ finally:
+ if not os.getenv(ENV_KEY_SKIP_CLEANUP):
+ shutil.rmtree(workdir)
+
+#---------------------------------------------------------------------------------------------------
+# invalidate files in the CloudFront distribution edge caches
+def cloudfront_invalidate(distribution_id, distribution_paths):
+ invalidation_resp = cloudfront.create_invalidation(
+ DistributionId=distribution_id,
+ InvalidationBatch={
+ 'Paths': {
+ 'Quantity': len(distribution_paths),
+ 'Items': distribution_paths
+ },
+ 'CallerReference': str(uuid4()),
+ })
+ # by default, will wait up to 10 minutes
+ cloudfront.get_waiter('invalidation_completed').wait(
+ DistributionId=distribution_id,
+ Id=invalidation_resp['Invalidation']['Id'])
+
+#---------------------------------------------------------------------------------------------------
+# set metadata
+def create_metadata_args(raw_user_metadata, raw_system_metadata):
+ if len(raw_user_metadata) == 0 and len(raw_system_metadata) == 0:
+ return []
+
+ format_system_metadata_key = lambda k: k.lower()
+ format_user_metadata_key = lambda k: k.lower()
+
+ system_metadata = { format_system_metadata_key(k): v for k, v in raw_system_metadata.items() }
+ user_metadata = { format_user_metadata_key(k): v for k, v in raw_user_metadata.items() }
+
+ flatten = lambda l: [item for sublist in l for item in sublist]
+ system_args = flatten([[f"--{k}", v] for k, v in system_metadata.items()])
+ user_args = ["--metadata", json.dumps(user_metadata, separators=(',', ':'))] if len(user_metadata) > 0 else []
+
+ return system_args + user_args + ["--metadata-directive", "REPLACE"]
+
+#---------------------------------------------------------------------------------------------------
+# executes an "aws" cli command
+def aws_command(*args):
+ aws="/opt/awscli/aws" # from AwsCliLayer
+ logger.info("| aws %s" % ' '.join(args))
+ subprocess.check_call([aws] + list(args))
+
+#---------------------------------------------------------------------------------------------------
+# sends a response to cloudformation
+def cfn_send(event, context, responseStatus, responseData={}, physicalResourceId=None, noEcho=False, reason=None):
+
+ responseUrl = event['ResponseURL']
+
+ responseBody = {}
+ responseBody['Status'] = responseStatus
+ responseBody['Reason'] = reason or ('See the details in CloudWatch Log Stream: ' + context.log_stream_name)
+ responseBody['PhysicalResourceId'] = physicalResourceId or context.log_stream_name
+ responseBody['StackId'] = event['StackId']
+ responseBody['RequestId'] = event['RequestId']
+ responseBody['LogicalResourceId'] = event['LogicalResourceId']
+ responseBody['NoEcho'] = noEcho
+ responseBody['Data'] = responseData
+
+ body = json.dumps(responseBody)
+ logger.info("| response body:\n" + body)
+
+ headers = {
+ 'content-type' : '',
+ 'content-length' : str(len(body))
+ }
+
+ try:
+ request = Request(responseUrl, method='PUT', data=bytes(body.encode('utf-8')), headers=headers)
+ with contextlib.closing(urlopen(request)) as response:
+ logger.info("| status code: " + response.reason)
+ except Exception as e:
+ logger.error("| unable to send response to CloudFormation")
+ logger.exception(e)
+
+
+#---------------------------------------------------------------------------------------------------
+# check if bucket is owned by a custom resource
+# if it is then we don't want to delete content
+def bucket_owned(bucketName, keyPrefix):
+ tag = CUSTOM_RESOURCE_OWNER_TAG
+ if keyPrefix != "":
+ tag = tag + ':' + keyPrefix
+ try:
+ request = s3.get_bucket_tagging(
+ Bucket=bucketName,
+ )
+ return any((x["Key"].startswith(tag)) for x in request["TagSet"])
+ except Exception as e:
+ logger.info("| error getting tags from bucket")
+ logger.exception(e)
+ return False
+
+# extract archive and replace markers in output files
+def extract_and_replace_markers(archive, contents_dir, markers):
+ with ZipFile(archive, "r") as zip:
+ zip.extractall(contents_dir)
+
+ # replace markers for this source
+ for file in zip.namelist():
+ file_path = os.path.join(contents_dir, file)
+ if os.path.isdir(file_path): continue
+ replace_markers(file_path, markers)
+
+def replace_markers(filename, markers):
+ # convert the dict of string markers to binary markers
+ replace_tokens = dict([(k.encode('utf-8'), v.encode('utf-8')) for k, v in markers.items()])
+
+ outfile = filename + '.new'
+ with open(filename, 'rb') as fi, open(outfile, 'wb') as fo:
+ for line in fi:
+ for token in replace_tokens:
+ line = line.replace(token, replace_tokens[token])
+ fo.write(line)
+
+ # # delete the original file and rename the new one to the original
+ os.remove(filename)
+ os.rename(outfile, filename)
+
\ No newline at end of file
diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.fc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222e/index.html b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.fc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222e/index.html
new file mode 100644
index 0000000000000..2529e8a586eaa
--- /dev/null
+++ b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.fc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222e/index.html
@@ -0,0 +1,2 @@
+
Hello, S3 bucket deployments!
+
diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.fc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222e/rabir2v.gif b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.fc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222e/rabir2v.gif
new file mode 100644
index 0000000000000..e82b75cdb2187
Binary files /dev/null and b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/asset.fc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222e/rabir2v.gif differ
diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/cdk.out
new file mode 100644
index 0000000000000..1f0068d32659a
--- /dev/null
+++ b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/cdk.out
@@ -0,0 +1 @@
+{"version":"36.0.0"}
\ No newline at end of file
diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/integ.json
new file mode 100644
index 0000000000000..ede359062b0cc
--- /dev/null
+++ b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/integ.json
@@ -0,0 +1,13 @@
+{
+ "version": "36.0.0",
+ "testCases": {
+ "integ-test-bucket-deployment-loggroup/DefaultTest": {
+ "stacks": [
+ "test-bucket-deployment-loggroup"
+ ],
+ "diffAssets": false,
+ "assertionStack": "integ-test-bucket-deployment-loggroup/DefaultTest/DeployAssert",
+ "assertionStackName": "integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A"
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A.assets.json
new file mode 100644
index 0000000000000..ab504d3bfcbc5
--- /dev/null
+++ b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A.assets.json
@@ -0,0 +1,19 @@
+{
+ "version": "36.0.0",
+ "files": {
+ "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
+ "source": {
+ "path": "integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A.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": {}
+}
\ No newline at end of file
diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A.template.json
new file mode 100644
index 0000000000000..ad9d0fb73d1dd
--- /dev/null
+++ b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A.template.json
@@ -0,0 +1,36 @@
+{
+ "Parameters": {
+ "BootstrapVersion": {
+ "Type": "AWS::SSM::Parameter::Value",
+ "Default": "/cdk-bootstrap/hnb659fds/version",
+ "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
+ }
+ },
+ "Rules": {
+ "CheckBootstrapVersion": {
+ "Assertions": [
+ {
+ "Assert": {
+ "Fn::Not": [
+ {
+ "Fn::Contains": [
+ [
+ "1",
+ "2",
+ "3",
+ "4",
+ "5"
+ ],
+ {
+ "Ref": "BootstrapVersion"
+ }
+ ]
+ }
+ ]
+ },
+ "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
+ }
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/manifest.json
new file mode 100644
index 0000000000000..0b56639257dc2
--- /dev/null
+++ b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/manifest.json
@@ -0,0 +1,173 @@
+{
+ "version": "36.0.0",
+ "artifacts": {
+ "test-bucket-deployment-loggroup.assets": {
+ "type": "cdk:asset-manifest",
+ "properties": {
+ "file": "test-bucket-deployment-loggroup.assets.json",
+ "requiresBootstrapStackVersion": 6,
+ "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
+ }
+ },
+ "test-bucket-deployment-loggroup": {
+ "type": "aws:cloudformation:stack",
+ "environment": "aws://unknown-account/unknown-region",
+ "properties": {
+ "templateFile": "test-bucket-deployment-loggroup.template.json",
+ "terminationProtection": false,
+ "validateOnSynth": false,
+ "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
+ "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
+ "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/b60f949080ac6d1041eef6335ef97042bd7102ad26d7f4c5acf0c707112dffad.json",
+ "requiresBootstrapStackVersion": 6,
+ "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
+ "additionalDependencies": [
+ "test-bucket-deployment-loggroup.assets"
+ ],
+ "lookupRole": {
+ "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
+ "requiresBootstrapStackVersion": 8,
+ "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
+ }
+ },
+ "dependencies": [
+ "test-bucket-deployment-loggroup.assets"
+ ],
+ "metadata": {
+ "/test-bucket-deployment-loggroup/Destination/Resource": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "Destination920A3C57"
+ }
+ ],
+ "/test-bucket-deployment-loggroup/Destination/Policy/Resource": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "DestinationPolicy7982387E"
+ }
+ ],
+ "/test-bucket-deployment-loggroup/Destination/AutoDeleteObjectsCustomResource/Default": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "DestinationAutoDeleteObjectsCustomResource15E926BA"
+ }
+ ],
+ "/test-bucket-deployment-loggroup/Custom::S3AutoDeleteObjectsCustomResourceProvider/Role": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092"
+ }
+ ],
+ "/test-bucket-deployment-loggroup/Custom::S3AutoDeleteObjectsCustomResourceProvider/Handler": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F"
+ }
+ ],
+ "/test-bucket-deployment-loggroup/LogGroup/Resource": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "LogGroupF5B46931"
+ }
+ ],
+ "/test-bucket-deployment-loggroup/DeployMe/AwsCliLayer/Resource": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "DeployMeAwsCliLayer5F9219E9"
+ }
+ ],
+ "/test-bucket-deployment-loggroup/DeployMe/CustomResource/Default": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "DeployMeCustomResource4455EE35"
+ }
+ ],
+ "/test-bucket-deployment-loggroup/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/ServiceRole/Resource": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265"
+ }
+ ],
+ "/test-bucket-deployment-loggroup/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/ServiceRole/DefaultPolicy/Resource": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF"
+ }
+ ],
+ "/test-bucket-deployment-loggroup/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/Resource": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C81C01536"
+ }
+ ],
+ "/test-bucket-deployment-loggroup/BootstrapVersion": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "BootstrapVersion"
+ }
+ ],
+ "/test-bucket-deployment-loggroup/CheckBootstrapVersion": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "CheckBootstrapVersion"
+ }
+ ]
+ },
+ "displayName": "test-bucket-deployment-loggroup"
+ },
+ "integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A.assets": {
+ "type": "cdk:asset-manifest",
+ "properties": {
+ "file": "integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A.assets.json",
+ "requiresBootstrapStackVersion": 6,
+ "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
+ }
+ },
+ "integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A": {
+ "type": "aws:cloudformation:stack",
+ "environment": "aws://unknown-account/unknown-region",
+ "properties": {
+ "templateFile": "integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A.template.json",
+ "terminationProtection": false,
+ "validateOnSynth": false,
+ "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
+ "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
+ "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
+ "requiresBootstrapStackVersion": 6,
+ "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
+ "additionalDependencies": [
+ "integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A.assets"
+ ],
+ "lookupRole": {
+ "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
+ "requiresBootstrapStackVersion": 8,
+ "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
+ }
+ },
+ "dependencies": [
+ "integtestbucketdeploymentloggroupDefaultTestDeployAssertB356FD0A.assets"
+ ],
+ "metadata": {
+ "/integ-test-bucket-deployment-loggroup/DefaultTest/DeployAssert/BootstrapVersion": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "BootstrapVersion"
+ }
+ ],
+ "/integ-test-bucket-deployment-loggroup/DefaultTest/DeployAssert/CheckBootstrapVersion": [
+ {
+ "type": "aws:cdk:logicalId",
+ "data": "CheckBootstrapVersion"
+ }
+ ]
+ },
+ "displayName": "integ-test-bucket-deployment-loggroup/DefaultTest/DeployAssert"
+ },
+ "Tree": {
+ "type": "cdk:tree",
+ "properties": {
+ "file": "tree.json"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/test-bucket-deployment-loggroup.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/test-bucket-deployment-loggroup.assets.json
new file mode 100644
index 0000000000000..8d5bd5424b742
--- /dev/null
+++ b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/test-bucket-deployment-loggroup.assets.json
@@ -0,0 +1,71 @@
+{
+ "version": "36.0.0",
+ "files": {
+ "2ec8ad9e91dcd6e7ad6a5c84ffc6c9c05c408aca3b26ceb2816d81043e6c4dc3": {
+ "source": {
+ "path": "asset.2ec8ad9e91dcd6e7ad6a5c84ffc6c9c05c408aca3b26ceb2816d81043e6c4dc3",
+ "packaging": "zip"
+ },
+ "destinations": {
+ "current_account-current_region": {
+ "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
+ "objectKey": "2ec8ad9e91dcd6e7ad6a5c84ffc6c9c05c408aca3b26ceb2816d81043e6c4dc3.zip",
+ "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
+ }
+ }
+ },
+ "3fb6287214999ddeafa7cd0e3e58bc5144c8678bb720f3b5e45e8fd32f333eb3": {
+ "source": {
+ "path": "asset.3fb6287214999ddeafa7cd0e3e58bc5144c8678bb720f3b5e45e8fd32f333eb3.zip",
+ "packaging": "file"
+ },
+ "destinations": {
+ "current_account-current_region": {
+ "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
+ "objectKey": "3fb6287214999ddeafa7cd0e3e58bc5144c8678bb720f3b5e45e8fd32f333eb3.zip",
+ "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
+ }
+ }
+ },
+ "e976a796f036a5efbf44b99e44cfb5a961df08d8dbf7cd37e60bf216fb982a00": {
+ "source": {
+ "path": "asset.e976a796f036a5efbf44b99e44cfb5a961df08d8dbf7cd37e60bf216fb982a00",
+ "packaging": "zip"
+ },
+ "destinations": {
+ "current_account-current_region": {
+ "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
+ "objectKey": "e976a796f036a5efbf44b99e44cfb5a961df08d8dbf7cd37e60bf216fb982a00.zip",
+ "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
+ }
+ }
+ },
+ "fc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222e": {
+ "source": {
+ "path": "asset.fc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222e",
+ "packaging": "zip"
+ },
+ "destinations": {
+ "current_account-current_region": {
+ "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
+ "objectKey": "fc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222e.zip",
+ "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
+ }
+ }
+ },
+ "b60f949080ac6d1041eef6335ef97042bd7102ad26d7f4c5acf0c707112dffad": {
+ "source": {
+ "path": "test-bucket-deployment-loggroup.template.json",
+ "packaging": "file"
+ },
+ "destinations": {
+ "current_account-current_region": {
+ "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
+ "objectKey": "b60f949080ac6d1041eef6335ef97042bd7102ad26d7f4c5acf0c707112dffad.json",
+ "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
+ }
+ }
+ }
+ },
+ "dockerImages": {}
+}
\ No newline at end of file
diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/test-bucket-deployment-loggroup.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/test-bucket-deployment-loggroup.template.json
new file mode 100644
index 0000000000000..b2aad8415ebe8
--- /dev/null
+++ b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/test-bucket-deployment-loggroup.template.json
@@ -0,0 +1,397 @@
+{
+ "Resources": {
+ "Destination920A3C57": {
+ "Type": "AWS::S3::Bucket",
+ "Properties": {
+ "Tags": [
+ {
+ "Key": "aws-cdk:auto-delete-objects",
+ "Value": "true"
+ },
+ {
+ "Key": "aws-cdk:cr-owned:2058d11c",
+ "Value": "true"
+ }
+ ],
+ "WebsiteConfiguration": {
+ "IndexDocument": "index.html"
+ }
+ },
+ "UpdateReplacePolicy": "Delete",
+ "DeletionPolicy": "Delete"
+ },
+ "DestinationPolicy7982387E": {
+ "Type": "AWS::S3::BucketPolicy",
+ "Properties": {
+ "Bucket": {
+ "Ref": "Destination920A3C57"
+ },
+ "PolicyDocument": {
+ "Statement": [
+ {
+ "Action": [
+ "s3:DeleteObject*",
+ "s3:GetBucket*",
+ "s3:List*",
+ "s3:PutBucketPolicy"
+ ],
+ "Effect": "Allow",
+ "Principal": {
+ "AWS": {
+ "Fn::GetAtt": [
+ "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092",
+ "Arn"
+ ]
+ }
+ },
+ "Resource": [
+ {
+ "Fn::GetAtt": [
+ "Destination920A3C57",
+ "Arn"
+ ]
+ },
+ {
+ "Fn::Join": [
+ "",
+ [
+ {
+ "Fn::GetAtt": [
+ "Destination920A3C57",
+ "Arn"
+ ]
+ },
+ "/*"
+ ]
+ ]
+ }
+ ]
+ }
+ ],
+ "Version": "2012-10-17"
+ }
+ }
+ },
+ "DestinationAutoDeleteObjectsCustomResource15E926BA": {
+ "Type": "Custom::S3AutoDeleteObjects",
+ "Properties": {
+ "ServiceToken": {
+ "Fn::GetAtt": [
+ "CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F",
+ "Arn"
+ ]
+ },
+ "BucketName": {
+ "Ref": "Destination920A3C57"
+ }
+ },
+ "DependsOn": [
+ "DestinationPolicy7982387E"
+ ],
+ "UpdateReplacePolicy": "Delete",
+ "DeletionPolicy": "Delete"
+ },
+ "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092": {
+ "Type": "AWS::IAM::Role",
+ "Properties": {
+ "AssumeRolePolicyDocument": {
+ "Version": "2012-10-17",
+ "Statement": [
+ {
+ "Action": "sts:AssumeRole",
+ "Effect": "Allow",
+ "Principal": {
+ "Service": "lambda.amazonaws.com"
+ }
+ }
+ ]
+ },
+ "ManagedPolicyArns": [
+ {
+ "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
+ }
+ ]
+ }
+ },
+ "CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F": {
+ "Type": "AWS::Lambda::Function",
+ "Properties": {
+ "Code": {
+ "S3Bucket": {
+ "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
+ },
+ "S3Key": "2ec8ad9e91dcd6e7ad6a5c84ffc6c9c05c408aca3b26ceb2816d81043e6c4dc3.zip"
+ },
+ "Timeout": 900,
+ "MemorySize": 128,
+ "Handler": "index.handler",
+ "Role": {
+ "Fn::GetAtt": [
+ "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092",
+ "Arn"
+ ]
+ },
+ "Runtime": "nodejs18.x",
+ "Description": {
+ "Fn::Join": [
+ "",
+ [
+ "Lambda function for auto-deleting objects in ",
+ {
+ "Ref": "Destination920A3C57"
+ },
+ " S3 bucket."
+ ]
+ ]
+ }
+ },
+ "DependsOn": [
+ "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092"
+ ]
+ },
+ "LogGroupF5B46931": {
+ "Type": "AWS::Logs::LogGroup",
+ "Properties": {
+ "RetentionInDays": 1
+ },
+ "UpdateReplacePolicy": "Delete",
+ "DeletionPolicy": "Delete"
+ },
+ "DeployMeAwsCliLayer5F9219E9": {
+ "Type": "AWS::Lambda::LayerVersion",
+ "Properties": {
+ "Content": {
+ "S3Bucket": {
+ "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
+ },
+ "S3Key": "3fb6287214999ddeafa7cd0e3e58bc5144c8678bb720f3b5e45e8fd32f333eb3.zip"
+ },
+ "Description": "/opt/awscli/aws"
+ }
+ },
+ "DeployMeCustomResource4455EE35": {
+ "Type": "Custom::CDKBucketDeployment",
+ "Properties": {
+ "ServiceToken": {
+ "Fn::GetAtt": [
+ "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C81C01536",
+ "Arn"
+ ]
+ },
+ "SourceBucketNames": [
+ {
+ "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
+ }
+ ],
+ "SourceObjectKeys": [
+ "fc4481abf279255619ff7418faa5d24456fef3432ea0da59c95542578ff0222e.zip"
+ ],
+ "DestinationBucketName": {
+ "Ref": "Destination920A3C57"
+ },
+ "RetainOnDelete": false,
+ "Prune": true
+ },
+ "UpdateReplacePolicy": "Delete",
+ "DeletionPolicy": "Delete"
+ },
+ "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265": {
+ "Type": "AWS::IAM::Role",
+ "Properties": {
+ "AssumeRolePolicyDocument": {
+ "Statement": [
+ {
+ "Action": "sts:AssumeRole",
+ "Effect": "Allow",
+ "Principal": {
+ "Service": "lambda.amazonaws.com"
+ }
+ }
+ ],
+ "Version": "2012-10-17"
+ },
+ "ManagedPolicyArns": [
+ {
+ "Fn::Join": [
+ "",
+ [
+ "arn:",
+ {
+ "Ref": "AWS::Partition"
+ },
+ ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
+ ]
+ ]
+ }
+ ]
+ }
+ },
+ "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF": {
+ "Type": "AWS::IAM::Policy",
+ "Properties": {
+ "PolicyDocument": {
+ "Statement": [
+ {
+ "Action": [
+ "s3:GetBucket*",
+ "s3:GetObject*",
+ "s3:List*"
+ ],
+ "Effect": "Allow",
+ "Resource": [
+ {
+ "Fn::Join": [
+ "",
+ [
+ "arn:",
+ {
+ "Ref": "AWS::Partition"
+ },
+ ":s3:::",
+ {
+ "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
+ },
+ "/*"
+ ]
+ ]
+ },
+ {
+ "Fn::Join": [
+ "",
+ [
+ "arn:",
+ {
+ "Ref": "AWS::Partition"
+ },
+ ":s3:::",
+ {
+ "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
+ }
+ ]
+ ]
+ }
+ ]
+ },
+ {
+ "Action": [
+ "s3:Abort*",
+ "s3:DeleteObject*",
+ "s3:GetBucket*",
+ "s3:GetObject*",
+ "s3:List*",
+ "s3:PutObject",
+ "s3:PutObjectLegalHold",
+ "s3:PutObjectRetention",
+ "s3:PutObjectTagging",
+ "s3:PutObjectVersionTagging"
+ ],
+ "Effect": "Allow",
+ "Resource": [
+ {
+ "Fn::GetAtt": [
+ "Destination920A3C57",
+ "Arn"
+ ]
+ },
+ {
+ "Fn::Join": [
+ "",
+ [
+ {
+ "Fn::GetAtt": [
+ "Destination920A3C57",
+ "Arn"
+ ]
+ },
+ "/*"
+ ]
+ ]
+ }
+ ]
+ }
+ ],
+ "Version": "2012-10-17"
+ },
+ "PolicyName": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF",
+ "Roles": [
+ {
+ "Ref": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265"
+ }
+ ]
+ }
+ },
+ "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C81C01536": {
+ "Type": "AWS::Lambda::Function",
+ "Properties": {
+ "Code": {
+ "S3Bucket": {
+ "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
+ },
+ "S3Key": "e976a796f036a5efbf44b99e44cfb5a961df08d8dbf7cd37e60bf216fb982a00.zip"
+ },
+ "Environment": {
+ "Variables": {
+ "AWS_CA_BUNDLE": "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"
+ }
+ },
+ "Handler": "index.handler",
+ "Layers": [
+ {
+ "Ref": "DeployMeAwsCliLayer5F9219E9"
+ }
+ ],
+ "LoggingConfig": {
+ "LogGroup": {
+ "Ref": "LogGroupF5B46931"
+ }
+ },
+ "Role": {
+ "Fn::GetAtt": [
+ "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265",
+ "Arn"
+ ]
+ },
+ "Runtime": "python3.9",
+ "Timeout": 900
+ },
+ "DependsOn": [
+ "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF",
+ "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265"
+ ]
+ }
+ },
+ "Parameters": {
+ "BootstrapVersion": {
+ "Type": "AWS::SSM::Parameter::Value",
+ "Default": "/cdk-bootstrap/hnb659fds/version",
+ "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
+ }
+ },
+ "Rules": {
+ "CheckBootstrapVersion": {
+ "Assertions": [
+ {
+ "Assert": {
+ "Fn::Not": [
+ {
+ "Fn::Contains": [
+ [
+ "1",
+ "2",
+ "3",
+ "4",
+ "5"
+ ],
+ {
+ "Ref": "BootstrapVersion"
+ }
+ ]
+ }
+ ]
+ },
+ "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
+ }
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/tree.json
new file mode 100644
index 0000000000000..c116577f01ef9
--- /dev/null
+++ b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.js.snapshot/tree.json
@@ -0,0 +1,649 @@
+{
+ "version": "tree-0.1",
+ "tree": {
+ "id": "App",
+ "path": "",
+ "children": {
+ "test-bucket-deployment-loggroup": {
+ "id": "test-bucket-deployment-loggroup",
+ "path": "test-bucket-deployment-loggroup",
+ "children": {
+ "Destination": {
+ "id": "Destination",
+ "path": "test-bucket-deployment-loggroup/Destination",
+ "children": {
+ "Resource": {
+ "id": "Resource",
+ "path": "test-bucket-deployment-loggroup/Destination/Resource",
+ "attributes": {
+ "aws:cdk:cloudformation:type": "AWS::S3::Bucket",
+ "aws:cdk:cloudformation:props": {
+ "tags": [
+ {
+ "key": "aws-cdk:auto-delete-objects",
+ "value": "true"
+ },
+ {
+ "key": "aws-cdk:cr-owned:2058d11c",
+ "value": "true"
+ }
+ ],
+ "websiteConfiguration": {
+ "indexDocument": "index.html"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_s3.CfnBucket",
+ "version": "0.0.0"
+ }
+ },
+ "Policy": {
+ "id": "Policy",
+ "path": "test-bucket-deployment-loggroup/Destination/Policy",
+ "children": {
+ "Resource": {
+ "id": "Resource",
+ "path": "test-bucket-deployment-loggroup/Destination/Policy/Resource",
+ "attributes": {
+ "aws:cdk:cloudformation:type": "AWS::S3::BucketPolicy",
+ "aws:cdk:cloudformation:props": {
+ "bucket": {
+ "Ref": "Destination920A3C57"
+ },
+ "policyDocument": {
+ "Statement": [
+ {
+ "Action": [
+ "s3:DeleteObject*",
+ "s3:GetBucket*",
+ "s3:List*",
+ "s3:PutBucketPolicy"
+ ],
+ "Effect": "Allow",
+ "Principal": {
+ "AWS": {
+ "Fn::GetAtt": [
+ "CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092",
+ "Arn"
+ ]
+ }
+ },
+ "Resource": [
+ {
+ "Fn::GetAtt": [
+ "Destination920A3C57",
+ "Arn"
+ ]
+ },
+ {
+ "Fn::Join": [
+ "",
+ [
+ {
+ "Fn::GetAtt": [
+ "Destination920A3C57",
+ "Arn"
+ ]
+ },
+ "/*"
+ ]
+ ]
+ }
+ ]
+ }
+ ],
+ "Version": "2012-10-17"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_s3.CfnBucketPolicy",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_s3.BucketPolicy",
+ "version": "0.0.0"
+ }
+ },
+ "AutoDeleteObjectsCustomResource": {
+ "id": "AutoDeleteObjectsCustomResource",
+ "path": "test-bucket-deployment-loggroup/Destination/AutoDeleteObjectsCustomResource",
+ "children": {
+ "Default": {
+ "id": "Default",
+ "path": "test-bucket-deployment-loggroup/Destination/AutoDeleteObjectsCustomResource/Default",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.CfnResource",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.CustomResource",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_s3.Bucket",
+ "version": "0.0.0"
+ }
+ },
+ "Custom::S3AutoDeleteObjectsCustomResourceProvider": {
+ "id": "Custom::S3AutoDeleteObjectsCustomResourceProvider",
+ "path": "test-bucket-deployment-loggroup/Custom::S3AutoDeleteObjectsCustomResourceProvider",
+ "children": {
+ "Staging": {
+ "id": "Staging",
+ "path": "test-bucket-deployment-loggroup/Custom::S3AutoDeleteObjectsCustomResourceProvider/Staging",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.AssetStaging",
+ "version": "0.0.0"
+ }
+ },
+ "Role": {
+ "id": "Role",
+ "path": "test-bucket-deployment-loggroup/Custom::S3AutoDeleteObjectsCustomResourceProvider/Role",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.CfnResource",
+ "version": "0.0.0"
+ }
+ },
+ "Handler": {
+ "id": "Handler",
+ "path": "test-bucket-deployment-loggroup/Custom::S3AutoDeleteObjectsCustomResourceProvider/Handler",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.CfnResource",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.CustomResourceProviderBase",
+ "version": "0.0.0"
+ }
+ },
+ "LogGroup": {
+ "id": "LogGroup",
+ "path": "test-bucket-deployment-loggroup/LogGroup",
+ "children": {
+ "Resource": {
+ "id": "Resource",
+ "path": "test-bucket-deployment-loggroup/LogGroup/Resource",
+ "attributes": {
+ "aws:cdk:cloudformation:type": "AWS::Logs::LogGroup",
+ "aws:cdk:cloudformation:props": {
+ "retentionInDays": 1
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_logs.CfnLogGroup",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_logs.LogGroup",
+ "version": "0.0.0"
+ }
+ },
+ "DeployMe": {
+ "id": "DeployMe",
+ "path": "test-bucket-deployment-loggroup/DeployMe",
+ "children": {
+ "AwsCliLayer": {
+ "id": "AwsCliLayer",
+ "path": "test-bucket-deployment-loggroup/DeployMe/AwsCliLayer",
+ "children": {
+ "Code": {
+ "id": "Code",
+ "path": "test-bucket-deployment-loggroup/DeployMe/AwsCliLayer/Code",
+ "children": {
+ "Stage": {
+ "id": "Stage",
+ "path": "test-bucket-deployment-loggroup/DeployMe/AwsCliLayer/Code/Stage",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.AssetStaging",
+ "version": "0.0.0"
+ }
+ },
+ "AssetBucket": {
+ "id": "AssetBucket",
+ "path": "test-bucket-deployment-loggroup/DeployMe/AwsCliLayer/Code/AssetBucket",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_s3.BucketBase",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_s3_assets.Asset",
+ "version": "0.0.0"
+ }
+ },
+ "Resource": {
+ "id": "Resource",
+ "path": "test-bucket-deployment-loggroup/DeployMe/AwsCliLayer/Resource",
+ "attributes": {
+ "aws:cdk:cloudformation:type": "AWS::Lambda::LayerVersion",
+ "aws:cdk:cloudformation:props": {
+ "content": {
+ "s3Bucket": {
+ "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
+ },
+ "s3Key": "3fb6287214999ddeafa7cd0e3e58bc5144c8678bb720f3b5e45e8fd32f333eb3.zip"
+ },
+ "description": "/opt/awscli/aws"
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_lambda.CfnLayerVersion",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.lambda_layer_awscli.AwsCliLayer",
+ "version": "0.0.0"
+ }
+ },
+ "CustomResourceHandler": {
+ "id": "CustomResourceHandler",
+ "path": "test-bucket-deployment-loggroup/DeployMe/CustomResourceHandler",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_lambda.SingletonFunction",
+ "version": "0.0.0"
+ }
+ },
+ "Asset1": {
+ "id": "Asset1",
+ "path": "test-bucket-deployment-loggroup/DeployMe/Asset1",
+ "children": {
+ "Stage": {
+ "id": "Stage",
+ "path": "test-bucket-deployment-loggroup/DeployMe/Asset1/Stage",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.AssetStaging",
+ "version": "0.0.0"
+ }
+ },
+ "AssetBucket": {
+ "id": "AssetBucket",
+ "path": "test-bucket-deployment-loggroup/DeployMe/Asset1/AssetBucket",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_s3.BucketBase",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_s3_assets.Asset",
+ "version": "0.0.0"
+ }
+ },
+ "CustomResource": {
+ "id": "CustomResource",
+ "path": "test-bucket-deployment-loggroup/DeployMe/CustomResource",
+ "children": {
+ "Default": {
+ "id": "Default",
+ "path": "test-bucket-deployment-loggroup/DeployMe/CustomResource/Default",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.CfnResource",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.CustomResource",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_s3_deployment.BucketDeployment",
+ "version": "0.0.0"
+ }
+ },
+ "Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C": {
+ "id": "Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C",
+ "path": "test-bucket-deployment-loggroup/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C",
+ "children": {
+ "ServiceRole": {
+ "id": "ServiceRole",
+ "path": "test-bucket-deployment-loggroup/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/ServiceRole",
+ "children": {
+ "ImportServiceRole": {
+ "id": "ImportServiceRole",
+ "path": "test-bucket-deployment-loggroup/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/ServiceRole/ImportServiceRole",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.Resource",
+ "version": "0.0.0"
+ }
+ },
+ "Resource": {
+ "id": "Resource",
+ "path": "test-bucket-deployment-loggroup/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/ServiceRole/Resource",
+ "attributes": {
+ "aws:cdk:cloudformation:type": "AWS::IAM::Role",
+ "aws:cdk:cloudformation:props": {
+ "assumeRolePolicyDocument": {
+ "Statement": [
+ {
+ "Action": "sts:AssumeRole",
+ "Effect": "Allow",
+ "Principal": {
+ "Service": "lambda.amazonaws.com"
+ }
+ }
+ ],
+ "Version": "2012-10-17"
+ },
+ "managedPolicyArns": [
+ {
+ "Fn::Join": [
+ "",
+ [
+ "arn:",
+ {
+ "Ref": "AWS::Partition"
+ },
+ ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
+ ]
+ ]
+ }
+ ]
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_iam.CfnRole",
+ "version": "0.0.0"
+ }
+ },
+ "DefaultPolicy": {
+ "id": "DefaultPolicy",
+ "path": "test-bucket-deployment-loggroup/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/ServiceRole/DefaultPolicy",
+ "children": {
+ "Resource": {
+ "id": "Resource",
+ "path": "test-bucket-deployment-loggroup/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/ServiceRole/DefaultPolicy/Resource",
+ "attributes": {
+ "aws:cdk:cloudformation:type": "AWS::IAM::Policy",
+ "aws:cdk:cloudformation:props": {
+ "policyDocument": {
+ "Statement": [
+ {
+ "Action": [
+ "s3:GetBucket*",
+ "s3:GetObject*",
+ "s3:List*"
+ ],
+ "Effect": "Allow",
+ "Resource": [
+ {
+ "Fn::Join": [
+ "",
+ [
+ "arn:",
+ {
+ "Ref": "AWS::Partition"
+ },
+ ":s3:::",
+ {
+ "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
+ },
+ "/*"
+ ]
+ ]
+ },
+ {
+ "Fn::Join": [
+ "",
+ [
+ "arn:",
+ {
+ "Ref": "AWS::Partition"
+ },
+ ":s3:::",
+ {
+ "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
+ }
+ ]
+ ]
+ }
+ ]
+ },
+ {
+ "Action": [
+ "s3:Abort*",
+ "s3:DeleteObject*",
+ "s3:GetBucket*",
+ "s3:GetObject*",
+ "s3:List*",
+ "s3:PutObject",
+ "s3:PutObjectLegalHold",
+ "s3:PutObjectRetention",
+ "s3:PutObjectTagging",
+ "s3:PutObjectVersionTagging"
+ ],
+ "Effect": "Allow",
+ "Resource": [
+ {
+ "Fn::GetAtt": [
+ "Destination920A3C57",
+ "Arn"
+ ]
+ },
+ {
+ "Fn::Join": [
+ "",
+ [
+ {
+ "Fn::GetAtt": [
+ "Destination920A3C57",
+ "Arn"
+ ]
+ },
+ "/*"
+ ]
+ ]
+ }
+ ]
+ }
+ ],
+ "Version": "2012-10-17"
+ },
+ "policyName": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF",
+ "roles": [
+ {
+ "Ref": "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265"
+ }
+ ]
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_iam.CfnPolicy",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_iam.Policy",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_iam.Role",
+ "version": "0.0.0"
+ }
+ },
+ "Code": {
+ "id": "Code",
+ "path": "test-bucket-deployment-loggroup/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/Code",
+ "children": {
+ "Stage": {
+ "id": "Stage",
+ "path": "test-bucket-deployment-loggroup/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/Code/Stage",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.AssetStaging",
+ "version": "0.0.0"
+ }
+ },
+ "AssetBucket": {
+ "id": "AssetBucket",
+ "path": "test-bucket-deployment-loggroup/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/Code/AssetBucket",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_s3.BucketBase",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_s3_assets.Asset",
+ "version": "0.0.0"
+ }
+ },
+ "Resource": {
+ "id": "Resource",
+ "path": "test-bucket-deployment-loggroup/Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C/Resource",
+ "attributes": {
+ "aws:cdk:cloudformation:type": "AWS::Lambda::Function",
+ "aws:cdk:cloudformation:props": {
+ "code": {
+ "s3Bucket": {
+ "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
+ },
+ "s3Key": "e976a796f036a5efbf44b99e44cfb5a961df08d8dbf7cd37e60bf216fb982a00.zip"
+ },
+ "environment": {
+ "variables": {
+ "AWS_CA_BUNDLE": "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"
+ }
+ },
+ "handler": "index.handler",
+ "layers": [
+ {
+ "Ref": "DeployMeAwsCliLayer5F9219E9"
+ }
+ ],
+ "loggingConfig": {
+ "logGroup": {
+ "Ref": "LogGroupF5B46931"
+ }
+ },
+ "role": {
+ "Fn::GetAtt": [
+ "CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265",
+ "Arn"
+ ]
+ },
+ "runtime": "python3.9",
+ "timeout": 900
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_lambda.CfnFunction",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.aws_lambda.Function",
+ "version": "0.0.0"
+ }
+ },
+ "BootstrapVersion": {
+ "id": "BootstrapVersion",
+ "path": "test-bucket-deployment-loggroup/BootstrapVersion",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.CfnParameter",
+ "version": "0.0.0"
+ }
+ },
+ "CheckBootstrapVersion": {
+ "id": "CheckBootstrapVersion",
+ "path": "test-bucket-deployment-loggroup/CheckBootstrapVersion",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.CfnRule",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.Stack",
+ "version": "0.0.0"
+ }
+ },
+ "integ-test-bucket-deployment-loggroup": {
+ "id": "integ-test-bucket-deployment-loggroup",
+ "path": "integ-test-bucket-deployment-loggroup",
+ "children": {
+ "DefaultTest": {
+ "id": "DefaultTest",
+ "path": "integ-test-bucket-deployment-loggroup/DefaultTest",
+ "children": {
+ "Default": {
+ "id": "Default",
+ "path": "integ-test-bucket-deployment-loggroup/DefaultTest/Default",
+ "constructInfo": {
+ "fqn": "constructs.Construct",
+ "version": "10.3.0"
+ }
+ },
+ "DeployAssert": {
+ "id": "DeployAssert",
+ "path": "integ-test-bucket-deployment-loggroup/DefaultTest/DeployAssert",
+ "children": {
+ "BootstrapVersion": {
+ "id": "BootstrapVersion",
+ "path": "integ-test-bucket-deployment-loggroup/DefaultTest/DeployAssert/BootstrapVersion",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.CfnParameter",
+ "version": "0.0.0"
+ }
+ },
+ "CheckBootstrapVersion": {
+ "id": "CheckBootstrapVersion",
+ "path": "integ-test-bucket-deployment-loggroup/DefaultTest/DeployAssert/CheckBootstrapVersion",
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.CfnRule",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.Stack",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase",
+ "version": "0.0.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "@aws-cdk/integ-tests-alpha.IntegTest",
+ "version": "0.0.0"
+ }
+ },
+ "Tree": {
+ "id": "Tree",
+ "path": "Tree",
+ "constructInfo": {
+ "fqn": "constructs.Construct",
+ "version": "10.3.0"
+ }
+ }
+ },
+ "constructInfo": {
+ "fqn": "aws-cdk-lib.App",
+ "version": "0.0.0"
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.ts
new file mode 100644
index 0000000000000..4de6431391377
--- /dev/null
+++ b/packages/@aws-cdk-testing/framework-integ/test/aws-s3-deployment/test/integ.bucket-deployment-loggroup.ts
@@ -0,0 +1,40 @@
+import * as path from 'path';
+import * as logs from 'aws-cdk-lib/aws-logs';
+import * as s3 from 'aws-cdk-lib/aws-s3';
+import * as cdk from 'aws-cdk-lib';
+import * as integ from '@aws-cdk/integ-tests-alpha';
+import { Construct } from 'constructs';
+import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment';
+
+class TestBucketDeployment extends cdk.Stack {
+ constructor(scope: Construct, id: string, props?: cdk.StackProps) {
+ super(scope, id, props);
+
+ const destinationBucket = new s3.Bucket(this, 'Destination', {
+ websiteIndexDocument: 'index.html',
+ publicReadAccess: false,
+ removalPolicy: cdk.RemovalPolicy.DESTROY,
+ autoDeleteObjects: true, // needed for integration test cleanup
+ });
+
+ new s3deploy.BucketDeployment(this, 'DeployMe', {
+ sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
+ destinationBucket,
+ logGroup: new logs.LogGroup(this, 'LogGroup', {
+ retention: logs.RetentionDays.ONE_DAY,
+ removalPolicy: cdk.RemovalPolicy.DESTROY, // cleanup integ test
+ }),
+ retainOnDelete: false, // default is true, which will block the integration test cleanup
+ });
+ }
+}
+
+const app = new cdk.App();
+const testCase = new TestBucketDeployment(app, 'test-bucket-deployment-loggroup');
+
+new integ.IntegTest(app, 'integ-test-bucket-deployment-loggroup', {
+ testCases: [testCase],
+ diffAssets: false,
+});
+
+app.synth();
diff --git a/packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts b/packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts
index f0f7148f8801d..ea2c6fb36f922 100644
--- a/packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts
+++ b/packages/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.ts
@@ -112,9 +112,17 @@ export interface BucketDeploymentProps {
* The number of days that the lambda function's log events are kept in CloudWatch Logs.
*
* @default logs.RetentionDays.INFINITE
+ * @deprecated Use logGroup for full control over the custom resource log group
*/
readonly logRetention?: logs.RetentionDays;
+ /**
+ * The Log Group used for logging of events emitted by the custom resource's lambda function.
+ *
+ * @default - a default log group created by AWS Lambda
+ */
+ readonly logGroup?: logs.ILogGroup;
+
/**
* The amount of memory (in MiB) to allocate to the AWS Lambda function which
* replicates the files from the CDK bucket to the destination bucket.
@@ -336,7 +344,10 @@ export class BucketDeployment extends Construct {
accessPoint,
mountPath,
) : undefined,
- logRetention: props.logRetention,
+ // props.logRetention is deprecated, make sure we only set it if it is actually provided
+ // otherwise jsii will print warnings even for users that don't use this directly
+ ...(props.logRetention ? { logRetention: props.logRetention } : {}),
+ logGroup: props.logGroup,
});
const handlerRole = handler.role;
diff --git a/packages/aws-cdk-lib/aws-s3-deployment/test/bucket-deployment.test.ts b/packages/aws-cdk-lib/aws-s3-deployment/test/bucket-deployment.test.ts
index f4cb9b8807678..d846be05a57e6 100644
--- a/packages/aws-cdk-lib/aws-s3-deployment/test/bucket-deployment.test.ts
+++ b/packages/aws-cdk-lib/aws-s3-deployment/test/bucket-deployment.test.ts
@@ -92,6 +92,24 @@ test('deploy with configured log retention', () => {
Template.fromStack(stack).hasResourceProperties('Custom::LogRetention', { RetentionInDays: 7 });
});
+test('deploy with log group', () => {
+ // GIVEN
+ const stack = new cdk.Stack();
+ const bucket = new s3.Bucket(stack, 'Dest');
+
+ // WHEN
+ new s3deploy.BucketDeployment(stack, 'Deploy', {
+ sources: [s3deploy.Source.asset(path.join(__dirname, 'my-website'))],
+ destinationBucket: bucket,
+ logGroup: new logs.LogGroup(stack, 'LogGroup', {
+ retention: logs.RetentionDays.ONE_WEEK,
+ }),
+ });
+
+ // THEN
+ Template.fromStack(stack).hasResourceProperties('AWS::Logs::LogGroup', { RetentionInDays: 7 });
+});
+
test('deploy from local directory assets', () => {
// GIVEN
const app = new cdk.App({ context: { [cxapi.NEW_STYLE_STACK_SYNTHESIS_CONTEXT]: false } });
diff --git a/packages/aws-cdk-lib/custom-resources/README.md b/packages/aws-cdk-lib/custom-resources/README.md
index d3c57bea20ddc..1677afcfa19f1 100644
--- a/packages/aws-cdk-lib/custom-resources/README.md
+++ b/packages/aws-cdk-lib/custom-resources/README.md
@@ -41,7 +41,9 @@ declare const myRole: iam.Role;
const myProvider = new cr.Provider(this, 'MyProvider', {
onEventHandler: onEvent,
isCompleteHandler: isComplete, // optional async "waiter"
- logRetention: logs.RetentionDays.ONE_DAY, // default is INFINITE
+ logGroup: new logs.LogGroup(this, 'MyProviderLogs', {
+ retention: logs.RetentionDays.ONE_DAY,
+ }),
role: myRole, // must be assumable by the `lambda.amazonaws.com` service principal
});
@@ -382,7 +384,9 @@ declare const myRole: iam.Role;
const myProvider = new cr.Provider(this, 'MyProvider', {
onEventHandler: onEvent,
isCompleteHandler: isComplete,
- logRetention: logs.RetentionDays.ONE_DAY,
+ logGroup: new logs.LogGroup(this, 'MyProviderLogs', {
+ retention: logs.RetentionDays.ONE_DAY,
+ }),
role: myRole,
providerFunctionName: 'the-lambda-name', // Optional
});
@@ -404,7 +408,9 @@ const key = new kms.Key(this, 'MyKey');
const myProvider = new cr.Provider(this, 'MyProvider', {
onEventHandler: onEvent,
isCompleteHandler: isComplete,
- logRetention: logs.RetentionDays.ONE_DAY,
+ logGroup: new logs.LogGroup(this, 'MyProviderLogs', {
+ retention: logs.RetentionDays.ONE_DAY,
+ }),
role: myRole,
providerFunctionEnvEncryption: key, // Optional
});
@@ -536,7 +542,7 @@ In both the cases, you will get a synth time error if you attempt to use it in c
### Customizing the Lambda function implementing the custom resource
-Use the `role`, `timeout`, `logRetention`, `functionName` and `removalPolicy` properties to customize
+Use the `role`, `timeout`, `logGroup`, `functionName` and `removalPolicy` properties to customize
the Lambda function implementing the custom resource:
```ts
@@ -544,7 +550,9 @@ declare const myRole: iam.Role;
new cr.AwsCustomResource(this, 'Customized', {
role: myRole, // must be assumable by the `lambda.amazonaws.com` service principal
timeout: Duration.minutes(10), // defaults to 2 minutes
- logRetention: logs.RetentionDays.ONE_WEEK, // defaults to never delete logs
+ logGroup: new logs.LogGroup(this, 'AwsCustomResourceLogs', {
+ retention: logs.RetentionDays.ONE_DAY,
+ }),
functionName: 'my-custom-name', // defaults to a CloudFormation generated name
removalPolicy: RemovalPolicy.RETAIN, // defaults to `RemovalPolicy.DESTROY`
policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
diff --git a/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts b/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts
index e9c0da466015e..57f0317505686 100644
--- a/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts
+++ b/packages/aws-cdk-lib/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts
@@ -330,9 +330,17 @@ export interface AwsCustomResourceProps {
* this custom resource are kept in CloudWatch Logs.
*
* @default logs.RetentionDays.INFINITE
+ * @deprecated Use logGroup for full control over the custom resource log group
*/
readonly logRetention?: logs.RetentionDays;
+ /**
+ * The Log Group used for logging of events emitted by the custom resource's lambda function.
+ *
+ * @default - a default log group created by AWS Lambda
+ */
+ readonly logGroup?: logs.ILogGroup;
+
/**
* Whether to install the latest AWS SDK v2.
*
@@ -450,7 +458,10 @@ export class AwsCustomResource extends Construct implements iam.IGrantable {
lambdaPurpose: 'AWS',
timeout: props.timeout || cdk.Duration.minutes(2),
role: props.role,
- logRetention: props.logRetention,
+ // props.logRetention is deprecated, make sure we only set it if it is actually provided
+ // otherwise jsii will print warnings even for users that don't use this directly
+ ...(props.logRetention ? { logRetention: props.logRetention } : {}),
+ logGroup: props.logGroup,
functionName: props.functionName,
vpc: props.vpc,
vpcSubnets: props.vpcSubnets,
diff --git a/packages/aws-cdk-lib/custom-resources/lib/provider-framework/provider.ts b/packages/aws-cdk-lib/custom-resources/lib/provider-framework/provider.ts
index 394570aeefcc2..5b15f71ed6eed 100644
--- a/packages/aws-cdk-lib/custom-resources/lib/provider-framework/provider.ts
+++ b/packages/aws-cdk-lib/custom-resources/lib/provider-framework/provider.ts
@@ -71,9 +71,17 @@ export interface ProviderProps {
* To remove the retention policy, set the value to `INFINITE`.
*
* @default logs.RetentionDays.INFINITE
+ * @deprecated Use logGroup for full control over the custom resource log group
*/
readonly logRetention?: logs.RetentionDays;
+ /**
+ * The Log Group used for logging of events emitted by the custom resource's lambda function.
+ *
+ * @default - a default log group created by AWS Lambda
+ */
+ readonly logGroup?: logs.ILogGroup;
+
/**
* The vpc to provision the lambda functions in.
*
@@ -153,6 +161,7 @@ export class Provider extends Construct implements ICustomResourceProvider {
private readonly entrypoint: lambda.Function;
private readonly logRetention?: logs.RetentionDays;
+ private readonly logGroup?: logs.ILogGroup;
private readonly vpc?: ec2.IVpc;
private readonly vpcSubnets?: ec2.SubnetSelection;
private readonly securityGroups?: ec2.ISecurityGroup[];
@@ -171,6 +180,7 @@ export class Provider extends Construct implements ICustomResourceProvider {
this.isCompleteHandler = props.isCompleteHandler;
this.logRetention = props.logRetention;
+ this.logGroup = props.logGroup;
this.vpc = props.vpc;
this.vpcSubnets = props.vpcSubnets;
this.securityGroups = props.securityGroups;
@@ -220,7 +230,10 @@ export class Provider extends Construct implements ICustomResourceProvider {
runtime: lambda.Runtime.NODEJS_18_X,
handler: `framework.${entrypoint}`,
timeout: FRAMEWORK_HANDLER_TIMEOUT,
- logRetention: this.logRetention,
+ // props.logRetention is deprecated, make sure we only set it if it is actually provided
+ // otherwise jsii will print warnings even for users that don't use this directly
+ ...(this.logRetention ? { logRetention: this.logRetention } : {}),
+ logGroup: this.logGroup,
vpc: this.vpc,
vpcSubnets: this.vpcSubnets,
securityGroups: this.securityGroups,
diff --git a/packages/aws-cdk-lib/custom-resources/test/aws-custom-resource/aws-custom-resource.test.ts b/packages/aws-cdk-lib/custom-resources/test/aws-custom-resource/aws-custom-resource.test.ts
index d81086f182b29..e555287e38937 100644
--- a/packages/aws-cdk-lib/custom-resources/test/aws-custom-resource/aws-custom-resource.test.ts
+++ b/packages/aws-cdk-lib/custom-resources/test/aws-custom-resource/aws-custom-resource.test.ts
@@ -869,6 +869,31 @@ test('can specify log retention', () => {
});
});
+test('can specify log group', () => {
+ // GIVEN
+ const stack = new cdk.Stack();
+
+ // WHEN
+ new AwsCustomResource(stack, 'AwsSdk', {
+ onCreate: {
+ service: 'service',
+ action: 'action',
+ physicalResourceId: PhysicalResourceId.of('id'),
+ },
+ logGroup: new logs.LogGroup(stack, 'LogGroup', {
+ logGroupName: '/test/log/group/name',
+ retention: logs.RetentionDays.ONE_WEEK,
+ }),
+ policy: AwsCustomResourcePolicy.fromSdkCalls({ resources: AwsCustomResourcePolicy.ANY_RESOURCE }),
+ });
+
+ // THEN
+ Template.fromStack(stack).hasResourceProperties('AWS::Logs::LogGroup', {
+ LogGroupName: '/test/log/group/name',
+ RetentionInDays: 7,
+ });
+});
+
test('disable AWS SDK installation', () => {
// GIVEN
const stack = new cdk.Stack();
diff --git a/packages/aws-cdk-lib/custom-resources/test/provider-framework/provider.test.ts b/packages/aws-cdk-lib/custom-resources/test/provider-framework/provider.test.ts
index 3c4989f4c567b..5cd5d0d6e15f9 100644
--- a/packages/aws-cdk-lib/custom-resources/test/provider-framework/provider.test.ts
+++ b/packages/aws-cdk-lib/custom-resources/test/provider-framework/provider.test.ts
@@ -343,6 +343,30 @@ describe('log retention', () => {
});
});
+it('can specify log group', () => {
+ // GIVEN
+ const stack = new Stack();
+
+ // WHEN
+ new cr.Provider(stack, 'MyProvider', {
+ onEventHandler: new lambda.Function(stack, 'MyHandler', {
+ code: new lambda.InlineCode('foo'),
+ handler: 'index.onEvent',
+ runtime: lambda.Runtime.NODEJS_LATEST,
+ }),
+ logGroup: new logs.LogGroup(stack, 'LogGroup', {
+ logGroupName: '/test/log/group/name',
+ retention: logs.RetentionDays.ONE_WEEK,
+ }),
+ });
+
+ // THEN
+ Template.fromStack(stack).hasResourceProperties('AWS::Logs::LogGroup', {
+ LogGroupName: '/test/log/group/name',
+ RetentionInDays: 7,
+ });
+});
+
describe('role', () => {
it('uses custom role when present', () => {
// GIVEN