AWSTemplateFormatVersion: "2010-09-09" Transform: AWS::Serverless-2016-10-31 Description: > data Sample SAM Template for data api # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst Globals: Function: Timeout: 3 Tracing: Active Api: TracingEnabled: True Parameters: Project: Type: String Default: cop301-voting Resources: VotesQueue: Type: AWS::SQS::Queue DataPollerFunction: Type: "AWS::Serverless::Function" Properties: CodeUri: dequeue/ Handler: dequeue.lambdaHandler Runtime: nodejs16.x Environment: Variables: TABLE_NAME: Ref: votingTable Policies: - SQSPollerPolicy: QueueName: !GetAtt VotesQueue.QueueName - DynamoDBCrudPolicy: TableName: Ref: votingTable Events: MySQSEvent: Type: SQS Properties: Queue: !GetAtt VotesQueue.Arn BatchSize: 10 DataStoreFunction: Type: AWS::Serverless::Function Properties: CodeUri: function/ Handler: app.lambdaHandler Runtime: nodejs16.x MemorySize: 512 Environment: Variables: QUEUE_URL: Ref: VotesQueue Policies: - SQSSendMessagePolicy: QueueName: !GetAtt VotesQueue.QueueName Architectures: - x86_64 votingTable: Type: "AWS::DynamoDB::Table" Properties: TableName: "Fn::Sub": "${Project}-table" AttributeDefinitions: - AttributeName: color AttributeType: S KeySchema: - AttributeName: color KeyType: HASH StreamSpecification: StreamViewType: NEW_IMAGE BillingMode: PAY_PER_REQUEST Outputs: # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function # Find out more about other implicit resources you can reference within SAM # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api #StoreVoteAPI: #Description: "Lambda Function URL for POST /votes" #Value: !Sub "https://${DataStoreFunction.FunctionUrl}" #Value: !Sub "https://${RestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/vote/" DataStoreFunction: Description: "Lambda Function ARN" Value: !GetAtt DataStoreFunction.Arn DataStoreFunctionIamRole: Description: "Implicit IAM Role created" Value: !GetAtt DataStoreFunction.Arn