Skip to content

Commit

Permalink
[DBCluster] Support EnableHttpEndpoint for Aurora MySQL engine to sup…
Browse files Browse the repository at this point in the history
…port Data Api
  • Loading branch information
kylenie-aws committed Oct 2, 2024
1 parent a4a70a6 commit ccab908
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aws-rds-dbcluster/aws-rds-dbcluster.json
Original file line number Diff line number Diff line change
Expand Up @@ -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])",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
public abstract class BaseHandlerStd extends BaseHandler<CallbackContext> {
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";
Expand Down Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ccab908

Please sign in to comment.