service: the-ear-production-transcode
# Create an optimized package for our functions
useDotenv: true
package:
  individually: true

plugins:
  - serverless-bundle # Package our functions with Webpack
  - serverless-offline
  - serverless-dotenv-plugin # Load .env as environment variables
custom:
    bucket: the-ear-prod-transcode

provider:
  name: aws
  runtime: nodejs12.x
  stage: production
  region: eu-west-1
  profile: theear_prod
  # vpc:
  #  securityGroupIds:
  #    - ${env:SECURITYGROUPIDS}
  #  subnetIds:
  #    - ${env:SUBNETIDS1}
  #    - ${env:SUBNETIDS2}
  memorySize: 512

  # 'iamRoleStatements' defines the permission policy for the Lambda function.
  iamRoleStatements:
    - Effect: Allow
      Action:
        - s3:GetObject
        - s3:PutObject
      Resource: arn:aws:s3:::*
    - Effect: Allow
      Action:
        - elastictranscoder:Read*
        - elastictranscoder:List*
        - elastictranscoder:*Job
        - elastictranscoder:*Preset
        - elastictranscoder:Create*
        - s3:List*
        - iam:List*
        - sns:List*
      Resource: "*"
functions:
  create:
    handler: create.main
    events:
      - http:
          path: create
          method: post
          cors: true
          authorizer: aws_iam
  transcode_process:  #input
    handler: transcode_process.main
    timeout: 60
    events:
      - s3:
          bucket: the-ear-prod-transcode
          event: s3:ObjectCreated:*
          existing: true
resources:
  # API Gateway Errors
  - ${file(resources/api-gateway-errors.yml)}