{ "$schema": "./aws-deploy-recipe-schema.json", "Id": "ConsoleAppEcsFargateScheduleTask", "Version": "1.0.2", "Name": "Scheduled Task on Amazon Elastic Container Service (ECS) using AWS Fargate", "DeploymentType": "CdkProject", "DeploymentBundle": "Container", "CdkProjectTemplate": "../CdkTemplates/ConsoleAppECSFargateScheduleTask", "CdkProjectTemplateId": "netdeploy.ConsoleAppECSFargateScheduleTask", "Description": "This .NET Console application will be built using a Dockerfile and deployed as a scheduled task to Amazon Elastic Container Service (Amazon ECS) with compute power managed by AWS Fargate compute engine. If your project does not contain a Dockerfile it will be automatically generated, otherwise an existing Dockerfile will be used. Recommended if you want to deploy a scheduled task as a container image on Linux.", "ShortDescription": "Deploys a scheduled task as a Linux container image to a fully managed container orchestration service. Dockerfile will be automatically generated if needed.", "TargetService": "Amazon Elastic Container Service", "TargetPlatform": "Linux", "DisplayedResources": [ { "LogicalId": "RecipeEcsClusterB4EDBB7E", "Description": "ECS Cluster" }, { "LogicalId": "RecipeAppTaskDefinitionAC7F53DB", "Description": "ECS Task Definition" }, { "LogicalId": "RecipeScheduleTaskScheduledEventRuleAB80FDC8", "Description": "CloudWatch Event" } ], "RecipePriority": 100, "RecommendationRules": [ { "Tests": [ { "Type": "MSProjectSdkAttribute", "Condition": { "Value": "Microsoft.NET.Sdk" } }, { "Type": "MSProperty", "Condition": { "PropertyName": "TargetFramework", "AllowedValues": [ "netcoreapp3.1", "net5.0", "net6.0", "net7.0" ] } }, { "Type": "MSProperty", "Condition": { "PropertyName": "OutputType", "AllowedValues": [ "Exe" ] } } ], "Effect": { "Pass": { "Include": true } } }, { "Tests": [ { "Type": "FileExists", "Condition": { "FileName": "Dockerfile" } } ], "Effect": { "Fail": { "PriorityAdjustment": -50, "Include": true } } }, { "Tests": [ { "Type": "MSPropertyExists", "Condition": { "PropertyName": "AWSProjectType" } } ], "Effect": { "Pass": { "Include": false }, "Fail": { "Include": true } } } ], "Validators": [ { "ValidatorType": "FargateTaskSizeCpuMemoryLimits" }, { "ValidatorType": "ValidDockerfilePath" } ], "Categories": [ { "Id": "General", "DisplayName": "General", "Order": 10 }, { "Id": "Compute", "DisplayName": "Compute", "Order": 20 }, { "Id": "Permissions", "DisplayName": "Permissions", "Order": 30 }, { "Id": "VPC", "DisplayName": "VPC", "Order": 40 }, { "Id": "EnvVariables", "DisplayName": "Environment Variables", "Order": 50 } ], "OptionSettings": [ { "Id": "ECSCluster", "Name": "ECS Cluster", "Category": "General", "Description": "The ECS cluster used for the deployment.", "Type": "Object", "TypeHint": "ECSCluster", "AdvancedSetting": false, "Updatable": false, "ChildOptionSettings": [ { "Id": "CreateNew", "Name": "Create New ECS Cluster", "Description": "Do you want to create a new ECS cluster?", "Type": "Bool", "DefaultValue": true, "AdvancedSetting": false, "Updatable": false }, { "Id": "ClusterArn", "Name": "Existing Cluster ARN", "Description": "The ARN of the existing cluster to use.", "Type": "String", "TypeHint": "ExistingECSCluster", "AdvancedSetting": false, "Updatable": false, "Validators": [ { "ValidatorType": "Regex", "Configuration": { "Regex": "arn:[^:]+:ecs:[^:]*:[0-9]{12}:cluster/.+", "ValidationFailedMessage": "Invalid cluster Arn. The ARN should contain the arn:[PARTITION]:ecs namespace, followed by the Region of the cluster, the AWS account ID of the cluster owner, the cluster namespace, and then the cluster name. For example, arn:aws:ecs:region:012345678910:cluster/test. For more information visit https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_Cluster.html" } } ], "DependsOn": [ { "Id": "ECSCluster.CreateNew", "Value": false } ] }, { "Id": "NewClusterName", "Name": "New Cluster Name", "Description": "The name of the new cluster to create.", "Type": "String", "DefaultValue": "{StackName}", "AdvancedSetting": false, "Updatable": false, "Validators": [ { "ValidatorType": "Regex", "Configuration": { "Regex": "^([A-Za-z0-9_-]{1,255})$", "ValidationFailedMessage": "Invalid cluster name. The cluster name can only contain letters (case-sensitive), numbers, hyphens, underscores and can't be longer than 255 character in length." } } ], "DependsOn": [ { "Id": "ECSCluster.CreateNew", "Value": true } ] } ] }, { "Id": "ApplicationIAMRole", "Name": "Application IAM Role", "Category": "Permissions", "Description": "The Identity and Access Management (IAM) role that provides AWS credentials to the application to access AWS services.", "Type": "Object", "TypeHint": "IAMRole", "TypeHintData": { "ServicePrincipal": "ecs-tasks.amazonaws.com" }, "AdvancedSetting": false, "Updatable": true, "ChildOptionSettings": [ { "Id": "CreateNew", "Name": "Create New Role", "Description": "Do you want to create a new role?", "Type": "Bool", "DefaultValue": true, "AdvancedSetting": false, "Updatable": true }, { "Id": "RoleArn", "Name": "Existing Role ARN", "Description": "The ARN of the existing role to use.", "Type": "String", "TypeHint": "ExistingIAMRole", "TypeHintData": { "ServicePrincipal": "ecs-tasks.amazonaws.com" }, "AdvancedSetting": false, "Updatable": true, "Validators": [ { "ValidatorType": "Regex", "Configuration": { "Regex": "arn:.+:iam::[0-9]{12}:.+", "ValidationFailedMessage": "Invalid IAM Role ARN. The ARN should contain the arn:[PARTITION]:iam namespace, followed by the account ID, and then the resource path. For example - arn:aws:iam::123456789012:role/S3Access is a valid IAM Role ARN. For more information visit https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-arns" } } ], "DependsOn": [ { "Id": "ApplicationIAMRole.CreateNew", "Value": false } ] } ] }, { "Id": "Schedule", "Name": "Task Schedule", "Category": "General", "Description": "The schedule or rate (frequency) that determines when Amazon CloudWatch Events runs the rule. For details about the format for this value, see the CloudWatch Events guide: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html", "Type": "String", "TypeHint": "ECSTaskSchedule", "DefaultValue": "rate(1 hour)", "AdvancedSetting": false, "Updatable": false }, { "Id": "Vpc", "Name": "Virtual Private Cloud (VPC)", "Category": "VPC", "Description": "A VPC enables you to launch the application into a virtual network that you've defined.", "Type": "Object", "TypeHint": "Vpc", "AdvancedSetting": false, "Updatable": false, "ChildOptionSettings": [ { "Id": "IsDefault", "Name": "Use default VPC", "Description": "Do you want to use the default VPC?", "Type": "Bool", "DefaultValue": "{HasDefaultVpc}", "AdvancedSetting": false, "Updatable": false, "Validators": [ { "ValidatorType": "VpcExists", "Configuration": { "FailValue": true, "DefaultVpc": true, "ValueType": "Bool", "ValidationFailedMessage": "A default VPC could not be found." } } ] }, { "Id": "CreateNew", "Name": "Create New VPC", "Description": "Do you want to create a new VPC?", "Type": "Bool", "DefaultValue": "{HasNotVpcs}", "AdvancedSetting": false, "Updatable": false, "Validators": [ { "ValidatorType": "VpcExists", "Configuration": { "FailValue": false, "DefaultVpc": false, "ValueType": "Bool", "ValidationFailedMessage": "You must create a new VPC since there are no existing VPCs to be used." } } ], "DependsOn": [ { "Id": "Vpc.IsDefault", "Value": false } ] }, { "Id": "VpcId", "Name": "Existing VPC ID", "Description": "The ID of the existing VPC to use.", "Type": "String", "TypeHint": "ExistingVpc", "DefaultValue": "{DefaultVpcId}", "AdvancedSetting": false, "Updatable": false, "Validators": [ { "ValidatorType": "Regex", "Configuration": { "Regex": "^vpc-([0-9a-f]{8}|[0-9a-f]{17})$", "ValidationFailedMessage": "Invalid VPC ID. The VPC ID must start with the \"vpc-\" prefix, followed by either 8 or 17 characters consisting of digits and letters(lower-case) from a to f. For example vpc-abc88de9 is a valid VPC ID." } } ], "DependsOn": [ { "Id": "Vpc.IsDefault", "Value": false }, { "Id": "Vpc.CreateNew", "Value": false } ] } ] }, { "Id": "TaskCpu", "Name": "Task CPU", "Category": "Compute", "Description": "The number of CPU units used by the task. See the following for details on CPU values: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html#fargate-task-defs", "Type": "Int", "DefaultValue": 256, "AdvancedSetting": true, "Updatable": true, "AllowedValues": [ "256", "512", "1024", "2048", "4096" ], "ValueMapping": { "256": "256 (.25 vCPU)", "512": "512 (.5 vCPU)", "1024": "1024 (1 vCPU)", "2048": "2048 (2 vCPU)", "4096": "4096 (4 vCPU)" } }, { "Id": "TaskMemory", "Name": "Task Memory", "Category": "Compute", "Description": "The amount of memory (in MB) used by the task. See the following for details on memory values: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/AWS_Fargate.html#fargate-task-defs", "Type": "Int", "DefaultValue": 512, "AdvancedSetting": true, "Updatable": true, "AllowedValues": [ "512", "1024", "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" ], "ValueMapping": { "512": "0.5 GB", "1024": "1 GB", "2048": "2 GB", "3072": "3 GB", "4096": "4 GB", "5120": "5 GB", "6144": "6 GB", "7168": "7 GB", "8192": "8 GB", "9216": "9 GB", "10240": "10 GB", "11264": "11 GB", "12288": "12 GB", "13312": "13 GB", "14336": "14 GB", "15360": "15 GB", "16384": "16 GB", "17408": "17 GB", "18432": "18 GB", "19456": "19 GB", "20480": "20 GB", "21504": "21 GB", "22528": "22 GB", "23552": "23 GB", "24576": "24 GB", "25600": "25 GB", "26624": "26 GB", "27648": "27 GB", "28672": "28 GB", "29696": "29 GB", "30720": "30 GB" } }, { "Id": "ECSEnvironmentVariables", "Name": "Environment Variables", "Category": "EnvVariables", "Description": "Configure environment properties for your application.", "Type": "KeyValue", "AdvancedSetting": false, "Updatable": true } ] }