stratospheric-dev / cdk-constructs

Some CDK constructs to get started with deploying to AWS.
Apache License 2.0
35 stars 22 forks source link

RDS Postgres version update #542

Closed TomSpencerLondon closed 6 months ago

TomSpencerLondon commented 9 months ago

Get this error when deploying stratospheric (using CDK)

staging-todo-app-Database: creating CloudFormation changeset...
15:39:09 | CREATE_FAILED        | AWS::RDS::DBInstance                        | DatabasepostgresInstance8
EA39D5E
Resource handler returned message: "Cannot find version 12.9 for postgres (Service: Rds, Status Code: 400
, Request ID: 2396ae25-09d4-474c-90cc-a7c516dedbac)" (RequestToken: 4079704e-08ce-7c66-f08c-b47707583196,
HandlerErrorCode: InvalidRequest)

 ❌  DatabaseStack (staging-todo-app-Database) failed: Error: The stack named staging-todo-app-Database failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "Cannot find version 12.9 for postgres (Service: Rds, Status Code: 400, Request ID: 2396ae25-09d4-474c-90cc-a7c516dedbac)" (RequestToken: 4079704e-08ce-7c66-f08c-b47707583196, HandlerErrorCode: InvalidRequest)
    at prepareAndExecuteChangeSet (/Users/tspencer/Desktop/stratospheric/cdk/node_modules/aws-cdk/lib/api/deploy-stack.ts:386:13)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at deployStack2 (/Users/tspencer/Desktop/stratospheric/cdk/node_modules/aws-cdk/lib/cdk-toolkit.ts:240:24)
    at /Users/tspencer/Desktop/stratospheric/cdk/node_modules/aws-cdk/lib/deploy.ts:39:11
    at run (/Users/tspencer/Desktop/stratospheric/cdk/node_modules/p-queue/dist/index.js:163:29)

 ❌ Deployment failed: Error: Stack Deployments Failed: Error: The stack named staging-todo-app-Database failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "Cannot find version 12.9 for postgres (Service: Rds, Status Code: 400, Request ID: 2396ae25-09d4-474c-90cc-a7c516dedbac)" (RequestToken: 4079704e-08ce-7c66-f08c-b47707583196, HandlerErrorCode: InvalidRequest)
    at deployStacks (/Users/tspencer/Desktop/stratospheric/cdk/node_modules/aws-cdk/lib/deploy.ts:61:11)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at CdkToolkit.deploy (/Users/tspencer/Desktop/stratospheric/cdk/node_modules/aws-cdk/lib/cdk-toolkit.ts:312:7)
    at initCommandLine (/Users/tspencer/Desktop/stratospheric/cdk/node_modules/aws-cdk/lib/cli.ts:349:12)

Stack Deployments Failed: Error: The stack named staging-todo-app-Database failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Resource handler returned message: "Cannot find version 12.9 for postgres (Service: Rds, Status Code: 400, Request ID: 2396ae25-09d4-474c-90cc-a7c516dedbac)" (RequestToken: 4079704e-08ce-7c66-f08c-b47707583196, HandlerErrorCode: InvalidRequest)
TomSpencerLondon commented 9 months ago

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_PostgreSQL.html

aws rds describe-db-engine-versions --default-only --engine postgres shows:

{
"DBEngineVersions": [
{
"Engine": "postgres",
"EngineVersion": "15.4",
"DBParameterGroupFamily": "postgres15",
"DBEngineDescription": "PostgreSQL",
"DBEngineVersionDescription": "PostgreSQL 15.4-R3",
"ValidUpgradeTarget": [
{
"Engine": "postgres",
"EngineVersion": "15.5",
"Description": "PostgreSQL 15.5-R1",
"AutoUpgrade": false,
"IsMajorVersionUpgrade": false
},
{
"Engine": "postgres",
"EngineVersion": "16.1",
"Description": "PostgreSQL 16.1-R1",
"AutoUpgrade": false,
"IsMajorVersionUpgrade": true
}
],
"ExportableLogTypes": [
"postgresql",
"upgrade"
],
"SupportsLogExportsToCloudwatchLogs": true,
"SupportsReadReplica": true,
"SupportedFeatureNames": [
"Lambda",
"s3Export",
"s3Import"
],
"Status": "available",
"SupportsParallelQuery": false,
"SupportsGlobalDatabases": false,
"MajorEngineVersion": "15",
"SupportsBabelfish": false,
"SupportsCertificateRotationWithoutRestart": true,
"SupportedCACertificateIdentifiers": [
"rds-ca-2019",
"rds-ca-ecc384-g1",
"rds-ca-rsa4096-g1",
"rds-ca-rsa2048-g1"
]
}
]
}
TomSpencerLondon commented 9 months ago

So should work if we update to 15.4. Will try on my version of stratospheric.

TomSpencerLondon commented 9 months ago

Actually, I think this is the issue: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html#Concepts.DBInstanceClass.Support

To have t2.micro now you need to have Postgres version below 13. So may have to use t3.micro with postgres version 15.

TomSpencerLondon commented 9 months ago

Strange this one worked:

  public static class DatabaseInputParameters {
    private int storageInGb = 20;
    private String instanceClass = "db.t2.micro";
    private String postgresVersion = "12";
}
BjoernKW commented 6 months ago

Closing this since the issue has been resolved.