AWSTemplateFormatVersion: '2010-09-09' Description: 'CloudFormation Template to create the DMS replication instance, endpoints, and tasks' ############################################################################### # Parameters ############################################################################### Parameters: ParentVPCStack: Description: 'Provide Stack name of parent VPC stack based on VPC-3AZs yaml template. Refer Cloudformation dashboard in AWS Console to get this.' Type: String MinLength: '1' MaxLength: '128' AllowedPattern: '^[a-zA-Z]+[0-9a-zA-Z\-]*$' DMSInstanceClass: Description: Replication Instance Type Type: String Default: dms.r5.large AllowedValues: - dms.r5.large - dms.r5.xlarge - dms.r5.2xlarge - dms.r5.4xlarge - dms.r5.8xlarge - dms.r5.12xlarge - dms.r5.16xlarge - dms.r5.24xlarge ########################################################################### # Mandatory tags that will be added to all resources that support tags ########################################################################### EnvironmentStage: Type: String Description: The environment tag is used to designate the Environment Stage of the associated AWS resource. AllowedValues: - dev - test - pre-prod - prod Default: dev ############################################################################### # Conditions ############################################################################### Conditions: IsProd: !Equals [!Ref EnvironmentStage, 'prod'] MultiAZ: !Or [!Equals [!Ref EnvironmentStage, 'pre-prod'], Condition: IsProd] ############################################################################### # Resources ############################################################################### Resources: ReplicationSubnetGroup: Type: AWS::DMS::ReplicationSubnetGroup Properties: ReplicationSubnetGroupDescription: !Ref 'AWS::StackName' SubnetIds: !Split [',', {'Fn::ImportValue': !Sub '${ParentVPCStack}-SubnetsPrivate'}] DMSSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: !Ref 'AWS::StackName' VpcId: {'Fn::ImportValue': !Sub '${ParentVPCStack}-VPC'} Tags: - Key: Name Value: !Sub '${AWS::StackName}-DMSSecurityGroup' ReplicationInstance: Type: AWS::DMS::ReplicationInstance Properties: MultiAZ: !If [MultiAZ, true, false] PubliclyAccessible: true ReplicationInstanceClass: !Ref DMSInstanceClass ReplicationSubnetGroupIdentifier: !Ref ReplicationSubnetGroup VpcSecurityGroupIds: - !Ref DMSSecurityGroup Outputs: ReplicationInstanceArn: Value: !Ref ReplicationInstance DMSSecurityGroupID: Description: Use this Security Group to reference incoming traffic from RDS instance Value: !Ref DMSSecurityGroup Export: Name: !Sub '${AWS::StackName}-DMSSecurityGroupID'