serverless-rest-api/javascript-http-sam/template.yaml [258:397]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  AccessLogs:
    Type: AWS::Logs::LogGroup
    Properties:
      RetentionInDays: 30
      LogGroupName: !Sub "/${AWS::StackName}/APIAccessLogs"


  LocationsTable:
    Type: AWS::Serverless::SimpleTable
    Properties:
      PrimaryKey:
        Name: locationid
        Type: String
      ProvisionedThroughput:
        ReadCapacityUnits: 2
        WriteCapacityUnits: 2
      Tags:
        Stack: !Sub "${AWS::StackName}"

  ResourcesTable:
    Type: AWS::DynamoDB::Table
    Properties:
      AttributeDefinitions:
        - AttributeName: resourceid
          AttributeType: S
        - AttributeName: locationid
          AttributeType: S
      KeySchema:
        - AttributeName: resourceid
          KeyType: HASH
      ProvisionedThroughput:
        ReadCapacityUnits: 2
        WriteCapacityUnits: 2
      GlobalSecondaryIndexes:
      - IndexName: locationidGSI
        KeySchema:
        - AttributeName: locationid
          KeyType: HASH
        Projection:
          ProjectionType: ALL
        ProvisionedThroughput:
          ReadCapacityUnits: 2
          WriteCapacityUnits: 2
      Tags:
        - Key: "Stack" 
          Value: !Sub "${AWS::StackName}"

  BookingsTable:
    Type: AWS::DynamoDB::Table
    Properties:
      AttributeDefinitions:
        - AttributeName: bookingid
          AttributeType: S
        - AttributeName: userid
          AttributeType: S
        - AttributeName: resourceid
          AttributeType: S
        - AttributeName: starttimeepochtime
          AttributeType: N
      KeySchema:
        - AttributeName: bookingid
          KeyType: HASH
      ProvisionedThroughput:
        ReadCapacityUnits: 2
        WriteCapacityUnits: 2
      GlobalSecondaryIndexes:
      - IndexName: useridGSI
        KeySchema:
        - AttributeName: userid
          KeyType: HASH
        Projection:
          ProjectionType: ALL
        ProvisionedThroughput:
          ReadCapacityUnits: 2
          WriteCapacityUnits: 2
      - IndexName: bookingsByUserByTimeGSI
        KeySchema:
        - AttributeName: userid
          KeyType: HASH
        - AttributeName: starttimeepochtime
          KeyType: RANGE
        Projection:
          ProjectionType: ALL
        ProvisionedThroughput:
          ReadCapacityUnits: 2
          WriteCapacityUnits: 2
      - IndexName: bookingsByResourceByTimeGSI
        KeySchema:
        - AttributeName: resourceid
          KeyType: HASH
        - AttributeName: starttimeepochtime
          KeyType: RANGE
        Projection:
          ProjectionType: ALL
        ProvisionedThroughput:
          ReadCapacityUnits: 2
          WriteCapacityUnits: 2
      Tags:
        - Key: "Stack" 
          Value: !Sub "${AWS::StackName}"

  AlarmsKMSKey:
    Type: AWS::KMS::Key
    Properties: 
      Description: CMK for SNS alarms topic
      Enabled: true
      EnableKeyRotation: True
      KeyPolicy: 
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal: 
              Service: 
                - "cloudwatch.amazonaws.com"
                - "sns.amazonaws.com"
            Action:
              - "kms:GenerateDataKey*"
              - "kms:Decrypt"
            Resource: "*"
          - Effect: Allow
            Principal: 
              AWS: 
                - !Sub "arn:aws:iam::${AWS::AccountId}:root"
            Action:
              - "kms:*"
            Resource: "*"
      KeySpec: SYMMETRIC_DEFAULT
      KeyUsage: ENCRYPT_DECRYPT
      PendingWindowInDays: 30
      Tags: 
        - Key: "Stack" 
          Value: !Sub "${AWS::StackName}"

  AlarmsTopic:
    Type: AWS::SNS::Topic
    Properties:
      KmsMasterKeyId: !Ref AlarmsKMSKey
      Tags:
        - Key: "Stack" 
          Value: !Sub "${AWS::StackName}"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



serverless-rest-api/python-rest-sam/template.yaml [258:396]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  AccessLogs:
    Type: AWS::Logs::LogGroup
    Properties:
      RetentionInDays: 30
      LogGroupName: !Sub "/${AWS::StackName}/APIAccessLogs"

  LocationsTable:
    Type: AWS::Serverless::SimpleTable
    Properties:
      PrimaryKey:
        Name: locationid
        Type: String
      ProvisionedThroughput:
        ReadCapacityUnits: 2
        WriteCapacityUnits: 2
      Tags:
        Stack: !Sub "${AWS::StackName}"

  ResourcesTable:
    Type: AWS::DynamoDB::Table
    Properties:
      AttributeDefinitions:
        - AttributeName: resourceid
          AttributeType: S
        - AttributeName: locationid
          AttributeType: S
      KeySchema:
        - AttributeName: resourceid
          KeyType: HASH
      ProvisionedThroughput:
        ReadCapacityUnits: 2
        WriteCapacityUnits: 2
      GlobalSecondaryIndexes:
        - IndexName: locationidGSI
          KeySchema:
            - AttributeName: locationid
              KeyType: HASH
          Projection:
            ProjectionType: ALL
          ProvisionedThroughput:
            ReadCapacityUnits: 2
            WriteCapacityUnits: 2
      Tags:
        - Key: "Stack"
          Value: !Sub "${AWS::StackName}"

  BookingsTable:
    Type: AWS::DynamoDB::Table
    Properties:
      AttributeDefinitions:
        - AttributeName: bookingid
          AttributeType: S
        - AttributeName: userid
          AttributeType: S
        - AttributeName: resourceid
          AttributeType: S
        - AttributeName: starttimeepochtime
          AttributeType: N
      KeySchema:
        - AttributeName: bookingid
          KeyType: HASH
      ProvisionedThroughput:
        ReadCapacityUnits: 2
        WriteCapacityUnits: 2
      GlobalSecondaryIndexes:
        - IndexName: useridGSI
          KeySchema:
            - AttributeName: userid
              KeyType: HASH
          Projection:
            ProjectionType: ALL
          ProvisionedThroughput:
            ReadCapacityUnits: 2
            WriteCapacityUnits: 2
        - IndexName: bookingsByUserByTimeGSI
          KeySchema:
            - AttributeName: userid
              KeyType: HASH
            - AttributeName: starttimeepochtime
              KeyType: RANGE
          Projection:
            ProjectionType: ALL
          ProvisionedThroughput:
            ReadCapacityUnits: 2
            WriteCapacityUnits: 2
        - IndexName: bookingsByResourceByTimeGSI
          KeySchema:
            - AttributeName: resourceid
              KeyType: HASH
            - AttributeName: starttimeepochtime
              KeyType: RANGE
          Projection:
            ProjectionType: ALL
          ProvisionedThroughput:
            ReadCapacityUnits: 2
            WriteCapacityUnits: 2
      Tags:
        - Key: "Stack"
          Value: !Sub "${AWS::StackName}"

  AlarmsKMSKey:
    Type: AWS::KMS::Key
    Properties: 
      Description: CMK for SNS alarms topic
      Enabled: true
      EnableKeyRotation: True
      KeyPolicy: 
        Version: "2012-10-17"
        Statement:
          - Effect: Allow
            Principal: 
              Service: 
                - "cloudwatch.amazonaws.com"
                - "sns.amazonaws.com"
            Action:
              - "kms:GenerateDataKey*"
              - "kms:Decrypt"
            Resource: "*"
          - Effect: Allow
            Principal: 
              AWS: 
                - !Sub "arn:aws:iam::${AWS::AccountId}:root"
            Action:
              - "kms:*"
            Resource: "*"
      KeySpec: SYMMETRIC_DEFAULT
      KeyUsage: ENCRYPT_DECRYPT
      PendingWindowInDays: 30
      Tags: 
        - Key: "Stack" 
          Value: !Sub "${AWS::StackName}"

  AlarmsTopic:
    Type: AWS::SNS::Topic
    Properties:
      KmsMasterKeyId: !Ref AlarmsKMSKey
      Tags:
        - Key: "Stack" 
          Value: !Sub "${AWS::StackName}"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



