Skip to content

(ec2): Passing PhysicalName.GENERATE_IF_NEEDED to a VPC results in an error #18912

@gshpychka

Description

@gshpychka

What is the problem?

If PhysicalName.GENERATE_IF_NEEDED is passed to the Vpc constructor in vpc_name, it fails to synth.

Reproduction Steps

import aws_cdk as cdk
from aws_cdk import aws_ec2 as ec2

class MyVPC(cdk.Stack):
    def __init__(self, scope, id, **kwargs):
        super().__init__(scope, id, **kwargs)
        ec2.Vpc(self, "vpc", vpc_name=cdk.PhysicalName.GENERATE_IF_NEEDED)

app = cdk.App()

MyVPC(app, "MyVPC")

app.synth()

What did you expect to happen?

Successful synth.

What actually happened?

jsii.errors.JSIIError: Resolution error: Resolution error: Resolution error: Invalid physical name passed to CloudFormation. Use "this.physicalName" instead...

CDK CLI Version

2.12.0

Framework Version

2.10.0

Node.js Version

17.3.0

OS

ArchLinux

Language

Python

Language Version

Python 3.9.10

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-ec2Related to Amazon Elastic Compute CloudbugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions