My use case is that I want to deploy a Lambda in a vpc but also give it internet access.
I initially created a VPC with default parameters, i.e.
const vpc = new ec2.Vpc(this, "vpc", {})
After this was deployed, I decided to change the parameters of the VPC to the below.
const vpc = new ec2.Vpc(this, "vpc", {
ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/20'),
natGateways: 1,
maxAzs: 2,
subnetConfiguration: [
{
name: 'private-subnet-1',
subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS,
cidrMask: 26
},
{
name: 'public-subnet-1',
subnetType: ec2.SubnetType.PUBLIC,
cidrMask: 26
}
]
})
However, when I try to deploy the stack, I am getting the error: "The new Subnets are not in the same Vpc as the existing subnet group".
For context, I currently see 6 subnets in the VPC, 3 public & 3 private. I believe this makes sense if the default maxAZs of a VPC creation is 3.
A couple questions:
- Can you explain what the error means? I am confused because since the subnets are configured inside the VPC, how is it possible that changing the parameters would make new subnets outside the VPC?
- Is there a workaround for this error?
- Where can I view my 'subnet groups'? I can't find it on the AWS console
Thank you.
Edit: I realized this error is related to my Neptune.
Here's the Neptune-related code:
// Get private Subnets
var privateSubnets = vpc.privateSubnets;
// Create Subnet selection for neptune.
const neptuneSubnets: ec2.SubnetSelection = { subnets: privateSubnets };
const neptune_cluster = new neptune.DatabaseCluster(this, 'neptune_cluster_id', {
vpc: vpc,
vpcSubnets: neptuneSubnets,
instanceType: neptune.InstanceType.T3_MEDIUM,
deletionProtection: false,
clusterParameterGroup: neptuneClusterParameterGroup
})
No, the services I'm using in my stack are Lambda and Neptune
I realized the error being displayed said it was related to AWS::Neptune::DBSubnetGroup.
I've posted the neptune-related code in my original post description. I believe I'm selecting the correct subnets from the vpc I created but still getting the same error.