cloudformation.yaml [43:280]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Metadata:
  AWS::CloudFormation::Interface: 
    ParameterGroups: 
      - 
        Label: 
          default: "DocumentDB Configuration"
        Parameters: 
          - DocDBInstanceType
          - DocDBUsername
          - DocDBPassword
    ParameterLabels: 
      DocDBInstanceType: 
        default: "Instance type for DocumentDB cluster"
      DocDBUsername: 
        default: "DocumentDB master username"
      DocDBPassword: 
        default: "DocumentDB master password"
        
Mappings:
  SubnetConfig:
    VPC:
      CIDR: '10.0.0.0/16'
    PublicOne:
      CIDR: '10.0.0.0/24'
    PrivateOne:
      CIDR: '10.0.100.0/24'
    PrivateTwo:
      CIDR: '10.0.101.0/24'
    PrivateThree:
      CIDR: '10.0.102.0/24'

Resources:
# Networking
  VPC:
    Type: AWS::EC2::VPC
    Properties:
      EnableDnsSupport: true
      EnableDnsHostnames: true
      CidrBlock: !FindInMap ['SubnetConfig', 'VPC', 'CIDR']
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-VPC

  PublicSubnetOne:
    Type: AWS::EC2::Subnet
    Properties:
      AvailabilityZone:
         Fn::Select:
         - 0
         - Fn::GetAZs: {Ref: 'AWS::Region'}
      VpcId: !Ref VPC
      CidrBlock: !FindInMap ['SubnetConfig', 'PublicOne', 'CIDR']
      MapPublicIpOnLaunch: true
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-PublicOne

  PrivateSubnetOne:
    Type: AWS::EC2::Subnet
    Properties:
      AvailabilityZone:
         Fn::Select:
         - 0
         - Fn::GetAZs: {Ref: 'AWS::Region'}
      VpcId: !Ref VPC
      CidrBlock: !FindInMap ['SubnetConfig', 'PrivateOne', 'CIDR']
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-PrivateOne

  PrivateSubnetTwo:
    Type: AWS::EC2::Subnet
    Properties:
      AvailabilityZone:
         Fn::Select:
         - 1
         - Fn::GetAZs: {Ref: 'AWS::Region'}
      VpcId: !Ref VPC
      CidrBlock: !FindInMap ['SubnetConfig', 'PrivateTwo', 'CIDR']
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-PrivateTwo

  PrivateSubnetThree:
    Type: AWS::EC2::Subnet
    Properties:
      AvailabilityZone:
         Fn::Select:
         - 2
         - Fn::GetAZs: {Ref: 'AWS::Region'}
      VpcId: !Ref VPC
      CidrBlock: !FindInMap ['SubnetConfig', 'PrivateThree', 'CIDR']
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-PrivateThree

  InternetGateway:
    Type: AWS::EC2::InternetGateway
    Properties:
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-igw
  GatewayAttachement:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId: !Ref VPC
      InternetGatewayId: !Ref InternetGateway
  PublicRouteTable:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId: !Ref VPC
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-PublicRouteTable
  PublicRoute:
    Type: AWS::EC2::Route
    DependsOn: GatewayAttachement
    Properties:
      RouteTableId: !Ref PublicRouteTable
      DestinationCidrBlock: 0.0.0.0/0
      GatewayId: !Ref InternetGateway
  PublicSubnetOneRouteTableAssociation:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      SubnetId: !Ref PublicSubnetOne
      RouteTableId: !Ref PublicRouteTable

# DocumentDB
  DocumentDBSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties: 
      GroupDescription: Amazon DocumentDB Security Group
      GroupName: !Sub ${AWS::StackName}-SG-DocumentDB
      VpcId: !Ref VPC
      SecurityGroupIngress:
         - IpProtocol: tcp
           CidrIp: 10.0.0.0/16
           FromPort: 27017
           ToPort: 27017
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-SG-DocumentDB
 
  DocumentDBSubnetGroup:
    Type: AWS::DocDB::DBSubnetGroup
    Properties: 
      DBSubnetGroupDescription: Subnet Group for DocumentDB
      DBSubnetGroupName: !Sub ${AWS::StackName}-SG-DocumentDB
      SubnetIds: 
         - !Ref PrivateSubnetOne
         - !Ref PrivateSubnetTwo
         - !Ref PrivateSubnetThree
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-SG-DocumentDB

  DocumentDBCluster:  
    Type: AWS::DocDB::DBCluster
    Properties: 
      DBClusterIdentifier: !Sub ${AWS::StackName}-DocumentDB
      MasterUsername: !Ref DocDBUsername
      MasterUserPassword: !Ref DocDBPassword
      DBSubnetGroupName : !Ref DocumentDBSubnetGroup
      StorageEncrypted: yes
      Tags: 
        - Key: Name
          Value: !Sub ${AWS::StackName}-DocumentDB
      VpcSecurityGroupIds: 
        - !Ref DocumentDBSecurityGroup
    DependsOn: VPC

  DocumentDBInstanceOne: 
    Type: AWS::DocDB::DBInstance
    Properties: 
      DBClusterIdentifier: !Ref DocumentDBCluster
      DBInstanceClass: !Ref DocDBInstanceType
      Tags: 
        - Key: Name
          Value: !Sub ${AWS::StackName}-DocumentDBInstance1

  DocumentDBInstanceTwo: 
    Type: AWS::DocDB::DBInstance
    Properties: 
      DBClusterIdentifier: !Ref DocumentDBCluster
      DBInstanceClass: !Ref DocDBInstanceType
      Tags: 
        - Key: Name
          Value: !Sub ${AWS::StackName}-DocumentDBInstance2

  DocumentDBInstanceThree: 
    Type: AWS::DocDB::DBInstance
    Properties: 
      DBClusterIdentifier: !Ref DocumentDBCluster
      DBInstanceClass: !Ref DocDBInstanceType
      Tags: 
        - Key: Name
          Value: !Sub ${AWS::StackName}-DocumentDBInstance3

  DocDBSecret:
    Type: 'AWS::SecretsManager::Secret'
    Properties:
      Name: !Sub ${AWS::StackName}-DocDBSecret
      Description: This secret has the credentials for the DocumentDB cluster
      SecretString:
        !Join
          - '' 
          - - '{"username":"'
            - !Ref DocDBUsername
            - '","password":"'
            - !Ref DocDBPassword
            - '", "ssl": true}'
  
  SecretDocDBClusterAttachment:
    Type: AWS::SecretsManager::SecretTargetAttachment
    Properties:
      SecretId: !Ref DocDBSecret
      TargetId: !Ref DocumentDBCluster
      TargetType: AWS::DocDB::DBCluster

# SageMaker
  SageMakerRole:
    Type: AWS::IAM::Role
    Properties: 
      AssumeRolePolicyDocument: 
        Version: "2012-10-17"
        Statement: 
          - 
            Effect: "Allow"
            Principal: 
              Service: 
                - "sagemaker.amazonaws.com"
            Action: 
              - "sts:AssumeRole"
      Description: SageMaker notebook instance role granting read access to Secrets Manager
      RoleName: !Sub ${AWS::StackName}-SageMakerRoleName
      Tags: 
        - Key: Name
          Value: !Sub ${AWS::StackName}-SageMakerRoleName
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



rekognition/cloudformation.yaml [48:285]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Metadata:
  AWS::CloudFormation::Interface: 
    ParameterGroups: 
      - 
        Label: 
          default: "DocumentDB Configuration"
        Parameters: 
          - DocDBInstanceType
          - DocDBUsername
          - DocDBPassword
    ParameterLabels: 
      DocDBInstanceType: 
        default: "Instance type for DocumentDB cluster"
      DocDBUsername: 
        default: "DocumentDB master username"
      DocDBPassword: 
        default: "DocumentDB master password"
        
Mappings:
  SubnetConfig:
    VPC:
      CIDR: '10.0.0.0/16'
    PublicOne:
      CIDR: '10.0.0.0/24'
    PrivateOne:
      CIDR: '10.0.100.0/24'
    PrivateTwo:
      CIDR: '10.0.101.0/24'
    PrivateThree:
      CIDR: '10.0.102.0/24'

Resources:
# Networking
  VPC:
    Type: AWS::EC2::VPC
    Properties:
      EnableDnsSupport: true
      EnableDnsHostnames: true
      CidrBlock: !FindInMap ['SubnetConfig', 'VPC', 'CIDR']
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-VPC

  PublicSubnetOne:
    Type: AWS::EC2::Subnet
    Properties:
      AvailabilityZone:
         Fn::Select:
         - 0
         - Fn::GetAZs: {Ref: 'AWS::Region'}
      VpcId: !Ref VPC
      CidrBlock: !FindInMap ['SubnetConfig', 'PublicOne', 'CIDR']
      MapPublicIpOnLaunch: true
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-PublicOne

  PrivateSubnetOne:
    Type: AWS::EC2::Subnet
    Properties:
      AvailabilityZone:
         Fn::Select:
         - 0
         - Fn::GetAZs: {Ref: 'AWS::Region'}
      VpcId: !Ref VPC
      CidrBlock: !FindInMap ['SubnetConfig', 'PrivateOne', 'CIDR']
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-PrivateOne

  PrivateSubnetTwo:
    Type: AWS::EC2::Subnet
    Properties:
      AvailabilityZone:
         Fn::Select:
         - 1
         - Fn::GetAZs: {Ref: 'AWS::Region'}
      VpcId: !Ref VPC
      CidrBlock: !FindInMap ['SubnetConfig', 'PrivateTwo', 'CIDR']
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-PrivateTwo

  PrivateSubnetThree:
    Type: AWS::EC2::Subnet
    Properties:
      AvailabilityZone:
         Fn::Select:
         - 2
         - Fn::GetAZs: {Ref: 'AWS::Region'}
      VpcId: !Ref VPC
      CidrBlock: !FindInMap ['SubnetConfig', 'PrivateThree', 'CIDR']
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-PrivateThree

  InternetGateway:
    Type: AWS::EC2::InternetGateway
    Properties:
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-igw
  GatewayAttachement:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId: !Ref VPC
      InternetGatewayId: !Ref InternetGateway
  PublicRouteTable:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId: !Ref VPC
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-PublicRouteTable
  PublicRoute:
    Type: AWS::EC2::Route
    DependsOn: GatewayAttachement
    Properties:
      RouteTableId: !Ref PublicRouteTable
      DestinationCidrBlock: 0.0.0.0/0
      GatewayId: !Ref InternetGateway
  PublicSubnetOneRouteTableAssociation:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      SubnetId: !Ref PublicSubnetOne
      RouteTableId: !Ref PublicRouteTable

# DocumentDB
  DocumentDBSecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties: 
      GroupDescription: Amazon DocumentDB Security Group
      GroupName: !Sub ${AWS::StackName}-SG-DocumentDB
      VpcId: !Ref VPC
      SecurityGroupIngress:
         - IpProtocol: tcp
           CidrIp: 10.0.0.0/16
           FromPort: 27017
           ToPort: 27017
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-SG-DocumentDB
 
  DocumentDBSubnetGroup:
    Type: AWS::DocDB::DBSubnetGroup
    Properties: 
      DBSubnetGroupDescription: Subnet Group for DocumentDB
      DBSubnetGroupName: !Sub ${AWS::StackName}-SG-DocumentDB
      SubnetIds: 
         - !Ref PrivateSubnetOne
         - !Ref PrivateSubnetTwo
         - !Ref PrivateSubnetThree
      Tags:
        - Key: Name
          Value: !Sub ${AWS::StackName}-SG-DocumentDB

  DocumentDBCluster:  
    Type: AWS::DocDB::DBCluster
    Properties: 
      DBClusterIdentifier: !Sub ${AWS::StackName}-DocumentDB
      MasterUsername: !Ref DocDBUsername
      MasterUserPassword: !Ref DocDBPassword
      DBSubnetGroupName : !Ref DocumentDBSubnetGroup
      StorageEncrypted: yes
      Tags: 
        - Key: Name
          Value: !Sub ${AWS::StackName}-DocumentDB
      VpcSecurityGroupIds: 
        - !Ref DocumentDBSecurityGroup
    DependsOn: VPC

  DocumentDBInstanceOne: 
    Type: AWS::DocDB::DBInstance
    Properties: 
      DBClusterIdentifier: !Ref DocumentDBCluster
      DBInstanceClass: !Ref DocDBInstanceType
      Tags: 
        - Key: Name
          Value: !Sub ${AWS::StackName}-DocumentDBInstance1

  DocumentDBInstanceTwo: 
    Type: AWS::DocDB::DBInstance
    Properties: 
      DBClusterIdentifier: !Ref DocumentDBCluster
      DBInstanceClass: !Ref DocDBInstanceType
      Tags: 
        - Key: Name
          Value: !Sub ${AWS::StackName}-DocumentDBInstance2

  DocumentDBInstanceThree: 
    Type: AWS::DocDB::DBInstance
    Properties: 
      DBClusterIdentifier: !Ref DocumentDBCluster
      DBInstanceClass: !Ref DocDBInstanceType
      Tags: 
        - Key: Name
          Value: !Sub ${AWS::StackName}-DocumentDBInstance3

  DocDBSecret:
    Type: 'AWS::SecretsManager::Secret'
    Properties:
      Name: !Sub ${AWS::StackName}-DocDBSecret
      Description: This secret has the credentials for the DocumentDB cluster
      SecretString:
        !Join
          - '' 
          - - '{"username":"'
            - !Ref DocDBUsername
            - '","password":"'
            - !Ref DocDBPassword
            - '", "ssl": true}'
  
  SecretDocDBClusterAttachment:
    Type: AWS::SecretsManager::SecretTargetAttachment
    Properties:
      SecretId: !Ref DocDBSecret
      TargetId: !Ref DocumentDBCluster
      TargetType: AWS::DocDB::DBCluster

# SageMaker
  SageMakerRole:
    Type: AWS::IAM::Role
    Properties: 
      AssumeRolePolicyDocument: 
        Version: "2012-10-17"
        Statement: 
          - 
            Effect: "Allow"
            Principal: 
              Service: 
                - "sagemaker.amazonaws.com"
            Action: 
              - "sts:AssumeRole"
      Description: SageMaker notebook instance role granting read access to Secrets Manager
      RoleName: !Sub ${AWS::StackName}-SageMakerRoleName
      Tags: 
        - Key: Name
          Value: !Sub ${AWS::StackName}-SageMakerRoleName
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



