Skip to content

Commit 96b2034

Browse files
authored
fix(rds): MySQL Cluster version 8.0 uses wrong Parameter for S3 import (#19145)
There was recently a new major version of the Aurora MySQL released (8.0). Apparently, it requires a different Parameter for S3 imports (`aws_default_s3_role`) than `aurora_load_from_s3_role`, which the pre-8.0 versions use. Fixes #19126 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 19ead77 commit 96b2034

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

packages/@aws-cdk/aws-rds/lib/cluster-engine.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ abstract class MySqlClusterEngineBase extends ClusterEngineBase {
177177
})
178178
: config.parameterGroup);
179179
if (options.s3ImportRole) {
180-
parameterGroup?.addParameter('aurora_load_from_s3_role', options.s3ImportRole.roleArn);
180+
// major version 8.0 uses a different name for the S3 import parameter
181+
const s3ImportParam = this.engineVersion?.majorVersion === '8.0'
182+
? 'aws_default_s3_role'
183+
: 'aurora_load_from_s3_role';
184+
parameterGroup?.addParameter(s3ImportParam, options.s3ImportRole.roleArn);
181185
}
182186
if (options.s3ExportRole) {
183187
parameterGroup?.addParameter('aurora_select_into_s3_role', options.s3ExportRole.roleArn);

packages/@aws-cdk/aws-rds/test/cluster.test.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Match, Template } from '@aws-cdk/assertions';
22
import * as ec2 from '@aws-cdk/aws-ec2';
33
import { ManagedPolicy, Role, ServicePrincipal } from '@aws-cdk/aws-iam';
4+
import * as iam from '@aws-cdk/aws-iam';
45
import * as kms from '@aws-cdk/aws-kms';
56
import * as logs from '@aws-cdk/aws-logs';
67
import * as s3 from '@aws-cdk/aws-s3';
@@ -953,7 +954,6 @@ describe('cluster', () => {
953954
});
954955
});
955956

956-
957957
test('addRotationSingleUser() with VPC interface endpoint', () => {
958958
// GIVEN
959959
const stack = new cdk.Stack();
@@ -1707,6 +1707,26 @@ describe('cluster', () => {
17071707
Template.fromStack(stack).resourceCountIs('AWS::RDS::DBClusterParameterGroup', 0);
17081708
});
17091709

1710+
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', () => {
1711+
// GIVEN
1712+
const stack = testStack();
1713+
const vpc = new ec2.Vpc(stack, 'VPC');
1714+
1715+
// WHEN
1716+
new DatabaseCluster(stack, 'Database', {
1717+
instanceProps: { vpc },
1718+
engine: DatabaseClusterEngine.auroraMysql({ version: AuroraMysqlEngineVersion.VER_3_01_0 }),
1719+
s3ImportRole: iam.Role.fromRoleArn(stack, 'S3ImportRole', 'arn:aws:iam::123456789012:role/my-role'),
1720+
});
1721+
1722+
Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBClusterParameterGroup', {
1723+
Family: 'aurora-mysql8.0',
1724+
Parameters: {
1725+
aws_default_s3_role: 'arn:aws:iam::123456789012:role/my-role',
1726+
},
1727+
});
1728+
});
1729+
17101730
test('throws when s3ExportRole and s3ExportBuckets properties are both specified', () => {
17111731
// GIVEN
17121732
const stack = testStack();

0 commit comments

Comments
 (0)