@@ -97,6 +97,14 @@ export interface IClusterEngine extends IEngine {
9797 /** The log types that are available with this engine type */
9898 readonly supportedLogTypes : string [ ] ;
9999
100+ /**
101+ * Whether the IAM Roles used for data importing and exporting need to be combined for this Engine,
102+ * or can they be kept separate.
103+ *
104+ * @default false
105+ */
106+ readonly combineImportAndExportRoles ?: boolean ;
107+
100108 /**
101109 * Method called when the engine is used to create a new cluster.
102110 */
@@ -154,11 +162,13 @@ interface MysqlClusterEngineBaseProps {
154162 readonly engineType : string ;
155163 readonly engineVersion ?: EngineVersion ;
156164 readonly defaultMajorVersion : string ;
165+ readonly combineImportAndExportRoles ?: boolean ;
157166}
158167
159168abstract class MySqlClusterEngineBase extends ClusterEngineBase {
160169 public readonly engineFamily = 'MYSQL' ;
161170 public readonly supportedLogTypes : string [ ] = [ 'error' , 'general' , 'slowquery' , 'audit' ] ;
171+ public readonly combineImportAndExportRoles ?: boolean ;
162172
163173 constructor ( props : MysqlClusterEngineBaseProps ) {
164174 super ( {
@@ -167,6 +177,7 @@ abstract class MySqlClusterEngineBase extends ClusterEngineBase {
167177 multiUserRotationApplication : secretsmanager . SecretRotationApplication . MYSQL_ROTATION_MULTI_USER ,
168178 engineVersion : props . engineVersion ? props . engineVersion : { majorVersion : props . defaultMajorVersion } ,
169179 } ) ;
180+ this . combineImportAndExportRoles = props . combineImportAndExportRoles ;
170181 }
171182
172183 public bindToCluster ( scope : Construct , options : ClusterEngineBindOptions ) : ClusterEngineConfig {
@@ -177,14 +188,18 @@ abstract class MySqlClusterEngineBase extends ClusterEngineBase {
177188 } )
178189 : config . parameterGroup ) ;
179190 if ( options . s3ImportRole ) {
180- // major version 8.0 uses a different name for the S3 import parameter
181- const s3ImportParam = this . engineVersion ?. majorVersion === '8.0'
191+ // versions which combine the import and export Roles (right now, this is only 8.0)
192+ // require a different parameter name (identical for both import and export)
193+ const s3ImportParam = this . combineImportAndExportRoles
182194 ? 'aws_default_s3_role'
183195 : 'aurora_load_from_s3_role' ;
184196 parameterGroup ?. addParameter ( s3ImportParam , options . s3ImportRole . roleArn ) ;
185197 }
186198 if ( options . s3ExportRole ) {
187- parameterGroup ?. addParameter ( 'aurora_select_into_s3_role' , options . s3ExportRole . roleArn ) ;
199+ const s3ExportParam = this . combineImportAndExportRoles
200+ ? 'aws_default_s3_role'
201+ : 'aurora_select_into_s3_role' ;
202+ parameterGroup ?. addParameter ( s3ExportParam , options . s3ExportRole . roleArn ) ;
188203 }
189204
190205 return {
@@ -366,17 +381,28 @@ export class AuroraMysqlEngineVersion {
366381 }
367382
368383 private static builtIn_8_0 ( minorVersion : string ) : AuroraMysqlEngineVersion {
369- return new AuroraMysqlEngineVersion ( `8.0.mysql_aurora.${ minorVersion } ` , '8.0' ) ;
384+ // 8.0 of the MySQL engine needs to combine the import and export Roles
385+ return new AuroraMysqlEngineVersion ( `8.0.mysql_aurora.${ minorVersion } ` , '8.0' , true ) ;
370386 }
371387
372388 /** The full version string, for example, "5.7.mysql_aurora.1.78.3.6". */
373389 public readonly auroraMysqlFullVersion : string ;
374- /** The major version of the engine. Currently, it's always "5.7". */
390+ /** The major version of the engine. Currently, it's either "5.7", or "8.0 ". */
375391 public readonly auroraMysqlMajorVersion : string ;
392+ /**
393+ * Whether this version requires combining the import and export IAM Roles.
394+ *
395+ * @internal
396+ */
397+ public readonly _combineImportAndExportRoles ?: boolean ;
376398
377- private constructor ( auroraMysqlFullVersion : string , auroraMysqlMajorVersion : string = '5.7' ) {
399+ private constructor (
400+ auroraMysqlFullVersion : string , auroraMysqlMajorVersion : string = '5.7' ,
401+ combineImportAndExportRoles ?: boolean ,
402+ ) {
378403 this . auroraMysqlFullVersion = auroraMysqlFullVersion ;
379404 this . auroraMysqlMajorVersion = auroraMysqlMajorVersion ;
405+ this . _combineImportAndExportRoles = combineImportAndExportRoles ;
380406 }
381407}
382408
@@ -400,6 +426,7 @@ class AuroraMysqlClusterEngine extends MySqlClusterEngineBase {
400426 }
401427 : undefined ,
402428 defaultMajorVersion : '5.7' ,
429+ combineImportAndExportRoles : version ?. _combineImportAndExportRoles ,
403430 } ) ;
404431 }
405432
0 commit comments