aws-cdk-local icon indicating copy to clipboard operation
aws-cdk-local copied to clipboard

[PRO] public subnets is not created

Open gooftroop opened this issue 3 years ago • 4 comments

Using the following code, I expect to see 3 subnets create - a private with NAT, isolated, and a public.

const vpc = new ec2.Vpc(this, `${id}CoreVpc`, {
    maxAzs: 1,
    cidr: scope.node.tryGetContext('cidr') || process.env.VPC_CIDR || '10.0.0.0/16',
    natGateways: 1,
    vpcName: `${name}-vpc`,
    subnetConfiguration: [{
        name: `${stage}-private-subnet`,
        subnetType: ec2.SubnetType.PRIVATE_WITH_NAT,
        cidrMask: 24,
    }, {
        name: `${stage}-public-subnet`,
        subnetType: ec2.SubnetType.PUBLIC,
        cidrMask: 24,
        mapPublicIpOnLaunch: true,
    }, {
        name: `${stage}-isolated-subnet`,
        subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
        cidrMask: 28,
    }],
});

Output:

VPC

{
            "CidrBlock": "10.0.0.0/16",
            "DhcpOptionsId": "dopt-7a8b9c2d",
            "State": "available",
            "VpcId": "vpc-912e4792",
            "OwnerId": "000000000000",
            "InstanceTenancy": "default",
            "Ipv6CidrBlockAssociationSet": [],
            "CidrBlockAssociationSet": [
                {
                    "AssociationId": "vpc-cidr-assoc-b57c5b2e",
                    "CidrBlock": "10.0.0.0/16",
                    "CidrBlockState": {
                        "State": "associated"
                    }
                }
            ],
            "IsDefault": false,
            "Tags": []
        }

Subnets

{
            "AvailabilityZone": "us-east-1a",
            "AvailabilityZoneId": "use1-az6",
            "AvailableIpAddressCount": 251,
            "CidrBlock": "10.0.0.0/24",
            "DefaultForAz": false,
            "MapPublicIpOnLaunch": false,
            "State": "available",
            "SubnetId": "subnet-043cbbc5",
            "VpcId": "vpc-912e4792",
            "OwnerId": "000000000000",
            "AssignIpv6AddressOnCreation": false,
            "Ipv6CidrBlockAssociationSet": [],
            "SubnetArn": "arn:aws:ec2:us-east-1:000000000000:subnet/subnet-043cbbc5"
        },
        {
            "AvailabilityZone": "us-east-1a",
            "AvailabilityZoneId": "use1-az6",
            "AvailableIpAddressCount": 250,
            "CidrBlock": "10.0.1.0/24",
            "DefaultForAz": false,
            "MapPublicIpOnLaunch": false,
            "State": "available",
            "SubnetId": "subnet-bb515ce0",
            "VpcId": "vpc-912e4792",
            "OwnerId": "000000000000",
            "AssignIpv6AddressOnCreation": false,
            "Ipv6CidrBlockAssociationSet": [],
            "SubnetArn": "arn:aws:ec2:us-east-1:000000000000:subnet/subnet-bb515ce0"
        },
        {
            "AvailabilityZone": "us-east-1a",
            "AvailabilityZoneId": "use1-az6",
            "AvailableIpAddressCount": 11,
            "CidrBlock": "10.0.2.0/28",
            "DefaultForAz": false,
            "MapPublicIpOnLaunch": false,
            "State": "available",
            "SubnetId": "subnet-d1c2ad16",
            "VpcId": "vpc-912e4792",
            "OwnerId": "000000000000",
            "AssignIpv6AddressOnCreation": false,
            "Ipv6CidrBlockAssociationSet": [],
            "SubnetArn": "arn:aws:ec2:us-east-1:000000000000:subnet/subnet-d1c2ad16"
        }

I would have expected subnet-bb515ce0 to have MapPublicIpOnLaunch set to true. I've tried various configurations to debug this (i.e. using the default configuration for vpcs by omitting the subnetConfiguration, only specifying the public configuration) without any luck. There is a pre-existing default VPC, but I've verified that no configuration is shared:

{
            "CidrBlock": "172.31.0.0/16",
            "DhcpOptionsId": "dopt-7a8b9c2d",
            "State": "available",
            "VpcId": "vpc-2d9e57fd",
            "OwnerId": "000000000000",
            "InstanceTenancy": "default",
            "Ipv6CidrBlockAssociationSet": [],
            "CidrBlockAssociationSet": [
                {
                    "AssociationId": "vpc-cidr-assoc-7d41565d",
                    "CidrBlock": "172.31.0.0/16",
                    "CidrBlockState": {
                        "State": "associated"
                    }
                }
            ],
            "IsDefault": true,
            "Tags": []
        }

I've attached the output log from my locastack container.

Could this be something up with the cdklocal library or maybe something with localstack (or my configuration)? localstack_output.txt

gooftroop avatar May 24 '22 02:05 gooftroop

Any guidance on this?

gooftroop avatar May 28 '22 20:05 gooftroop

Hi @gooftroop , thanks for reporting. Turns out this was an issue in LocalStack itself (not the cdklocal script per se). We have now pushed a small fix for this - can you please pull the latest Docker image and give it another try? Please let us know if the problem persists.. Thanks!

whummer avatar Jun 01 '22 15:06 whummer

Hi @whummer just confirmed that most of this appears to be fixed. I am able to use public and private subnets now, but isolated subnets are still missing from the returned VPC resource. Is that related to the original issue?

gooftroop avatar Jun 11 '22 20:06 gooftroop

Hi! We just wanted to follow up on our last message to see whether your issue has been resolved. Were you able to get it working with the latest version of LocalStack? We would appreciate your feedback!

lakkeger avatar Nov 14 '23 07:11 lakkeger