I want to create read replicas if the user needs it, the choice is a parameter of the cloudformation template. The template executes through when the choice is made to create the replica, but when No is selected to not to create the replica, it throws below error. Please check and let me know what am I missing.
....
DatabaseReadReplicaRequired:
Type: String
Default: 'No'
AllowedValues:
- 'Yes'
- 'No'
Description: The database cluster needs a read replica
....
Conditions:
CreateReadReplica: !Equals [ !Ref DatabaseReadReplicaRequired, "Yes" ]
.....
DatabasePrimaryInstance:
....
DatabaseReplicaInstance:
Metadata:
cfn_nag:
rules_to_suppress:
- id: F22
Type: AWS::RDS::DBInstance
Condition: CreateReadReplica
Properties:
Engine: aurora-postgresql
EngineVersion: '10.6'
DBClusterIdentifier:
Ref: DatabaseCluster
DBInstanceClass:
Ref: DatabaseInstanceType
DBSubnetGroupName:
Ref: DatabaseSubnetGroup
PubliclyAccessible: False
EnablePerformanceInsights: True
DBParameterGroupName: aurora-postgresql-10dot6
After the block for primary and replica instances, there are blocks for creating alarms for both primary and replicas. The condition has been put for remaining replicas alarms code as well. The error it throws is
An error occurred (ValidationError) when calling the CreateStack operation: Template format error: Unresolved resource dependencies [DatabaseReplicaInstance] in the Resources block of the template
DatabaseReplicaInstancein the template? - John Rotenstein