Skip to content

‼️ (python): NameError: name 'SubnetSelection' is not defined #21790

@anggras

Description

@anggras

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

Status: Fixed in CDK v2.39.1 and v1.170.1

Overview:

CDK Python applications throw a NameError error on synthesis indicating that a name is 'not defined'.

For example when trying to use SubnetSelection

lb = elbv2.ApplicationLoadBalancer(
            self, "MainLB",
            vpc=vpc,
            vpc_subnets={
                'subnet_group_name': "Ingress"
            },
            internet_facing=True
        )

Will throw the error NameError: name 'SubnetSelection' is not defined

Complete Error Message:

Traceback (most recent call last):
  File "/tmp/cdk-tmp-python/app.py", line 10, in <module>
    CdkTmpPythonStack(app, "CdkTmpPythonStack",
  File "/tmp/cdk-tmp-python/.venv/lib/python3.9/site-packages/jsii/_runtime.py", line 86, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/tmp/cdk-tmp-python/cdk_tmp_python/cdk_tmp_python_stack.py", line 24, in __init__
    lb = elbv2.ApplicationLoadBalancer(
  File "/tmp/cdk-tmp-python/.venv/lib/python3.9/site-packages/jsii/_runtime.py", line 86, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/tmp/cdk-tmp-python/.venv/lib/python3.9/site-packages/aws_cdk/aws_elasticloadbalancingv2/__init__.py", line 16381, in __init__
    props = ApplicationLoadBalancerProps(
  File "/tmp/cdk-tmp-python/.venv/lib/python3.9/site-packages/aws_cdk/aws_elasticloadbalancingv2/__init__.py", line 15357, in __init__
    vpc_subnets = SubnetSelection(**vpc_subnets)
NameError: name 'SubnetSelection' is not defined

Workaround:

Currently the only workaround is to stay on v2.38.1

Solution:

Related Issues:

Framework Version

2.39.0

Language

Python

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-ec2Related to Amazon Elastic Compute CloudbugThis issue is a bug.language/pythonRelated to Python bindingsmanagement/trackingIssues that track a subject or multiple issuesp0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions