Skip to content

Instantly share code, notes, and snippets.

@spkjp
Created July 20, 2021 11:02
Show Gist options
  • Save spkjp/dd4861a066b1fd7913c156fb6b3881a6 to your computer and use it in GitHub Desktop.
Save spkjp/dd4861a066b1fd7913c156fb6b3881a6 to your computer and use it in GitHub Desktop.
AWS S3 Deployment Cloudfront WASM MIME type fix
diff --git a/node_modules/@aws-cdk/aws-s3-deployment/lib/lambda/index.py b/node_modules/@aws-cdk/aws-s3-deployment/lib/lambda/index.py
index 3935e31..78c4dc3 100644
--- a/node_modules/@aws-cdk/aws-s3-deployment/lib/lambda/index.py
+++ b/node_modules/@aws-cdk/aws-s3-deployment/lib/lambda/index.py
@@ -134,7 +134,7 @@ def s3_deploy(s3_source_zips, s3_dest, user_metadata, system_metadata, prune):
# sync from "contents" to destination
- s3_command = ["s3", "sync"]
+ s3_command = ["s3", "sync", "--exclude=*.wasm"]
if prune:
s3_command.append("--delete")
@@ -143,6 +143,12 @@ def s3_deploy(s3_source_zips, s3_dest, user_metadata, system_metadata, prune):
s3_command.extend(create_metadata_args(user_metadata, system_metadata))
aws_command(*s3_command)
+ s3_command = ["s3", "sync", "--exclude", "*", "--include", "*.wasm", "--delete"]
+ s3_command.extend([contents_dir, s3_dest])
+ s3_command.extend(create_metadata_args({}, {"Content-Type": "application/wasm"}))
+
+ aws_command(*s3_command)
+
shutil.rmtree(workdir)
#---------------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment