From 9afaa7b820c64969dd1213a4063f6b97373d215e Mon Sep 17 00:00:00 2001 From: Eoin Shanaghy Date: Fri, 20 May 2022 20:24:20 +0100 Subject: [PATCH] Regenerate test template and tidy up README and ymls --- README.md | 20 ++- .../cloudformation-template-stack.json | 125 +++++++++++----- serverless-test-project/serverless-v2.yml | 89 +---------- serverless-test-project/serverless.yml | 138 +----------------- serverless-test-project/sls-resources.yml | 137 +++++++++++++++++ 5 files changed, 249 insertions(+), 260 deletions(-) create mode 100644 serverless-test-project/sls-resources.yml diff --git a/README.md b/README.md index e9423a15..4efca7c9 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ SLIC Watch provides a CloudWatch Dashboard and Alarms for: 4. Kinesis Data Streams 5. SQS Queues 6. Step Functions - 7. ECS on Fargate + 7. ECS (Fargate or EC2) Currently, SLIC Watch is available as a Serverless Framework plugin. Serverless Framework v2 and v3 are supported. @@ -139,6 +139,12 @@ The dashboard contains one widget per Step Function: |--| |![Step Function widget](https://raw.githubusercontent.com/fourtheorem/slic-watch/main/docs/stepFunctions.png) +### ECS / Fargate + +ECS alarms are created for Fargate or EC2 clusters: +1. Memory Utilization +2. CPU Utilization + ## Configuration Configuration is entirely optional - SLIC Watch provides defaults that work out of the box. @@ -253,6 +259,13 @@ custom: InFlightMessagesPc: Statistic: Maximum Threshold: 80 # 80% of 120.000 for regular queues or 80% of 20000 for FIFO queues + ECS: + MemoryUtilization: + Statistic: Average + Threshold: 90 + CPUUtilization: + Statistic: Average + Threshold: 90 dashboard: enabled: true @@ -328,6 +341,11 @@ custom: Statistic: ["Maximum"] ApproximateNumberOfMessagesVisible: Statistic: ["Maximum"] + ECS: + MemoryUtilization: + Statistic: ["Average"] + CPUUtilization: + Statistic: ["Average"] ``` An example project is provided for reference: [serverless-test-project](./serverless-test-project) diff --git a/serverless-plugin/tests/resources/cloudformation-template-stack.json b/serverless-plugin/tests/resources/cloudformation-template-stack.json index 7c36ed12..c8da0476 100644 --- a/serverless-plugin/tests/resources/cloudformation-template-stack.json +++ b/serverless-plugin/tests/resources/cloudformation-template-stack.json @@ -220,7 +220,7 @@ "S3Bucket": { "Ref": "ServerlessDeploymentBucket" }, - "S3Key": "serverless/serverless-test-project/dev/1652971024918-2022-05-19T14:37:04.918Z/serverless-test-project.zip" + "S3Key": "serverless/serverless-test-project/dev/1653074572190-2022-05-20T19:22:52.190Z/serverless-test-project.zip" }, "Handler": "basic-handler.hello", "Runtime": "nodejs12.x", @@ -245,7 +245,7 @@ "S3Bucket": { "Ref": "ServerlessDeploymentBucket" }, - "S3Key": "serverless/serverless-test-project/dev/1652971024918-2022-05-19T14:37:04.918Z/serverless-test-project.zip" + "S3Key": "serverless/serverless-test-project/dev/1653074572190-2022-05-20T19:22:52.190Z/serverless-test-project.zip" }, "Handler": "basic-handler.hello", "Runtime": "nodejs12.x", @@ -270,7 +270,7 @@ "S3Bucket": { "Ref": "ServerlessDeploymentBucket" }, - "S3Key": "serverless/serverless-test-project/dev/1652971024918-2022-05-19T14:37:04.918Z/serverless-test-project.zip" + "S3Key": "serverless/serverless-test-project/dev/1653074572190-2022-05-20T19:22:52.190Z/serverless-test-project.zip" }, "Handler": "basic-handler.hello", "Runtime": "nodejs12.x", @@ -296,7 +296,7 @@ "S3Bucket": { "Ref": "ServerlessDeploymentBucket" }, - "S3Key": "serverless/serverless-test-project/dev/1652971024918-2022-05-19T14:37:04.918Z/serverless-test-project.zip" + "S3Key": "serverless/serverless-test-project/dev/1653074572190-2022-05-20T19:22:52.190Z/serverless-test-project.zip" }, "Handler": "stream-test-handler.handleDrive", "Runtime": "nodejs12.x", @@ -328,7 +328,7 @@ "S3Bucket": { "Ref": "ServerlessDeploymentBucket" }, - "S3Key": "serverless/serverless-test-project/dev/1652971024918-2022-05-19T14:37:04.918Z/serverless-test-project.zip" + "S3Key": "serverless/serverless-test-project/dev/1653074572190-2022-05-20T19:22:52.190Z/serverless-test-project.zip" }, "Handler": "queue-test-handler.handleDrive", "Runtime": "nodejs12.x", @@ -353,7 +353,7 @@ "S3Bucket": { "Ref": "ServerlessDeploymentBucket" }, - "S3Key": "serverless/serverless-test-project/dev/1652971024918-2022-05-19T14:37:04.918Z/serverless-test-project.zip" + "S3Key": "serverless/serverless-test-project/dev/1653074572190-2022-05-20T19:22:52.190Z/serverless-test-project.zip" }, "Handler": "table-test-hander.handleDrive", "Runtime": "nodejs12.x", @@ -378,7 +378,7 @@ "S3Bucket": { "Ref": "ServerlessDeploymentBucket" }, - "S3Key": "serverless/serverless-test-project/dev/1652971024918-2022-05-19T14:37:04.918Z/serverless-test-project.zip" + "S3Key": "serverless/serverless-test-project/dev/1653074572190-2022-05-20T19:22:52.190Z/serverless-test-project.zip" }, "Handler": "stream-handler.handle", "Runtime": "nodejs12.x", @@ -403,7 +403,7 @@ "S3Bucket": { "Ref": "ServerlessDeploymentBucket" }, - "S3Key": "serverless/serverless-test-project/dev/1652971024918-2022-05-19T14:37:04.918Z/serverless-test-project.zip" + "S3Key": "serverless/serverless-test-project/dev/1653074572190-2022-05-20T19:22:52.190Z/serverless-test-project.zip" }, "Handler": "apigw-handler.handleGet", "Runtime": "nodejs12.x", @@ -421,84 +421,84 @@ "HttpGetterLogGroup" ] }, - "HelloLambdaVersionHKXJuXgeYK24V0jAKRC7KaQUIARaC0kev5TAPmRBOM": { + "HelloLambdaVersion722UxcHK84FtzQksFJLgO33214XN092rFeZxfBAWMI": { "Type": "AWS::Lambda::Version", "DeletionPolicy": "Retain", "Properties": { "FunctionName": { "Ref": "HelloLambdaFunction" }, - "CodeSha256": "ioyXQRkX35upN27acK2lHIXf6rzydwQyWyC+WjYATl8=" + "CodeSha256": "FiQzGCDK0fxVWHwCwOVhJmiILUfHAGFpReDupCZm4IY=" } }, - "PingLambdaVersionivrf6dIZWzXv8jGaqqossToBBai1QiV7kuefBNU0Xc": { + "PingLambdaVersionkRCLggFwidyGPubIpsDG3Bz131vjOVNlzKj7NBM8UgE": { "Type": "AWS::Lambda::Version", "DeletionPolicy": "Retain", "Properties": { "FunctionName": { "Ref": "PingLambdaFunction" }, - "CodeSha256": "ioyXQRkX35upN27acK2lHIXf6rzydwQyWyC+WjYATl8=" + "CodeSha256": "FiQzGCDK0fxVWHwCwOVhJmiILUfHAGFpReDupCZm4IY=" } }, - "ThrottlerLambdaVersionWHo4eySHjExzIm6sn8tyhX4tUxNvoM2vTi8SEMEjK0": { + "ThrottlerLambdaVersionl91cFljDzhpqWXdQeA2t4nCL4O8S6eewBytew6LYg": { "Type": "AWS::Lambda::Version", "DeletionPolicy": "Retain", "Properties": { "FunctionName": { "Ref": "ThrottlerLambdaFunction" }, - "CodeSha256": "ioyXQRkX35upN27acK2lHIXf6rzydwQyWyC+WjYATl8=" + "CodeSha256": "FiQzGCDK0fxVWHwCwOVhJmiILUfHAGFpReDupCZm4IY=" } }, - "DriveStreamLambdaVersion8BINjBgQgQLwrsojAUC2l9zsiEkFaTbLzqD81toJd8": { + "DriveStreamLambdaVersionZym9I4CW26PuJ2g26SXA4zCtxJm3jUEOzGB9JSpCIA": { "Type": "AWS::Lambda::Version", "DeletionPolicy": "Retain", "Properties": { "FunctionName": { "Ref": "DriveStreamLambdaFunction" }, - "CodeSha256": "ioyXQRkX35upN27acK2lHIXf6rzydwQyWyC+WjYATl8=" + "CodeSha256": "FiQzGCDK0fxVWHwCwOVhJmiILUfHAGFpReDupCZm4IY=" } }, - "DriveQueueLambdaVersionnQWkvsurMZfdbvJ5JQ800smP3XYTdNjQ56nH5N6Pzg": { + "DriveQueueLambdaVersionqxLBmX6bkW9KfIv3nK7Euv6IWU2k1LNIfruRKLQ": { "Type": "AWS::Lambda::Version", "DeletionPolicy": "Retain", "Properties": { "FunctionName": { "Ref": "DriveQueueLambdaFunction" }, - "CodeSha256": "ioyXQRkX35upN27acK2lHIXf6rzydwQyWyC+WjYATl8=" + "CodeSha256": "FiQzGCDK0fxVWHwCwOVhJmiILUfHAGFpReDupCZm4IY=" } }, - "DriveTableLambdaVersionAsgfm3jPQKIicJD2Tsu4qH5VqW5K5yi5nmq2tk4Po": { + "DriveTableLambdaVersionmshp4vuCFXIuqNxokV8OQhvrXhDNTcfJirpkqQC5PM": { "Type": "AWS::Lambda::Version", "DeletionPolicy": "Retain", "Properties": { "FunctionName": { "Ref": "DriveTableLambdaFunction" }, - "CodeSha256": "ioyXQRkX35upN27acK2lHIXf6rzydwQyWyC+WjYATl8=" + "CodeSha256": "FiQzGCDK0fxVWHwCwOVhJmiILUfHAGFpReDupCZm4IY=" } }, - "StreamProcessorLambdaVersionyMKRoNaY0699T5oh5ae9YBYHvESiBHITGCLSPHGaLdk": { + "StreamProcessorLambdaVersionwlUSF2MKmypdz7S8ASUEQJniFQJWYRU4J5ElG6ncY": { "Type": "AWS::Lambda::Version", "DeletionPolicy": "Retain", "Properties": { "FunctionName": { "Ref": "StreamProcessorLambdaFunction" }, - "CodeSha256": "ioyXQRkX35upN27acK2lHIXf6rzydwQyWyC+WjYATl8=" + "CodeSha256": "FiQzGCDK0fxVWHwCwOVhJmiILUfHAGFpReDupCZm4IY=" } }, - "HttpGetterLambdaVersionyoyVGg99BR9qEwqfluEa261oLc1Hp5uhkAHD24QxI": { + "HttpGetterLambdaVersion8bkTDhhXsi9cMBh96OfTi3WanBalxcwLoE8XqtXkHcc": { "Type": "AWS::Lambda::Version", "DeletionPolicy": "Retain", "Properties": { "FunctionName": { "Ref": "HttpGetterLambdaFunction" }, - "CodeSha256": "ioyXQRkX35upN27acK2lHIXf6rzydwQyWyC+WjYATl8=" + "CodeSha256": "FiQzGCDK0fxVWHwCwOVhJmiILUfHAGFpReDupCZm4IY=" } }, "WorkflowRole": { @@ -803,7 +803,7 @@ "HttpGetterLambdaPermissionApiGateway" ] }, - "ApiGatewayDeployment1652971020829": { + "ApiGatewayDeployment1653074568829": { "Type": "AWS::ApiGateway::Deployment", "Properties": { "RestApiId": { @@ -1005,6 +1005,22 @@ "RetentionInDays": 1 } }, + "vpc": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.0.0.0/16" + } + }, + "subnet": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": "eu-west-1a", + "CidrBlock": "10.0.16.0/20", + "VpcId": { + "Ref": "vpc" + } + } + }, "ecsCluster": { "Type": "AWS::ECS::Cluster", "Properties": { @@ -1019,7 +1035,48 @@ "Ref": "ecsCluster" }, "DesiredCount": 0, - "LaunchType": "FARGATE" + "LaunchType": "FARGATE", + "TaskDefinition": { + "Ref": "taskDef" + }, + "NetworkConfiguration": { + "AwsvpcConfiguration": { + "AssignPublicIp": "ENABLED", + "SecurityGroups": [], + "Subnets": [ + { + "Ref": "subnet" + } + ] + } + } + } + }, + "taskDef": { + "Type": "AWS::ECS::TaskDefinition", + "Properties": { + "RequiresCompatibilities": [ + "FARGATE" + ], + "Cpu": 256, + "Memory": 512, + "ContainerDefinitions": [ + { + "Name": "busybox", + "Image": "busybox", + "Cpu": 256, + "EntryPoint": [ + "sh", + "-c" + ], + "Memory": 512, + "Command": [ + "/bin/sh -c \"while true; do echo Hello; sleep 10; done\"" + ], + "Essential": true + } + ], + "NetworkMode": "awsvpc" } } }, @@ -1035,7 +1092,7 @@ "HelloLambdaFunctionQualifiedArn": { "Description": "Current Lambda function version", "Value": { - "Ref": "HelloLambdaVersionHKXJuXgeYK24V0jAKRC7KaQUIARaC0kev5TAPmRBOM" + "Ref": "HelloLambdaVersion722UxcHK84FtzQksFJLgO33214XN092rFeZxfBAWMI" }, "Export": { "Name": "sls-serverless-test-project-dev-HelloLambdaFunctionQualifiedArn" @@ -1044,7 +1101,7 @@ "PingLambdaFunctionQualifiedArn": { "Description": "Current Lambda function version", "Value": { - "Ref": "PingLambdaVersionivrf6dIZWzXv8jGaqqossToBBai1QiV7kuefBNU0Xc" + "Ref": "PingLambdaVersionkRCLggFwidyGPubIpsDG3Bz131vjOVNlzKj7NBM8UgE" }, "Export": { "Name": "sls-serverless-test-project-dev-PingLambdaFunctionQualifiedArn" @@ -1053,7 +1110,7 @@ "ThrottlerLambdaFunctionQualifiedArn": { "Description": "Current Lambda function version", "Value": { - "Ref": "ThrottlerLambdaVersionWHo4eySHjExzIm6sn8tyhX4tUxNvoM2vTi8SEMEjK0" + "Ref": "ThrottlerLambdaVersionl91cFljDzhpqWXdQeA2t4nCL4O8S6eewBytew6LYg" }, "Export": { "Name": "sls-serverless-test-project-dev-ThrottlerLambdaFunctionQualifiedArn" @@ -1062,7 +1119,7 @@ "DriveStreamLambdaFunctionQualifiedArn": { "Description": "Current Lambda function version", "Value": { - "Ref": "DriveStreamLambdaVersion8BINjBgQgQLwrsojAUC2l9zsiEkFaTbLzqD81toJd8" + "Ref": "DriveStreamLambdaVersionZym9I4CW26PuJ2g26SXA4zCtxJm3jUEOzGB9JSpCIA" }, "Export": { "Name": "sls-serverless-test-project-dev-DriveStreamLambdaFunctionQualifiedArn" @@ -1071,7 +1128,7 @@ "DriveQueueLambdaFunctionQualifiedArn": { "Description": "Current Lambda function version", "Value": { - "Ref": "DriveQueueLambdaVersionnQWkvsurMZfdbvJ5JQ800smP3XYTdNjQ56nH5N6Pzg" + "Ref": "DriveQueueLambdaVersionqxLBmX6bkW9KfIv3nK7Euv6IWU2k1LNIfruRKLQ" }, "Export": { "Name": "sls-serverless-test-project-dev-DriveQueueLambdaFunctionQualifiedArn" @@ -1080,7 +1137,7 @@ "DriveTableLambdaFunctionQualifiedArn": { "Description": "Current Lambda function version", "Value": { - "Ref": "DriveTableLambdaVersionAsgfm3jPQKIicJD2Tsu4qH5VqW5K5yi5nmq2tk4Po" + "Ref": "DriveTableLambdaVersionmshp4vuCFXIuqNxokV8OQhvrXhDNTcfJirpkqQC5PM" }, "Export": { "Name": "sls-serverless-test-project-dev-DriveTableLambdaFunctionQualifiedArn" @@ -1089,7 +1146,7 @@ "StreamProcessorLambdaFunctionQualifiedArn": { "Description": "Current Lambda function version", "Value": { - "Ref": "StreamProcessorLambdaVersionyMKRoNaY0699T5oh5ae9YBYHvESiBHITGCLSPHGaLdk" + "Ref": "StreamProcessorLambdaVersionwlUSF2MKmypdz7S8ASUEQJniFQJWYRU4J5ElG6ncY" }, "Export": { "Name": "sls-serverless-test-project-dev-StreamProcessorLambdaFunctionQualifiedArn" @@ -1098,7 +1155,7 @@ "HttpGetterLambdaFunctionQualifiedArn": { "Description": "Current Lambda function version", "Value": { - "Ref": "HttpGetterLambdaVersionyoyVGg99BR9qEwqfluEa261oLc1Hp5uhkAHD24QxI" + "Ref": "HttpGetterLambdaVersion8bkTDhhXsi9cMBh96OfTi3WanBalxcwLoE8XqtXkHcc" }, "Export": { "Name": "sls-serverless-test-project-dev-HttpGetterLambdaFunctionQualifiedArn" diff --git a/serverless-test-project/serverless-v2.yml b/serverless-test-project/serverless-v2.yml index efa84bca..d4cd2f36 100644 --- a/serverless-test-project/serverless-v2.yml +++ b/serverless-test-project/serverless-v2.yml @@ -78,95 +78,8 @@ functions: - http: method: get path: "item" -resources: - Resources: - stream: - Type: AWS::Kinesis::Stream - Properties: - Name: awesome-savage-stream - ShardCount: 1 - bucket: - Type: AWS::S3::Bucket - Properties: - BucketName: awesome-savage-bucket - - dataTable: - Type: AWS::DynamoDB::Table - DeletionPolicy: Delete - Properties: - TableName: MyTable - ProvisionedThroughput: - ReadCapacityUnits: 1 - WriteCapacityUnits: 1 - AttributeDefinitions: - - AttributeName: pk - AttributeType: S - - AttributeName: sk - AttributeType: S - - AttributeName: gsi1pk - AttributeType: S - - AttributeName: gsi1sk - AttributeType: S - - AttributeName: field1 - AttributeType: S - - AttributeName: field2 - AttributeType: S - - AttributeName: timestamp - AttributeType: N - KeySchema: - - AttributeName: pk - KeyType: HASH - - AttributeName: sk - KeyType: RANGE - GlobalSecondaryIndexes: - - IndexName: GSI1 - ProvisionedThroughput: - ReadCapacityUnits: 1 - WriteCapacityUnits: 1 - KeySchema: - - AttributeName: gsi1pk - KeyType: HASH - - AttributeName: gsi1sk - KeyType: RANGE - Projection: - NonKeyAttributes: - - address - ProjectionType: INCLUDE - LocalSecondaryIndexes: - - IndexName: LSI1 - KeySchema: - - AttributeName: pk - KeyType: HASH - - AttributeName: timestamp - KeyType: RANGE - Projection: - NonKeyAttributes: - - name - ProjectionType: INCLUDE - - regularQueue: - Type: "AWS::SQS::Queue" - Properties: - QueueName: "SomeRegularQueue" - - fifoQueue: - Type: "AWS::SQS::Queue" - Properties: - QueueName: "SomeFifoQueue.fifo" - FifoQueue: true - - workflowLogGroup: - Type: AWS::Logs::LogGroup - Properties: - LogGroupName: WorkflowLogs - RetentionInDays: 1 - - expressWorkflowLogGroup: - Type: AWS::Logs::LogGroup - Properties: - LogGroupName: ExpressWorkflowLogs - RetentionInDays: 1 +resources: ${file(./sls-resources.yml)} stepFunctions: stateMachines: diff --git a/serverless-test-project/serverless.yml b/serverless-test-project/serverless.yml index 7eacbf56..21f9e220 100644 --- a/serverless-test-project/serverless.yml +++ b/serverless-test-project/serverless.yml @@ -77,144 +77,8 @@ functions: - http: method: get path: "item" -resources: - Resources: - stream: - Type: AWS::Kinesis::Stream - Properties: - Name: awesome-savage-stream - ShardCount: 1 - bucket: - Type: AWS::S3::Bucket - Properties: - BucketName: awesome-savage-bucket - - dataTable: - Type: AWS::DynamoDB::Table - DeletionPolicy: Delete - Properties: - TableName: MyTable - ProvisionedThroughput: - ReadCapacityUnits: 1 - WriteCapacityUnits: 1 - AttributeDefinitions: - - AttributeName: pk - AttributeType: S - - AttributeName: sk - AttributeType: S - - AttributeName: gsi1pk - AttributeType: S - - AttributeName: gsi1sk - AttributeType: S - - AttributeName: timestamp - AttributeType: N - KeySchema: - - AttributeName: pk - KeyType: HASH - - AttributeName: sk - KeyType: RANGE - GlobalSecondaryIndexes: - - IndexName: GSI1 - ProvisionedThroughput: - ReadCapacityUnits: 1 - WriteCapacityUnits: 1 - KeySchema: - - AttributeName: gsi1pk - KeyType: HASH - - AttributeName: gsi1sk - KeyType: RANGE - Projection: - NonKeyAttributes: - - address - ProjectionType: INCLUDE - LocalSecondaryIndexes: - - IndexName: LSI1 - KeySchema: - - AttributeName: pk - KeyType: HASH - - AttributeName: timestamp - KeyType: RANGE - Projection: - NonKeyAttributes: - - name - ProjectionType: INCLUDE - - regularQueue: - Type: "AWS::SQS::Queue" - Properties: - QueueName: "SomeRegularQueue" - - fifoQueue: - Type: "AWS::SQS::Queue" - Properties: - QueueName: "SomeFifoQueue.fifo" - FifoQueue: true - - workflowLogGroup: - Type: AWS::Logs::LogGroup - Properties: - LogGroupName: WorkflowLogs - RetentionInDays: 1 - - expressWorkflowLogGroup: - Type: AWS::Logs::LogGroup - Properties: - LogGroupName: ExpressWorkflowLogs - RetentionInDays: 1 - - vpc: - Type: AWS::EC2::VPC - Properties: - CidrBlock: 10.0.0.0/16 - - subnet: - Type: AWS::EC2::Subnet - Properties: - AvailabilityZone: ${self:provider.region}a - CidrBlock: 10.0.16.0/20 - VpcId: !Ref vpc - - ecsCluster: - Type: AWS::ECS::Cluster - Properties: - ClusterName: awesome-cluster - - ecsService: - Type: AWS::ECS::Service - Properties: - ServiceName: awesome-service - Cluster: - Ref: ecsCluster - DesiredCount: 0 - LaunchType: FARGATE - TaskDefinition: !Ref taskDef - NetworkConfiguration: - AwsvpcConfiguration: - AssignPublicIp: ENABLED - SecurityGroups: [] - Subnets: - - !Ref subnet - - taskDef: - Type: AWS::ECS::TaskDefinition - Properties: - RequiresCompatibilities: - - FARGATE - Cpu: 256 - Memory: 512 - ContainerDefinitions: - - Name: "busybox" - Image: "busybox" - Cpu: 256 - EntryPoint: - - "sh" - - "-c" - Memory: 512 - Command: - - "/bin/sh -c \"while true; do echo Hello; sleep 10; done\"" - Essential: true - NetworkMode: awsvpc +resources: ${file(./sls-resources.yml)} stepFunctions: stateMachines: diff --git a/serverless-test-project/sls-resources.yml b/serverless-test-project/sls-resources.yml new file mode 100644 index 00000000..17b7e035 --- /dev/null +++ b/serverless-test-project/sls-resources.yml @@ -0,0 +1,137 @@ +Resources: + stream: + Type: AWS::Kinesis::Stream + Properties: + Name: awesome-savage-stream + ShardCount: 1 + + bucket: + Type: AWS::S3::Bucket + Properties: + BucketName: awesome-savage-bucket + + dataTable: + Type: AWS::DynamoDB::Table + DeletionPolicy: Delete + Properties: + TableName: MyTable + ProvisionedThroughput: + ReadCapacityUnits: 1 + WriteCapacityUnits: 1 + AttributeDefinitions: + - AttributeName: pk + AttributeType: S + - AttributeName: sk + AttributeType: S + - AttributeName: gsi1pk + AttributeType: S + - AttributeName: gsi1sk + AttributeType: S + - AttributeName: timestamp + AttributeType: N + KeySchema: + - AttributeName: pk + KeyType: HASH + - AttributeName: sk + KeyType: RANGE + GlobalSecondaryIndexes: + - IndexName: GSI1 + ProvisionedThroughput: + ReadCapacityUnits: 1 + WriteCapacityUnits: 1 + KeySchema: + - AttributeName: gsi1pk + KeyType: HASH + - AttributeName: gsi1sk + KeyType: RANGE + Projection: + NonKeyAttributes: + - address + ProjectionType: INCLUDE + LocalSecondaryIndexes: + - IndexName: LSI1 + KeySchema: + - AttributeName: pk + KeyType: HASH + - AttributeName: timestamp + KeyType: RANGE + Projection: + NonKeyAttributes: + - name + ProjectionType: INCLUDE + + regularQueue: + Type: "AWS::SQS::Queue" + Properties: + QueueName: "SomeRegularQueue" + + fifoQueue: + Type: "AWS::SQS::Queue" + Properties: + QueueName: "SomeFifoQueue.fifo" + FifoQueue: true + + workflowLogGroup: + Type: AWS::Logs::LogGroup + Properties: + LogGroupName: WorkflowLogs + RetentionInDays: 1 + + expressWorkflowLogGroup: + Type: AWS::Logs::LogGroup + Properties: + LogGroupName: ExpressWorkflowLogs + RetentionInDays: 1 + + vpc: + Type: AWS::EC2::VPC + Properties: + CidrBlock: 10.0.0.0/16 + + subnet: + Type: AWS::EC2::Subnet + Properties: + AvailabilityZone: ${self:provider.region}a + CidrBlock: 10.0.16.0/20 + VpcId: !Ref vpc + + ecsCluster: + Type: AWS::ECS::Cluster + Properties: + ClusterName: awesome-cluster + + ecsService: + Type: AWS::ECS::Service + Properties: + ServiceName: awesome-service + Cluster: + Ref: ecsCluster + DesiredCount: 0 + LaunchType: FARGATE + TaskDefinition: !Ref taskDef + NetworkConfiguration: + AwsvpcConfiguration: + AssignPublicIp: ENABLED + SecurityGroups: [] + Subnets: + - !Ref subnet + + taskDef: + Type: AWS::ECS::TaskDefinition + Properties: + RequiresCompatibilities: + - FARGATE + Cpu: 256 + Memory: 512 + ContainerDefinitions: + - Name: "busybox" + Image: "busybox" + Cpu: 256 + EntryPoint: + - "sh" + - "-c" + Memory: 512 + Command: + - "/bin/sh -c \"while true; do echo Hello; sleep 10; done\"" + Essential: true + NetworkMode: awsvpc