-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet: Error importing existing Vpc #816
Comments
Duplicate of aws/jsii#223. @costleya, is the fix released yet, and if so, what version of what tool should be installed? |
Coming up in jsii-0.7.7 |
With
Looks like it imports the Vpc, but when creating a security group attached to it throws
Any idea what's going wrong? PS. Can you please add some examples on how to import a VPC with multiple private subnets (e.g. to import a subnet configuration like this one where there are private subnets for Application and DB tiers)? |
Any updates on this one? |
Is this still an issue? I wrote the following bootstrap code, and copied in the code you provided. using System;
using Amazon.CDK;
using Amazon.CDK.AWS.EC2;
namespace aws_cdk_816
{
class TestStack : Stack
{
public TestStack(App app, string name, IStackProps stackProps) : base(app, name, stackProps)
{
var vpc = VpcNetworkRef.Import(this, "ExternalVpc", new VpcNetworkRefProps
{
VpcId = "vpc-3f0a6758",
AvailabilityZones = new[] {"ap-southeast-2a", "ap-southeast-2b", "ap-southeast-2c"},
PrivateSubnetIds = new[]
{"subnet-07a29232a40c5b7c3", "subnet-087d4e011854270fd", "subnet-08d59b2790f41f7fe"},
PublicSubnetIds = new[] {"subnet-59207e3e", "subnet-7c66ac24", "subnet-8ac78fc3"}
});
Console.WriteLine($"VpcId = {vpc?.VpcId}");
new SecurityGroup(this, "LambdaSecurityGroup", new SecurityGroupProps
{
Description = "Enable lambda access to Vpc resources",
Vpc = vpc,
GroupName = "LambdaSecurityGroup"
});
}
}
class Program
{
static void Main(string[] args)
{
var app = new App();
new TestStack(app, "TestStack", new StackProps());
app.Run();
}
}
} Which ran successfully, giving the following output: VpcId = vpc-3f0a6758
Resources:
LambdaSecurityGroup0BD9FC99:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Enable lambda access to Vpc resources
GroupName: LambdaSecurityGroup
SecurityGroupEgress:
- CidrIp: 0.0.0.0/0
Description: Allow all outbound traffic by default
IpProtocol: "-1"
SecurityGroupIngress:
[]
VpcId: vpc-3f0a6758
Metadata:
aws:cdk:path: TestStack/LambdaSecurityGroup/Resource
CDKMetadata:
Type: AWS::CDK::Metadata
Properties:
Modules: aws-cdk=0.21.0,@aws-cdk/aws-ec2=0.21.0,@aws-cdk/aws-iam=0.21.0,@aws-cdk/cdk=0.21.0,@aws-cdk/cx-api=0.21.0,jsii-runtime=DotNet/4.0.30319.42000 I am using .NET Core 2.2 and CDK version 0.21.0. |
Thanks @costleya. Haven't tested recently. Please close if it's working. |
I'm trying to import an existing Vpc into a
dotnet
cdk stack using the example here provided by @eladbHowever, when I do
cdk deploy
it saysIs 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
?)The text was updated successfully, but these errors were encountered: