AWSTemplateFormatVersion: '2010-09-09'
Parameters:
  TableNameParameter:
    Type: String
Description: A simple backend (read/write to DynamoDB) with a RESTful API endpoint using Amazon API Gateway.
Resources:
  microservicehttpendpointpython:
    Type: AWS::Serverless::Function
    Properties:
      Description: A simple backend (read/write to DynamoDB) with a RESTful API endpoint using Amazon API Gateway.
      MemorySize: 512
      Policies:
      - Statement:
        - Action:
          - dynamodb:GetItem
          - dynamodb:DeleteItem
          - dynamodb:PutItem
          - dynamodb:Scan
          - dynamodb:Query
          - dynamodb:UpdateItem
          - dynamodb:BatchWriteItem
          - dynamodb:BatchGetItem
          Resource:
            Fn::Sub:
            - arn:${AWS::Partition}:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${tableName}
            - tableName:
                Ref: TableNameParameter
          Effect: Allow
      Handler: lambda_function.lambda_handler
      Timeout: 10
      CodeUri:
        Bucket: <%REPO_BUCKET%>
        Key: bb84e60c-a27b-4f01-bee8-ae95f7257c03
      Runtime: python2.7
      Events:
        Api1:
          Type: Api
          Properties:
            Path: /MyResource
            RestApiId:
              Ref: ServerlessRestApi
            Method: ANY
  ServerlessRestApi:
    Type: AWS::Serverless::Api
    Properties:
      __MANAGE_SWAGGER: true
      DefinitionBody:
        info:
          version: '1.0'
          title:
            Ref: AWS::StackName
        paths:
          /MyResource:
            x-amazon-apigateway-any-method:
              x-amazon-apigateway-integration:
                httpMethod: POST
                type: aws_proxy
                uri:
                  Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${microservicehttpendpointpython.Arn}/invocations
              responses: {}
        swagger: '2.0'
      StageName: Prod
Transform: AWS::Serverless-2016-10-31
