AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: > microservice name Globals: Api: Cors: "'*'" Resources: NamesDataTable: Type: AWS::DynamoDB::Table Properties: TableName: !Sub NamesData-${AWS::StackName} BillingMode: PAY_PER_REQUEST AttributeDefinitions: - AttributeName: Id AttributeType: S KeySchema: - AttributeName: Id KeyType: HASH SSESpecification: SSEEnabled: yes NamesFunction: Type: AWS::Serverless::Function Properties: CodeUri: ./microservices-name/build/main/ Handler: index.handler Runtime: nodejs10.x MemorySize: 512 Timeout: 20 Policies: - DynamoDBReadPolicy: TableName: !Ref NamesDataTable Environment: Variables: TABLE_NAME: !Ref NamesDataTable Tracing: Active Events: findname: Type: Api Properties: Path: /resources/names/{id} Method: GET RestApiId: !Ref NameApi names: Type: Api Properties: Path: /resources/names Method: GET RestApiId: !Ref NameApi NameApi: Type: AWS::Serverless::Api Properties: Name: NameApiMicroservice StageName: prod DefinitionBody: swagger: "2.0" definitions: Name: type: "object" properties: id: type: "number" name: type: "string" paths: "/resources/names": get: produces: - application/json - application/xml x-amazon-apigateway-integration: httpMethod: POST type: aws_proxy uri: !Sub "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NamesFunction.Arn}/invocations" responses: {} "/resources/names/{id}": get: produces: - text/plain - application/json - application/xml parameters: - name: id in: path required: true type: number responses: "200": content: text/plain: scheme: type: string x-amazon-apigateway-integration: httpMethod: POST type: aws_proxy uri: !Sub "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NamesFunction.Arn}/invocations" Parameter: Type: "AWS::SSM::Parameter" Properties: Name: NameApiEndpoint Description: Name API Endpoint Type: String Value: !Sub '${NameApi}.execute-api.${AWS::Region}.amazonaws.com' Outputs: nameApiEndpoint: Description: Names API URL for application Value: !Sub 'https://${NameApi}.execute-api.${AWS::Region}.amazonaws.com/prod/resources/names'