service: mxnet-ci-master-scaling

frameworkVersion: ">=1.2.0 <2.0.0"

provider:
  name: aws
  runtime: python3.6
  region: us-west-2
  memorySize: 128
  timeout: 290
  stage: ${opt:stage}
  environment: ${file(environment.yml):${self:provider.stage}}
  iamRoleStatements:
    -  Effect: "Allow"
       Action:
         - "secretsmanager:DescribeSecret"
         - "secretsmanager:GetSecretValue"
       Resource:
         - ${self:provider.environment.SECRETS_MANAGER_ARN}
    -  Effect: "Allow"
       Action:
         - "ec2:Describe*"
       Resource:
         - "*"
    -  Effect: "Allow"
       Action:
         - "ec2:RunInstances"
         - "ec2:TerminateInstances"
         - "ec2:CreateTags"
       Resource:
         - ${self:provider.environment.EC2_ACCOUNT_ARN}
         - "arn:aws:ec2:us-west-2::image/ami-*"
    -  Effect: "Allow"
       Action:
         - "iam:PassRole"
       Resource:
         - ${self:provider.environment.IAM_JENKINS_SLAVE_ROLE}
         - ${self:provider.environment.IAM_JENKINS_RESTRICTED_SLAVE_ROLE}

functions:
  mxnet-ci-master-scaling:
    handler: handler.scaling_handler
    reservedConcurrency: 1
    events:
      # Invoke Lambda function on a schedule
      - schedule: rate(5 minutes)

custom:
  pythonRequirements:
    dockerizePip: true

plugins:
  - serverless-python-requirements
