From 90b078803c3ac623f97f430b786f2a49ec352746 Mon Sep 17 00:00:00 2001 From: Tarun Menon <64295670+tarunmenon95@users.noreply.github.com> Date: Wed, 6 Dec 2023 12:15:58 +1100 Subject: [PATCH] Feature/fix metadata append (#3) * Fix append call to dict for metadata * Add property for metadata * Add metadata parameter from config --- lambdas/s3_deployer.py | 2 +- s3-deployer.cfndsl.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lambdas/s3_deployer.py b/lambdas/s3_deployer.py index 461d05c..9eba1d9 100644 --- a/lambdas/s3_deployer.py +++ b/lambdas/s3_deployer.py @@ -82,7 +82,7 @@ def deploy_artifact(source_bucket, zip_key, dest_bucket, dest_key='', filters=[] content_type = mimetypes.guess_type(filename)[0] if content_type is None: content_type = 'binary/octet-stream' - metadata.append({'deployment': zip_key}) + metadata['deployment'] = zip_key s3_resource.meta.client.upload_fileobj( filter_deployment(filename, z.open(filename), filters), Bucket=dest_bucket, diff --git a/s3-deployer.cfndsl.rb b/s3-deployer.cfndsl.rb index b4dcbbd..2c20241 100644 --- a/s3-deployer.cfndsl.rb +++ b/s3-deployer.cfndsl.rb @@ -2,6 +2,7 @@ CloudFormation do deployment_filter = external_parameters.fetch(:deployment_filter, nil) + deployment_metadata = external_parameters.fetch(:deployment_metadata, nil) Resource("S3DeployerCR") do Type 'Custom::S3Deployer' @@ -11,6 +12,7 @@ Property 'DeploymentBucket', Ref(:DeploymentBucket) Property 'DeploymentKey', Ref(:DeploymentKey) Property 'DeploymentFilter', FnSub(deployment_filter.to_json()) unless deployment_filter.nil? + Property 'DeploymentMetaData', FnSub(deployment_metadata.to_json()) unless deployment_metadata.nil? end end \ No newline at end of file