Last active
May 10, 2023 18:50
-
-
Save antoniogrv/8d2db1ea5c42ab98f1615db407b2bc8b to your computer and use it in GitHub Desktop.
SLS-Provisioned AWS Step Functions Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Common use-case example of an AWS-managed state machine that orchestrates AWS Lambda instances. | |
# Provisioned via Serverless Framework as a CloudFormation stack. | |
provider: | |
name: aws | |
stage: ${opt:stage, self:custom.defaultStage} | |
region: eu-central-1 // us-east-1, us-west-2, ... | |
runtime: python3.9 // 3.7, 3.8, ... | |
stackName: ${self:service}-${self:provider.stage} | |
timeout: 300 | |
logRetentionInDays: 7 // CloudWatch Group Logs | |
environment: | |
// optional. just use .env.{stage} (eg. .env.dev, .env.prod) if you don't plan .. | |
// .. to use locally-set environment variables. | |
ecr: | |
images: | |
{sls_local_image_name}: | |
// CloudFormation logical ID resolves to image.name -- imperative when using heavy pip packages (eg. Tensorflow) | |
path: ./{path} | |
iam: | |
role: | |
statements: | |
- Effect: "Allow" // deny, ... | |
Action: | |
- {actions} | |
Resource: | |
- arn:aws:s3:::{...} // sqs:::{...}, ... | |
package: | |
individually: true | |
excludeDevDependencies: true | |
patterns: | |
- '!venv' | |
- '!.idea' | |
- '!.git' | |
- '.requirements.zip' | |
resources: | |
Description: {desc} | |
Resources: | |
{resources} // sqs queues, s3 buckets, ... | |
custom: | |
defaultStage: dev // stage, ... | |
lambdaTimeout: 300 // can definitely be lowered based on use-case | |
pythonRequirements: | |
dockerizePip: true | |
zip: true | |
stepFunctions: | |
validate: true | |
stateMachines: | |
{local_sls_state_machine_name}: | |
name: ${self:service}-state-machine-${sls:stage} | |
events: | |
- http: | |
{apy_gateway if needed} | |
definition: | |
{definition} // yaml exported from the AWS console can be injected here | |
useDotenv: true | |
service: SERVICE_NAME | |
frameworkVersion: '3' | |
plugins: | |
- serverless-dotenv-plugin | |
- serverless-python-requirements | |
- serverless-iam-roles-per-function | |
- serverless-step-functions | |
function: | |
$lambdas |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment