From ccab908a3bfecce25196d924ded90703a5758e47 Mon Sep 17 00:00:00 2001 From: Kyle Nie Date: Mon, 16 Sep 2024 11:22:21 +1000 Subject: [PATCH] [DBCluster] Support EnableHttpEndpoint for Aurora MySQL engine to support Data Api --- aws-rds-dbcluster/aws-rds-dbcluster.json | 2 +- .../amazon/rds/dbcluster/BaseHandlerStd.java | 3 ++- .../software/amazon/rds/dbcluster/SchemaTest.java | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/aws-rds-dbcluster/aws-rds-dbcluster.json b/aws-rds-dbcluster/aws-rds-dbcluster.json index 5d83851f6..3480e3065 100644 --- a/aws-rds-dbcluster/aws-rds-dbcluster.json +++ b/aws-rds-dbcluster/aws-rds-dbcluster.json @@ -410,7 +410,7 @@ "/properties/DBClusterIdentifier": "$lowercase(DBClusterIdentifier)", "/properties/DBClusterParameterGroupName": "$lowercase(DBClusterParameterGroupName)", "/properties/DBSubnetGroupName": "$lowercase(DBSubnetGroupName)", - "/properties/EnableHttpEndpoint": "$lowercase($string(EngineMode)) = 'serverless' ? EnableHttpEndpoint : ($lowercase($string(Engine)) = 'aurora-postgresql' ? EnableHttpEndpoint : false )", + "/properties/EnableHttpEndpoint": "$lowercase($string(EngineMode)) = 'serverless' ? EnableHttpEndpoint : ($lowercase($string(Engine)) in ['aurora-postgresql', 'aurora-mysql'] ? EnableHttpEndpoint : false )", "/properties/Engine": "$lowercase(Engine)", "/properties/EngineVersion": "$join([$string(EngineVersion), \".*\"])", "/properties/KmsKeyId": "$join([\"arn:(aws)[-]{0,1}[a-z]{0,2}[-]{0,1}[a-z]{0,3}:kms:[a-z]{2}[-]{1}[a-z]{3,10}[-]{0,1}[a-z]{0,10}[-]{1}[1-3]{1}:[0-9]{12}[:]{1}key\\/\", KmsKeyId])", diff --git a/aws-rds-dbcluster/src/main/java/software/amazon/rds/dbcluster/BaseHandlerStd.java b/aws-rds-dbcluster/src/main/java/software/amazon/rds/dbcluster/BaseHandlerStd.java index 3a09b76f8..a35737a1c 100644 --- a/aws-rds-dbcluster/src/main/java/software/amazon/rds/dbcluster/BaseHandlerStd.java +++ b/aws-rds-dbcluster/src/main/java/software/amazon/rds/dbcluster/BaseHandlerStd.java @@ -94,6 +94,7 @@ public abstract class BaseHandlerStd extends BaseHandler { public static final String RESOURCE_IDENTIFIER = "dbcluster"; public static final String ENGINE_AURORA_POSTGRESQL = "aurora-postgresql"; + public static final String ENGINE_AURORA_MYSQL = "aurora-mysql"; private static final String MASTER_USER_SECRET_ACTIVE = "active"; protected static final String DB_CLUSTER_REQUEST_STARTED_AT = "dbcluster-request-started-at"; protected static final String DB_CLUSTER_REQUEST_IN_PROGRESS_AT = "dbcluster-request-in-progress-at"; @@ -729,7 +730,7 @@ protected boolean shouldSetDefaultVpcSecurityGroupIds(final ResourceModel previo } protected boolean shouldUpdateHttpEndpointV2(final ResourceModel previousState, final ResourceModel desiredState) { - return ENGINE_AURORA_POSTGRESQL.equalsIgnoreCase(desiredState.getEngine()) && + return (ENGINE_AURORA_POSTGRESQL.equalsIgnoreCase(desiredState.getEngine()) || ENGINE_AURORA_MYSQL.equalsIgnoreCase(desiredState.getEngine())) && !EngineMode.Serverless.equals(EngineMode.fromString(desiredState.getEngineMode())) && ObjectUtils.notEqual(previousState.getEnableHttpEndpoint(), desiredState.getEnableHttpEndpoint()); } diff --git a/aws-rds-dbcluster/src/test/java/software/amazon/rds/dbcluster/SchemaTest.java b/aws-rds-dbcluster/src/test/java/software/amazon/rds/dbcluster/SchemaTest.java index 21309e477..da6e51082 100644 --- a/aws-rds-dbcluster/src/test/java/software/amazon/rds/dbcluster/SchemaTest.java +++ b/aws-rds-dbcluster/src/test/java/software/amazon/rds/dbcluster/SchemaTest.java @@ -155,6 +155,21 @@ void testDrift_EnableHttpEndpoint_Aurora_Postgresql_Drifted() { }).isInstanceOf(AssertionError.class); } + @Test + void testDrift_EnableHttpEndpoint_Aurora_Mysql_Drifted() { + final ResourceModel input = ResourceModel.builder() + .enableHttpEndpoint(true) + .engine("aurora-mysql") + .build(); + final ResourceModel output = ResourceModel.builder() + .enableHttpEndpoint(false) + .engine("aurora-mysql") + .build(); + Assertions.assertThatThrownBy(() -> { + assertResourceNotDrifted(input, output, resourceSchema); + }).isInstanceOf(AssertionError.class); + } + @Test void testDrift_EnableHttpEndpoint_Provisioned() { final ResourceModel input = ResourceModel.builder()