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

aws_cdk.aws_ec2.InstanceType : Database instance type being synthesised into cloudformation incorrectly #28355

Closed
dnrico1 opened this issue Dec 13, 2023 · 3 comments
Assignees
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud

Comments

@dnrico1
Copy link

dnrico1 commented Dec 13, 2023

Describe the bug

Defining instance_type=ec2.InstanceType("db.t4g.micro"), for a aws_rds.DatabaseInstance synths to "DBInstanceClass": "db.db.t4g.micro", causing the following error when deploying:
Resource handler returned message: "Invalid DB Instance class: db.db.t4g.micro (Service: Rds, Status Code: 400, Request ID: xxx)" (RequestToken: xxx HandlerErrorCode: InvalidRequest)

Expected Behavior

For the synth to be "DBInstanceClass": "db.t4g.micro", and the database to be created correctly

Current Behavior

Synth was "DBInstanceClass": "db.db.t4g.micro",

Reproduction Steps

  1. Init an cdk app
  2. Put the following into app.py:
    `
    from aws_cdk import (
    aws_rds as rds,
    aws_ec2 as ec2,
    )
    import aws_cdk as cdk
    from constructs import Construct

class StatefulStack(cdk.Stack):
def init(self, scope: Construct, id: str, **kwargs) -> None:
super().init(scope, id, **kwargs)

    # Define a VPC (minimal configuration for example purposes)
    vpc = ec2.Vpc(self, "MyVPC", max_azs=2)

    db_secret = rds.DatabaseSecret(self, "DBSecret",
        username="admin",
        secret_name="DBCredentials"
    )

    funnelsystems_database_name = "database"
    self.database = rds.DatabaseInstance(self, "database",
        engine=rds.DatabaseInstanceEngine.mysql(version=rds.MysqlEngineVersion.VER_8_0_28),
        instance_type=ec2.InstanceType("db.t4g.micro"),
        vpc=vpc,
        multi_az=False,
        allocated_storage=20, 
        database_name="name",
        publicly_accessible=False,
        credentials=rds.Credentials.from_secret(db_secret),

app = cdk.App()
StatefulStack(app, "StatefulStack")

app.synth()
3. Runcdk synth4. Check the synthesised cloudformation and noticeDBInstanceClass: db.db.t4g.micro`

Possible Solution

Unfortunately do not have enough experience with CDK / CFN to suggest a solution.

Additional Information/Context

No response

CDK CLI Version

2.114.1 (build 02bbb1d)

Framework Version

No response

Node.js Version

Node.js v20.5.1

OS

macOS Ventura 13.0

Language

Python

Language Version

No response

Other information

No response

@dnrico1 dnrico1 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 13, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Dec 13, 2023
@tim-finnigan tim-finnigan self-assigned this Dec 14, 2023
@tim-finnigan
Copy link

Hi @dnrico1 thanks for reaching out. Have you tried just passing t4g.micro without the db.?

Here is the documentation for DatabaseInstance: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rds.DatabaseInstance.html. As noted there, the default for InstanceType is m5.large, so the db. appears to get added automatically.

Here is a list of DB instance classes supported in RDS: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html.

@tim-finnigan tim-finnigan added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 14, 2023
@pahud
Copy link
Contributor

pahud commented Dec 14, 2023

@dnrico1

You should remove the prefix db., the DatabaseInstance() construct will handle the prefixing for you.

dbInstanceClass: `db.${props.instanceType}`,

@tim-finnigan tim-finnigan removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Dec 14, 2023
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud
Projects
None yet
Development

No branches or pull requests

3 participants