awslabs / aws-solutions-constructs

The AWS Solutions Constructs Library is an open-source extension of the AWS Cloud Development Kit (AWS CDK) that provides multi-service, well-architected patterns for quickly defining solutions
https://docs.aws.amazon.com/solutions/latest/constructs/
Apache License 2.0
1.21k stars 247 forks source link

aws_eventbridge_lambdam- Issue with cdk synth when using existing role for lambda and overrideWarningsEnabled=true #1057

Open vkondareddy-godaddy opened 7 months ago

vkondareddy-godaddy commented 7 months ago

aws_eventbridge_lambda - Using existing role for lambda has issue with cdk synth when overrideWarningsEnabled=true

Reproduction Steps

EventbridgeToLambda( self, "EventbridgeToLambda", lambda_functionprops=lambda.FunctionProps( code=lambda_.InlineCode(lambda_code), handler="index.lambdahandler", runtime=lambda.Runtime.PYTHON_3_9, role=iam.Role.from_role_arn( self, id="x", role_arn="arn:aws:iam::numbers:path/rolename" ), ), event_rule_props=events.RuleProps( events.Schedule.rate( Duration.hours(1) ) ), )

Error Log

cdk ls or listing stack doesn't work with overrideWarningsEnabled=true

stack trace:

from aws_solutions_constructs.aws_eventbridge_lambda import ( File "\site-packages\aws_solutions_constructs\ aws_eventbridge_lambda__init.py", line 157, in from ._jsii import File "\site-packages\aws_solutions_constructs\ aws_eventbridge_lambda_jsii__init__.py", line 14, in import aws_solutions_constructs.core._jsii File "\site-packages\aws_solutions_constructs\ core__init__.py", line 96, in from ._jsii import File "\site-packages\aws_solutions_constructs\ core_jsii__init.py", line 16, in jsii_assembly = jsii.JSIIAssembly.load( File "\site-packages\jsii_runtime.py", line 5 5, in load _kernel.load(assembly.name, assembly.version, os.fspath(assembly_path)) File "\site-packages\jsii_kernel__init__.py" , line 299, in load self.provider.load(LoadRequest(name=name, version=version, tarball=tarball)) File "\site-packages\jsii_kernel\providers\pr ocess.py", line 354, in load return self._process.send(request, LoadResponse) File "\site-packages\jsii_kernel\providers\pr ocess.py", line 332, in send self._next_message(), _ProcessResponse File "\site-packages\jsii_kernel\providers\pr ocess.py", line 251, in _next_message return json.loads(self._process.stdout.readline(), object_hook=ohook) KeyboardInterrupt Error in atexit._run_exitfuncs: ocess.py", line 295, in stop self._process.stdin.close() OSError: [Errno 22] Invalid argument

Environment

Other


This is :bug: Bug Report

biffgaut commented 7 months ago

Thanks - we'll take a look

vkondareddy-godaddy commented 7 months ago

Error log:

PS > cdk ls WARN AWS_SOLUTIONS_CONSTRUCTS_WARNING: An override has been provided for the property: tracing. Default value: 'Active'. You provided: 'Disabled'.
WARN AWS_SOLUTIONS_CONSTRUCTS_WARNING: An override has been provided for the property: tracing. Default value: 'Active'. You provided: 'Disabled'.
WARN AWS_SOLUTIONS_CONSTRUCTS_WARNING: An override has been provided for the property: encryption. Default value: 'KMS_MANAGED'. You provided: 'NONE'.

<--- Last few GCs --->

[16664:000002983F337660] 1430913 ms: Mark-sweep 3809.7 (4101.4) -> 3793.7 (4101.4) MB, 40288.8 / 0.0 ms (average mu = 0.057, current mu = 0.020) allocation failure; scavenge might not succeed [16664:000002983F337660] 1442511 ms: Mark-sweep 3809.5 (4101.4) -> 3793.8 (4101.6) MB, 11548.4 / 0.0 ms (average mu = 0.041, current mu = 0.004) allocation failure; scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 00007FF668241C7F node_api_throw_syntax_error+175855 2: 00007FF6681C6476 EVP_MD_meth_get_input_blocksize+59654 3: 00007FF6681C8160 EVP_MD_meth_get_input_blocksize+67056 4: 00007FF668C70434 v8::Isolate::ReportExternalAllocationLimitReached+116 5: 00007FF668C5B7C2 v8::Isolate::Exit+674 6: 00007FF668ADD65C v8::internal::EmbedderStackStateScope::ExplicitScopeForTesting+124 7: 00007FF668AEA93D v8::internal::Heap::PublishPendingAllocations+1117 8: 00007FF668AE79C7 v8::internal::Heap::PageFlagsAreConsistent+3367 9: 00007FF668ADA0F7 v8::internal::Heap::CollectGarbage+2039 10: 00007FF668AF0AB3 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath+2099 11: 00007FF668AF135D v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath+93 12: 00007FF668B00B20 v8::internal::Factory::NewFillerObject+816 13: 00007FF6687F1565 v8::internal::DateCache::Weekday+1349 14: 00007FF668D0D961 v8::internal::SetupIsolateDelegate::SetupHeap+558193 15: 00007FF5E92057DA Traceback (most recent call last): File "\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "\cdk\app.py", line 388, in main() File "\cdk\app.py", line 375, in main EventBridgeLambdaStack( File "\lib\site-packages\jsii_runtime.py", line 118, in call inst = super(JSIIMeta, cast(JSIIMeta, cls)).call(*args, *kwargs) File "\lambda_stack.py", line 61, in init event_bridge_lambda = EventbridgeToLambda( File "\lib\site-packages\jsii_runtime.py", line 118, in call inst = super(JSIIMeta, cast(JSIIMeta, cls)).call(args, kwargs) File "\lib\site-packages\aws_solutions_constructs\aws_eventbridge_lambda__init.py", line 204, in init jsii.create(self.class, self, [scope, id, props]) File "\lib\site-packages\jsii_kernel__init__.py", line 334, in create response = self.provider.create( File "\lib\site-packages\jsii_kernel\providers\process.py", line 365, in create return self._process.send(request, CreateResponse) File "\lib\site-packages\jsii_kernel\providers\process.py", line 332, in send self._next_message(), _ProcessResponse File "\lib\site-packages\jsii_kernel\providers\process.py", line 251, in _next_message return json.loads(self._process.stdout.readline(), object_hook=ohook) File "\AppData\Local\Programs\Python\Python39\lib\json\init__.py", line 359, in loads return cls(kw).decode(s) File "\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) Error in atexit._run_exitfuncs: Traceback (most recent call last): File "\lib\site-packages\jsii_kernel\providers\process.py", line 295, in stop self._process.stdin.close() OSError: [Errno 22] Invalid argument

biffgaut commented 7 months ago

When we try to replicate this, we're not seeing the same error - but we are seeing an error. We'll fix the error we're seeing and let you know when it's available. You can try the new version and see if it addresses your issue as well.

biffgaut commented 7 months ago

v2.50.0 corrects a problem when a role is provided in LambdaFunctionProps, please give it a try and see if it addresses your issue. Thanks.

biffgaut commented 7 months ago

Correction - try 2.51.0, we had some version issues in 2.50.0 (unrelated to this issue)

vkondareddy-godaddy commented 7 months ago

Hi @biffgaut, I tried with new version 2.51.0, but still seeing the same issue. I guess may be issue is with too many override warnings. I have around 5 stacks where I am using aws-solution-constructs and overriding default settings.

Here's the error log: <--- Last few GCs --->

[14484:0000012F5C40A5C0] 1650071 ms: Mark-sweep 3834.0 (4101.3) -> 3818.2 (4101.5) MB, 14059.9 / 0.0 ms (average mu = 0.091, current mu = 0.025) a llocation failure; scavenge might not succeed [14484:0000012F5C40A5C0] 1728779 ms: Mark-sweep 3834.2 (4101.5) -> 3818.3 (4101.5) MB, 78634.0 / 0.0 ms (average mu = 0.015, current mu = 0.001) a llocation failure; scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 00007FF603311C7F node_api_throw_syntax_error+175855 2: 00007FF603296476 EVP_MD_meth_get_input_blocksize+59654 3: 00007FF603298160 EVP_MD_meth_get_input_blocksize+67056 4: 00007FF603D40434 v8::Isolate::ReportExternalAllocationLimitReached+116 5: 00007FF603D2B7C2 v8::Isolate::Exit+674 6: 00007FF603BAD65C v8::internal::EmbedderStackStateScope::ExplicitScopeForTesting+124 7: 00007FF603BBA93D v8::internal::Heap::PublishPendingAllocations+1117 8: 00007FF603BB79C7 v8::internal::Heap::PageFlagsAreConsistent+3367 9: 00007FF603BAA0F7 v8::internal::Heap::CollectGarbage+2039 10: 00007FF603BC0AB3 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath+2099 11: 00007FF603BC135D v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath+93 12: 00007FF603BD0B20 v8::internal::Factory::NewFillerObject+816 13: 00007FF6038C1565 v8::internal::DateCache::Weekday+1349 14: 00007FF603DDD961 v8::internal::SetupIsolateDelegate::SetupHeap+558193 15: 00007FF603D63472 v8::internal::SetupIsolateDelegate::SetupHeap+57218 16: 00007FF58430C76D Traceback (most recent call last): File "\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "\cdk\app.py", line 388, in main() File "\cdk\app.py", line 375, in main LambdaStack( File "\AppData\Local\pypoetry\Cache\virtualenvs-Lxi7jqtO-py3.9\lib\site-packages\jsii_runtime.py", line 1 18, in call inst = super(JSIIMeta, cast(JSIIMeta, cls)).call(*args, *kwargs) File "\cdk\lambda_stack.py", line 61, in init
event_bridge_lambda = EventbridgeToLambda( File "\AppData\Local\pypoetry\Cache\virtualenvs-Lxi7jqtO-py3.9\lib\site-packages\jsii_runtime.py", line 1 18, in call inst = super(JSIIMeta, cast(JSIIMeta, cls)).call(
args, **kwargs) File "\AppData\Local\pypoetry\Cache\virtualenvs-Lxi7jqtO-py3.9\lib\site-packages\aws_solutions_constructs\ aws_eventbridge_lambda__init.py", line 204, in init jsii.create(self.class, self, [scope, id, props]) File "\AppData\Local\pypoetry\Cache\virtualenvs-Lxi7jqtO-py3.9\lib\site-packages\jsii_kernel\init__.py" , line 334, in create response = self.provider.create( File "\AppData\Local\pypoetry\Cache\virtualenvs-Lxi7jqtO-py3.9\lib\site-packages\jsii_kernel\providers\pr ocess.py", line 365, in create return self._process.send(request, CreateResponse) File "\AppData\Local\pypoetry\Cache\virtualenvs-Lxi7jqtO-py3.9\lib\site-packages\jsii_kernel\providers\pr ocess.py", line 332, in send self._next_message(), _ProcessResponse File "\AppData\Local\pypoetry\Cache\virtualenvs-Lxi7jqtO-py3.9\lib\site-packages\jsii_kernel\providers\pr ocess.py", line 251, in _next_message return json.loads(self._process.stdout.readline(), object_hook=ohook) obj, end = self.raw_decode(s, idx=_w(s, 0).end())

biffgaut commented 7 months ago

Does it work when overrideWarnings is set to false?

vkondareddy-godaddy commented 7 months ago

Yes, it works when overrideWarnings is set to false

Get Outlook for iOShttps://aka.ms/o0ukef


From: biffgaut @.> Sent: Wednesday, January 31, 2024 3:36:45 PM To: awslabs/aws-solutions-constructs @.> Cc: VivekReddy KondaReddy (Contractor) @.>; Author @.> Subject: Re: [awslabs/aws-solutions-constructs] aws_eventbridge_lambdam- Issue with cdk synth when using existing role for lambda and overrideWarningsEnabled=true (Issue #1057)

You don't often get email from @. Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification Caution: This email is from an external sender. Please do not click links or open attachments unless you recognize the sender and know the content is safe. Forward suspicious emails to @.

Does it work when overrideWarnings is set to false?

— Reply to this email directly, view it on GitHubhttps://github.com/awslabs/aws-solutions-constructs/issues/1057#issuecomment-1919914440, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BDZZYNZIX7YQKIK5G65TSTDYRKTN3AVCNFSM6AAAAABCJZFRL2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJZHEYTINBUGA. You are receiving this because you authored the thread.Message ID: @.***>

biffgaut commented 7 months ago

Are all 5 stacks in the same CDK app? It does sound like that could stress memory. Is there any way you can isolate it to the point where you could post code that breaks?

vkondareddy-godaddy commented 7 months ago

Yes all 5 stacks are under same cdk app. I will check with my team and try to post code. But I don't see the same memory problem when "overrideWarnings is set to false". I feel it's issue with the warnings

biffgaut commented 6 months ago

Any additional info you can provide to help us attempt to reproduce the error would be helpful, e.g.-

The Restaurant Management use case in our repo uses 4 independent stacks without a problem.