AWSTemplateFormatVersion: "2010-09-09"
Resources:
  VPCB9E5F0B4:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: 10.0.0.0/16
      EnableDnsHostnames: true
      EnableDnsSupport: true
      InstanceTenancy: default
      Tags:
        - Key: Name
          Value: vro-blog/VPC
  VPCPublicSubnet1SubnetB4246D30:
    Type: AWS::EC2::Subnet
    Properties:
      CidrBlock: 10.0.0.0/18
      VpcId:
        Ref: VPCB9E5F0B4
      AvailabilityZone:
        Fn::Select:
          - 0
          - Fn::GetAZs: ""
      MapPublicIpOnLaunch: false
      Tags:
        - Key: aws-cdk:subnet-name
          Value: Public
        - Key: aws-cdk:subnet-type
          Value: Public
        - Key: Name
          Value: vro-blog/VPC/PublicSubnet1
  VPCPublicSubnet1RouteTableFEE4B781:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId:
        Ref: VPCB9E5F0B4
      Tags:
        - Key: Name
          Value: vro-blog/VPC/PublicSubnet1
  VPCPublicSubnet1RouteTableAssociation0B0896DC:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      RouteTableId:
        Ref: VPCPublicSubnet1RouteTableFEE4B781
      SubnetId:
        Ref: VPCPublicSubnet1SubnetB4246D30
  VPCPublicSubnet1DefaultRoute91CEF279:
    Type: AWS::EC2::Route
    Properties:
      RouteTableId:
        Ref: VPCPublicSubnet1RouteTableFEE4B781
      DestinationCidrBlock: 0.0.0.0/0
      GatewayId:
        Ref: VPCIGWB7E252D3
    DependsOn:
      - VPCVPCGW99B986DC
  VPCPublicSubnet1EIP6AD938E8:
    Type: AWS::EC2::EIP
    Properties:
      Domain: vpc
      Tags:
        - Key: Name
          Value: vro-blog/VPC/PublicSubnet1
  VPCPublicSubnet1NATGatewayE0556630:
    Type: AWS::EC2::NatGateway
    Properties:
      AllocationId:
        Fn::GetAtt:
          - VPCPublicSubnet1EIP6AD938E8
          - AllocationId
      SubnetId:
        Ref: VPCPublicSubnet1SubnetB4246D30
      Tags:
        - Key: Name
          Value: vro-blog/VPC/PublicSubnet1
  VPCPublicSubnet2Subnet74179F39:
    Type: AWS::EC2::Subnet
    Properties:
      CidrBlock: 10.0.64.0/18
      VpcId:
        Ref: VPCB9E5F0B4
      AvailabilityZone:
        Fn::Select:
          - 1
          - Fn::GetAZs: ""
      MapPublicIpOnLaunch: false
      Tags:
        - Key: aws-cdk:subnet-name
          Value: Public
        - Key: aws-cdk:subnet-type
          Value: Public
        - Key: Name
          Value: vro-blog/VPC/PublicSubnet2
  VPCPublicSubnet2RouteTable6F1A15F1:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId:
        Ref: VPCB9E5F0B4
      Tags:
        - Key: Name
          Value: vro-blog/VPC/PublicSubnet2
  VPCPublicSubnet2RouteTableAssociation5A808732:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      RouteTableId:
        Ref: VPCPublicSubnet2RouteTable6F1A15F1
      SubnetId:
        Ref: VPCPublicSubnet2Subnet74179F39
  VPCPublicSubnet2DefaultRouteB7481BBA:
    Type: AWS::EC2::Route
    Properties:
      RouteTableId:
        Ref: VPCPublicSubnet2RouteTable6F1A15F1
      DestinationCidrBlock: 0.0.0.0/0
      GatewayId:
        Ref: VPCIGWB7E252D3
    DependsOn:
      - VPCVPCGW99B986DC
  VPCPublicSubnet2EIP4947BC00:
    Type: AWS::EC2::EIP
    Properties:
      Domain: vpc
      Tags:
        - Key: Name
          Value: vro-blog/VPC/PublicSubnet2
  VPCPublicSubnet2NATGateway3C070193:
    Type: AWS::EC2::NatGateway
    Properties:
      AllocationId:
        Fn::GetAtt:
          - VPCPublicSubnet2EIP4947BC00
          - AllocationId
      SubnetId:
        Ref: VPCPublicSubnet2Subnet74179F39
      Tags:
        - Key: Name
          Value: vro-blog/VPC/PublicSubnet2
  VPCPrivateSubnet1Subnet8BCA10E0:
    Type: AWS::EC2::Subnet
    Properties:
      CidrBlock: 10.0.128.0/18
      VpcId:
        Ref: VPCB9E5F0B4
      AvailabilityZone:
        Fn::Select:
          - 0
          - Fn::GetAZs: ""
      MapPublicIpOnLaunch: false
      Tags:
        - Key: aws-cdk:subnet-name
          Value: Private
        - Key: aws-cdk:subnet-type
          Value: Private
        - Key: Name
          Value: vro-blog/VPC/PrivateSubnet1
  VPCPrivateSubnet1RouteTableBE8A6027:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId:
        Ref: VPCB9E5F0B4
      Tags:
        - Key: Name
          Value: vro-blog/VPC/PrivateSubnet1
  VPCPrivateSubnet1RouteTableAssociation347902D1:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      RouteTableId:
        Ref: VPCPrivateSubnet1RouteTableBE8A6027
      SubnetId:
        Ref: VPCPrivateSubnet1Subnet8BCA10E0
  VPCPrivateSubnet1DefaultRouteAE1D6490:
    Type: AWS::EC2::Route
    Properties:
      RouteTableId:
        Ref: VPCPrivateSubnet1RouteTableBE8A6027
      DestinationCidrBlock: 0.0.0.0/0
      NatGatewayId:
        Ref: VPCPublicSubnet1NATGatewayE0556630
  VPCPrivateSubnet2SubnetCFCDAA7A:
    Type: AWS::EC2::Subnet
    Properties:
      CidrBlock: 10.0.192.0/18
      VpcId:
        Ref: VPCB9E5F0B4
      AvailabilityZone:
        Fn::Select:
          - 1
          - Fn::GetAZs: ""
      MapPublicIpOnLaunch: false
      Tags:
        - Key: aws-cdk:subnet-name
          Value: Private
        - Key: aws-cdk:subnet-type
          Value: Private
        - Key: Name
          Value: vro-blog/VPC/PrivateSubnet2
  VPCPrivateSubnet2RouteTable0A19E10E:
    Type: AWS::EC2::RouteTable
    Properties:
      VpcId:
        Ref: VPCB9E5F0B4
      Tags:
        - Key: Name
          Value: vro-blog/VPC/PrivateSubnet2
  VPCPrivateSubnet2RouteTableAssociation0C73D413:
    Type: AWS::EC2::SubnetRouteTableAssociation
    Properties:
      RouteTableId:
        Ref: VPCPrivateSubnet2RouteTable0A19E10E
      SubnetId:
        Ref: VPCPrivateSubnet2SubnetCFCDAA7A
  VPCPrivateSubnet2DefaultRouteF4F5CFD2:
    Type: AWS::EC2::Route
    Properties:
      RouteTableId:
        Ref: VPCPrivateSubnet2RouteTable0A19E10E
      DestinationCidrBlock: 0.0.0.0/0
      NatGatewayId:
        Ref: VPCPublicSubnet2NATGateway3C070193
  VPCIGWB7E252D3:
    Type: AWS::EC2::InternetGateway
    Properties:
      Tags:
        - Key: Name
          Value: vro-blog/VPC
  VPCVPCGW99B986DC:
    Type: AWS::EC2::VPCGatewayAttachment
    Properties:
      VpcId:
        Ref: VPCB9E5F0B4
      InternetGatewayId:
        Ref: VPCIGWB7E252D3
  dbsgCE6973BD:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: vro-blog/db-sg
      SecurityGroupEgress:
        - CidrIp: 10.0.0.0/16
          Description: Allow 5432 outbound traffic to the VPC
          IpProtocol: "tcp"
          FromPort: 5432
          ToPort: 5432
      SecurityGroupIngress: 
        - CidrIp: 10.0.0.0/16
          Description: Allow 5432 inbound traffic from the VPC
          IpProtocol: "tcp"
          FromPort: 5432
          ToPort: 5432
      VpcId:
        Ref: VPCB9E5F0B4
      Tags:
        - Key: "Name"
          Value: "postgres-sg"
  RDSSubnets873FC54A:
    Type: AWS::RDS::DBSubnetGroup
    Properties:
      DBSubnetGroupDescription: Subnets for RDS database
      SubnetIds:
        - Ref: VPCPublicSubnet1SubnetB4246D30
        - Ref: VPCPublicSubnet2Subnet74179F39
  vroblogRDSSecret86205DF33fdaad7efa858a3daf9490cf0a702aeb:
    Type: AWS::SecretsManager::Secret
    Properties:
      Description:
        Fn::Join:
          - ""
          - - "Generated by the CDK for stack: "
            - Ref: AWS::StackName
      GenerateSecretString:
        ExcludeCharacters: " %+~`#$&*()|[]{}:;<>?!'/@\"\\"
        GenerateStringKey: password
        PasswordLength: 30
        SecretStringTemplate: '{"username":"postgres"}'
      Name: RDSSecret
  RDSSecretAttachment39FC3A79:
    Type: AWS::SecretsManager::SecretTargetAttachment
    Properties:
      SecretId:
        Ref: vroblogRDSSecret86205DF33fdaad7efa858a3daf9490cf0a702aeb
      TargetId:
        Ref: RDSE0E96D00
      TargetType: AWS::RDS::DBCluster
  RDSE0E96D00:
    Type: AWS::RDS::DBCluster
    Properties:
      Engine: aurora-postgresql
      DatabaseName: geomap
      DBClusterParameterGroupName: default.aurora-postgresql12
      DBSubnetGroupName:
        Ref: RDSSubnets873FC54A
      DeletionProtection: false
      EngineVersion: "12.4"
      MasterUsername: postgres
      MasterUserPassword:
        Fn::Join:
          - ""
          - - "{{resolve:secretsmanager:"
            - Ref: vroblogRDSSecret86205DF33fdaad7efa858a3daf9490cf0a702aeb
            - :SecretString:password::}}
      Port: 5432
      VpcSecurityGroupIds:
        - Fn::GetAtt:
            - dbsgCE6973BD
            - GroupId
      StorageEncrypted: true
    UpdateReplacePolicy: Delete
    DeletionPolicy: Delete
  RDSInstance173AB26B0:
    Type: AWS::RDS::DBInstance
    Properties:
      DBInstanceClass: db.r4.large
      DBClusterIdentifier:
        Ref: RDSE0E96D00
      DBSubnetGroupName:
        Ref: RDSSubnets873FC54A
      Engine: aurora-postgresql
      EngineVersion: "12.4"
      PubliclyAccessible: false
    DependsOn:
      - VPCPublicSubnet1DefaultRoute91CEF279
      - VPCPublicSubnet2DefaultRouteB7481BBA
    UpdateReplacePolicy: Delete
    DeletionPolicy: Delete
  Cloud9Instance001:
    Type: AWS::Cloud9::EnvironmentEC2
    Properties: 
      AutomaticStopTimeMinutes: 60
      Description: "Cloud9 instance for VRO"
      ImageId: "amazonlinux-2-x86_64"
      InstanceType: "m4.large"
      Name: "VRO env"
      SubnetId: 
        Ref: VPCPublicSubnet1SubnetB4246D30
    DependsOn:
      - VPCPublicSubnet1SubnetB4246D30  
