Skip to content

Allow change InstanceClass without replacing resource #43

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

Closed
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
8 changes: 2 additions & 6 deletions aurora-mysql.cfhighlander.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@
ComponentParam 'ReaderPromotionTier', 1, allowedValues: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
ComponentParam 'BacktrackWindow', 0

if engine_mode == 'provisioned'
ComponentParam 'WriterInstanceType'
ComponentParam 'ReaderInstanceType'
end

if engine_mode == 'serverless' || engine_mode == 'serverlessv2'
ComponentParam 'MaxCapacity', 2, allowedValues: [1, 2, 4, 8, 16, 32, 64, 128, 192, 256]
ComponentParam 'MinCapacity', 2, allowedValues: [0, 0.5, 1, 2, 4, 8, 16, 32, 64, 128, 192, 256]
end

ComponentParam 'WriterInstanceType'
ComponentParam 'ReaderInstanceType'
ComponentParam 'KmsKeyId' if defined? kms_key_id
ComponentParam 'VPCId', type: 'AWS::EC2::VPC::Id'
ComponentParam 'SubnetIds', type: 'CommaDelimitedList'
Expand Down
75 changes: 26 additions & 49 deletions aurora-mysql.cfndsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
Engine external_parameters[:engine]
EngineVersion engine_version unless engine_version.nil?

EngineMode(external_parameters[:engine_mode] == 'serverlessv2' ? 'provisioned' : external_parameters[:engine_mode])
# The serverless engine mode only applies for Aurora Serverless v1 DB clusters. Aurora Serverless v1 no more supported.
EngineMode 'provisioned'
EnableLocalWriteForwarding FnIf('EnableLocalWriteForwarding', true, Ref('AWS::NoValue'))

PreferredMaintenanceWindow maintenance_window unless maintenance_window.nil?
Expand Down Expand Up @@ -128,55 +129,31 @@
end
}

if engine_mode == 'serverless' || engine_mode == 'serverlessv2'
RDS_DBInstance(:ServerlessDBInstance) {
DBParameterGroupName Ref(:DBInstanceParameterGroup)
Engine external_parameters[:engine]
DBInstanceClass 'db.serverless'
DBClusterIdentifier Ref(:DBCluster)
EnablePerformanceInsights Ref('EnablePerformanceInsights')
PerformanceInsightsRetentionPeriod FnIf('EnablePerformanceInsights', Ref('PerformanceInsightsRetentionPeriod'), Ref('AWS::NoValue'))
Tags tags
}

RDS_DBInstance(:ServerlessDBInstanceReader) {
Condition(:EnableReader)
DBParameterGroupName Ref(:DBInstanceParameterGroup)
Engine external_parameters[:engine]
DBInstanceClass 'db.serverless'
DBClusterIdentifier Ref(:DBCluster)
EnablePerformanceInsights Ref('EnablePerformanceInsights')
PerformanceInsightsRetentionPeriod FnIf('EnablePerformanceInsights', Ref('PerformanceInsightsRetentionPeriod'), Ref('AWS::NoValue'))
PromotionTier FnJoin('', ['0', Ref(:ReaderPromotionTier)])
Tags tags
}
else
RDS_DBInstance(:DBClusterInstanceWriter) {
DBSubnetGroupName Ref(:DBClusterSubnetGroup)
DBParameterGroupName Ref(:DBInstanceParameterGroup)
DBClusterIdentifier Ref(:DBCluster)
Engine external_parameters[:engine]
PubliclyAccessible 'false'
DBInstanceClass Ref(:WriterInstanceType)
EnablePerformanceInsights Ref('EnablePerformanceInsights')
PerformanceInsightsRetentionPeriod FnIf('EnablePerformanceInsights', Ref('PerformanceInsightsRetentionPeriod'), Ref('AWS::NoValue'))
Tags tags + [{ Key: 'Name', Value: FnJoin('-', [ Ref(:EnvironmentName), external_parameters[:component_name], 'writer-instance' ])}]
}
RDS_DBInstance(:DBClusterInstanceWriter) {
DBParameterGroupName Ref(:DBInstanceParameterGroup)
Engine external_parameters[:engine]
DBClusterIdentifier Ref(:DBCluster)
DBSubnetGroupName Ref(:DBClusterSubnetGroup)
EnablePerformanceInsights Ref('EnablePerformanceInsights')
PerformanceInsightsRetentionPeriod FnIf('EnablePerformanceInsights', Ref('PerformanceInsightsRetentionPeriod'), Ref('AWS::NoValue'))
Tags tags + [{ Key: 'Name', Value: FnJoin('-', [ Ref(:EnvironmentName), external_parameters[:component_name], 'writer-instance' ])}]
PubliclyAccessible 'false'
DBInstanceClass Ref(:WriterInstanceType)
}

RDS_DBInstance(:DBClusterInstanceReader) {
Condition(:EnableReader)
DBSubnetGroupName Ref(:DBClusterSubnetGroup)
DBParameterGroupName Ref(:DBInstanceParameterGroup)
DBClusterIdentifier Ref(:DBCluster)
Engine external_parameters[:engine]
PubliclyAccessible 'false'
DBInstanceClass Ref(:ReaderInstanceType)
EnablePerformanceInsights Ref('EnablePerformanceInsights')
PerformanceInsightsRetentionPeriod FnIf('EnablePerformanceInsights', Ref('PerformanceInsightsRetentionPeriod'), Ref('AWS::NoValue'))
PromotionTier FnJoin('', ['0', Ref(:ReaderPromotionTier)])
Tags tags + [{ Key: 'Name', Value: FnJoin('-', [ Ref(:EnvironmentName), external_parameters[:component_name], 'reader-instance' ])}]
}
end
RDS_DBInstance(:DBClusterInstanceReader) {
Condition(:EnableReader)
DBParameterGroupName Ref(:DBInstanceParameterGroup)
Engine external_parameters[:engine]
DBClusterIdentifier Ref(:DBCluster)
DBSubnetGroupName Ref(:DBClusterSubnetGroup)
EnablePerformanceInsights Ref('EnablePerformanceInsights')
PerformanceInsightsRetentionPeriod FnIf('EnablePerformanceInsights', Ref('PerformanceInsightsRetentionPeriod'), Ref('AWS::NoValue'))
Tags tags + [{ Key: 'Name', Value: FnJoin('-', [ Ref(:EnvironmentName), external_parameters[:component_name], 'reader-instance' ])}]
PubliclyAccessible 'false'
PromotionTier FnJoin('', ['0', Ref(:ReaderPromotionTier)])
DBInstanceClass Ref(:ReaderInstanceType)
}

Route53_RecordSet(:DBHostRecord) {
if external_parameters[:dns_format]
Expand Down