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

fix(rds): MySQL Cluster version 8.0 uses wrong Parameter for S3 import #19145

Merged
merged 2 commits into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/@aws-cdk/aws-rds/lib/cluster-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,11 @@ abstract class MySqlClusterEngineBase extends ClusterEngineBase {
})
: config.parameterGroup);
if (options.s3ImportRole) {
parameterGroup?.addParameter('aurora_load_from_s3_role', options.s3ImportRole.roleArn);
// major version 8.0 uses a different name for the S3 import parameter
const s3ImportParam = this.engineVersion?.majorVersion === '8.0'
? 'aws_default_s3_role'
: 'aurora_load_from_s3_role';
parameterGroup?.addParameter(s3ImportParam, options.s3ImportRole.roleArn);
}
if (options.s3ExportRole) {
parameterGroup?.addParameter('aurora_select_into_s3_role', options.s3ExportRole.roleArn);
Expand Down
22 changes: 21 additions & 1 deletion packages/@aws-cdk/aws-rds/test/cluster.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Match, Template } from '@aws-cdk/assertions';
import * as ec2 from '@aws-cdk/aws-ec2';
import { ManagedPolicy, Role, ServicePrincipal } from '@aws-cdk/aws-iam';
import * as iam from '@aws-cdk/aws-iam';
import * as kms from '@aws-cdk/aws-kms';
import * as logs from '@aws-cdk/aws-logs';
import * as s3 from '@aws-cdk/aws-s3';
Expand Down Expand Up @@ -953,7 +954,6 @@ describe('cluster', () => {
});
});


test('addRotationSingleUser() with VPC interface endpoint', () => {
// GIVEN
const stack = new cdk.Stack();
Expand Down Expand Up @@ -1707,6 +1707,26 @@ describe('cluster', () => {
Template.fromStack(stack).resourceCountIs('AWS::RDS::DBClusterParameterGroup', 0);
});

test('MySQL cluster in version 8.0 uses aws_default_s3_role as a Parameter for S3 import, instead of aurora_load_from_s3_role', () => {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
new DatabaseCluster(stack, 'Database', {
instanceProps: { vpc },
engine: DatabaseClusterEngine.auroraMysql({ version: AuroraMysqlEngineVersion.VER_3_01_0 }),
s3ImportRole: iam.Role.fromRoleArn(stack, 'S3ImportRole', 'arn:aws:iam::123456789012:role/my-role'),
});

Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBClusterParameterGroup', {
Family: 'aurora-mysql8.0',
Parameters: {
aws_default_s3_role: 'arn:aws:iam::123456789012:role/my-role',
},
});
});

test('throws when s3ExportRole and s3ExportBuckets properties are both specified', () => {
// GIVEN
const stack = testStack();
Expand Down