AWSTemplateFormatVersion: "2010-09-09" Transform: AWS::Serverless-2016-10-31 Globals: Function: MemorySize: 1024 Architectures: ["x86_64"] Runtime: provided.al2 Timeout: 30 Tracing: Active Environment: Variables: PRODUCT_TABLE_NAME: !Ref Table Resources: GetProductsFunction: Type: AWS::Serverless::Function Properties: CodeUri: . Handler: bootstrap Events: Api: Type: HttpApi Properties: Path: / Method: GET Policies: - DynamoDBReadPolicy: TableName: !Ref Table Metadata: BuildMethod: makefile GetProductFunction: Type: AWS::Serverless::Function Properties: CodeUri: . Handler: GetProduct Events: Api: Type: HttpApi Properties: Path: /{id} Method: GET Policies: - Version: "2012-10-17" Statement: - Effect: Allow Action: dynamodb:GetItem Resource: !GetAtt Table.Arn Metadata: BuildMethod: makefile DeleteProductFunction: Type: AWS::Serverless::Function Properties: CodeUri: . Handler: DeleteProduct Events: Api: Type: HttpApi Properties: Path: /{id} Method: DELETE Policies: - Version: "2012-10-17" Statement: - Effect: Allow Action: - dynamodb:DeleteItem - dynamodb:GetItem Resource: !GetAtt Table.Arn Metadata: BuildMethod: makefile PutProductFunction: Type: AWS::Serverless::Function Properties: CodeUri: . Handler: PutProduct Events: Api: Type: HttpApi Properties: Path: /{id} Method: PUT Policies: - Version: "2012-10-17" Statement: - Effect: Allow Action: dynamodb:PutItem Resource: !GetAtt Table.Arn Metadata: BuildMethod: makefile Table: Type: AWS::DynamoDB::Table Properties: AttributeDefinitions: - AttributeName: id AttributeType: S BillingMode: PAY_PER_REQUEST KeySchema: - AttributeName: id KeyType: HASH Outputs: ApiUrl: Description: "API Gateway endpoint URL" Value: !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/"