https://pulumi.com logo
#aws
Title
a

able-flag-79751

05/31/2023, 11:37 AM
Hello all. Please how do I create subnets with valid cidrBlock values? Is there a way to auto generate cidrblock values from the vpc’s cidrblock?
c

calm-queen-58154

05/31/2023, 1:30 PM
If you use AWS crosswalk it will do this for you. https://www.pulumi.com/docs/clouds/aws/guides/vpc/ Not sure what you are looking for otherwise.
a

able-flag-79751

05/31/2023, 2:03 PM
I used the example from this doc, now I’m getting this error:
Copy code
Diagnostics:
    aws:rds:SubnetGroup (develop-dbsubnets):
      error: 1 error occurred:
      	* updating urn:pulumi:develop::swapfx::aws:rds/subnetGroup:SubnetGroup::develop-dbsubnets: 1 error occurred:
      	* updating RDS DB Subnet Group (develop-dbsubnets-04082cd): InvalidParameterValue: The new Subnets are not in the same Vpc as the existing subnet group
      	status code: 400, request id: d9056ce4-31a8-4e63-84df-cd6ac439805a
l

little-cartoon-10569

05/31/2023, 7:22 PM
Put the new subnets into the same VPC as the old subnets.
a

able-flag-79751

05/31/2023, 7:23 PM
kindly share any typescript code to enlighten me more how to go about this please
l

little-cartoon-10569

05/31/2023, 8:35 PM
The problem is most likely that you're using the example from the doc to create a new VPC, would that be right? The error message is saying that you're putting the database into a different VPC and you can't do that.
You could share your code and we can see how it can be improved.
a

able-flag-79751

05/31/2023, 8:48 PM
this is my code:
Copy code
const vpc = new awsx.ec2.Vpc(`${pulumi.getStack()}-vpc`, {
  cidrBlock: "10.3.0.0/16",
  enableDnsSupport: true,
  enableDnsHostnames: true,
});
l

little-cartoon-10569

05/31/2023, 9:02 PM
The problem isn't with that code. The problem may be (can't be sure, can't see the code) that you're using the subnets created in that code with the database. But since the database has already been created, and it's using subnets from a different VPC, AWS is refusing to make the change, and Pulumi is telling you that.
a

able-flag-79751

05/31/2023, 11:36 PM
Copy code
const subnetGroup = new aws.rds.SubnetGroup(`${stackName}-dbsubnets`, {
  subnetIds: vpc.publicSubnetIds,
});

// create rds db instance from a snapshot
const db = new aws.rds.Instance(`${stackName}-db`, {
  engine: "postgres",
  instanceClass: aws.rds.InstanceTypes.T3_Micro,
  allocatedStorage: 5,
  dbSubnetGroupName: subnetGroup.id,
  vpcSecurityGroupIds: [securityGroup.id],
  name: dbName,
  username: dbUsername,
  password: dbPassword,
  skipFinalSnapshot: true,
  publiclyAccessible: true,
});
l

little-cartoon-10569

06/01/2023, 12:39 AM
1. dbSubnetGroupName is the name of the subnet group, not its id. 2. Before you used awsx, you had created this instance (right?). What value were you passing in to dbSubnetGroupName?
4 Views