dotnet: Error importing existing Vpc
See original GitHub issueI’m trying to import an existing Vpc into a dotnet
cdk stack using the example here provided by @eladb
var vpc = VpcNetworkRef.Import(this, "ExternalVpc", new VpcNetworkRefProps
{
VpcId = "vpc-ff",
AvailabilityZones = new AvailabilityZoneProvider(this).AvailabilityZones,
PrivateSubnetIds = new[] {"subnet-0xx", "subnet-0yy", "subnet-0zz"},
PublicSubnetIds = new[] {"subnet-aa", "subnet-bb", "subnet-cc"}
});
However, when I do cdk deploy
it says
Unhandled Exception: System.MemberAccessException: Cannot create an instance of Amazon.CDK.AWS.EC2.VpcNetworkRef because it is an abstract class.
at System.Reflection.RuntimeConstructorInfo.CheckCanCreateInstance(Type declaringType, Boolean isVarArg)
at System.Reflection.RuntimeConstructorInfo.ThrowNoInvokeException()
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Amazon.JSII.Runtime.Services.ReferenceMap.GetOrCreateNativeReference(ByRefValue byRefValue)
at Amazon.JSII.Runtime.Services.Converters.JsiiToFrameworkConverter.TryConvertClass(IReferenceMap referenceMap, Object value, Object& result)
at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvertCustomType(IReferenceMap referenceMap, Object value, Boolean isOptional, String fullyQualifiedName, Object& result)
at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvert(TypeReference typeReference, IReferenceMap referenceMap, Object value, Object& result)
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeStaticMethod[T](Type type, Object[] arguments, String methodName)
at Stack.AppStack..ctor(App parent, String name, IStackProps props) in E:\Stack\AppStack.cs:line 13
Is this a bug? Or is there another way to import an existing Vpc? (on a side note why is it required to specify all the properties and not just the VpcId
?)
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to import existing VPC in aws cdk | Edureka Community
I am trying to get existing non-default vpc. I tried below options. vpc = ec2.Vpc.from_lookup(self, id = "VPC", vpc_id='vpcid', vpc_name='vpc ...
Read more >Terraform plan failing after aws vpc import - HashiCorp Discuss
I'm new to terraform and am trying to import existing resources from my aws cloud. What am I doing wrong here ? Hi...
Read more >How to import existing VPC in aws cdk? - Stack Overflow
I am trying to get existing non-default vpc. I tried below options. vpc = ec2.Vpc.from_lookup(self, id = "VPC", vpc_id='vpcid', vpc_name=' ...
Read more >interface VpcLookupOptions · AWS CDK
Properties for looking up an existing VPC. The combination of properties must specify filter down to exactly one non-default VPC, otherwise an error...
Read more >Importing Existing Cloud Infrastructure - Pulumi
Learn how to import existing cloud infrastructure into Pulumi no matter ... error: Preview failed: importing sg-04aeda9a214730248: security group not found.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Duplicate of https://github.com/awslabs/jsii/issues/223. @costleya, is the fix released yet, and if so, what version of what tool should be installed?
Thanks @costleya. Haven’t tested recently. Please close if it’s working.