Skip to content

Instantly share code, notes, and snippets.

@CarlosDomingues
Last active February 13, 2024 22:22
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CarlosDomingues/09cf89f29c9c4c4f39e8ac2d1764a7ee to your computer and use it in GitHub Desktop.
Save CarlosDomingues/09cf89f29c9c4c4f39e8ac2d1764a7ee to your computer and use it in GitHub Desktop.
Implementing aws_cdk.core.ILocalBundling in Python (avoids using Docker for bundling)
from aws_cdk.core import (
BundlingDockerImage,
BundlingOptions,
ILocalBundling
)
from aws_cdk.aws_lambda import Code
from jsii import implements, member
@implements(ILocalBundling)
class MyLocalBundler:
@member(jsii_name="tryBundle")
def try_bundle(self, output_dir: str, options: BundlingOptions) -> bool:
# ... do stuff, return bool ...
return True
my_local_bundler = MyLocalBundler()
my_code = Code.from_asset(
path=path.join(".."),
exclude=["*.pyc"],
asset_hash_type=AssetHashType.BUNDLE,
bundling=BundlingOptions(
image=BundlingDockerImage.from_registry(
"dummy"
), # We are not going to use Docker Bundling, but the image parameter needs to be set.
local=my_local_bundler,
),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment