question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet: Error importing existing Vpc

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rix0rrrcommented, Sep 30, 2018

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?

0reactions
IndikaUdagedaracommented, Dec 21, 2018

Thanks @costleya. Haven’t tested recently. Please close if it’s working.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found