hey everybody. Long time reader, first time poster...
# sst
d
hey everybody. Long time reader, first time poster 🙂 Does anyone have a good example (preferably Typescript) where they utilize an existing RDS database in their stacks? This is what I have tried so far
Copy code
import * as ec2 from '@aws-cdk/aws-ec2';
import * as rds from '@aws-cdk/aws-rds';
import * as sst from '@serverless-stack/resources'

import { FixMeLater } from '../src/types/FixMeLater';

export default class RdsStack extends sst.Stack {
  public readonly vpc: FixMeLater
  public readonly rmwDb: FixMeLater

  constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
    super(scope, id, props)

    // Attach to the existing VPC
    this.vpc = ec2.Vpc.fromLookup(this, 'VPC', {
      vpcId: 'vpc-**********'
    })

    // Attach to the existing RM Workspace RDS instance
    this.rmwDb = rds.DatabaseInstance.fromDatabaseInstanceAttributes(this, 'RMWDB', {
      instanceIdentifier: '*******-staging-rds',
      instanceEndpointAddress: '********************.<http://rds.amazonaws.com|rds.amazonaws.com>',
      engine: rds.DatabaseInstanceEngine.postgres({
        version: rds.PostgresEngineVersion.VER_11_12
      }),
      securityGroups: [],
      port: 5432
    })
  }
}
I get this error message, which to be fair I am not sure if its from my code, or from my organizations restrictions (although my user is admin-level)
so if you have a working example utilizing an existing RDS, that could point me in the right direction. not finding much online or in github publicly
Just a quick update I got past the error by simplifying my RdsStack
Copy code
import * as rds from '@aws-cdk/aws-rds';
import * as sst from '@serverless-stack/resources'

export default class RdsStack extends sst.Stack {
  public readonly rmwDb: rds.IDatabaseInstance;

  constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
    super(scope, id, props)

    // Attach to the existing RM Workspace RDS instance
    this.rmwDb = rds.DatabaseInstance.fromDatabaseInstanceAttributes(this, 'RMWDB', {
      instanceIdentifier: '*****-staging-rds',
      instanceEndpointAddress: '*******.<http://rds.amazonaws.com|rds.amazonaws.com>',
      securityGroups: [],
      port: 5432
    })
  }
}
So making progress 🙂 This issue led me to a simpler spot, in case it can help anyone else: https://github.com/aws/aws-cdk/issues/7295
f
Hey @Daniel! Glad you figured it out!