Skip to content

Instantly share code, notes, and snippets.

@unknownliviu
Created January 8, 2019 13:08
Show Gist options
  • Save unknownliviu/1b1be8157fe13e572afa38e432940283 to your computer and use it in GitHub Desktop.
Save unknownliviu/1b1be8157fe13e572afa38e432940283 to your computer and use it in GitHub Desktop.
serverless.yml
service:
name: zaius-data
plugins:
- serverless-step-functions
- serverless-pseudo-parameters
provider:
name: aws
stage: ${opt:stage, 'sandbox'}
region: us-east-2
resources:
Resources:
EcsCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: user-api
EcsTask:
Type: AWS::ECS::TaskDefinition
Properties:
ExecutionRoleArn: ecsTaskExecutionRole
RequiresCompatibilities:
- FARGATE
Cpu: 512
Memory: 1024
NetworkMode: awsvpc
ContainerDefinitions:
-
Name: zaius-data-${self:provider.stage}
Command:
- /bin/sh
- "-c"
- "python events.py && python customers.py"
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: /ecs/zaius-data-${self:provider.stage}
awslogs-region: us-east-2
awslogs-stream-prefix: ecs
VolumesFrom: []
Image: { "Fn::Join" : ["", [ "", { "Ref" : "AWS::AccountId" }, ".dkr.ecr.us-east-2.amazonaws.com/zaius-data:latest" ] ] }
Essential: true
DisableNetworking: false
Environment:
-
Name: PROJECT_ENV
Value: ${self:provider.stage}
stepFunctions:
stateMachines:
ZaiusDataMachine:
name: ZaiusDataMachine
role: "arn:aws:iam::#{AWS::AccountId}:role/StepFunctionsLambdaRole"
events:
- schedule:
rate: rate(1 day)
name: "Daily Sync"
description: "Runs every 1 day"
- enabled: true
definition:
Comment: "A state machine"
StartAt: EcsZaius
States:
EcsZaius:
Type: Task
Resource: arn:aws:states:::ecs:runTask.sync
End: true
Parameters:
LaunchType: FARGATE
Cluster: "#{EcsCluster}"
TaskDefinition: "#{EcsTask}"
# StateMachine:
# Type: "AWS::StepFunctions::StateMachine"
# Properties:
# StateMachineName: ZaiusDataMachine
# DefinitionString: |-
# {
# "StartAt":"EcsTest",
# "States":{
# "EcsTest": {
# "Type":"Task",
# "Resource":"arn:aws:states:::ecs:runTask.sync",
# "Parameters": {
# "LaunchType":"FARGATE",
# "Cluster": "Fn::GetAtt: [EcsCluster, Arn]",
# "TaskDefinition":
# - Ref: EcsTask
# },
# "End": true
# }
# }
# }
# RoleArn: { "Fn::Join" : ["", [ "arn:aws:iam::", { "Ref" : "AWS::AccountId" }, ":role/StepFunctionsLambdaRole" ] ] }
# TaskSchedule:
# Type: AWS::Events::Rule
# Properties:
# Name: Daily-Zaius-Sync
# Description: Schedules the task to be run every day at 1:00 am
# ScheduleExpression: rate(10 minutes)
# State: ENABLED
# Targets:
# -
# Id: zaius-data-daily-sync
# Arn:
# Fn::GetAtt:
# - EcsCluster
# - Arn
# RoleArn: { "Fn::Join" : ["", [ "arn:aws:iam::", { "Ref" : "AWS::AccountId" }, ":role/ecsTaskExecutionRole" ] ] }
# EcsParameters:
# TaskDefinitionArn:
# Ref: EcsTask
# TaskCount: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment