AWSTemplateFormatVersion: '2010-09-09' Outputs: DynamoDBTable: Description: The name of the DynamoDB Table Value: Ref: DynamoDBTable Api: Description: The URL of the API Gateway you invoke with a GET request to retrieve all of your items in a DynamoDB Table. Value: Fn::Sub: https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/${DynamoDBTable} Parameters: DynamoDBTable: AllowedPattern: ^[A-Za-z_]+$ Type: String Description: (Required) The name of the existing DynamoDB table you want to get records from. Minimum 3 characters MaxLength: 50 MinLength: 3 ConstraintDescription: Required parameter. Can be characters and underscores. No numbers allowed. CorsOrigin: Default: '' Type: String Description: (Optional) Cross-origin resource sharing (CORS) Origin. You can specify a single origin, all "*" or leave empty and no CORS will be applied. MaxLength: 250 Resources: GetAllLambda: Type: AWS::Serverless::Function Properties: Environment: Variables: TABLE_NAME: Ref: DynamoDBTable CORS_ORIGIN: Ref: CorsOrigin Handler: index.handler Policies: - Statement: - Action: - dynamodb:GetItem - dynamodb:DeleteItem - dynamodb:PutItem - dynamodb:Scan - dynamodb:Query - dynamodb:UpdateItem - dynamodb:BatchWriteItem - dynamodb:BatchGetItem - dynamodb:DescribeTable Resource: Fn::Sub: - arn:${AWS::Partition}:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${tableName} - tableName: Ref: DynamoDBTable Effect: Allow CodeUri: Bucket: <%REPO_BUCKET%> Key: 69e05eaf-b8f1-4a29-b379-0fb064226b03 Runtime: nodejs10.x Events: OptionsApi: Type: Api Properties: Path: /{items} RestApiId: Ref: ServerlessRestApi Method: OPTIONS GetAllApi: Type: Api Properties: Path: /{items} RestApiId: Ref: ServerlessRestApi Method: GET ServerlessRestApi: Type: AWS::Serverless::Api Properties: __MANAGE_SWAGGER: true DefinitionBody: info: version: '1.0' title: Ref: AWS::StackName paths: /{items}: options: x-amazon-apigateway-integration: httpMethod: POST type: aws_proxy uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetAllLambda.Arn}/invocations responses: {} get: x-amazon-apigateway-integration: httpMethod: POST type: aws_proxy uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetAllLambda.Arn}/invocations responses: {} swagger: '2.0' StageName: Prod Transform: AWS::Serverless-2016-10-31