Hello all. Please how do I create subnets with val...
# aws
a
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
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
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
Put the new subnets into the same VPC as the old subnets.
a
kindly share any typescript code to enlighten me more how to go about this please
l
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
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
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
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
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?