Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

❗ NOTICE (elasticloadbalancerv2): ApplicationLoadBalancer failing with "RuntimeError: TypeError: Cannot read properties of undefined (reading 'shouldSynthesize')" in v2.106.0 #27928

Closed
ddjordjevic-daon opened this issue Nov 10, 2023 · 4 comments · Fixed by #27948
Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 bug This issue is a bug. effort/medium Medium work item – several days of effort management/tracking Issues that track a subject or multiple issues p0

Comments

@ddjordjevic-daon
Copy link

ddjordjevic-daon commented Nov 10, 2023

Please add your +1 👍 to let us know you have encountered this

Status: COMPLETE

Overview:

#27558 fixed a circular dependency issue between the bucket and the ELB when using logAccessLogs by adding the dependency at the L1 level. The dependency was added on both the bucket and the bucket policy (which already refers to the bucket). This introduced a new bug when adding a dependency for imported buckets (as bucket.node.defaultChild is undefined).

Root cause: #27558
Affected users: CDK users on 2.106.0-2.108.0 using ELB with imported buckets

Complete Error Message:

File "/codebuild/output/src3432/src/s3/01/lib/alb.py", line 108, in __init__
    self.alb.log_access_logs(
  File "/root/.pyenv/versions/3.11.4/lib/python3.11/site-packages/aws_cdk/aws_elasticloadbalancingv2/__init__.py", line 2389, in log_access_logs
    return typing.cast(None, jsii.invoke(self, "logAccessLogs", [bucket, prefix]))
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/3.11.4/lib/python3.11/site-packages/jsii/_kernel/__init__.py", line 149, in wrapped
    return _recursize_dereference(kernel, fn(kernel, *args, **kwargs))
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/3.11.4/lib/python3.11/site-packages/jsii/_kernel/__init__.py", line 399, in invoke
    response = self.provider.invoke(
               ^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/3.11.4/lib/python3.11/site-packages/jsii/_kernel/providers/process.py", line 380, in invoke
    return self._process.send(request, InvokeResponse)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/3.11.4/lib/python3.11/site-packages/jsii/_kernel/providers/process.py", line 342, in send
    raise RuntimeError(resp.error) from JavaScriptError(resp.stack)
RuntimeError: TypeError: Cannot read properties of undefined (reading 'shouldSynthesize')

Workaround:

Downgrade to CDK v2.105.0, or wait for impending release CDK v2.108.1.

Solution:

#27948


Original issue reproduced below:

Describe the bug

I have a code that is creating ALBs with logAccessLogs enabled. I am passing IBucket to the method which I'm getting by referencing the bucket name with S3.fromBucketName method. In version 2.105 this piece of code has worked without any issues. Only after I switched to 2.106 I started getting issues with this. My assumption is that this is related to commit 1b86634 which fixed issue #27528

Expected Behavior

Attach bucket for ALB to use to write access logs.

Current Behavior

Fails with following errors:

File "/codebuild/output/src3432/src/s3/01/lib/alb.py", line 108, in __init__
    self.alb.log_access_logs(
  File "/root/.pyenv/versions/3.11.4/lib/python3.11/site-packages/aws_cdk/aws_elasticloadbalancingv2/__init__.py", line 2389, in log_access_logs
    return typing.cast(None, jsii.invoke(self, "logAccessLogs", [bucket, prefix]))
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/3.11.4/lib/python3.11/site-packages/jsii/_kernel/__init__.py", line 149, in wrapped
    return _recursize_dereference(kernel, fn(kernel, *args, **kwargs))
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/3.11.4/lib/python3.11/site-packages/jsii/_kernel/__init__.py", line 399, in invoke
    response = self.provider.invoke(
               ^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/3.11.4/lib/python3.11/site-packages/jsii/_kernel/providers/process.py", line 380, in invoke
    return self._process.send(request, InvokeResponse)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/3.11.4/lib/python3.11/site-packages/jsii/_kernel/providers/process.py", line 342, in send
    raise RuntimeError(resp.error) from JavaScriptError(resp.stack)
RuntimeError: TypeError: Cannot read properties of undefined (reading 'shouldSynthesize')

Reproduction Steps

self.alb = elbv2.ApplicationLoadBalancer(
    scope, "ALB",
    vpc=vpc,
    internet_facing=internet_facing,
    vpc_subnets=subnets,
    security_group=security_groups[0],
    load_balancer_name=self.name,
    **kwargs
)
self.alb.log_access_logs(
    aws_s3.Bucket.from_bucket_name(
        scope, "ALBLogsBucket", get_alb_bucket_name(vpc_name)
    ),
    ""
)

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.106.0

Framework Version

2.106.0

Node.js Version

18.16.1

OS

aws-codebuild-docker-images/ubuntu/standard/7.0

Language

Python

Language Version

3.11.4

Other information

No response

@ddjordjevic-daon ddjordjevic-daon added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 10, 2023
@github-actions github-actions bot added the @aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 label Nov 10, 2023
@pahud pahud added p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Nov 10, 2023
@pahud
Copy link
Contributor

pahud commented Nov 10, 2023

Yes I ca reproduce this.

const alb = new elbv2.ApplicationLoadBalancer(this, 'ALB', {
	vpc: getDefaultVpc(this),
});

const bucket = s3.Bucket.fromBucketName(this, 'importedBucket', 'my-tmp-us-east-1')
alb.logAccessLogs(bucket);

Error

TypeError: Cannot read properties of undefined (reading 'shouldSynthesize')
    at CfnLoadBalancer.addDependency (/Users/pahud/repo/issue-triage/node_modules/aws-cdk-lib/core/lib/cfn-resource.js:1:5406)
    at ApplicationLoadBalancer.logAccessLogs (/Users/pahud/repo/issue-triage/node_modules/aws-cdk-lib/aws-elasticloadbalancingv2/lib/shared/base-load-balancer.js:1:4960)
    at new Demo (/Users/pahud/repo/issue-triage/lib/issue-triage-stack.ts:108:7)
    at Object.<anonymous> (/Users/pahud/repo/issue-triage/bin/issue-triage.ts:23:1)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module.m._compile (/Users/pahud/repo/issue-triage/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/pahud/repo/issue-triage/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Function.Module._load (node:internal/modules/cjs/loader:958:12)

@olsimin
Copy link

olsimin commented Nov 14, 2023

Yes we have the same problem with the npm module.

@sakshith007
Copy link

Same issue seen with 2.108.0 still .
Installation is with npm install -g aws-cdk@2.105 . Please provide an update

mergify bot added a commit to lpizzinidev/aws-cdk that referenced this issue Nov 14, 2023
@mergify mergify bot closed this as completed in #27948 Nov 14, 2023
mergify bot pushed a commit that referenced this issue Nov 14, 2023
…27948)

#27558 fixed a circular dependency issue between the bucket and the ELB when using `logAccessLogs` by adding the dependency at the L1 level.
The dependency was added on both the bucket and the bucket policy (which already refers to the bucket).

This introduced a new bug when adding a dependency for imported buckets (as `bucket.node.defaultChild` is `undefined`).

This PR fixes the issue by adding the dependency at the L1 level on the bucket policy directly.

Closes #27928.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@kaizencc kaizencc added management/tracking Issues that track a subject or multiple issues p0 and removed p1 needs-review labels Nov 14, 2023
kaizencc pushed a commit that referenced this issue Nov 14, 2023
…27948)

#27558 fixed a circular dependency issue between the bucket and the ELB when using `logAccessLogs` by adding the dependency at the L1 level.
The dependency was added on both the bucket and the bucket policy (which already refers to the bucket).

This introduced a new bug when adding a dependency for imported buckets (as `bucket.node.defaultChild` is `undefined`).

This PR fixes the issue by adding the dependency at the L1 level on the bucket policy directly.

Closes #27928.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@kaizencc kaizencc changed the title ApplicationLoadBalancer: failing call to logAccessLogs after version change from 2.105 to 2.106 ❗ NOTICE (elasticloadbalancerv2): ApplicationLoadBalancer failing with "RuntimeError: TypeError: Cannot read properties of undefined (reading 'shouldSynthesize')" in v2.106.0 Nov 14, 2023
@kaizencc kaizencc pinned this issue Nov 15, 2023
mergify bot pushed a commit to cdklabs/aws-cdk-notices that referenced this issue Nov 30, 2023
@comcalvi comcalvi unpinned this issue Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-elasticloadbalancingv2 Related to Amazon Elastic Load Balancing V2 bug This issue is a bug. effort/medium Medium work item – several days of effort management/tracking Issues that track a subject or multiple issues p0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants