---
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  myApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: prod
  myFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs22.x
      CodeUri: 's3://test-bucket/mySourceCode.zip'
      AutoPublishAlias: live
      DeploymentPreference:
        Type: Linear10PercentEvery10Minutes
      Events:
        OriginalApi:
          Type: Api
          Properties:
            Path: /original
            Method: GET
        DoubleApi:
          Type: Api
          Properties:
            Path: /double
            Method: GET
        ThumbnailApi:
          Type: Api
          Properties:
            Path: /thumbnail
            Method: GET
            RestApiId: !Ref myApi
        WatermarkApi:
          Type: Api
          Properties:
            Path: /watermark
            Method: GET
            RestApiId: !Ref myApi
        S3Trigger:
          Type: S3
          Properties:
            Bucket: !Ref myBucket
            Events: s3:ObjectCreated:*
        MySnsTrigger:
          Type: SNS
          Properties:
            Topic: arn:aws:sns:us-east-1:123456789012:my_topic
        MyKinesisTrigger:
          Type: Kinesis
          Properties:
            Stream: arn:aws:kinesis:us-east-1:123456789012:stream/my-stream
            StartingPosition: TRIM_HORIZON
        MyDynamoDbTrigger:
          Type: DynamoDB
          Properties:
            Stream: arn:aws:dynamodb:us-east-1:123456789012:table/TestTable/stream/2016-08-11T21:21:33.291
            StartingPosition: TRIM_HORIZON
        MyTimer:
          Type: Schedule
          Properties:
            Schedule: rate(5 minutes)
        OnTerminate:
          Type: CloudWatchEvent
          Properties:
            Pattern:
              detail:
                state:
                  - terminated
  myBucket:
    Type: AWS::S3::Bucket
    Properties: {}
  myIamPolicy:
    Type: AWS::IAM::Policy
    Properties:
      PolicyName: "CFNUsers"
      PolicyDocument:
        Version: "2012-10-17"
        Statement:
          -
            Effect: "Allow"
            Action:
              - "cloudformation:Describe*"
              - "cloudformation:List*"
              - "cloudformation:Get*"
            Resource: "*"
      Roles:
      - !Ref myFunctionRole
