boundless-telephone-75738
07/16/2021, 2:19 PMconst pgProvider = (db: rds.Instance, pw: string) => {
return new pg.Provider(`${name}-db-provider`, {
port: db.port,
host: db.address,
password: pw,
username: db.username,
superuser: true
});
}
but that causes pulumi to try to connect to the rds.Instance private ip. and I end up with error: error detecting capabilities: error PostgreSQL version: dial tcp: lookup <privateip>
when trying to define a role.
Is there a way to use aws.rds to create roles and databases in addition to the initialDatabase created when using
aws.rds.Instance('name', config)
From the docs it's not clear to me how to do this. Which is the reason why I moved to the postgresql package, and tried to define a provider to tell it about my rds instance.
I found https://www.pulumi.com/blog/managing-your-mysql-databases-with-pulumi/ for mysql, but the pg.Provider does not accept an endpoint, I tried using endpoint for the host property, but that causes a double :PORT:PORT
great-sunset-355
07/16/2021, 3:49 PMbillowy-army-68599
07/16/2021, 5:40 PMboundless-telephone-75738
07/19/2021, 6:43 AMconst dbSubnets = new aws.rds.SubnetGroup(
`unleash-iaac-private-subnets`,
{
subnetIds: vpc.privateSubnetIds,
}
);
export const unleashDb = new aws.rds.Instance(name, {
instanceClass: 'db.t3.micro',
dbSubnetGroupName: dbSubnets.id,
vpcSecurityGroupIds: [sg.id],
name: 'unleash',
allocatedStorage: 20,
maxAllocatedStorage: 100,
engine: 'postgres',
engineVersion: "13.3",
username: 'unleash',
publiclyAccessible: false,
skipFinalSnapshot: true,
deletionProtection: false,
password: randomPassword("database").result,
allowMajorVersionUpgrade: true
});
So, I might want to expand dbSubnet
to include the public subnet, and turn publiclyAccessible to true
?billowy-army-68599
07/19/2021, 6:55 AMboundless-telephone-75738
07/19/2021, 6:56 AMgreat-sunset-355
07/19/2021, 10:03 AM# on remote ec2
RDS_ENDPOINT=<instance>.<http://eu-central-1.rds.amazonaws.com:5432|eu-central-1.rds.amazonaws.com:5432>
REMOTE_PORT=5432
sudo socat TCP-LISTEN:${DEST_PORT},reuseaddr,fork TCP4:${RDS_ENDPOINT}
# on local machine:
$INSTANCE_ID=<cloud9 instanceID> # ID of cloud9 instance
REMOTE_PORT=5432 # port where cloud9 listens on
LOCAL_PORT=5432 # port on the local machine that is exposed
aws ssm start-session --target $INSTANCE_ID --document-name AWS-StartPortForwardingSession --parameters "{\"portNumber\":[\"${REMOTE_PORT}\"], \"localPortNumber\":[\"${LOCAL_PORT}\"]}"
# access RDS at <postgresql://localhost>:$LOCAL_PORT/db
boundless-telephone-75738
07/19/2021, 11:11 AM