AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Globals: Function: MemorySize: 128 Architectures: ["arm64"] Handler: bootstrap Runtime: provided.al2 Timeout: 5 Tracing: Active Environment: Variables: RUST_LOG: info TABLE_NAME: !Ref Table Resources: GetProductsFunction: Type: AWS::Serverless::Function Properties: CodeUri: target/lambda/get-products/ Events: Api: Type: HttpApi Properties: Path: / Method: GET Policies: - Version: "2012-10-17" Statement: - Effect: Allow Action: dynamodb:Scan Resource: !GetAtt Table.Arn Metadata: BuildMethod: makefile GetProductFunction: Type: AWS::Serverless::Function Properties: CodeUri: target/lambda/get-product/ 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 PutProductFunction: Type: AWS::Serverless::Function Properties: CodeUri: target/lambda/put-product/ 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 DeleteProductFunction: Type: AWS::Serverless::Function Properties: CodeUri: target/lambda/delete-product/ Events: Api: Type: HttpApi Properties: Path: /{id} Method: DELETE Policies: - Version: "2012-10-17" Statement: - Effect: Allow Action: dynamodb:DeleteItem Resource: !GetAtt Table.Arn Metadata: BuildMethod: makefile DDBStreamsFunction: Type: AWS::Serverless::Function Properties: CodeUri: target/lambda/dynamodb-streams/ Timeout: 10 Events: TableStream: Type: DynamoDB Properties: BatchSize: 1000 MaximumBatchingWindowInSeconds: 10 StartingPosition: TRIM_HORIZON Stream: !GetAtt Table.StreamArn Environment: Variables: EVENT_BUS_NAME: !Ref EventBus Policies: - Version: "2012-10-17" Statement: - Effect: Allow Action: events:PutEvents Resource: !GetAtt EventBus.Arn Table: Type: AWS::DynamoDB::Table Properties: AttributeDefinitions: - AttributeName: id AttributeType: S BillingMode: PAY_PER_REQUEST KeySchema: - AttributeName: id KeyType: HASH StreamSpecification: StreamViewType: NEW_AND_OLD_IMAGES EventBus: Type: AWS::Events::EventBus Properties: Name: !Ref AWS::StackName Outputs: ApiUrl: Description: "API Gateway endpoint URL" Value: !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/"