Last active
February 13, 2024 22:22
-
-
Save CarlosDomingues/09cf89f29c9c4c4f39e8ac2d1764a7ee to your computer and use it in GitHub Desktop.
Implementing aws_cdk.core.ILocalBundling in Python (avoids using Docker for bundling)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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