Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(RDS): deploy-time value can't be used for nr of instances in Cluster #13558

Closed
TLadd opened this issue Mar 11, 2021 · 3 comments · Fixed by #13765
Closed

(RDS): deploy-time value can't be used for nr of instances in Cluster #13558

TLadd opened this issue Mar 11, 2021 · 3 comments · Fixed by #13765
Assignees
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p2

Comments

@TLadd
Copy link
Contributor

TLadd commented Mar 11, 2021

I'm attempting to store some configuration variables in parameter store for my RDS cluster but am running into this validation error about instance size needing to be at least 1. It's comparing the token's value, which is a big negative number.

Reproduction Steps

import * as rds from "@aws-cdk/aws-rds";
import * as ec2 from "@aws-cdk/aws-ec2";
import * as ssm from "@aws-cdk/aws-ssm";


class DbStack extends Stack {
    vpc: ec2.Vpc;

    constructor(scope: Construct, id: string, props?: StackProps) {
      this.vpc = new ec2.Vpc(this, "GrowMeVpc", {
        maxAzs: 3,
        enableDnsSupport: true,
        enableDnsHostnames: true,
      });

      const RDS_INSTANCES = Token.asNumber(getSsmStringParam("RDS_INSTANCES"));

        new rds.DatabaseCluster(this, "DbCluster", {
          engine: rds.DatabaseClusterEngine.auroraPostgres({
            version: rds.AuroraPostgresEngineVersion.of("12.4", "12", {
              s3Import: true,
              s3Export: true,
            }),
          }),
          defaultDatabaseName: "db",
          instances: RDS_INSTANCES,
          instanceProps: {
            instanceType: ec2.InstanceType.of(
             "t3",
             "medium"
            ),
            vpcSubnets: {
              subnetType: ec2.SubnetType.PRIVATE,
            },
            vpc: this.vpc,
          },
      });
  }
    

What did you expect to happen?

I would expect the validation to run after the token has resolved only

What actually happened?

Validation ran on the token's value itself

Environment

  • CDK CLI Version : 1.92.0
  • Framework Version: 1.92.0
  • Node.js Version: 14.16.0
  • OS : Max OS
  • Language (Version): TypeScript 4.2.2

This is 🐛 Bug Report

@TLadd TLadd added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 11, 2021
@github-actions github-actions bot added the @aws-cdk/aws-rds Related to Amazon Relational Database label Mar 11, 2021
@skinny85
Copy link
Contributor

skinny85 commented Mar 12, 2021

Hey @TLadd ,

thanks for opening the issue. Unfortunately, what you're trying to do is not possible. Since every instance is a separate resource that the DatabaseCluster Construct has to create, it's not possible to do it with a value only available at deploy time, like with the getSsmStringParam("RDS_INSTANCES") value.

I agree that the error message could be better here though! Keeping this open to fix that (PR are welcome, as always!).

BTW. We have a constant for the 12.4 version of the Aurora PostgreSQL engine defined here, so no need to use the of method in your code.

Thanks,
Adam

@skinny85 skinny85 added effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p2 and removed needs-triage This issue or PR still needs to be triaged. labels Mar 12, 2021
@BLasan
Copy link
Contributor

BLasan commented Mar 22, 2021

@skinny85 Will work on this

@skinny85 skinny85 changed the title (rds): short issue description (RDS): deploy-time value can't be used for nr of instances in Cluster Mar 23, 2021
BLasan added a commit to BLasan/aws-cdk that referenced this issue Mar 25, 2021
BLasan added a commit to BLasan/aws-cdk that referenced this issue Mar 25, 2021
BLasan added a commit to BLasan/aws-cdk that referenced this issue Mar 25, 2021
BLasan added a commit to BLasan/aws-cdk that referenced this issue Mar 25, 2021
@mergify mergify bot closed this as completed in #13765 Mar 26, 2021
mergify bot pushed a commit that referenced this issue Mar 26, 2021
…s a deploy-time value (#13765)

Added a condition to check whether the `instanceCount` is a token or not. If it's not a token then an exception will be thrown.

Fixes #13558 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️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.

hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Mar 31, 2021
…s a deploy-time value (aws#13765)

Added a condition to check whether the `instanceCount` is a token or not. If it's not a token then an exception will be thrown.

Fixes aws#13558 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
…s a deploy-time value (aws#13765)

Added a condition to check whether the `instanceCount` is a token or not. If it's not a token then an exception will be thrown.

Fixes aws#13558 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database bug This issue is a bug. effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p2
Projects
None yet
3 participants