code/backend/template.yaml [53:167]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  getAllItemsFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: src/handlers/get-all-items.getAllItemsHandler
      Description: A simple example includes a HTTP get method to get all items from a DynamoDB table.
      Policies:
        - DynamoDBCrudPolicy:
            TableName: !Ref SampleTable
        - CloudWatchPutMetricPolicy: {}
        - CloudWatchLambdaInsightsExecutionRolePolicy
      Events:
        Api:
          Type: Api
          Properties:
            RestApiId: !Ref Api
            Path: /items
            Method: GET
            
  getByIdFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: src/handlers/get-by-id.getByIdHandler
      Description: A simple example includes a HTTP get method to get one item by id from a DynamoDB table.
      Policies:
        - DynamoDBCrudPolicy:
            TableName: !Ref SampleTable
        - CloudWatchPutMetricPolicy: {}
        - CloudWatchLambdaInsightsExecutionRolePolicy
      Events:
        Api:
          Type: Api
          Properties:
            RestApiId: !Ref Api
            Path: /items/{id}
            Method: GET
            
  putItemFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: src/handlers/put-item.putItemHandler
      Description: A simple example includes a HTTP post method to add one item to a DynamoDB table.
      Policies:
        - DynamoDBCrudPolicy:
            TableName: !Ref SampleTable
        - CloudWatchPutMetricPolicy: {}
        - SNSPublishMessagePolicy:
            TopicName: !Sub ${NewItemTopic.TopicName}
        - CloudWatchLambdaInsightsExecutionRolePolicy
      Environment:
        Variables:
          TOPIC_NAME: !Ref NewItemTopic
      Events:
        Api:
          Type: Api
          Properties:
            RestApiId: !Ref Api
            Path: /items
            Method: POST

  notifyNewItemFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: src/handlers/notify-item.notifyNewItemHandler
      Description: A simple example that is triggered by a SNS message to notify of a new item insertion.
      Policies:
        - CloudWatchLambdaInsightsExecutionRolePolicy
      Events:
        TopicListener:
          Type: SNS
          Properties:
            Topic: !Ref NewItemTopic
            FilterPolicy:
              Status:
                - Success

# SNS Topic
  NewItemTopic:
    Type: AWS::SNS::Topic

# DynamoDB Table            
  SampleTable:
    Type: AWS::Serverless::SimpleTable
    Properties:
      PrimaryKey:
        Name: id
        Type: String

# CloudWatch Logs - Log Groups
  ApiAccessLogGroup:
    Type: AWS::Logs::LogGroup
    DependsOn: Api
    Properties:
      LogGroupName: !Sub /aws/apigateway/${Api}
      RetentionInDays: 7
  
  GetByIdLogGroup:
    Type: AWS::Logs::LogGroup
    DependsOn: getByIdFunction
    Properties:
      LogGroupName: !Sub /aws/lambda/${getByIdFunction}
      RetentionInDays: 7

  GetAllItemsLogGroup:
    Type: AWS::Logs::LogGroup
    DependsOn: getAllItemsFunction
    Properties:
      LogGroupName: !Sub /aws/lambda/${getAllItemsFunction}
      RetentionInDays: 7

  PutItemLogGroup:
    Type: AWS::Logs::LogGroup
    DependsOn: putItemFunction
    Properties:
      LogGroupName: !Sub /aws/lambda/${putItemFunction}
      RetentionInDays: 7
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



code/sample-app-tracing/template.yaml [31:145]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  getAllItemsFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: src/handlers/get-all-items.getAllItemsHandler
      Description: A simple example includes a HTTP get method to get all items from a DynamoDB table.
      Policies:
        - DynamoDBCrudPolicy:
            TableName: !Ref SampleTable
        - CloudWatchPutMetricPolicy: {}
        - CloudWatchLambdaInsightsExecutionRolePolicy
      Events:
        Api:
          Type: Api
          Properties:
            RestApiId: !Ref Api
            Path: /items
            Method: GET
            
  getByIdFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: src/handlers/get-by-id.getByIdHandler
      Description: A simple example includes a HTTP get method to get one item by id from a DynamoDB table.
      Policies:
        - DynamoDBCrudPolicy:
            TableName: !Ref SampleTable
        - CloudWatchPutMetricPolicy: {}
        - CloudWatchLambdaInsightsExecutionRolePolicy
      Events:
        Api:
          Type: Api
          Properties:
            RestApiId: !Ref Api
            Path: /items/{id}
            Method: GET
            
  putItemFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: src/handlers/put-item.putItemHandler
      Description: A simple example includes a HTTP post method to add one item to a DynamoDB table.
      Policies:
        - DynamoDBCrudPolicy:
            TableName: !Ref SampleTable
        - CloudWatchPutMetricPolicy: {}
        - SNSPublishMessagePolicy:
            TopicName: !Sub ${NewItemTopic.TopicName}
        - CloudWatchLambdaInsightsExecutionRolePolicy
      Environment:
        Variables:
          TOPIC_NAME: !Ref NewItemTopic
      Events:
        Api:
          Type: Api
          Properties:
            RestApiId: !Ref Api
            Path: /items
            Method: POST

  notifyNewItemFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: src/handlers/notify-item.notifyNewItemHandler
      Description: A simple example that is triggered by a SNS message to notify of a new item insertion.
      Policies:
        - CloudWatchLambdaInsightsExecutionRolePolicy
      Events:
        TopicListener:
          Type: SNS
          Properties:
            Topic: !Ref NewItemTopic
            FilterPolicy:
              Status:
                - Success

# SNS Topic
  NewItemTopic:
    Type: AWS::SNS::Topic

# DynamoDB Table            
  SampleTable:
    Type: AWS::Serverless::SimpleTable
    Properties:
      PrimaryKey:
        Name: id
        Type: String

# CloudWatch Logs - Log Groups
  ApiAccessLogGroup:
    Type: AWS::Logs::LogGroup
    DependsOn: Api
    Properties:
      LogGroupName: !Sub /aws/apigateway/${Api}
      RetentionInDays: 7
  
  GetByIdLogGroup:
    Type: AWS::Logs::LogGroup
    DependsOn: getByIdFunction
    Properties:
      LogGroupName: !Sub /aws/lambda/${getByIdFunction}
      RetentionInDays: 7

  GetAllItemsLogGroup:
    Type: AWS::Logs::LogGroup
    DependsOn: getAllItemsFunction
    Properties:
      LogGroupName: !Sub /aws/lambda/${getAllItemsFunction}
      RetentionInDays: 7

  PutItemLogGroup:
    Type: AWS::Logs::LogGroup
    DependsOn: putItemFunction
    Properties:
      LogGroupName: !Sub /aws/lambda/${putItemFunction}
      RetentionInDays: 7
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



