Unable to reference subnet group name tag on an imported VPC #7580
Labels
@aws-cdk/aws-ec2
Related to Amazon Elastic Compute Cloud
bug
This issue is a bug.
needs-triage
This issue or PR still needs to be triaged.
I am not able to reference a custom subnet group name on an imported VPC. I have tried to reference both the default tag (aws-cdk:subnet-name) and also by passing the a custom tag key to the vpc.from_lookup() method. Both to no avail unless I manually prebuild my cdk.context.json and commit to my repo.
This issue seems related to #3650 which is marked as resolved, but does not appear to be functioning as expected.
Reproduction Steps
` vpc = aws_ec2.Vpc.from_lookup(self
, "VPC"
, vpc_name='VPC1'
, subnet_group_name_tag='custom-subnet-group-tag-name'
)
`
Error Log
If I run the above code with an empty context I get the following error:
vpc_subnets=ec2.SubnetSelection(subnet_group_name="application") File "C:\Users\<username>\AppData\Local\Programs\Python\Python37\lib\site-packages\jsii\_runtime.py", line 66, in __call__ inst = super().__call__(*args, **kwargs) File "C:\Users\<username>\AppData\Local\Programs\Python\Python37\lib\site-packages\aws_cdk\aws_ec2\__init__.py", line 22158, in __init__ jsii.create(Instance, self, [scope, id, props]) File "C:\Users\<username>\AppData\Local\Programs\Python\Python37\lib\site-packages\jsii\_kernel\__init__.py", line 229, in create interfaces=[iface.__jsii_type__ for iface in getattr(klass, "__jsii_ifaces__", [])], File "C:\Users\<username>\AppData\Local\Programs\Python\Python37\lib\site-packages\jsii\_kernel\providers\process.py", line 333, in create return self._process.send(request, CreateResponse) File "C:\Users\<username>\AppData\Local\Programs\Python\Python37\lib\site-packages\jsii\_kernel\providers\process.py", line 318, in send raise JSIIError(resp.error) from JavaScriptError(resp.stack) jsii.errors.JSIIError: Cannot read property 'subnetId' of undefined Subprocess exited with error 1
If I prebuild my cdk.context.json and rerun it successfully builds. While I recognize this work around fixes the immediate issue, it also creates technical debt because now any time I deploy the stack to a new account or region I have to update my cdk.context.json manually.
Environment
Other
I believe that the issue is that the CDK is relying on the dummy vpc instead of making the call to get the context before trying to make the aws_ec2.Instance() call. If it were to instead fetch the context first I believe it would fix the issue.
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: