question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

aws_rds.ServerlessCluster and secret property

See original GitHub issue

❓ General Issue

The Question

The secret property of the ServerlessCluster is available in the Python AWS CDK, but not available in the TypeScript AWS CDK.

Environment

  • CDK CLI Version: 1.90.0 (build 7edba31)
  • Module Version: 1.90.0
  • Node.js Version: v10.20.1
  • OS: Cloud9
  • Language (Version): TypeScript (3.8.3)

Python Example (works)

from aws_cdk import (core,aws_ec2,aws_rds)

class SecretPythonStack(core.Stack):

    def __init__(self, scope: core.Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        self.vpc = aws_ec2.Vpc(self, "Vpc",
            max_azs=2,
            cidr="10.10.0.0/16",
            subnet_configuration=[
                aws_ec2.SubnetConfiguration(
                   subnet_type=aws_ec2.SubnetType.PUBLIC,
                   name="Public Subnets",
                   cidr_mask=24
                ),
                aws_ec2.SubnetConfiguration(
                   subnet_type=aws_ec2.SubnetType.PRIVATE,
                   name="Private Subnets",
                   cidr_mask=24
                ),
                aws_ec2.SubnetConfiguration(
                   subnet_type=aws_ec2.SubnetType.ISOLATED,
                   name="Isolated Subnets",
                   cidr_mask=24
                )
            ],
            nat_gateways=2,
            )
            
            
        self.rds_securitygroup = aws_ec2.SecurityGroup(self, "Rds Security Group",
            description= "Security group for database",
            security_group_name= "Aurora Rds Security Group",
            vpc = self.vpc,
            )

        # Rds Client security group
        self.rdsclient_securitygroup = aws_ec2.SecurityGroup(self, "Rds Client Security Group",
        description= "Allows lambda access to VPC",
        security_group_name= "Aurora Lambda Security Group",
        vpc = self.vpc
        )
        
        self.rds_securitygroup.add_ingress_rule(self.rdsclient_securitygroup,aws_ec2.Port.tcp(5432),"Allow RDS client security group members access to RDS on port 5432")

        self.rds = db_serverless_cluster = aws_rds.ServerlessCluster(self, "AuroraRds",
            engine=aws_rds.DatabaseClusterEngine.AURORA_POSTGRESQL,
            parameter_group =aws_rds.ParameterGroup.from_parameter_group_name(self, "ParameterGroup", "default.aurora-postgresql10"),
            default_database_name='MyDatabase',
            vpc=self.vpc,
            security_groups=[self.rds_securitygroup],
            enable_data_api=True,
            scaling=aws_rds.ServerlessScalingOptions(auto_pause=None)
        )
        
        core.CfnOutput(self, "RDSSecret", value=self.rds.secret.secret_arn)

TypeScript Example (does not work)

import * as cdk from "@aws-cdk/core";
import * as aws_ec2 from "@aws-cdk/aws-ec2";
import * as aws_rds from "@aws-cdk/aws-rds";

export class SecretTypescriptStack extends cdk.Stack {
  public vpc: aws_ec2.Vpc;
  public rds: aws_rds.IServerlessCluster;
  public rdsSecurityGroup: aws_ec2.SecurityGroup;
  public rdsClientSecurityGroup: aws_ec2.SecurityGroup;

  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    this.vpc = new aws_ec2.Vpc(this, id, {
      maxAzs: 2,
      cidr: "10.10.0.0/16",
      enableDnsHostnames: false,
      enableDnsSupport: false,
      subnetConfiguration: [
        {
          name: "Isolated Subnets",
          subnetType: aws_ec2.SubnetType.ISOLATED,
          cidrMask: 24,
        },
        {
          name: "Private Subnets",
          subnetType: aws_ec2.SubnetType.PRIVATE,
          cidrMask: 24,
        },
        {
          name: "Public Subnets",
          subnetType: aws_ec2.SubnetType.PUBLIC,
          cidrMask: 24,
        },
      ],
    });

    this.rdsSecurityGroup = new aws_ec2.SecurityGroup(
      this,
      "Rds Security Group",
      {
        description: "Security group for database",
        securityGroupName: "Aurora Rds Security Group",
        vpc: this.vpc,
      }
    );

    this.rdsClientSecurityGroup = new aws_ec2.SecurityGroup(
      this,
      "Rds Client Security Group",
      {
        description: "Client Security group for database",
        securityGroupName: "Aurora Rds Client Security Group",
        vpc: this.vpc,
      }
    );

    this.rdsSecurityGroup.addIngressRule(
      this.rdsClientSecurityGroup,
      aws_ec2.Port.tcp(5432),
      "Allow RDS client security group members access to RDS on port 5432"
    );

    this.rds = new aws_rds.ServerlessCluster(this, "AuroraRds", {
      engine: aws_rds.DatabaseClusterEngine.AURORA_POSTGRESQL,
      parameterGroup: aws_rds.ParameterGroup.fromParameterGroupName(
        this,
        "ParameterGroup",
        "default.aurora-postgresql10"
      ),
      defaultDatabaseName: "MyDatabase",
      vpc: this.vpc,
      securityGroups: [this.rdsSecurityGroup],
      enableDataApi: true,
      scaling: { autoPause: cdk.Duration.seconds(0) },
    });


    // new cdk.CfnOutput(this, "RDSSecret", {
    //   value: this.rds.secret.secretArn,
    // });
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
tomcavanaughcommented, Mar 1, 2021

Reinstalled all packages and am no longer seeing this behavior. Looks like this was an issue with my local installation, and never an issue as reported.

0reactions
github-actions[bot]commented, Mar 2, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

class ServerlessCluster (construct) · AWS CDK
Go, github.com/aws/aws-cdk-go/awscdk/v2/awsrds#ServerlessCluster ... Create username and password secret for DB Cluster const secret = new rds.
Read more >
Build Aurora Serverless cluster with DataAPI and Secrets ...
How to secure access to Aurora Serverless over DataAPI using Secrets Manager and IAM access policies in a few easy steps.
Read more >
Aurora Serverless Secret issue (Connection failed - AWS re:Post
I just created an Aurora Serverless cluster through the AWS console. There were few (seemingly relevant) options to configure. I then created another...
Read more >
RDS - SST docs
Docs for the sst.RDS construct in the @serverless-stack/resources package. This construct creates an RDS Serverless Cluster with Data API ...
Read more >
Setting up an RDS Aurora Serverless cluster with Secrets ...
I also want to rotate the secret using a Lambda function every X amount of days. However, I can't get the Lambda function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found