AWSTemplateFormatVersion: '2010-09-09' Description: Data plane Transform: - sqlserverdevfabric-macro Metadata: AWS::CloudFormation::Interface: ParameterLabels: ClusterName: default: "ECS Cluster name" DBInstancesCount: default: "SQL Instance count" CloudWatchLogGroup: default: "Cloud Watch Log Group name" ImageUrl: default: "SQL Server docker image" TaskCPU: default: "Server CPU shares" TaskMemory: default: "Server RAM Memory (MB)" UseSpot: default: "Enable Fargate Spot for this setup" MSSQLCOLLATION: default: "Collation and Unicode support" OfficeHours: default: "Enable / Disable" OfficeHoursActive: default: "Select a weekly schedule" OfficeHoursStart: default: "Time to start (UTC)" OfficeHoursStop: default: "Time to stop (UTC)" ParameterGroups: - Label: default: "Service settings ..." Parameters: - ClusterName - DBInstancesCount - CloudWatchLogGroup - Label: default: "SQL Server configuration ..." Parameters: - ImageUrl - TaskCPU - TaskMemory - UseSpot - MSSQLCOLLATION - Label: default: "Office hours ..." Parameters: - OfficeHours - OfficeHoursActive - OfficeHoursStart - OfficeHoursStop Conditions: EverydayCondition: !Equals [!Ref OfficeHoursActive, 'Everyday'] Parameters: ClusterName: Type: String Default: sqlserverdevfabric-cluster Description: > Must match the ECS Cluster created by the Control Plane, were you intend to deploy the SQL Instances AllowedValues: - sqlserverdevfabric-cluster DBInstancesCount: Type: Number Description: > How many DB instances with the exact same configuration do you want to deploy? Default: 1 CloudWatchLogGroup: Type: String Description: > Specify the destination Log Group in CloudWatch Default: /ecs/SQLServerFargate ImageUrl: Type: String Description: > SQL Server Docker image to deploy Default: mcr.microsoft.com/mssql/server:2019-CU4-ubuntu-18.04 TaskCPU: Type: Number Description: > Allocated CPU shares for the container that will run the database engine. Please consider the following supported combinations: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html Default: 2048 AllowedValues: - 1024 - 2048 - 4096 TaskMemory: Type: Number Description: > Allocated RAM memory for the container that will run the database engine. Please consider the following supported combinations: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html Default: 16384 AllowedValues: - 2048 - 3072 - 4096 - 5120 - 6144 - 7168 - 8192 - 9216 - 10240 - 11264 - 12288 - 13312 - 14336 - 15360 - 16384 - 17408 - 18432 - 19456 - 20480 - 21504 - 22528 - 23552 - 24576 - 25600 - 26624 - 27648 - 28672 - 29696 - 30720 UseSpot: Type: String Description: > Choose if you want to use Fargate Spot technology Default: No AllowedValues: - Yes - No OfficeHours: Type: String Description: > Choose if you want to enable scheduled on / off Default: No AllowedValues: - Yes - No OfficeHoursActive: Type: String Description: > Select whether the schedule will be enabled for the whole week or only on business days Default: Everyday AllowedValues: - Everyday - Monday-to-Friday OfficeHoursStart: Type: String Description: > This value must be in UTC Default: 9-AM AllowedValues: - 12-Midnight - 1-AM - 2-AM - 3-AM - 4-AM - 6-AM - 7-AM - 8-AM - 9-AM - 10-AM - 11-AM - 12-Noon - 1-PM - 2-PM - 3-PM - 4-PM - 5-PM - 6-PM - 7-PM - 8-PM - 9-PM - 10-PM - 11-PM OfficeHoursStop: Type: String Description: > This value must be in UTC Default: 6-PM AllowedValues: - 12-Midnight - 1-AM - 2-AM - 3-AM - 4-AM - 6-AM - 7-AM - 8-AM - 9-AM - 10-AM - 11-AM - 12-Noon - 1-PM - 2-PM - 3-PM - 4-PM - 5-PM - 6-PM - 7-PM - 8-PM - 9-PM - 10-PM - 11-PM MSSQLCOLLATION: Type: String Default: SQL_Latin1_General_CP1_CI_AS Description: SQL Server collation setting Mappings: 24hTimeMap: 12-Midnight: 24h: '0' 1-AM: 24h: '1' 2-AM: 24h: '2' 3-AM: 24h: '3' 4-AM: 24h: '4' 5-AM: 24h: '5' 6-AM: 24h: '6' 7-AM: 24h: '7' 8-AM: 24h: '8' 9-AM: 24h: '9' 10-AM: 24h: '10' 11-AM: 24h: '11' 12-Noon: 24h: '12' 1-PM: 24h: '13' 2-PM: 24h: '14' 3-PM: 24h: '15' 4-PM: 24h: '16' 5-PM: 24h: '17' 6-PM: 24h: '18' 7-PM: 24h: '19' 8-PM: 24h: '20' 9-PM: 24h: '21' 10-PM: 24h: '22' 11-PM: 24h: '23' Resources: ServiceStack: Type: AWS::CloudFormation::Stack Count: !Ref DBInstancesCount Properties: TemplateURL: fargate-sql-service/fargate-sql-service.yaml Parameters: UseSpot: !Ref UseSpot ClusterName: Fn::ImportValue: !Sub '${ClusterName}::TheECSCluster' TheVPCID: Fn::ImportValue: !Sub '${ClusterName}::TheVPCID' DefaultAccessCIDR: Fn::ImportValue: !Sub '${ClusterName}::TheVPCCIDR' SubnetsPrivate: Fn::ImportValue: !Sub '${ClusterName}::SubnetsPrivate' SRVPrefix: !Sub db-${IdGenerator.unique_id}-%s ServiceDiscoveryNamespace: Fn::ImportValue: !Sub '${ClusterName}::ServiceDiscoveryNamespace' EFSID: Fn::ImportValue: !Sub '${ClusterName}::EFS' CloudWatchLogGroup: !Ref CloudWatchLogGroup ImageUrl: !Ref ImageUrl ContainerPort: 1433 TaskCPU: !Ref TaskCPU TaskMemory: !Ref TaskMemory MSSQLCOLLATION: !Ref MSSQLCOLLATION OfficeHours: !Ref OfficeHours OfficeHoursActive: !If [EverydayCondition, '?', 'MON-FRI'] OfficeHoursStart: !FindInMap - 24hTimeMap - !Ref OfficeHoursStart - 24h OfficeHoursStop: !FindInMap - 24hTimeMap - !Ref OfficeHoursStop - '24h' IdGenerator: Type: Custom::IdGenerator Properties: ServiceToken: Fn::ImportValue: !Sub '${ClusterName}::IdGeneratorServiceToken'