{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Conditions": {
    "AMPSUse0": {
      "Fn::Equals": [
        0,
        {
          "Ref": "AMPsPerSubpool"
        }
      ]
    },
    "DBTemporalEnabled": {
      "Fn::Equals": [
        {
          "Ref": "DBTemporal"
        },
        "yes"
      ]
    },
    "DBUseCapacityReservation": {
      "Fn::Not": [
        {
          "Fn::Equals": [
            {
              "Ref": "DBCapacityReservation"
            },
            ""
          ]
        }
      ]
    },
    "DBUseEBS12": {
      "Fn::Equals": [
        "EBS12",
        {
          "Fn::FindInMap": [
            "DBInstanceStorageTypes",
            {
              "Ref": "DBInstanceStorageType"
            },
            {
              "Fn::FindInMap": [
                "DBUnfoldConfigTypes",
                {
                  "Ref": "DBUnfoldConfigType"
                },
                "LaunchConfig"
              ]
            }
          ]
        }
      ]
    },
    "DBUseEBS24": {
      "Fn::Equals": [
        "EBS24",
        {
          "Fn::FindInMap": [
            "DBInstanceStorageTypes",
            {
              "Ref": "DBInstanceStorageType"
            },
            {
              "Fn::FindInMap": [
                "DBUnfoldConfigTypes",
                {
                  "Ref": "DBUnfoldConfigType"
                },
                "LaunchConfig"
              ]
            }
          ]
        }
      ]
    },
    "DBUseEBS6": {
      "Fn::Equals": [
        "EBS6",
        {
          "Fn::FindInMap": [
            "DBInstanceStorageTypes",
            {
              "Ref": "DBInstanceStorageType"
            },
            {
              "Fn::FindInMap": [
                "DBUnfoldConfigTypes",
                {
                  "Ref": "DBUnfoldConfigType"
                },
                "LaunchConfig"
              ]
            }
          ]
        }
      ]
    },
    "DBUseElasticIPs": {
      "Fn::Equals": [
        {
          "Ref": "DBElasticIPs"
        },
        "yes"
      ]
    },
    "DBUseEncryption": {
      "Fn::Equals": [
        {
          "Ref": "DBEBSEncryption"
        },
        "yes"
      ]
    },
    "DBUseRootEncryption": {
      "Fn::Equals": [
        {
          "Ref": "DBRootEncryption"
        },
        "yes"
      ]
    },
    "DBUseVolume0": {
      "Fn::Equals": [
        0,
        {
          "Ref": "UserDefinedVolumeCount"
        }
      ]
    },
    "IsOTFInstanceSelected": {
      "Fn::Equals": [
        {
          "Ref": "DBInstanceStorageType"
        },
        "r6id.12xlarge-EBS"
      ]
    },
    "SubpoolUse0": {
      "Fn::Equals": [
        0,
        {
          "Ref": "SubpoolPerClique"
        }
      ]
    }
  },
  "Description": "Teradata Ecosystem - Test / Dev",
  "Mappings": {
    "DBAMIs": {
      "af-south-1": {
        "AMI": "ami-056ce9b33d2a557a5"
      },
      "ap-east-1": {
        "AMI": "ami-024271f98a3cf51c9"
      },
      "ap-northeast-1": {
        "AMI": "ami-0b2b5a355dacf0d26"
      },
      "ap-northeast-2": {
        "AMI": "ami-09053e8e0782511c8"
      },
      "ap-northeast-3": {
        "AMI": "ami-0324b48d3614b27ce"
      },
      "ap-south-1": {
        "AMI": "ami-0daf1053b38a1bfd8"
      },
      "ap-southeast-1": {
        "AMI": "ami-05f6b283616de8f82"
      },
      "ap-southeast-2": {
        "AMI": "ami-0dfe7f762db3a6937"
      },
      "ca-central-1": {
        "AMI": "ami-00bf67ae55bf17b79"
      },
      "eu-central-1": {
        "AMI": "ami-01335fb5d6b907521"
      },
      "eu-central-2": {
        "AMI": "ami-0961916d1f2c994c5"
      },
      "eu-north-1": {
        "AMI": "ami-0fa2f21b70f9f1678"
      },
      "eu-south-1": {
        "AMI": "ami-071fbaa2f70907020"
      },
      "eu-south-2": {
        "AMI": "ami-09658f7a41f985315"
      },
      "eu-west-1": {
        "AMI": "ami-03c569208c0fd0f06"
      },
      "eu-west-2": {
        "AMI": "ami-02d8699a73bea4e0f"
      },
      "eu-west-3": {
        "AMI": "ami-04adeae5f856652ff"
      },
      "me-south-1": {
        "AMI": "ami-01053179d503d1be1"
      },
      "sa-east-1": {
        "AMI": "ami-030547e4f90aa930c"
      },
      "us-east-1": {
        "AMI": "ami-0e80b5ac044578bd7"
      },
      "us-east-2": {
        "AMI": "ami-0ecdf68595b04d004"
      },
      "us-gov-east-1": {
        "AMI": "ami-0be0bb0eef905cf29"
      },
      "us-gov-west-1": {
        "AMI": "ami-03293302fa2444824"
      },
      "us-west-1": {
        "AMI": "ami-0e95f488d4152a71b"
      },
      "us-west-2": {
        "AMI": "ami-02601d6b8296acf87"
      }
    },
    "DBInstanceStorageTypes": {
      "r6i.12xlarge-EBS": {
        "DefaultVolumeCount": 24,
        "InstanceType": "r6i.12xlarge",
        "LaunchConfig": "EBS24",
        "LaunchConfig2": "EBS12",
        "LaunchConfig4": "EBS6",
        "VolumeCountUnfold2": 12,
        "VolumeCountUnfold4": 6
      },
      "r6i.16xlarge-EBS": {
        "DefaultVolumeCount": 24,
        "InstanceType": "r6i.16xlarge",
        "LaunchConfig": "EBS24",
        "LaunchConfig2": "EBS12",
        "LaunchConfig4": "EBS6",
        "VolumeCountUnfold2": 12,
        "VolumeCountUnfold4": 6
      },
      "r6i.24xlarge-EBS": {
        "DefaultVolumeCount": 24,
        "InstanceType": "r6i.24xlarge",
        "LaunchConfig": "EBS24",
        "LaunchConfig2": "EBS12",
        "LaunchConfig4": "EBS6",
        "VolumeCountUnfold2": 12,
        "VolumeCountUnfold4": 6
      },
      "r6i.4xlarge-EBS": {
        "DefaultVolumeCount": 24,
        "InstanceType": "r6i.4xlarge",
        "LaunchConfig": "EBS24",
        "LaunchConfig2": "EBS12",
        "LaunchConfig4": "EBS6",
        "VolumeCountUnfold2": 12,
        "VolumeCountUnfold4": 6
      },
      "r6i.8xlarge-EBS": {
        "DefaultVolumeCount": 24,
        "InstanceType": "r6i.8xlarge",
        "LaunchConfig": "EBS24",
        "LaunchConfig2": "EBS12",
        "LaunchConfig4": "EBS6",
        "VolumeCountUnfold2": 12,
        "VolumeCountUnfold4": 6
      },
      "r6id.12xlarge-EBS": {
        "DefaultVolumeCount": 24,
        "InstanceType": "r6id.12xlarge",
        "LaunchConfig": "EBS24",
        "LaunchConfig2": "EBS12",
        "LaunchConfig4": "EBS6",
        "VolumeCountUnfold2": 12,
        "VolumeCountUnfold4": 6
      }
    },
    "DBStorageSizes": {
      "5": {
        "0": 0,
        "24": 195
      },
      "6": {
        "0": 0,
        "24": 233
      },
      "7": {
        "0": 0,
        "24": 272
      },
      "8": {
        "0": 0,
        "24": 311
      },
      "9": {
        "0": 0,
        "24": 350
      },
      "10": {
        "0": 0,
        "24": 389
      },
      "11": {
        "0": 0,
        "24": 427
      },
      "12": {
        "0": 0,
        "24": 466
      },
      "13": {
        "0": 0,
        "24": 505
      },
      "14": {
        "0": 0,
        "24": 544
      },
      "15": {
        "0": 0,
        "24": 583
      },
      "16": {
        "0": 0,
        "24": 621
      },
      "17": {
        "0": 0,
        "24": 660
      },
      "18": {
        "0": 0,
        "24": 699
      },
      "19": {
        "0": 0,
        "24": 738
      },
      "20": {
        "0": 0,
        "24": 777
      },
      "21": {
        "0": 0,
        "24": 815
      },
      "22": {
        "0": 0,
        "24": 854
      },
      "23": {
        "0": 0,
        "24": 893
      },
      "24": {
        "0": 0,
        "24": 932
      },
      "25": {
        "0": 0,
        "24": 971
      },
      "26": {
        "0": 0,
        "24": 1009
      },
      "27": {
        "0": 0,
        "24": 1048
      },
      "28": {
        "0": 0,
        "24": 1087
      },
      "29": {
        "0": 0,
        "24": 1126
      },
      "30": {
        "0": 0,
        "24": 1165
      },
      "31": {
        "0": 0,
        "24": 1203
      },
      "32": {
        "0": 0,
        "24": 1242
      },
      "33": {
        "0": 0,
        "24": 1281
      },
      "34": {
        "0": 0,
        "24": 1320
      },
      "35": {
        "0": 0,
        "24": 1359
      },
      "36": {
        "0": 0,
        "24": 1397
      },
      "37": {
        "0": 0,
        "24": 1436
      },
      "38": {
        "0": 0,
        "24": 1475
      },
      "39": {
        "0": 0,
        "24": 1514
      },
      "40": {
        "0": 0,
        "24": 1553
      },
      "41": {
        "0": 0,
        "24": 1592
      },
      "42": {
        "0": 0,
        "24": 1630
      },
      "43": {
        "0": 0,
        "24": 1669
      },
      "44": {
        "0": 0,
        "24": 1708
      },
      "45": {
        "0": 0,
        "24": 1747
      },
      "46": {
        "0": 0,
        "24": 1786
      },
      "47": {
        "0": 0,
        "24": 1824
      },
      "48": {
        "0": 0,
        "24": 1863
      },
      "49": {
        "0": 0,
        "24": 1902
      },
      "50": {
        "0": 0,
        "24": 1941
      },
      "51": {
        "0": 0,
        "24": 1980
      },
      "52": {
        "0": 0,
        "24": 2018
      },
      "53": {
        "0": 0,
        "24": 2057
      },
      "54": {
        "0": 0,
        "24": 2096
      },
      "55": {
        "0": 0,
        "24": 2135
      },
      "56": {
        "0": 0,
        "24": 2174
      },
      "57": {
        "0": 0,
        "24": 2212
      },
      "58": {
        "0": 0,
        "24": 2251
      },
      "59": {
        "0": 0,
        "24": 2290
      },
      "60": {
        "0": 0,
        "24": 2329
      },
      "61": {
        "0": 0,
        "24": 2368
      },
      "62": {
        "0": 0,
        "24": 2406
      },
      "63": {
        "0": 0,
        "24": 2445
      },
      "64": {
        "0": 0,
        "24": 2484
      },
      "65": {
        "0": 0,
        "24": 2523
      },
      "66": {
        "0": 0,
        "24": 2562
      },
      "67": {
        "0": 0,
        "24": 2600
      },
      "68": {
        "0": 0,
        "24": 2639
      },
      "69": {
        "0": 0,
        "24": 2678
      },
      "70": {
        "0": 0,
        "24": 2717
      },
      "71": {
        "0": 0,
        "24": 2756
      },
      "72": {
        "0": 0,
        "24": 2794
      }
    },
    "DBUnfoldConfigTypes": {
      "None": {
        "LaunchConfig": "LaunchConfig",
        "UnfoldPosition": "0",
        "VolumeCount": "DefaultVolumeCount"
      },
      "Scale-Out-Ready": {
        "LaunchConfig": "LaunchConfig",
        "UnfoldPosition": "1",
        "VolumeCount": "DefaultVolumeCount"
      }
    },
    "PSIMAMIs": {
      "af-south-1": {
        "AMI": "ami-09bd6e79916ca8ff7"
      },
      "ap-east-1": {
        "AMI": "ami-04136a802f3cb7c2c"
      },
      "ap-northeast-1": {
        "AMI": "ami-07f1d82f8821c07ef"
      },
      "ap-northeast-2": {
        "AMI": "ami-0b25f05944da7be19"
      },
      "ap-northeast-3": {
        "AMI": "ami-0534e260b6eccda21"
      },
      "ap-south-1": {
        "AMI": "ami-02f7b1474238bda41"
      },
      "ap-southeast-1": {
        "AMI": "ami-0cc5e7010f1ace5c0"
      },
      "ap-southeast-2": {
        "AMI": "ami-0c49122669f13daba"
      },
      "ca-central-1": {
        "AMI": "ami-0b726f0701c878b9d"
      },
      "eu-central-1": {
        "AMI": "ami-0116e0202fa6ff31e"
      },
      "eu-central-2": {
        "AMI": "ami-001cef7346a59e0c6"
      },
      "eu-north-1": {
        "AMI": "ami-08b7072b232918f4f"
      },
      "eu-south-1": {
        "AMI": "ami-01ea66140ab59fa59"
      },
      "eu-south-2": {
        "AMI": "ami-09578874e4e4d4c53"
      },
      "eu-west-1": {
        "AMI": "ami-0aac61547e74540f2"
      },
      "eu-west-2": {
        "AMI": "ami-0f1cf599cbae9192c"
      },
      "eu-west-3": {
        "AMI": "ami-0a35d855d29203339"
      },
      "me-south-1": {
        "AMI": "ami-0d16c5e3281aa3e67"
      },
      "sa-east-1": {
        "AMI": "ami-0eb79c0e8a98c7766"
      },
      "us-east-1": {
        "AMI": "ami-0f14467d3132fea53"
      },
      "us-east-2": {
        "AMI": "ami-0faeec46496b3b23f"
      },
      "us-gov-east-1": {
        "AMI": "ami-09b8723ff528ad2a8"
      },
      "us-gov-west-1": {
        "AMI": "ami-015a35ac06061bad3"
      },
      "us-west-1": {
        "AMI": "ami-06a9e831081241a15"
      },
      "us-west-2": {
        "AMI": "ami-05a6cf37130d0933f"
      }
    },
    "VPAMIs": {
      "af-south-1": {
        "AMI": "ami-0c814bcec1be5c160"
      },
      "ap-east-1": {
        "AMI": "ami-08f2f92da69a15b8b"
      },
      "ap-northeast-1": {
        "AMI": "ami-044c13cbdcb267f43"
      },
      "ap-northeast-2": {
        "AMI": "ami-03f784d7875c0d45c"
      },
      "ap-northeast-3": {
        "AMI": "ami-0b36a02621dfbbc05"
      },
      "ap-south-1": {
        "AMI": "ami-0d241decc8356b95f"
      },
      "ap-southeast-1": {
        "AMI": "ami-0e6295d0f11e25bcd"
      },
      "ap-southeast-2": {
        "AMI": "ami-08a634f171cae767a"
      },
      "ca-central-1": {
        "AMI": "ami-0522dad5205aaa815"
      },
      "eu-central-1": {
        "AMI": "ami-01e26e6708b878784"
      },
      "eu-central-2": {
        "AMI": "ami-0147ccdff2ecac809"
      },
      "eu-north-1": {
        "AMI": "ami-0ea2ed8381b23351a"
      },
      "eu-south-1": {
        "AMI": "ami-0a2325147830f74b5"
      },
      "eu-south-2": {
        "AMI": "ami-0dfcbe172b9772b45"
      },
      "eu-west-1": {
        "AMI": "ami-09142acedf6a70c19"
      },
      "eu-west-2": {
        "AMI": "ami-095769e3bb41f1876"
      },
      "eu-west-3": {
        "AMI": "ami-02d25c1be8220be49"
      },
      "me-south-1": {
        "AMI": "ami-072deba7b7aeab043"
      },
      "sa-east-1": {
        "AMI": "ami-08113a926a061b6a2"
      },
      "us-east-1": {
        "AMI": "ami-0a4bb54b539fa35c3"
      },
      "us-east-2": {
        "AMI": "ami-03556866ecaf1e50b"
      },
      "us-gov-east-1": {
        "AMI": "ami-08b440cafe741f9f8"
      },
      "us-gov-west-1": {
        "AMI": "ami-00ed456201e37b199"
      },
      "us-west-1": {
        "AMI": "ami-06d390489c663e4a3"
      },
      "us-west-2": {
        "AMI": "ami-0f0112621a7394de2"
      }
    }
  },
  "Metadata": {
    "AWS::CloudFormation::Interface": {
      "ParameterGroups": [
        {
          "Label": {
            "default": "Teradata Vantage"
          },
          "Parameters": [
            "DBSystemName",
            "EcoVPSystemNickname",
            "DBSystemPassword",
            "DBNodeCount",
            "DBHsnNodeCount",
            "DBInstanceStorageType",
            "DBCapacityReservation",
            "DBUnfoldConfigType",
            "DBStorageSize",
            "SubpoolPerClique",
            "AMPsPerSubpool",
            "UserDefinedVolumeCount",
            "DBEBSEncryption",
            "DBRootEncryption",
            "DBKanjiSupport",
            "OTFFeatureAcknowledgement",
            "DBElasticIPs",
            "DBTemporal",
            "DBSecureZones",
            "DBRowLevelSecurity",
            "DBTimPercent"
          ]
        },
        {
          "Label": {
            "default": "Date and Time"
          },
          "Parameters": [
            "NTPServers",
            "Timezone"
          ]
        },
        {
          "Label": {
            "default": "VPC/Network"
          },
          "Parameters": [
            "VPC",
            "PublicSubnet",
            "DBPlacementGroupParam"
          ]
        },
        {
          "Label": {
            "default": "Security Group"
          },
          "Parameters": [
            "SecurityGroupAccess"
          ]
        },
        {
          "Label": {
            "default": "Proxy Server Configuration"
          },
          "Parameters": [
            "ProxyServerURL"
          ]
        },
        {
          "Label": {
            "default": "Key Pair"
          },
          "Parameters": [
            "KeyName"
          ]
        },
        {
          "Label": {
            "default": "Teradata Server Management"
          },
          "Parameters": [
            "PSIMInstanceType",
            "PSIMNodeCount",
            "PSIMPassword",
            "PSIMRESTPassword",
            "PSIMSiteid"
          ]
        },
        {
          "Label": {
            "default": "Teradata Viewpoint"
          },
          "Parameters": [
            "VPInstanceType"
          ]
        },
        {
          "Label": {
            "default": "Custom Tags"
          },
          "Parameters": [
            "CustomTagParam"
          ]
        }
      ],
      "ParameterLabels": {
        "AMPsPerSubpool": {
          "default": "AMPs Per Subpool"
        },
        "CustomTagParam": {
          "default": "Custom Tags"
        },
        "DBCapacityReservation": {
          "default": "Capacity Reservation"
        },
        "DBEBSEncryption": {
          "default": "EBS Encryption"
        },
        "DBElasticIPs": {
          "default": "Elastic IPs"
        },
        "DBHsnNodeCount": {
          "default": "Number of Hot Standby Nodes"
        },
        "DBInstanceStorageType": {
          "default": "Instance and Storage Type"
        },
        "DBKanjiSupport": {
          "default": "Japanese Support"
        },
        "DBNodeCount": {
          "default": "Number of Nodes"
        },
        "DBPlacementGroupParam": {
          "default": "Database Placement Group"
        },
        "DBRootEncryption": {
          "default": "Root Disk Encryption"
        },
        "DBRowLevelSecurity": {
          "default": "Enable Row-Level Security"
        },
        "DBSecureZones": {
          "default": "Enable Secure Zones"
        },
        "DBStorageSize": {
          "default": "Data Storage"
        },
        "DBSystemName": {
          "default": "System Name"
        },
        "DBSystemPassword": {
          "default": "DBC Password"
        },
        "DBTemporal": {
          "default": "Enable Temporal"
        },
        "DBTimPercent": {
          "default": "Enable Teradata Intelligent Memory"
        },
        "DBUnfoldConfigType": {
          "default": "Scale Out/In"
        },
        "EcoVPSystemNickname": {
          "default": "System Nickname"
        },
        "KeyName": {
          "default": "AWS Key Pair"
        },
        "NTPServers": {
          "default": "NTP Servers"
        },
        "OTFFeatureAcknowledgement": {
          "default": "Enable Teradata Externally Managed OTF (Native Iceberg Reads)"
        },
        "PSIMInstanceType": {
          "default": "Instance Type"
        },
        "PSIMNodeCount": {
          "default": "Number of PSIMs"
        },
        "PSIMPassword": {
          "default": "Admin Password"
        },
        "PSIMRESTPassword": {
          "default": "Teradata Query Service Password"
        },
        "PSIMSiteid": {
          "default": "Site ID"
        },
        "ProxyServerURL": {
          "default": "Proxy Server Configuration"
        },
        "PublicSubnet": {
          "default": "Ecosystem Subnet"
        },
        "SMASiteid": {
          "default": "Site ID"
        },
        "SecurityGroupAccess": {
          "default": "Remote Access From"
        },
        "SubpoolPerClique": {
          "default": "Subpool Per Clique"
        },
        "Timezone": {
          "default": "System Timezone"
        },
        "UserDefinedVolumeCount": {
          "default": "User Defined Volume Count"
        },
        "VPC": {
          "default": "VPC"
        },
        "VPInstanceType": {
          "default": "Instance Type"
        }
      }
    }
  },
  "Parameters": {
    "AMPsPerSubpool": {
      "AllowedValues": [
        "0",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8",
        "9"
      ],
      "Default": "0",
      "Description": "Reference: docs.teradata.com > Teradata Vantage on AWS (DIY) Installation and Administration Guide > Before Deploying Vantage on AWS DIY > Supported Instance Types",
      "Type": "Number"
    },
    "CustomTagParam": {
      "Default": "",
      "Description": "Custom tags are added to all instances in the format key:value. For example, cloud:aws, dbs:teradata",
      "Type": "String"
    },
    "DBCapacityReservation": {
      "AllowedPattern": "(^cr-[a-zA-Z0-9]+)?",
      "Description": "Capacity Reservation ID. Required",
      "Type": "String"
    },
    "DBEBSEncryption": {
      "AllowedValues": [
        "no",
        "yes"
      ],
      "Default": "yes",
      "Description": "Encrypt attached EBS volumes",
      "Type": "String"
    },
    "DBElasticIPs": {
      "AllowedValues": [
        "no",
        "yes"
      ],
      "Default": "no",
      "Description": "Allocate an Elastic IP for each node. NOTE: These will not be deleted when the stack is removed.",
      "Type": "String"
    },
    "DBHsnNodeCount": {
      "Default": 0,
      "Description": "Hot Standby Node count (0-Database node count)",
      "MaxValue": 128,
      "MinValue": 0,
      "Type": "Number"
    },
    "DBInstanceStorageType": {
      "AllowedValues": [
        "r6i.4xlarge-EBS",
        "r6i.8xlarge-EBS",
        "r6i.12xlarge-EBS",
        "r6i.16xlarge-EBS",
        "r6i.24xlarge-EBS",
        "r6id.12xlarge-EBS"
      ],
      "Default": "r6i.4xlarge-EBS",
      "Description": "Storage sizes are per node. Default value will be overridden by AMPs Per Subpool, Subpool Per Clique and User Defined Volume Count.(r6id.12xlarge requires Teradata Externally Managed OTF to be set to YES)",
      "Type": "String"
    },
    "DBKanjiSupport": {
      "AllowedValues": [
        "no",
        "yes"
      ],
      "Default": "no",
      "Description": "Japanese language support",
      "Type": "String"
    },
    "DBNodeCount": {
      "Default": "4",
      "Description": "Database node count (1-128)",
      "MaxValue": 128,
      "MinValue": 1,
      "Type": "Number"
    },
    "DBPlacementGroupParam": {
      "Description": "Existing Placement Group name",
      "MinLength": "1",
      "Type": "String"
    },
    "DBRootEncryption": {
      "AllowedValues": [
        "no",
        "yes"
      ],
      "Default": "no",
      "Description": "Root encryption feature support on all regions of Vantage DIY",
      "Type": "String"
    },
    "DBRowLevelSecurity": {
      "AllowedValues": [
        "no",
        "yes"
      ],
      "Default": "no",
      "Description": "",
      "Type": "String"
    },
    "DBSecureZones": {
      "AllowedValues": [
        "no",
        "yes"
      ],
      "Default": "no",
      "Description": "",
      "Type": "String"
    },
    "DBStorageSize": {
      "Default": "5",
      "Description": "Storage size, in TB, per node (5-72). Only applies to EBS instance types.",
      "MaxValue": 72,
      "MinValue": 5,
      "Type": "Number"
    },
    "DBSystemName": {
      "AllowedPattern": "[a-zA-Z0-9]+",
      "ConstraintDescription": "must only contain 1-15 alphanumeric characters",
      "Default": "mpp",
      "Description": "",
      "MaxLength": "15",
      "MinLength": "1",
      "Type": "String"
    },
    "DBSystemPassword": {
      "Description": "Database DBC Password",
      "MinLength": "1",
      "NoEcho": true,
      "Type": "String"
    },
    "DBTemporal": {
      "AllowedValues": [
        "no",
        "yes"
      ],
      "Default": "no",
      "Description": "When enabled, temporal data is stored in the Teradata file system and displayed in UTC time.\nIf using a time zone other than UTC or enabling daylight savings is required,\nthen Teradata Professional Services engagement will be required.",
      "Type": "String"
    },
    "DBTimPercent": {
      "Default": "0",
      "Description": "TIM cache percent (1-80). 0=TIM disabled.",
      "MaxValue": "80",
      "MinValue": "0",
      "Type": "Number"
    },
    "DBUnfoldConfigType": {
      "AllowedValues": [
        "None",
        "Scale-Out-Ready"
      ],
      "Default": "None",
      "Description": "Initial scale out configuration and support",
      "Type": "String"
    },
    "EcoVPSystemNickname": {
      "AllowedPattern": "[a-zA-Z0-9]+",
      "ConstraintDescription": "must only contain 1-8 alphanumeric characters",
      "Default": "mpp",
      "Description": "Name for monitored system in Viewpoint",
      "MaxLength": "8",
      "MinLength": "1",
      "Type": "String"
    },
    "KeyName": {
      "Description": "",
      "Type": "AWS::EC2::KeyPair::KeyName"
    },
    "NTPServers": {
      "Default": "169.254.169.123",
      "Description": "Comma-delimited Network Time Protocol (NTP) servers, default is to use the Amazon Time Sync Service local IP",
      "Type": "String"
    },
    "OTFFeatureAcknowledgement": {
      "AllowedValues": [
        "no",
        "yes"
      ],
      "Default": "no",
      "Description": "Important note: Set this parameter to YES only if you explicitly plan to provision this site for Teradata Externally Managed OTF (Native Iceberg Reads)Feature. When enabled, only the r6id.12xlarge instance type is supported and must be selected in the Instance Type parameter below. Set to NO (default) for VantageCloud Enterprise Site. \nReference: docs.teradata.com > Teradata Vantage on AWS (DIY) Installation and Administration Guide.",
      "Type": "String"
    },
    "PSIMInstanceType": {
      "AllowedValues": [
        "m5.large"
      ],
      "Default": "m5.large",
      "Description": "",
      "Type": "String"
    },
    "PSIMNodeCount": {
      "Default": "1",
      "Description": "The number of PSIM instances to deploy (1-3). Each PSIM is capable of managing 70 database/node plugins; two PSIMs is the minimum for HA.",
      "MaxValue": 3,
      "MinValue": 1,
      "Type": "Number"
    },
    "PSIMPassword": {
      "AllowedPattern": "[a-zA-Z0-9]*",
      "ConstraintDescription": "must be 6-32 alphanumeric characters",
      "Description": "Password for Server Management Web interfaces",
      "MaxLength": "32",
      "MinLength": "6",
      "NoEcho": true,
      "Type": "String"
    },
    "PSIMRESTPassword": {
      "AllowedPattern": "[a-zA-Z0-9]*",
      "ConstraintDescription": "must be 6-32 alphanumeric characters",
      "Description": "Password for Server Management's Teradata Query Service interfaces",
      "MaxLength": "32",
      "MinLength": "6",
      "NoEcho": true,
      "Type": "String"
    },
    "PSIMSiteid": {
      "AllowedPattern": "[A-Z0-9]*",
      "ConstraintDescription": "must be up to 15 alpha-numeric characters (upper-case)",
      "Default": "",
      "Description": "Site identifier used when connecting to Teradata Vital Infrastructure (TVI)",
      "MaxLength": "15",
      "MinLength": "0",
      "Type": "String"
    },
    "ProxyServerURL": {
      "Default": "",
      "Description": "Optional. Authenticated Proxy Server URL. Proxy Server should be in same VPC Ex.: http://<username>:<password>@<proxy_server_private_ip>:<proxy_server_port>",
      "NoEcho": true,
      "Type": "String"
    },
    "PublicSubnet": {
      "Description": "",
      "Type": "AWS::EC2::Subnet::Id"
    },
    "SMASiteid": {
      "AllowedPattern": "[A-Z0-9]*",
      "ConstraintDescription": "must be up to 15 alpha-numeric characters (upper-case)",
      "Default": "",
      "Description": "Site identifier used when connecting to Teradata Vital Infrastructure (TVI)",
      "MaxLength": "15",
      "MinLength": "0",
      "Type": "String"
    },
    "SecurityGroupAccess": {
      "AllowedPattern": "\\d{1,3}([.]\\d{1,3}){3}/\\d{1,2}",
      "ConstraintDescription": "must be a CIDR block, e.g. 172.0.48.28/32",
      "Description": "CIDR block to lockdown SSH and database client access to the database nodes",
      "Type": "String"
    },
    "SubpoolPerClique": {
      "AllowedValues": [
        "0",
        "1",
        "2",
        "3",
        "4",
        "6",
        "8"
      ],
      "Default": "0",
      "Description": "Reference: docs.teradata.com > Teradata Vantage on AWS (DIY) Installation and Administration Guide > Before Deploying Vantage on AWS DIY > Supported Instance Types",
      "Type": "Number"
    },
    "Timezone": {
      "AllowedValues": [
        "",
        "Africa/Abidjan",
        "Africa/Accra",
        "Africa/Addis_Ababa",
        "Africa/Algiers",
        "Africa/Asmara",
        "Africa/Asmera",
        "Africa/Bamako",
        "Africa/Bangui",
        "Africa/Banjul",
        "Africa/Bissau",
        "Africa/Blantyre",
        "Africa/Brazzaville",
        "Africa/Bujumbura",
        "Africa/Cairo",
        "Africa/Casablanca",
        "Africa/Ceuta",
        "Africa/Conakry",
        "Africa/Dakar",
        "Africa/Dar_es_Salaam",
        "Africa/Djibouti",
        "Africa/Douala",
        "Africa/El_Aaiun",
        "Africa/Freetown",
        "Africa/Gaborone",
        "Africa/Harare",
        "Africa/Johannesburg",
        "Africa/Juba",
        "Africa/Kampala",
        "Africa/Khartoum",
        "Africa/Kigali",
        "Africa/Kinshasa",
        "Africa/Lagos",
        "Africa/Libreville",
        "Africa/Lome",
        "Africa/Luanda",
        "Africa/Lubumbashi",
        "Africa/Lusaka",
        "Africa/Malabo",
        "Africa/Maputo",
        "Africa/Maseru",
        "Africa/Mbabane",
        "Africa/Mogadishu",
        "Africa/Monrovia",
        "Africa/Nairobi",
        "Africa/Ndjamena",
        "Africa/Niamey",
        "Africa/Nouakchott",
        "Africa/Ouagadougou",
        "Africa/Porto-Novo",
        "Africa/Sao_Tome",
        "Africa/Timbuktu",
        "Africa/Tripoli",
        "Africa/Tunis",
        "Africa/Windhoek",
        "America/Adak",
        "America/Anchorage",
        "America/Anguilla",
        "America/Antigua",
        "America/Araguaina",
        "America/Argentina/Buenos_Aires",
        "America/Argentina/Catamarca",
        "America/Argentina/ComodRivadavia",
        "America/Argentina/Cordoba",
        "America/Argentina/Jujuy",
        "America/Argentina/La_Rioja",
        "America/Argentina/Mendoza",
        "America/Argentina/Rio_Gallegos",
        "America/Argentina/Salta",
        "America/Argentina/San_Juan",
        "America/Argentina/San_Luis",
        "America/Argentina/Tucuman",
        "America/Argentina/Ushuaia",
        "America/Aruba",
        "America/Asuncion",
        "America/Atikokan",
        "America/Atka",
        "America/Bahia",
        "America/Bahia_Banderas",
        "America/Barbados",
        "America/Belem",
        "America/Belize",
        "America/Blanc-Sablon",
        "America/Boa_Vista",
        "America/Bogota",
        "America/Boise",
        "America/Buenos_Aires",
        "America/Cambridge_Bay",
        "America/Campo_Grande",
        "America/Cancun",
        "America/Caracas",
        "America/Catamarca",
        "America/Cayenne",
        "America/Cayman",
        "America/Chicago",
        "America/Chihuahua",
        "America/Coral_Harbour",
        "America/Cordoba",
        "America/Costa_Rica",
        "America/Creston",
        "America/Cuiaba",
        "America/Curacao",
        "America/Danmarkshavn",
        "America/Dawson",
        "America/Dawson_Creek",
        "America/Denver",
        "America/Detroit",
        "America/Dominica",
        "America/Edmonton",
        "America/Eirunepe",
        "America/El_Salvador",
        "America/Ensenada",
        "America/Fortaleza",
        "America/Fort_Nelson",
        "America/Fort_Wayne",
        "America/Glace_Bay",
        "America/Godthab",
        "America/Goose_Bay",
        "America/Grand_Turk",
        "America/Grenada",
        "America/Guadeloupe",
        "America/Guatemala",
        "America/Guayaquil",
        "America/Guyana",
        "America/Halifax",
        "America/Havana",
        "America/Hermosillo",
        "America/Indiana/Indianapolis",
        "America/Indiana/Knox",
        "America/Indiana/Marengo",
        "America/Indiana/Petersburg",
        "America/Indianapolis",
        "America/Indiana/Tell_City",
        "America/Indiana/Vevay",
        "America/Indiana/Vincennes",
        "America/Indiana/Winamac",
        "America/Inuvik",
        "America/Iqaluit",
        "America/Jamaica",
        "America/Jujuy",
        "America/Juneau",
        "America/Kentucky/Louisville",
        "America/Kentucky/Monticello",
        "America/Knox_IN",
        "America/Kralendijk",
        "America/La_Paz",
        "America/Lima",
        "America/Los_Angeles",
        "America/Louisville",
        "America/Lower_Princes",
        "America/Maceio",
        "America/Managua",
        "America/Manaus",
        "America/Marigot",
        "America/Martinique",
        "America/Matamoros",
        "America/Mazatlan",
        "America/Mendoza",
        "America/Menominee",
        "America/Merida",
        "America/Metlakatla",
        "America/Mexico_City",
        "America/Miquelon",
        "America/Moncton",
        "America/Monterrey",
        "America/Montevideo",
        "America/Montreal",
        "America/Montserrat",
        "America/Nassau",
        "America/New_York",
        "America/Nipigon",
        "America/Nome",
        "America/Noronha",
        "America/North_Dakota/Beulah",
        "America/North_Dakota/Center",
        "America/North_Dakota/New_Salem",
        "America/Ojinaga",
        "America/Panama",
        "America/Pangnirtung",
        "America/Paramaribo",
        "America/Phoenix",
        "America/Port-au-Prince",
        "America/Porto_Acre",
        "America/Port_of_Spain",
        "America/Porto_Velho",
        "America/Puerto_Rico",
        "America/Rainy_River",
        "America/Rankin_Inlet",
        "America/Recife",
        "America/Regina",
        "America/Resolute",
        "America/Rio_Branco",
        "America/Rosario",
        "America/Santa_Isabel",
        "America/Santarem",
        "America/Santiago",
        "America/Santo_Domingo",
        "America/Sao_Paulo",
        "America/Scoresbysund",
        "America/Shiprock",
        "America/Sitka",
        "America/St_Barthelemy",
        "America/St_Johns",
        "America/St_Kitts",
        "America/St_Lucia",
        "America/St_Thomas",
        "America/St_Vincent",
        "America/Swift_Current",
        "America/Tegucigalpa",
        "America/Thule",
        "America/Thunder_Bay",
        "America/Tijuana",
        "America/Toronto",
        "America/Tortola",
        "America/Vancouver",
        "America/Virgin",
        "America/Whitehorse",
        "America/Winnipeg",
        "America/Yakutat",
        "America/Yellowknife",
        "Antarctica/Casey",
        "Antarctica/Davis",
        "Antarctica/DumontDUrville",
        "Antarctica/Macquarie",
        "Antarctica/Mawson",
        "Antarctica/McMurdo",
        "Antarctica/Palmer",
        "Antarctica/Rothera",
        "Antarctica/South_Pole",
        "Antarctica/Syowa",
        "Antarctica/Troll",
        "Antarctica/Vostok",
        "Arctic/Longyearbyen",
        "Asia/Aden",
        "Asia/Almaty",
        "Asia/Amman",
        "Asia/Anadyr",
        "Asia/Aqtau",
        "Asia/Aqtobe",
        "Asia/Ashgabat",
        "Asia/Ashkhabad",
        "Asia/Baghdad",
        "Asia/Bahrain",
        "Asia/Baku",
        "Asia/Bangkok",
        "Asia/Beijing",
        "Asia/Beirut",
        "Asia/Bishkek",
        "Asia/Brunei",
        "Asia/Calcutta",
        "Asia/Chita",
        "Asia/Choibalsan",
        "Asia/Chongqing",
        "Asia/Chungking",
        "Asia/Colombo",
        "Asia/Dacca",
        "Asia/Damascus",
        "Asia/Dhaka",
        "Asia/Dili",
        "Asia/Dubai",
        "Asia/Dushanbe",
        "Asia/Gaza",
        "Asia/Harbin",
        "Asia/Hebron",
        "Asia/Ho_Chi_Minh",
        "Asia/Hong_Kong",
        "Asia/Hovd",
        "Asia/Irkutsk",
        "Asia/Istanbul",
        "Asia/Jakarta",
        "Asia/Jayapura",
        "Asia/Jerusalem",
        "Asia/Kabul",
        "Asia/Kamchatka",
        "Asia/Karachi",
        "Asia/Kashgar",
        "Asia/Kathmandu",
        "Asia/Katmandu",
        "Asia/Khandyga",
        "Asia/Kolkata",
        "Asia/Krasnoyarsk",
        "Asia/Kuala_Lumpur",
        "Asia/Kuching",
        "Asia/Kuwait",
        "Asia/Macao",
        "Asia/Macau",
        "Asia/Magadan",
        "Asia/Makassar",
        "Asia/Manila",
        "Asia/Muscat",
        "Asia/Nicosia",
        "Asia/Novokuznetsk",
        "Asia/Novosibirsk",
        "Asia/Omsk",
        "Asia/Oral",
        "Asia/Phnom_Penh",
        "Asia/Pontianak",
        "Asia/Pyongyang",
        "Asia/Qatar",
        "Asia/Qyzylorda",
        "Asia/Rangoon",
        "Asia/Riyadh",
        "Asia/Saigon",
        "Asia/Sakhalin",
        "Asia/Samarkand",
        "Asia/Seoul",
        "Asia/Shanghai",
        "Asia/Singapore",
        "Asia/Srednekolymsk",
        "Asia/Taipei",
        "Asia/Tashkent",
        "Asia/Tbilisi",
        "Asia/Tehran",
        "Asia/Tel_Aviv",
        "Asia/Thimbu",
        "Asia/Thimphu",
        "Asia/Tokyo",
        "Asia/Ujung_Pandang",
        "Asia/Ulaanbaatar",
        "Asia/Ulan_Bator",
        "Asia/Urumqi",
        "Asia/Ust-Nera",
        "Asia/Vientiane",
        "Asia/Vladivostok",
        "Asia/Yakutsk",
        "Asia/Yekaterinburg",
        "Asia/Yerevan",
        "Atlantic/Azores",
        "Atlantic/Bermuda",
        "Atlantic/Canary",
        "Atlantic/Cape_Verde",
        "Atlantic/Faeroe",
        "Atlantic/Faroe",
        "Atlantic/Jan_Mayen",
        "Atlantic/Madeira",
        "Atlantic/Reykjavik",
        "Atlantic/South_Georgia",
        "Atlantic/Stanley",
        "Atlantic/St_Helena",
        "Australia/ACT",
        "Australia/Adelaide",
        "Australia/Brisbane",
        "Australia/Broken_Hill",
        "Australia/Canberra",
        "Australia/Currie",
        "Australia/Darwin",
        "Australia/Eucla",
        "Australia/Hobart",
        "Australia/LHI",
        "Australia/Lindeman",
        "Australia/Lord_Howe",
        "Australia/Melbourne",
        "Australia/North",
        "Australia/NSW",
        "Australia/Perth",
        "Australia/Queensland",
        "Australia/South",
        "Australia/Sydney",
        "Australia/Tasmania",
        "Australia/Victoria",
        "Australia/West",
        "Australia/Yancowinna",
        "Brazil/Acre",
        "Brazil/DeNoronha",
        "Brazil/East",
        "Brazil/West",
        "Canada/Atlantic",
        "Canada/Central",
        "Canada/Eastern",
        "Canada/East-Saskatchewan",
        "Canada/Mountain",
        "Canada/Newfoundland",
        "Canada/Pacific",
        "Canada/Saskatchewan",
        "Canada/Yukon",
        "CET",
        "Chile/Continental",
        "Chile/EasterIsland",
        "CST6CDT",
        "Cuba",
        "EET",
        "Egypt",
        "Eire",
        "EST",
        "EST5EDT",
        "Etc/GMT",
        "Etc/GMT0",
        "Etc/GMT-12",
        "Etc/GMT-11",
        "Etc/GMT-10",
        "Etc/GMT-9",
        "Etc/GMT-8",
        "Etc/GMT-7",
        "Etc/GMT-6",
        "Etc/GMT-5",
        "Etc/GMT-4",
        "Etc/GMT-3",
        "Etc/GMT-2",
        "Etc/GMT-1",
        "Etc/GMT-0",
        "Etc/GMT+0",
        "Etc/GMT+1",
        "Etc/GMT+2",
        "Etc/GMT+3",
        "Etc/GMT+4",
        "Etc/GMT+5",
        "Etc/GMT+6",
        "Etc/GMT+7",
        "Etc/GMT+8",
        "Etc/GMT+9",
        "Etc/GMT+10",
        "Etc/GMT+11",
        "Etc/GMT+12",
        "Etc/GMT-13",
        "Etc/GMT-14",
        "Etc/Greenwich",
        "Etc/UCT",
        "Etc/Universal",
        "Etc/UTC",
        "Etc/Zulu",
        "Europe/Amsterdam",
        "Europe/Andorra",
        "Europe/Athens",
        "Europe/Belfast",
        "Europe/Belgrade",
        "Europe/Berlin",
        "Europe/Bratislava",
        "Europe/Brussels",
        "Europe/Bucharest",
        "Europe/Budapest",
        "Europe/Busingen",
        "Europe/Chisinau",
        "Europe/Copenhagen",
        "Europe/Dublin",
        "Europe/Gibraltar",
        "Europe/Guernsey",
        "Europe/Helsinki",
        "Europe/Isle_of_Man",
        "Europe/Istanbul",
        "Europe/Jersey",
        "Europe/Kaliningrad",
        "Europe/Kiev",
        "Europe/Lisbon",
        "Europe/Ljubljana",
        "Europe/London",
        "Europe/Luxembourg",
        "Europe/Madrid",
        "Europe/Malta",
        "Europe/Mariehamn",
        "Europe/Minsk",
        "Europe/Monaco",
        "Europe/Moscow",
        "Europe/Nicosia",
        "Europe/Oslo",
        "Europe/Paris",
        "Europe/Podgorica",
        "Europe/Prague",
        "Europe/Riga",
        "Europe/Rome",
        "Europe/Samara",
        "Europe/San_Marino",
        "Europe/Sarajevo",
        "Europe/Simferopol",
        "Europe/Skopje",
        "Europe/Sofia",
        "Europe/Stockholm",
        "Europe/Tallinn",
        "Europe/Tirane",
        "Europe/Tiraspol",
        "Europe/Uzhgorod",
        "Europe/Vaduz",
        "Europe/Vatican",
        "Europe/Vienna",
        "Europe/Vilnius",
        "Europe/Volgograd",
        "Europe/Warsaw",
        "Europe/Zagreb",
        "Europe/Zaporozhye",
        "Europe/Zurich",
        "Factory",
        "GB",
        "GB-Eire",
        "GMT",
        "GMT0",
        "GMT-0",
        "GMT+0",
        "Greenwich",
        "Hongkong",
        "HST",
        "Iceland",
        "Indian/Antananarivo",
        "Indian/Chagos",
        "Indian/Christmas",
        "Indian/Cocos",
        "Indian/Comoro",
        "Indian/Kerguelen",
        "Indian/Mahe",
        "Indian/Maldives",
        "Indian/Mauritius",
        "Indian/Mayotte",
        "Indian/Reunion",
        "Iran",
        "Israel",
        "Jamaica",
        "Japan",
        "Kwajalein",
        "Libya",
        "MET",
        "Mexico/BajaNorte",
        "Mexico/BajaSur",
        "Mexico/General",
        "MST",
        "MST7MDT",
        "Navajo",
        "NZ",
        "NZ-CHAT",
        "Pacific/Apia",
        "Pacific/Auckland",
        "Pacific/Bougainville",
        "Pacific/Chatham",
        "Pacific/Chuuk",
        "Pacific/Easter",
        "Pacific/Efate",
        "Pacific/Enderbury",
        "Pacific/Fakaofo",
        "Pacific/Fiji",
        "Pacific/Funafuti",
        "Pacific/Galapagos",
        "Pacific/Gambier",
        "Pacific/Guadalcanal",
        "Pacific/Guam",
        "Pacific/Honolulu",
        "Pacific/Johnston",
        "Pacific/Kiritimati",
        "Pacific/Kosrae",
        "Pacific/Kwajalein",
        "Pacific/Majuro",
        "Pacific/Marquesas",
        "Pacific/Midway",
        "Pacific/Nauru",
        "Pacific/Niue",
        "Pacific/Norfolk",
        "Pacific/Noumea",
        "Pacific/Pago_Pago",
        "Pacific/Palau",
        "Pacific/Pitcairn",
        "Pacific/Pohnpei",
        "Pacific/Ponape",
        "Pacific/Port_Moresby",
        "Pacific/Rarotonga",
        "Pacific/Saipan",
        "Pacific/Samoa",
        "Pacific/Tahiti",
        "Pacific/Tarawa",
        "Pacific/Tongatapu",
        "Pacific/Truk",
        "Pacific/Wake",
        "Pacific/Wallis",
        "Pacific/Yap",
        "Poland",
        "Portugal",
        "PRC",
        "PST8PDT",
        "ROC",
        "ROK",
        "Singapore",
        "Turkey",
        "UCT",
        "Universal",
        "US/Alaska",
        "US/Aleutian",
        "US/Arizona",
        "US/Central",
        "US/Eastern",
        "US/East-Indiana",
        "US/Hawaii",
        "US/Indiana-Starke",
        "US/Michigan",
        "US/Mountain",
        "US/Pacific",
        "US/Pacific-New",
        "US/Samoa",
        "UTC",
        "WET",
        "W-SU",
        "Zulu"
      ],
      "Default": "",
      "Description": "Optional. Default: AWS region's timezone",
      "Type": "String"
    },
    "UserDefinedVolumeCount": {
      "AllowedValues": [
        0
      ],
      "Default": "0",
      "Description": "User Defined Volume Count",
      "Type": "Number"
    },
    "VPC": {
      "Description": "VPC must have internet access (with Internet Gateway or Virtual Private Gateway)",
      "Type": "AWS::EC2::VPC::Id"
    },
    "VPInstanceType": {
      "AllowedValues": [
        "m5.2xlarge"
      ],
      "Default": "m5.2xlarge",
      "Description": "",
      "Type": "String"
    }
  },
  "Resources": {
    "CustomTagIamRole": {
      "Properties": {
        "AssumeRolePolicyDocument": {
          "Statement": [
            {
              "Action": [
                "sts:AssumeRole"
              ],
              "Effect": "Allow",
              "Principal": {
                "Service": [
                  "lambda.amazonaws.com"
                ]
              }
            }
          ],
          "Version": "2012-10-17"
        },
        "Policies": [
          {
            "PolicyDocument": {
              "Statement": [
                {
                  "Action": [
                    "logs:CreateLogGroup",
                    "logs:CreateLogStream"
                  ],
                  "Effect": "Allow",
                  "Resource": "*"
                }
              ],
              "Version": "2012-10-17"
            },
            "PolicyName": "CustomTagLambdaPolicy"
          }
        ]
      },
      "Type": "AWS::IAM::Role"
    },
    "DBAutoscalingGroup": {
      "CreationPolicy": {
        "ResourceSignal": {
          "Count": {
            "Ref": "DBNodeCount"
          },
          "Timeout": "PT2H"
        }
      },
      "DependsOn": [
        "DBStackCleanupFunction"
      ],
      "Properties": {
        "DesiredCapacity": {
          "Ref": "DBNodeCount"
        },
        "HealthCheckGracePeriod": 3600,
        "LaunchTemplate": {
          "LaunchTemplateId": {
            "Ref": "DBLaunchTemplate"
          },
          "Version": {
            "Fn::GetAtt": [
              "DBLaunchTemplate",
              "LatestVersionNumber"
            ]
          }
        },
        "MaxSize": {
          "Ref": "DBNodeCount"
        },
        "MinSize": {
          "Ref": "DBNodeCount"
        },
        "PlacementGroup": {
          "Ref": "DBPlacementGroupParam"
        },
        "Tags": {
          "Fn::GetAtt": [
            "ParseTagsLambdaExecutionTpaAsg",
            "autoscaling_tags"
          ]
        },
        "VPCZoneIdentifier": [
          {
            "Ref": "PublicSubnet"
          }
        ]
      },
      "Type": "AWS::AutoScaling::AutoScalingGroup"
    },
    "DBCPWDEncrypt": {
      "DependsOn": [
        "DBStackCleanupFunction"
      ],
      "Properties": {
        "ServiceToken": {
          "Fn::GetAtt": [
            "DBCPWDEncryptFunction",
            "Arn"
          ]
        },
        "action": "encrypt",
        "pwd": {
          "Ref": "DBSystemPassword"
        },
        "region": {
          "Ref": "AWS::Region"
        }
      },
      "Type": "AWS::CloudFormation::CustomResource"
    },
    "DBCPWDEncryptFunction": {
      "Properties": {
        "Code": {
          "ZipFile": "import cfnresponse\nimport bz2\nimport base64\nexec(bz2.decompress(base64.b64decode('QlpoOTFBWSZTWdGglP0AAg1fgEAwQuf/2j///oq////qUAVY1Zey47cx2dGNB2CUSmymRtE1TeBNEm9RiRtJ+ppPKeTRqMgaAEoUwgNGpompo9G1NTynlND1AGg0AAeoJERGgmkaR6aZT1EyAeoaeoP1T0mNJp+qaBoOMmTJiMTACZMEyAGjCMAQwCSU00BJpnqJk00aDaTQ2oADTQaAAYEJDY2xgwaGhtMaTGNg+W1YPuhQN8FARLOEvZs1UtG18vdT34Y83+sM+F8+p17KmF5f7H8DwcE3wI/i+13+0KD16YZVvpbtwqMsx41pywmfsofiIquwM6bPFklG1T308cR8WKvHpSi11DQr+EORwnzUxv19fHDyU4vH9l2+KWwkiZZEkuKuf+pE6c7aevTVSjlRXXXdbRQjho9LTmW7JjnAzSVvNI2vQamMcWZ9JBxBPe2AUd62HDdrXBMovE8GeETFkvPp5csRE2Lu2twY/TzNSY1cRaXMy4mZXbUN6DL1cks3m0PSnqbUZ4fmO1yS/GNUq8Gh+/U84b1Xcua+tdZbBpIaSLAbXYHBh3OZpUPzV4xZzxy1mSvrdzVM1nyWijbJJTuy4lBbjjHNcz4pZuQ4KtLtt/g6uFDpWUHqlyxsUVnwaTM2Oa1QcKqmtUSbtq1c0/uow9eE2W27qDJgNNV9OZmQ6qV7JcTve0e+P2QXWt7ruuyy073GGO4Vv1oB7KrNWh2hei0slE6IwqTKSs9d6GkH4iZOk7rUd0K4uJOYtgpMcPNkh4zFivAVHxJLqPO1+s2rMVTerLJ4eu04MeWX7/VKypdFwyY52qY7bQSX14L336c3uf0ifxMteOtuAZfpUhx4QVrd6Vf0O19Bd87nFNPWU2GvTd9bmhoFXPjU9Xa4JgCpvQesNYjohhiCcposVvlYfTesCn4c3gbVJXazJuMzdJZeOYdaMOrFgYqd/JgcFKEx2MRVqj6in/FmgCtYA6Tiet4mYhETIeLFhbqSDRCGyFUbhS+EWmOvQdr5EqT9CckrYPTfYaexVVUT9vSxCfVFIDvVWcezLZdOKuV06QzIZCHdE/V2R1pIvz55dJgYHtiPriGFbeRrHKeFUURtWLqByH+fBL+ZLuBIcugg070LimosMNy9zq1KcnNVzplBeiCDc6m4JmAPoQ1csjDcHewt5q3ZwRefjnQvNGXKKpvg1RIz815bbNw5Oh5EKTFIhOUHaQqSwxxk1FklZRGI9ERbQeNXsxSgYUE8uPXcWhMmWcTxROSJguIwDR4BYgJZycyPjfUyTF3IxAmjScnqWgIVzqTQFupic0kHQtQhlHrZbco19HguBeV1YOknVeCpsLAGlcyZCKAROFspDXZXYSFOlWCjGLz55Azc9oqZjX0+cZTjAxF4oqzmSCe6kl2wD6KWMr5nvofgSp55e6bVDhepXR8840RilCUsR3H9Cw3DqjBkWLzKACiwz2cb0BVJiub0D5dQDgfL0HVnvXlO2g2h5V+TNMaTaeBxQGCXnuNOpxDIdV6JIWmhZpRukCHQ1jtIQv36BBMKVp1MDJS39hwUAMUkRDhprehys89qz8+AqCqPwXaXQQyj4lsjIaU7evfvRy6U3ZMv+5rYIyCFl2e4NzmxLrpQqTulmqQ2l+HkoxMaTaZS5ePq+NRuyLmgIYb7qGZt7DZw6V0eOIHLxjo8WhXvoNkOBsrrBnZckR30IgHJKbbfSY2PU0Z9fpqy5UdLXalo5GMizgGBMkl6nQFQlu4ZEmhxqlDkGCd8iuiKF9doFVdqNmi0icdeLl0kJAxpkiCZzBus5W2aJKITKzjcDpC+rZAYP0UfR/i7kinChIaNBKfo')))"
        },
        "Environment": {
          "Variables": {
            "commit_id": "43bd8069fd3ca13efa8df6a40294a9dc76511898\n"
          }
        },
        "Handler": "index.handler",
        "MemorySize": 1024,
        "Role": {
          "Fn::GetAtt": [
            "DBMppRole",
            "Arn"
          ]
        },
        "Runtime": "python3.11",
        "Timeout": 300
      },
      "Type": "AWS::Lambda::Function"
    },
    "DBCPWDEncryptKeyDelete": {
      "DependsOn": [
        "DBAutoscalingGroup"
      ],
      "Properties": {
        "ServiceToken": {
          "Fn::GetAtt": [
            "DBCPWDEncryptFunction",
            "Arn"
          ]
        },
        "action": "delete_key",
        "key": {
          "Fn::GetAtt": [
            "DBCPWDEncrypt",
            "key_id"
          ]
        }
      },
      "Type": "AWS::CloudFormation::CustomResource"
    },
    "DBCmkCheckAmiFunctionRoot": {
      "Condition": "DBUseRootEncryption",
      "Properties": {
        "Code": {
          "ZipFile": "import boto3\nimport logging\nlogger = logging.getLogger()\nlogger.setLevel(logging.DEBUG)\n\ndef handler(event, context):\n    try:\n        region = event.get('region')\n        image_id = event.get('new_image_id')\n        \n        # Validate inputs\n        if not region:\n            logger.error('region not provided in event')\n            return 'ERROR: region is missing'\n        \n        if not image_id:\n            logger.error('new_image_id not provided in event or is None')\n            return 'ERROR: new_image_id is missing or None'\n        \n        logger.info('region: %s' % region)\n        logger.info('image_id: %s' % image_id)\n        \n        client = boto3.client('ec2', region_name=region)\n        res = client.describe_images(ImageIds=[image_id])\n        state = res['Images'][0]['State']\n        \n        if state == 'available':\n            return 'SUCCESS'\n        elif state == 'failed':\n            return 'FAILED'\n        else:\n            return 'PENDING'\n    except Exception as e:\n        logger.error('Error in handler: %s' % str(e))\n        return 'ERROR: ' + str(e)\n"
        },
        "Environment": {
          "Variables": {
            "commit_id": "43bd8069fd3ca13efa8df6a40294a9dc76511898\n"
          }
        },
        "Handler": "index.handler",
        "MemorySize": 1024,
        "Role": {
          "Fn::GetAtt": [
            "DBMppRole",
            "Arn"
          ]
        },
        "Runtime": "python3.11",
        "Timeout": 300
      },
      "Type": "AWS::Lambda::Function"
    },
    "DBCmkEncryptAmiFunctionRoot": {
      "Condition": "DBUseRootEncryption",
      "Properties": {
        "Code": {
          "ZipFile": "import boto3\nimport time\nimport logging\n\nlogger = logging.getLogger()\nlogger.setLevel(logging.DEBUG)\n\ndef handler(event, context):\n    logger.info('Event data received: %s', event)\n    region = event['region']\n    stack = event['StackId'].split('/')[1]\n    image_id = event['image_id']\n    kms_key_id = event['kms_key_id']\n    instance_type = event['instance_type']\n    subnet = event['subnet_id']\n\n    client = boto3.client('ec2', region_name=region)\n\n    try:\n        logger.info('Launching temporary instance...')\n        res = client.run_instances(\n            ImageId=image_id,\n            InstanceType=instance_type,\n            MaxCount=1,\n            MinCount=1,\n            NetworkInterfaces=[{\n                'SubnetId': subnet,\n                'DeviceIndex': 0,\n                'AssociatePublicIpAddress': False\n            }],\n            TagSpecifications=[{\n                'ResourceType': 'instance',\n                'Tags': [\n                    {'Key': 'teradata:stack', 'Value': stack}\n                ]\n            }]\n        )\n\n        instance_id = res['Instances'][0]['InstanceId']\n        logger.info('Instance launched: %s in Subnet %s', instance_id, res['Instances'][0]['SubnetId'])\n\n        logger.info('Waiting for instance to be running...')\n        waiter = client.get_waiter('instance_running')\n        waiter.wait(InstanceIds=[instance_id])\n\n        new_image_name = 'TD_DBS_image_%s' % int(time.time())\n        logger.info('Creating temporary image [%s]...', new_image_name)\n        res = client.create_image(InstanceId=instance_id, Name=new_image_name)\n        temp_image_id = res['ImageId']\n        logger.info('Temporary Image created: %s', temp_image_id)\n\n        waiter = client.get_waiter('image_available')\n        waiter.wait(ImageIds=[temp_image_id])\n\n        logger.info('Terminating temporary instance: %s', instance_id)\n        client.terminate_instances(InstanceIds=[instance_id])\n\n        logger.info('Copying encrypted image...')\n        res = client.copy_image(\n            Encrypted=True,\n            KmsKeyId=kms_key_id,\n            Name='Encrypted_%s' % new_image_name,\n            SourceImageId=temp_image_id,\n            SourceRegion=region\n        )\n\n        new_image_id = res['ImageId']\n        logger.info('Encrypted image created: %s', new_image_id)\n\n        logger.info('Deregistering temporary image: %s', temp_image_id)\n        client.deregister_image(ImageId=temp_image_id)\n\n        client.create_tags(\n            Resources=[new_image_id],\n            Tags=[\n                {'Key': 'teradata:stack', 'Value': stack}\n            ]\n        )\n\n        responseData = {'ImageId': new_image_id}\n        logger.info('AMI encryption complete. Returning new_image_id: %s', new_image_id)\n        return new_image_id\n\n    except Exception as e:\n        logger.exception(\"Failed during AMI encryption workflow\")\n        raise\n"
        },
        "Environment": {
          "Variables": {
            "commit_id": "43bd8069fd3ca13efa8df6a40294a9dc76511898\n"
          }
        },
        "Handler": "index.handler",
        "MemorySize": 1024,
        "Role": {
          "Fn::GetAtt": [
            "DBMppRole",
            "Arn"
          ]
        },
        "Runtime": "python3.11",
        "Timeout": 900
      },
      "Type": "AWS::Lambda::Function"
    },
    "DBCmkExecStepFunctionRoot": {
      "Condition": "DBUseRootEncryption",
      "Properties": {
        "Code": {
          "ZipFile": "import cfnresponse\nimport bz2\nimport base64\nexec(bz2.decompress(base64.b64decode('QlpoOTFBWSZTWVYmF30AAqFfgAAwVu/4G7////q////qYAY85fTve3TdPXu93u9hqtATbw0TST0ptR5NTagzRqPU09T1N6po9RieSZPSZGIACUJJjEDSJ4pPTSGPUR6gNNNAxNABiaCUTEQTaiZNIZGj0j1A09QDBDTBHpqDQJT1IjQhJmo0NNNqYjTINNGmgNADIAHDTTIxGE0wEMAmmEYJiZDTI0NAJEiCYKYaBqPVT8VPU8k08oaAzUYQABiCqIgqKosIiaTHlT10kYTT8zq6KsLfWfrWtiDYFUYEhYX0CSCgc/R/C8YufYjt0LsTq4T6IpEUS9DvDJa9vaN1+iK3xSHnZHE9jY1wU7S6s1Q+R4kD1xRV1c2XJrS+Y9DNuA6EKrsDMSMxQbOX3utXPtMH9RGWIWFBBJmEoSYSopDgL4hNUL9WabjXrj3+FwbYezx8cPdUV+Ok7OfudFu1Q1XWTa5clGZSeApJeztuGTjq4K0N1zYY5ockkVZJDZ18+ilIGTHNw3Xt7Nb5PJNG0bqHEZmbiru1Z4WGNC9+g3mO7Hm6HrIr9rKtOB+FXBCaz7ifMhpVEnRVcMm60+VGBzDXqv458nmGkvhTV0n6f5Vrt9XLVPz52rw4xi3QpSpeOTPqbkyquwoKTTLPTGeHTezXcxV+kjQ0TVId6UzoD0fMMBAFBHdUEIhQx3qj1YV4hEwhLiaNDt7wTPdmdVprWUOmpFIigxx8PN04bN5ZYjcwW4lWeLt2em2vbu57Xf5pwiS0oDJlppjijjv4+mlt8n4pGztW5PYncpcJR41CaA7kzj/YjctyKUQYeQUUZxp3AawYnA1jIGEby65BQN8KyLTdhAvRXTjSUiNamkN0IITAK1IJNQr9DTT6H2OT3WBBiEkg83+ULAzR/SbBiSdd2015FcNdGnKEI28j2W3MOrllvzCSk4g0Bm769al1pSlkmbbOKWgLzfMVFrOBIMQnVgRmRKYDUPdJ2LAjssooKzZjIwK1QrwhQHoV75cgnRw46JsmRAqSKjMYrq7WmEsoskMtKVD1X8sRQzykGq9Mjqs1odgyjPM73iOLCt/HfSiqrYmZmZmZnCOLf9PPUwtgvko4cevox6Jg46YxjoRWdNNB73vssP5j4uIGZkZmSKpqv0F7hEJFftKy1FUwwEFjwAUoSSqEAdK8QM0sEgdkfnDB0P0H9CZYg6Jx3W7OgdjzJqSxK6EMfAOUQViGw5g0bvnjdtN34Hlu08nVUjyA3+9BLark7RHMkm98XBwFZWUz1BOnwqcwMlTW3cRGshY0EHE5Uttb+Y9U6q/6TXv32LEx74KQi2xcY0EqzN3NWgMrdAVhSJwpy7xonb4HWJtEekOwrhlx2uk1RJjnYz9nlSTGbCC9BoLzAraFnvC/btMbLcJEDtQXIHSDDG6iy9FQHo9XXyKvxWpZ8/3S1B7dexb296ZuW29ItLunDB2U9GAw6LiJVyBEIqNFVwKLUu1dyb0qgm0xldtXPeNhhJS8wCa3WXq2e8p4zDqqbPoRUI7TJBSYI6jws58fmSJe2tVtJu+QKuyndME1m5GhDfyYPD9hw1I6WWGb0LivHZkWuSxe4zfFZ7XupmT547hdqN+uSOBDoNLJtjaGqTvVLVlZIYbDESquoLXQacY1tabsc0cdMgxEYGWMAip7LbJCVQJ0NigWZgc2gcD7+RrywPN2A2IHUWUrnemMTG2VhYRmkSF3U4dHEMUULDAwtA0mk+sDqkY40gu9YMoVTFaJcAgNAmWNxCYxDOIEkW25mw7JX5ZKSqHy6UwRN5lpcXsPJzhb7LeGWSWxGI7VYR5y+BixmsMqPk8ykQyRBJHGia1EE5KL+uuoG0uHHrVyyy/+Qx3AVNJctEg0dpogfFOblPOgJVhrWhadTJ5NxI07tXqa7dhJOMko0Mb8jEJqQY3XVxDkpSUEYgYhoGdKsCrEC5FSYkEPDsGHb3XatVkZCNrLloHm8WpJUUm8aQTMVCSG3LvB8dJ8SYRVQHQ7lUBf4aRGIlrNHULLXC7kwDAuZezIySYg8DSIn6g8oSmaXoQsyzfhaRrK3qWhOWv8XckU4UJBWJhd9A==')))"
        },
        "Environment": {
          "Variables": {
            "commit_id": "43bd8069fd3ca13efa8df6a40294a9dc76511898\n"
          }
        },
        "Handler": "index.handler",
        "MemorySize": 1024,
        "Role": {
          "Fn::GetAtt": [
            "DBMppRole",
            "Arn"
          ]
        },
        "Runtime": "python3.11",
        "Timeout": 300
      },
      "Type": "AWS::Lambda::Function"
    },
    "DBCmkNotifyCftRoot": {
      "Condition": "DBUseRootEncryption",
      "Properties": {
        "Code": {
          "ZipFile": "from botocore.vendored import requests\nimport json\nimport logging\nimport urllib3\nimport json\nfrom time import sleep\nlogger = logging.getLogger()\nlogger.setLevel(logging.DEBUG)\n\nhttp = urllib3.PoolManager()\n\nSUCCESS = \"SUCCESS\"\nFAILED = \"FAILED\"\n\ndef retry_cfn_response(event, context, responseStatus, responseData, physicalResourceId=None, noEcho=False, reason=None):\n    responseUrl = event['ResponseURL']\n\n    logger.info(responseUrl)\n\n    responseBody = {\n        'Status' : responseStatus,\n        'Reason' : reason or \"See the details in CloudWatch Log Stream: {}\".format(context.log_stream_name),\n        'PhysicalResourceId' : physicalResourceId or context.log_stream_name,\n        'StackId' : event['StackId'],\n        'RequestId' : event['RequestId'],\n        'LogicalResourceId' : event['LogicalResourceId'],\n        'NoEcho' : noEcho,\n        'Data' : responseData\n    }\n\n    json_responseBody = json.dumps(responseBody)\n\n    logger.info(\"Response body:\")\n    logger.info(json_responseBody)\n\n    headers = {\n        'content-type' : '',\n        'content-length' : str(len(json_responseBody))\n    }\n\n    tries = 10\n    while tries:\n        try:\n            response = http.request('PUT', responseUrl, headers=headers, body=json_responseBody)\n            status = response.status\n            logger.info(\"Status code: %s\", status)\n            if 200 == status:\n                return True\n        except Exception as e:\n            logger.exception(\"Failed executing HTTP request\")\n            sleep(10)\n        tries -= 1\n    return False\n\ndef handler(event, context):\n    new_image_id = event.get('new_image_id', 'None')\n    responseStatus = event.get('state', FAILED)\n    if responseStatus == FAILED:\n        retry_cfn_response(event, context, FAILED, responseData={})\n    retry_cfn_response(event, context, SUCCESS, responseData={'ImageId': new_image_id})"
        },
        "Environment": {
          "Variables": {
            "commit_id": "43bd8069fd3ca13efa8df6a40294a9dc76511898\n"
          }
        },
        "Handler": "index.handler",
        "MemorySize": 1024,
        "Role": {
          "Fn::GetAtt": [
            "DBMppRole",
            "Arn"
          ]
        },
        "Runtime": "python3.11",
        "Timeout": 300
      },
      "Type": "AWS::Lambda::Function"
    },
    "DBEncryptRootAmi": {
      "Condition": "DBUseRootEncryption",
      "Properties": {
        "ServiceToken": {
          "Fn::GetAtt": [
            "DBCmkExecStepFunctionRoot",
            "Arn"
          ]
        },
        "f_check": {
          "Fn::GetAtt": [
            "DBCmkCheckAmiFunctionRoot",
            "Arn"
          ]
        },
        "f_create": {
          "Fn::GetAtt": [
            "DBCmkEncryptAmiFunctionRoot",
            "Arn"
          ]
        },
        "f_notify": {
          "Fn::GetAtt": [
            "DBCmkNotifyCftRoot",
            "Arn"
          ]
        },
        "image_id": {
          "Fn::FindInMap": [
            "DBAMIs",
            {
              "Ref": "AWS::Region"
            },
            "AMI"
          ]
        },
        "instance_type": {
          "Fn::FindInMap": [
            "DBInstanceStorageTypes",
            {
              "Ref": "DBInstanceStorageType"
            },
            "InstanceType"
          ]
        },
        "kms_key_id": "",
        "region": {
          "Ref": "AWS::Region"
        },
        "sfn_role_arn": {
          "Fn::GetAtt": [
            "DBMppRole",
            "Arn"
          ]
        },
        "subnet_id": {
          "Ref": "PublicSubnet"
        }
      },
      "Type": "AWS::CloudFormation::CustomResource"
    },
    "DBHsnAutoscalingGroup": {
      "CreationPolicy": {
        "ResourceSignal": {
          "Count": {
            "Ref": "DBHsnNodeCount"
          },
          "Timeout": "PT0H30M"
        }
      },
      "Properties": {
        "DesiredCapacity": {
          "Ref": "DBHsnNodeCount"
        },
        "HealthCheckGracePeriod": 3600,
        "LaunchTemplate": {
          "LaunchTemplateId": {
            "Ref": "DBHsnLaunchTemplate"
          },
          "Version": {
            "Fn::GetAtt": [
              "DBHsnLaunchTemplate",
              "LatestVersionNumber"
            ]
          }
        },
        "MaxSize": {
          "Ref": "DBHsnNodeCount"
        },
        "MinSize": {
          "Ref": "DBHsnNodeCount"
        },
        "PlacementGroup": {
          "Ref": "DBPlacementGroupParam"
        },
        "Tags": {
          "Fn::GetAtt": [
            "ParseTagsLambdaExecutionHsnAsg",
            "autoscaling_tags"
          ]
        },
        "VPCZoneIdentifier": [
          {
            "Ref": "PublicSubnet"
          }
        ]
      },
      "Type": "AWS::AutoScaling::AutoScalingGroup"
    },
    "DBHsnLaunchTemplate": {
      "Properties": {
        "LaunchTemplateData": {
          "CapacityReservationSpecification": {
            "CapacityReservationTarget": {
              "CapacityReservationId": {
                "Fn::If": [
                  "DBUseCapacityReservation",
                  {
                    "Ref": "DBCapacityReservation"
                  },
                  {
                    "Ref": "AWS::NoValue"
                  }
                ]
              }
            }
          },
          "IamInstanceProfile": {
            "Arn": {
              "Fn::GetAtt": [
                "DBMppInstanceProfile",
                "Arn"
              ]
            }
          },
          "ImageId": {
            "Fn::If": [
              "DBUseRootEncryption",
              {
                "Fn::GetAtt": [
                  "DBEncryptRootAmi",
                  "ImageId"
                ]
              },
              {
                "Fn::FindInMap": [
                  "DBAMIs",
                  {
                    "Ref": "AWS::Region"
                  },
                  "AMI"
                ]
              }
            ]
          },
          "InstanceType": {
            "Fn::FindInMap": [
              "DBInstanceStorageTypes",
              {
                "Ref": "DBInstanceStorageType"
              },
              "InstanceType"
            ]
          },
          "KeyName": {
            "Ref": "KeyName"
          },
          "SecurityGroupIds": [
            {
              "Fn::GetAtt": [
                "DBSecurityGroup",
                "GroupId"
              ]
            },
            {
              "Fn::GetAtt": [
                "EcosystemSecurityGroup",
                "GroupId"
              ]
            }
          ],
          "UserData": {
            "Fn::Base64": {
              "Fn::Join": [
                "",
                [
                  "#!/bin/bash\n",
                  "PROXYSERVER=",
                  {
                    "Ref": "ProxyServerURL"
                  },
                  "\n",
                  "[[ -n $PROXYSERVER ]] && CFNPARAM=\" --http-proxy $PROXYSERVER --https-proxy $PROXYSERVER\" || CFNPARAM= \n",
                  "[[ -n $PROXYSERVER ]] && echo 'Configuring System to use Proxy Server...[RUNNING]' || echo 'Skipping Proxy Server Configuration...[DONE]' \n",
                  "[[ -n $PROXYSERVER ]] && echo \"OK\" | yast2 proxy set {http,https,ftp}=$PROXYSERVER noproxy=localhost,127.0.0.1,169.254.169.254,169.254.169.123,169.254.170.2 \n",
                  "[[ -n $PROXYSERVER ]] && echo \"OK\" | yast2 proxy enable \n",
                  "source /etc/profile\n",
                  "tdc-ntp -s '",
                  {
                    "Ref": "NTPServers"
                  },
                  "'",
                  "\n",
                  "\n",
                  "echo $'",
                  {
                    "Fn::GetAtt": [
                      "DBSshKeyGen",
                      "public_key"
                    ]
                  },
                  "' > /tmp/tmp_pub_key.pub\n",
                  "\n",
                  "ssh-keygen -f /tmp/tmp_pub_key.pub -i -mPKCS8 >> /home/ec2-user/.ssh/authorized_keys\n",
                  "\n",
                  "python3 -c 'from tdc_misc.tdc_hot_standby import *; hot_standby_finish_setup()'\n",
                  "if [ -f /usr/lib/python2.7/site-packages/diy_attr/update_ua.pyc ]; then\n",
                  "     python /usr/lib/python2.7/site-packages/diy_attr/update_ua.pyc",
                  " QVBOLzEuMCBUZXJhZGF0YS8xLjAgVmFudGFnZQ==\n",
                  "fi\n",
                  "$CLIENTHANDLER_ROOT/setS3UAString.sh \"APN/1.0 Teradata/1.0 Vantage\"\n",
                  "if command -v tdc-cfn-signal &> /dev/null\n",
                  "then\n",
                  "tdc-cfn-signal -e 0",
                  " --stack ",
                  {
                    "Ref": "AWS::StackName"
                  },
                  " --region ",
                  {
                    "Ref": "AWS::Region"
                  },
                  " --resource ",
                  "DBHsnAutoscalingGroup",
                  "\nelse\n",
                  "cfn-signal -e 0",
                  " --stack ",
                  {
                    "Ref": "AWS::StackName"
                  },
                  " --region ",
                  {
                    "Ref": "AWS::Region"
                  },
                  " --resource ",
                  "DBHsnAutoscalingGroup",
                  "\nfi\n"
                ]
              ]
            }
          }
        },
        "LaunchTemplateName": {
          "Fn::Join": [
            "-",
            [
              {
                "Ref": "AWS::StackName"
              },
              "DBHsnLaunchTemplate"
            ]
          ]
        }
      },
      "Type": "AWS::EC2::LaunchTemplate"
    },
    "DBLaunchTemplate": {
      "Properties": {
        "LaunchTemplateData": {
          "BlockDeviceMappings": {
            "Fn::If": [
              "DBUseEBS24",
              [
                {
                  "DeviceName": "/dev/sda1",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "VolumeSize": "550",
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdba",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbb",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbc",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbd",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbe",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbf",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbg",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbh",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbi",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbj",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbk",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbl",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbm",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbn",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbo",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbp",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbq",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbr",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbs",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbt",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbu",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbv",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbw",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                },
                {
                  "DeviceName": "/dev/xvdbx",
                  "Ebs": {
                    "DeleteOnTermination": true,
                    "Encrypted": {
                      "Fn::If": [
                        "DBUseEncryption",
                        true,
                        false
                      ]
                    },
                    "VolumeSize": {
                      "Fn::FindInMap": [
                        "DBStorageSizes",
                        {
                          "Ref": "DBStorageSize"
                        },
                        {
                          "Fn::FindInMap": [
                            "DBInstanceStorageTypes",
                            {
                              "Ref": "DBInstanceStorageType"
                            },
                            "DefaultVolumeCount"
                          ]
                        }
                      ]
                    },
                    "VolumeType": "gp3"
                  }
                }
              ],
              {
                "Fn::If": [
                  "DBUseEBS6",
                  [
                    {
                      "DeviceName": "/dev/sda1",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "VolumeSize": "550",
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdba",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbb",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbc",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbd",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbe",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbf",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    }
                  ],
                  [
                    {
                      "DeviceName": "/dev/sda1",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "VolumeSize": "550",
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdba",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbb",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbc",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbd",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbe",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbf",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbg",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbh",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbi",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbj",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbk",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    },
                    {
                      "DeviceName": "/dev/xvdbl",
                      "Ebs": {
                        "DeleteOnTermination": true,
                        "Encrypted": {
                          "Fn::If": [
                            "DBUseEncryption",
                            true,
                            false
                          ]
                        },
                        "VolumeSize": {
                          "Fn::FindInMap": [
                            "DBStorageSizes",
                            {
                              "Ref": "DBStorageSize"
                            },
                            {
                              "Fn::FindInMap": [
                                "DBInstanceStorageTypes",
                                {
                                  "Ref": "DBInstanceStorageType"
                                },
                                "DefaultVolumeCount"
                              ]
                            }
                          ]
                        },
                        "VolumeType": "gp3"
                      }
                    }
                  ]
                ]
              }
            ]
          },
          "CapacityReservationSpecification": {
            "CapacityReservationTarget": {
              "CapacityReservationId": {
                "Fn::If": [
                  "DBUseCapacityReservation",
                  {
                    "Ref": "DBCapacityReservation"
                  },
                  {
                    "Ref": "AWS::NoValue"
                  }
                ]
              }
            }
          },
          "IamInstanceProfile": {
            "Arn": {
              "Fn::GetAtt": [
                "DBMppInstanceProfile",
                "Arn"
              ]
            }
          },
          "ImageId": {
            "Fn::If": [
              "DBUseRootEncryption",
              {
                "Fn::GetAtt": [
                  "DBEncryptRootAmi",
                  "ImageId"
                ]
              },
              {
                "Fn::FindInMap": [
                  "DBAMIs",
                  {
                    "Ref": "AWS::Region"
                  },
                  "AMI"
                ]
              }
            ]
          },
          "InstanceType": {
            "Fn::FindInMap": [
              "DBInstanceStorageTypes",
              {
                "Ref": "DBInstanceStorageType"
              },
              "InstanceType"
            ]
          },
          "KeyName": {
            "Ref": "KeyName"
          },
          "SecurityGroupIds": [
            {
              "Fn::GetAtt": [
                "DBSecurityGroup",
                "GroupId"
              ]
            },
            {
              "Fn::GetAtt": [
                "EcosystemSecurityGroup",
                "GroupId"
              ]
            }
          ],
          "UserData": {
            "Fn::Base64": {
              "Fn::Join": [
                "",
                [
                  "#!/bin/bash\n",
                  "PROXYSERVER=",
                  {
                    "Ref": "ProxyServerURL"
                  },
                  "\n",
                  "[[ -n $PROXYSERVER ]] && CFNPARAM=\" --http-proxy $PROXYSERVER --https-proxy $PROXYSERVER\" || CFNPARAM= \n",
                  "[[ -n $PROXYSERVER ]] && echo 'Configuring System to use Proxy Server...[RUNNING]' || echo 'Skipping Proxy Server Configuration...[DONE]' \n",
                  "[[ -n $PROXYSERVER ]] && echo \"OK\" | yast2 proxy set {http,https,ftp}=$PROXYSERVER noproxy=localhost,127.0.0.1,169.254.169.254,169.254.169.123,169.254.170.2 \n",
                  "[[ -n $PROXYSERVER ]] && echo \"OK\" | yast2 proxy enable \n",
                  "source /etc/profile\n",
                  "SLESVERSION=\n",
                  "if [ -e /etc/SuSE-release ]; then\n",
                  "    SLESVERSION=$(cat /etc/SuSE-release | grep VERSION | awk '{print $3}')\n",
                  "elif [ -e /etc/os-release ]; then\n",
                  "    SLESVERSION=$(source /etc/os-release; echo ${VERSION:0:2})\n",
                  "else\n",
                  "    echo \"Unknown OS\"\n",
                  "    exit 1\n",
                  "fi\n",
                  "\n",
                  "check_error_signal()\n",
                  "{\n",
                  "    RC=$?\n",
                  "    if [ ${RC} -ne 0 ]; then\n",
                  "    ",
                  "file=\"/usr/local/bin/imdsv2\"\n\n",
                  "# Check if the directory exists\n",
                  "if [ -e \"${file}\" ]; then ",
                  "\n",
                  "    export command=${file}\n",
                  "else",
                  "\n",
                  "    export command=\"curl -s\"\n",
                  "fi",
                  "\n",
                  "instance_id=$(${command} http://169.254.169.254/latest/meta-data/instance-id; echo)\n",
                  "    tdc-log",
                  " --file /var/log/cloud-init-output.log",
                  " --region ",
                  {
                    "Ref": "AWS::Region"
                  },
                  " --group Teradata/DBS/",
                  {
                    "Ref": "AWS::StackName"
                  },
                  " --stream cloud-init-output.log.error",
                  "-",
                  "${instance_id}",
                  "\n",
                  "    ",
                  "if command -v tdc-cfn-signal &> /dev/null\n",
                  "then\n",
                  "tdc-cfn-signal -e ${RC}",
                  " --stack ",
                  {
                    "Ref": "AWS::StackName"
                  },
                  " --region ",
                  {
                    "Ref": "AWS::Region"
                  },
                  " --resource ",
                  "DBAutoscalingGroup",
                  "\nelse\n",
                  "cfn-signal -e ${RC}",
                  " --stack ",
                  {
                    "Ref": "AWS::StackName"
                  },
                  " --region ",
                  {
                    "Ref": "AWS::Region"
                  },
                  " --resource ",
                  "DBAutoscalingGroup",
                  "\nfi\n",
                  "        exit ${RC}\n",
                  "    fi\n",
                  "}\n",
                  "tdc-log --init",
                  " --region ",
                  {
                    "Ref": "AWS::Region"
                  },
                  " --group Teradata/DBS/",
                  {
                    "Ref": "AWS::StackName"
                  },
                  "\n",
                  "if [ -n '",
                  {
                    "Ref": "Timezone"
                  },
                  "' ]; then\n    tdc-timezone '",
                  {
                    "Ref": "Timezone"
                  },
                  "'\n",
                  "fi\n",
                  "/usr/local/bin/tdc-info -updateMOTD short\n",
                  "\n",
                  "tdc-disable-autoscale\n",
                  "check_error_signal\n",
                  "\n",
                  "\n",
                  "tdc-network-configure",
                  " --nodes ",
                  {
                    "Ref": "DBNodeCount"
                  },
                  "",
                  " --systemname '",
                  {
                    "Ref": "DBSystemName"
                  },
                  "'",
                  {
                    "Fn::If": [
                      "DBUseElasticIPs",
                      " --elastic",
                      ""
                    ]
                  },
                  " --unfoldposition ",
                  {
                    "Fn::FindInMap": [
                      "DBUnfoldConfigTypes",
                      {
                        "Ref": "DBUnfoldConfigType"
                      },
                      "UnfoldPosition"
                    ]
                  },
                  "",
                  "\n",
                  "check_error_signal\n",
                  "\n",
                  "PMAID=$(blmd -p)\n",
                  "tdc-ntp -s '",
                  {
                    "Ref": "NTPServers"
                  },
                  "'",
                  "\n",
                  "\n",
                  "tdc-init",
                  " --system_name '",
                  {
                    "Ref": "DBSystemName"
                  },
                  "'",
                  " --dbc_password '",
                  {
                    "Fn::GetAtt": [
                      "DBCPWDEncrypt",
                      "pwd"
                    ]
                  },
                  "'",
                  " --pwd_aws_encrypted",
                  " --force_config",
                  " --kanji_support ",
                  {
                    "Ref": "DBKanjiSupport"
                  },
                  " -g -p -t",
                  "",
                  "",
                  {
                    "Fn::If": [
                      "AMPSUse0",
                      "",
                      {
                        "Fn::Join": [
                          " ",
                          [
                            " --amps_per_subpool",
                            {
                              "Ref": "AMPsPerSubpool"
                            }
                          ]
                        ]
                      }
                    ]
                  },
                  {
                    "Fn::If": [
                      "SubpoolUse0",
                      "",
                      {
                        "Fn::Join": [
                          " ",
                          [
                            " --subpools_per_node",
                            {
                              "Ref": "SubpoolPerClique"
                            }
                          ]
                        ]
                      }
                    ]
                  },
                  {
                    "Fn::If": [
                      "DBTemporalEnabled",
                      " --enable_temporal",
                      ""
                    ]
                  },
                  "\n",
                  "check_error_signal\n",
                  "\n",
                  "\n",
                  "if [ $PMAID = '33' ]; then\n",
                  "    /usr/tdbms/bin/dbscontrol << EOD\n",
                  "m n 1 = t\n",
                  "wr\n",
                  "q\n",
                  "EOD\n",
                  "tpareset -y enable NOS\n",
                  "fi\n",
                  "check_error_signal\n",
                  "\n",
                  "\n",
                  "/usr/local/bin/tdc-nodestart-init --update-file\n",
                  "check_error_signal\n",
                  "\n",
                  "if [ $PMAID = '33' ]; then\n",
                  "    psh /usr/local/bin/tdc-info -updateMOTD short\n",
                  "    if [ '",
                  {
                    "Ref": "DBRowLevelSecurity"
                  },
                  "' = 'yes' ]; then\n",
                  "        tdc-rlsecurity -n\n",
                  "    fi\n",
                  "    if [ '",
                  {
                    "Ref": "DBSecureZones"
                  },
                  "' = 'yes' ]; then\n",
                  "        tdc-securezones -n -p '",
                  {
                    "Fn::GetAtt": [
                      "DBCPWDEncrypt",
                      "pwd"
                    ]
                  },
                  "'",
                  " --pwd_aws_encrypted",
                  "\n",
                  "    fi\n",
                  "    if [ '",
                  {
                    "Ref": "DBTimPercent"
                  },
                  "' != '0' ]; then\n",
                  "        tdc-feature tim enable --force --tim-size ",
                  {
                    "Ref": "DBTimPercent"
                  },
                  "\n",
                  "    fi\n",
                  "fi\n",
                  "/usr/local/bin/tdc-ecosystem-ssh --enable\n",
                  "tdc-log --file /var/log/cloud-init-output.log",
                  " --region ",
                  {
                    "Ref": "AWS::Region"
                  },
                  " --group Teradata/DBS/",
                  {
                    "Ref": "AWS::StackName"
                  },
                  " --stream cloud-init-output.log",
                  "-",
                  "$PMAID",
                  "\n",
                  "if [ $PMAID = '33' ]; then\n",
                  "   tdc-log  --file /etc/motd",
                  " --region ",
                  {
                    "Ref": "AWS::Region"
                  },
                  " --group Teradata/DBS/",
                  {
                    "Ref": "AWS::StackName"
                  },
                  " --stream tdc-info",
                  "\nfi\n",
                  "if [ $PMAID = '33' ]; then\n",
                  "\n",
                  "tdc-configssh",
                  " enable",
                  " --user ec2-user\n",
                  "check_error_signal\n",
                  "\n",
                  "fi\n",
                  "\n",
                  "tdc-write-file '",
                  {
                    "Fn::GetAtt": [
                      "DBSshKeyGen",
                      "encrypted_private_key"
                    ]
                  },
                  "' /home/ec2-user/.ssh/new_node --decrypt\n",
                  "check_error_signal\n",
                  "\n",
                  "\n",
                  "echo $'",
                  {
                    "Fn::GetAtt": [
                      "DBSshKeyGen",
                      "public_key"
                    ]
                  },
                  "' > /tmp/tmp_pub_key.pub\n",
                  "check_error_signal\n",
                  "\n",
                  "\n",
                  "ssh-keygen -f /tmp/tmp_pub_key.pub -i -mPKCS8 > /home/ec2-user/.ssh/new_node.pub\n",
                  "check_error_signal\n",
                  "\n",
                  "\n",
                  "chown ec2-user:users /home/ec2-user/.ssh/new_node\n",
                  "check_error_signal\n",
                  "\n",
                  "\n",
                  "chown ec2-user:users /home/ec2-user/.ssh/new_node.pub\n",
                  "check_error_signal\n",
                  "\n",
                  "if [ -f /usr/lib/python2.7/site-packages/diy_attr/update_ua.pyc ]; then\n",
                  "     python /usr/lib/python2.7/site-packages/diy_attr/update_ua.pyc",
                  " QVBOLzEuMCBUZXJhZGF0YS8xLjAgVmFudGFnZQ==\n",
                  "fi\n",
                  "$CLIENTHANDLER_ROOT/setS3UAString.sh \"APN/1.0 Teradata/1.0 Vantage\"\n",
                  "if command -v tdc-cfn-signal &> /dev/null\n",
                  "then\n",
                  "tdc-cfn-signal -e 0",
                  " --stack ",
                  {
                    "Ref": "AWS::StackName"
                  },
                  " --region ",
                  {
                    "Ref": "AWS::Region"
                  },
                  " --resource ",
                  "DBAutoscalingGroup",
                  "\nelse\n",
                  "cfn-signal -e 0",
                  " --stack ",
                  {
                    "Ref": "AWS::StackName"
                  },
                  " --region ",
                  {
                    "Ref": "AWS::Region"
                  },
                  " --resource ",
                  "DBAutoscalingGroup",
                  "\nfi\n"
                ]
              ]
            }
          }
        },
        "LaunchTemplateName": {
          "Fn::Join": [
            "-",
            [
              {
                "Ref": "AWS::StackName"
              },
              "DBLaunchTemplate"
            ]
          ]
        }
      },
      "Type": "AWS::EC2::LaunchTemplate"
    },
    "DBMppInstanceProfile": {
      "Properties": {
        "Path": "/",
        "Roles": [
          {
            "Ref": "DBMppRole"
          }
        ]
      },
      "Type": "AWS::IAM::InstanceProfile"
    },
    "DBMppRole": {
      "Properties": {
        "AssumeRolePolicyDocument": {
          "Statement": [
            {
              "Action": [
                "sts:AssumeRole"
              ],
              "Effect": "Allow",
              "Principal": {
                "Service": [
                  "ec2.amazonaws.com",
                  "lambda.amazonaws.com",
                  {
                    "Fn::Join": [
                      ".",
                      [
                        "states",
                        {
                          "Ref": "AWS::Region"
                        },
                        "amazonaws.com"
                      ]
                    ]
                  }
                ]
              }
            }
          ],
          "Version": "2012-10-17"
        },
        "Policies": [
          {
            "PolicyDocument": {
              "Statement": [
                {
                  "Action": [
                    "ec2:DescribeNetworkInterfaces",
                    "ec2:DescribeSubnets",
                    "ec2:CreateNetworkInterface",
                    "ec2:AttachNetworkInterface",
                    "ec2:DetachNetworkInterface",
                    "ec2:DescribeLaunchTemplateVersions",
                    "ec2:CreateLaunchTemplateVersion",
                    "ec2:DeleteLaunchTemplateVersions",
                    "ec2:DeleteLaunchTemplate",
                    "ec2:CreateLaunchTemplate",
                    "ec2:DescribeLaunchTemplates",
                    "ec2:ModifyLaunchTemplate",
                    "ec2:ModifyNetworkInterfaceAttribute",
                    "ec2:AssignPrivateIpAddresses",
                    "ec2:UnassignPrivateIpAddresses",
                    "ec2:AllocateAddress",
                    "ec2:AssociateAddress",
                    "ec2:DisassociateAddress",
                    "ec2:CreateTags",
                    "ec2:DeleteTags",
                    "ec2:DescribeTags",
                    "ec2:CreateVolume",
                    "ec2:ModifyVolume",
                    "ec2:DescribeVolumes",
                    "ec2:DescribeVolumeAttribute",
                    "ec2:DescribeVolumeStatus",
                    "ec2:DescribeInstances",
                    "ec2:DescribeInstanceStatus",
                    "ec2:ModifyInstanceAttribute",
                    "ec2:CreateImage",
                    "ec2:CopyImage",
                    "ec2:DeregisterImage",
                    "ec2:DescribeImages",
                    "ec2:DeleteSnapshot",
                    "ec2:DescribeSnapshots",
                    "ec2:RunInstances",
                    "ec2:StopInstances",
                    "ec2:StartInstances",
                    "ec2:ReleaseAddress",
                    "ec2:DeleteNetworkInterface",
                    "ec2:CreatePlacementGroup",
                    "ec2:DescribePlacementGroups",
                    "ec2:DeletePlacementGroup",
                    "ec2:CreateSnapshot",
                    "ec2:RegisterImage",
                    "cloudformation:DescribeStacks",
                    "iam:GetRole",
                    "states:StartExecution",
                    "states:StopExecution",
                    "lambda:CreateFunction",
                    "lambda:DeleteFunction",
                    "states:CreateStateMachine",
                    "states:DeleteStateMachine",
                    "states:ListStateMachines",
                    "lambda:InvokeFunction",
                    "autoscaling:DescribeAutoScalingGroups",
                    "autoscaling:DetachInstances",
                    "autoscaling:DescribeLaunchConfigurations",
                    "autoscaling:AttachInstances",
                    "autoscaling:SuspendProcesses",
                    "autoscaling:UpdateAutoScalingGroup",
                    "autoscaling:CreateAutoScalingGroup",
                    "autoscaling:CreateLaunchConfiguration",
                    "autoscaling:DeleteLaunchConfiguration",
                    "autoscaling:DeleteAutoScalingGroup",
                    "autoscaling:DescribeTags",
                    "kms:CreateKey",
                    "kms:Decrypt",
                    "kms:Encrypt",
                    "kms:DisableKey",
                    "kms:CreateAlias",
                    "kms:ListAliases",
                    "kms:ScheduleKeyDeletion",
                    "tag:GetResources",
                    "s3:HeadBucket",
                    "s3:ListAllMyBuckets",
                    "s3:ListBucket",
                    "s3:GetObject",
                    "s3:GetBucketTagging",
                    "s3:GetBucketLocation",
                    "ssm:GetParametersByPath",
                    "ssm:PutParameter",
                    "cloudwatch:PutMetricAlarm",
                    "cloudwatch:DescribeAlarms",
                    "cloudwatch:DeleteAlarms"
                  ],
                  "Effect": "Allow",
                  "Resource": "*"
                },
                {
                  "Action": "sts:AssumeRole",
                  "Effect": "Allow",
                  "NotResource": {
                    "Fn::Join": [
                      "",
                      [
                        "arn:",
                        {
                          "Ref": "AWS::Partition"
                        },
                        ":iam::",
                        {
                          "Ref": "AWS::AccountId"
                        },
                        ":role/*"
                      ]
                    ]
                  }
                },
                {
                  "Action": "cloudformation:SignalResource",
                  "Effect": "Allow",
                  "Resource": {
                    "Fn::Join": [
                      "",
                      [
                        "arn:",
                        {
                          "Ref": "AWS::Partition"
                        },
                        ":cloudformation:",
                        {
                          "Ref": "AWS::Region"
                        },
                        ":",
                        {
                          "Ref": "AWS::AccountId"
                        },
                        ":stack/",
                        {
                          "Ref": "AWS::StackName"
                        },
                        "/*"
                      ]
                    ]
                  }
                },
                {
                  "Action": [
                    "ec2:AttachVolume",
                    "ec2:DetachVolume",
                    "ec2:DeleteVolume"
                  ],
                  "Condition": {
                    "StringEquals": {
                      "ec2:ResourceTag/teradata:stack": {
                        "Ref": "AWS::StackName"
                      }
                    }
                  },
                  "Effect": "Allow",
                  "Resource": "*"
                },
                {
                  "Action": [
                    "logs:DescribeLogGroups",
                    "logs:DescribeLogStreams",
                    "logs:CreateLogGroup",
                    "logs:CreateLogStream",
                    "logs:PutLogEvents"
                  ],
                  "Effect": "Allow",
                  "Resource": {
                    "Fn::Join": [
                      ":",
                      [
                        "arn",
                        {
                          "Ref": "AWS::Partition"
                        },
                        "logs",
                        "*",
                        "*",
                        "*"
                      ]
                    ]
                  }
                },
                {
                  "Action": [
                    "iam:PassRole"
                  ],
                  "Effect": "Allow",
                  "Resource": {
                    "Fn::Join": [
                      "",
                      [
                        "arn:",
                        {
                          "Ref": "AWS::Partition"
                        },
                        ":iam::",
                        {
                          "Ref": "AWS::AccountId"
                        },
                        ":role/",
                        {
                          "Fn::Join": [
                            "-",
                            [
                              {
                                "Ref": "AWS::StackName"
                              },
                              "DBMppRole"
                            ]
                          ]
                        }
                      ]
                    ]
                  }
                },
                {
                  "Action": "ec2:TerminateInstances",
                  "Condition": {
                    "StringEquals": {
                      "ec2:ResourceTag/teradata:stack": {
                        "Ref": "AWS::StackName"
                      }
                    }
                  },
                  "Effect": "Allow",
                  "Resource": "arn:aws:ec2:*:*:instance/*"
                }
              ],
              "Version": "2012-10-17"
            },
            "PolicyName": "tdmpp"
          }
        ],
        "RoleName": {
          "Fn::Join": [
            "-",
            [
              {
                "Ref": "AWS::StackName"
              },
              "DBMppRole"
            ]
          ]
        }
      },
      "Type": "AWS::IAM::Role"
    },
    "DBSecurityGroup": {
      "Properties": {
        "GroupDescription": "Security group for Teradata Vantage",
        "SecurityGroupIngress": [
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "22",
            "IpProtocol": "tcp",
            "ToPort": "22"
          },
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "1025",
            "IpProtocol": "tcp",
            "ToPort": "1025"
          }
        ],
        "VpcId": {
          "Ref": "VPC"
        }
      },
      "Type": "AWS::EC2::SecurityGroup"
    },
    "DBSecurityGroupSelfRule": {
      "Properties": {
        "GroupId": {
          "Fn::GetAtt": [
            "DBSecurityGroup",
            "GroupId"
          ]
        },
        "IpProtocol": "-1",
        "SourceSecurityGroupId": {
          "Fn::GetAtt": [
            "DBSecurityGroup",
            "GroupId"
          ]
        }
      },
      "Type": "AWS::EC2::SecurityGroupIngress"
    },
    "DBSshKeyGen": {
      "Properties": {
        "ServiceToken": {
          "Fn::GetAtt": [
            "DBSshKeyGenFunction",
            "Arn"
          ]
        },
        "key_id": {
          "Fn::GetAtt": [
            "DBCPWDEncrypt",
            "key_id"
          ]
        },
        "region": {
          "Ref": "AWS::Region"
        }
      },
      "Type": "AWS::CloudFormation::CustomResource"
    },
    "DBSshKeyGenFunction": {
      "Properties": {
        "Code": {
          "ZipFile": "const response = require('./cfn-response')\nconst crypto = require('crypto');\nconst { KMSClient, EncryptCommand, CreateKeyCommand } = require(\"@aws-sdk/client-kms\");\n\nfunction gen_ec521(event, context, kms, keyid) {\n    console.log(\"Creating ec521 key\")\n\n    const ecKeyPair = crypto.generateKeyPairSync('ec', {\n        namedCurve: 'secp521r1', \n        publicKeyEncoding: {type: 'spki', format: 'pem'},\n        privateKeyEncoding: {type: 'pkcs8', format: 'pem'},\n    });\n\n    const publicKeyPem = ecKeyPair.publicKey;\n    const privateKeyPem = ecKeyPair.privateKey;\n\n    const encryptCommand = new EncryptCommand({\n        KeyId: keyid,\n        Plaintext: Buffer.from(privateKeyPem),\n    });\n\n    kms.send(encryptCommand, (err, data) => {\n        if (err) {\n            console.error('Error encrypting data:', err);\n            response.send(event, context, \"FAILED\", {Reason: \"Failed to encrypt e521 key with kms\"});\n        } else {\n            const encrypted_pkey = Buffer.from(data.CiphertextBlob).toString('base64');\n            const response_dict = {\n                public_key: publicKeyPem,\n                encrypted_private_key: encrypted_pkey,\n                key_id: keyid\n            }\n            console.log(\"Successful encryption\")\n            response.send(event, context, \"SUCCESS\", response_dict);\n        }\n    });\n}\n\n\nfunction gen_rsa(event, context, kms, keyid) {\n\n    const rsaKeyPair = crypto.generateKeyPairSync('rsa', {\n        modulusLength: 2048,\n        publicKeyEncoding: { type: 'pkcs1', format: 'pem'},\n        privateKeyEncoding: { type: 'pkcs1', format: 'pem'}\n    });\n\n    const publicKeyPem = rsaKeyPair.publicKey;\n    const privateKeyPem = rsaKeyPair.privateKey;\n\n    const encryptCommand = new EncryptCommand({\n        KeyId: keyid,\n        Plaintext: Buffer.from(privateKeyPem),\n    });\n\n    var success = false\n    kms.send(encryptCommand, (err, data) => {\n        if (err) {\n            console.error('Error encrypting data:', err);\n            response.send(event, context, \"FAILED\", {Reason: \"Failed to encrypt rsa key with kms\"});\n            return false;\n        }\n        const encrypted_pkey = Buffer.from(data.CiphertextBlob).toString('base64');\n        const response_dict = {\n            public_key: publicKeyPem,\n            encrypted_private_key: encrypted_pkey,\n            key_id: keyid\n        }\n        console.log(\"Successful encryption\")\n        response.send(event, context, \"SUCCESS\", response_dict);\n        success = true\n    });\n    return success\n}\n\nfunction generate_key(event, context, kms, keyid, key_type, callback) {\n    if (!keyid) {\n        const createKeyCommand = new CreateKeyCommand({\n            Description: 'Teradata Database stack temporary key.',\n        });\n        kms.send(createKeyCommand)\n            .then(({ KeyMetadata }) => {\n                keyid = KeyMetadata.KeyId;\n                console.log(\"KMS Key Created with ID:\", keyid);\n                callback(event, context, kms, keyid, key_type)\n            })\n            .catch((error) => {\n                console.error(\"Error creating KMS key:\", error);\n                response.send(event, context, \"FAILED\", {Reason: \"Failed to create key id\"});\n            });\n    } else {\n        callback(event, context, kms, keyid, key_type)\n    }\n}\n\nfunction create_keys(event, context, kms, keyid, key_type) {\n    if (key_type == \"ec521\") {\n        gen_ec521(event, context, kms, keyid)\n    }\n    else if (key_type.includes(\"rsa\")) {\n        gen_rsa(event, context, kms, keyid, key_type.includes(\"host\"))\n    } else {\n        response.send(event, context, \"FAILED\", {Reason: \"No valid key type provided\"});\n    }\n}\n\nexports.handler = function(event, context) {\n    if (event.RequestType == \"Delete\") {\n        response.send(event, context, \"SUCCESS\");\n        return;\n    }\n\n    console.log(\"event: \", event)\n\n    const kms = new KMSClient();\n\n    var keyid = event.ResourceProperties.key_id;\n    const key_type = event.ResourceProperties.key_type ?? \"ec521\"\n\n    generate_key(event, context, kms, keyid, key_type, create_keys);\n\n    return response;\n};"
        },
        "Environment": {
          "Variables": {
            "commit_id": "43bd8069fd3ca13efa8df6a40294a9dc76511898\n"
          }
        },
        "Handler": "index.handler",
        "MemorySize": 1024,
        "Role": {
          "Fn::GetAtt": [
            "DBMppRole",
            "Arn"
          ]
        },
        "Runtime": "nodejs22.x",
        "Timeout": 300
      },
      "Type": "AWS::Lambda::Function"
    },
    "DBStackCleanUp": {
      "Properties": {
        "Environment": {
          "Variables": {
            "security_group": {
              "Ref": "DBSecurityGroup"
            },
            "td_stack_name": {
              "Ref": "AWS::StackName"
            }
          }
        },
        "Region": {
          "Ref": "AWS::Region"
        },
        "ServiceToken": {
          "Fn::GetAtt": [
            "DBStackCleanupFunction",
            "Arn"
          ]
        }
      },
      "Type": "AWS::CloudFormation::CustomResource"
    },
    "DBStackCleanupFunction": {
      "Properties": {
        "Code": {
          "ZipFile": "import cfnresponse\nimport bz2\nimport base64\nexec(bz2.decompress(base64.b64decode('QlpoOTFBWSZTWeiklo0AA/lfgAAwcuf4Gj//34q////6YAqcOdztwuLbXdxr7z3uKlZjUQ6NKFu7dgYSmohoRqeRkNNNTBTTDSepp6NTTAhoAGp6EmE001U/1NJPUZB6TxQaPUaAGRoABppoRAoANEADBNqGgD1AAASakUxBNMqfoU/Ip6n5U09R6gPU9RoehPUHqBoOaMmJgAmIwI0wIMRgmTAIwSJCJgQyCA0DKankTE9RpoaNDQNEgioRYIyCwYKioKiCAxGKpGKKKCKJtmfIfclkN6FRGKfg0DJ9rP+sB7cqCyZN+nD0uV1V256dIyUGk9Cntq7bVh+960BZM09mHoSpSKlBRa1J0dhBTuCQnD2htmyx+NknhWFvso6ekWtVZZNEHN5GMUKjMUF/KFsM50xOKsZYhBWhbS1dHUODsKhf1M5gW3V5g2Nmtnm/QzMBgogvaOjPHrOb8YCUJfcuZRySZHxwZIzSZ+novY5gEQF83TCQst8rEI/jhq+BM9QtpoqJeJyd9FmA3S9LA+bLodD0j5ZHRk4i3IvNnJ1cmixVKI0RKKaLKMpspWNrWphjhPgnAa5hS8EUtISp/lAg3cV+1EmlVwwLM18iBjc95QESHcgEu5YrllgvqeDSEI3ompcFluZl5ppLYvg+VoFiqCIp4JBTYXV07fi15z5zr6+zprwe63CZ571LQnm3nt1EChTB9fNhNoxEZZSm1kPvvxuxZ+LSSOPZlpMhIbC4eFo+lQARzbrXhFatSWdMOUXQWCORDeEyMgWdYb+38Y6xRoNqwrlvyg3EYu8YNgeCwiyQW/aJ6DsHGJVXUuKwzWJonDgwQCyTkamtgktng9qJUmHpIQqDBeh+p3txOHN0MbwOs9z23eF3v9hHObbsjzJj2SElwNZElecTlhKbnacFD+/064YJDdtjuA45BcDZwOOnPuvc1gkXFSoPIVpyDoDWCb24GpAysXAl0UcOpVLvtyp3XoAk8ZNna5cgEsI9sefjW7foLbTfLmfPmucTTbYVMdCC/LnRNvNWquyky6sqaSwGgOujqvfBMYK9yKgze9Oc2UQoAYqtSybx0LRJkWqyWerFLryXYthzgSeyOpmd2j3d0fqCB55xRPQ9DoO3vy/TTofCqv5ijYS/M4nxpioOAVzM1a0YM4kbRpgpgkmBgRUsXGIwvlizmjIVoFhiFDIEmg7AOYDCVBT3MnzdiF5ckBqGkao9TWFWLmoMbAEyQbutONMiDhUUcKAV7o7HZ6gCKcHZcqlkIiCJiYbZtyDwyWFliGV6GQkdblEOkOMYxD4xcML9SY2zFmu44eqZpjOBv3V8lUKKs1bX3Ou1YzVMPzstHRQKWYRGy93jwB9TPPAqmqIp1R6ukwFEpsu6N1hEBLSzNmNz8LV+1OhvcvCSWQNZB46wlgcP5bWNE2JNYY8NOCPwuLFSE32k8UXtwXd2uQuxOEdLnRbihz2SZ2pW0EZAzigaSAOHqdwOnIju408+yDz56jWyi6KPvlXtAQhQNeze4hvCvYCBed8Jrlhwh6txye71eYVe5W+1htgDmdpVULFmJWJt4zkF6GjoX3I/BDPWUFQkKkocEI8j41UdPCQ/RFZJMjicpSIhSkXUFJeYiK1UXlCCLWK/4fuEAxSQsVvtJAYq1oj1v/O6NFZ8g+gxCtqlWPNgmieSrEgjGY8bnnphLzpkvoPxMM5PHE/3Ij4B28blzLag8zpTXwka8dg6iDLDCpHy6WmifgznwaqM6moVj+RdAT9R+kcaKMvb5dIZbSkoPVDvIyT87modwVQ1WEbB75CNIqovy/AtchE4GF6Z4sWnV3GhHWtimpI2m0mWBkBsDXFT19dQog2iUT30bZsnQOc2B5+EJt2N9o5Umh2e8h2ZXG0AHz2ptQ3Bt32+0I8K73J+IrSWsyfA+IgjDiTYkYvHW9oODUw7ptSa6kCWD4oCmFjbCbUkUIlYqhQQND7wjC0VE/m7g3XLtqus6frGuU5DMvDZrLDASxOfKR6mxgmZHBFQXHuseo0uWi03a0oGqiICS6QsL7lkkJkG/mL2iGkNiQ1vhVrG/Rl2NHY52KsV55kBqJzEGylR5MrStYlWYgisS5j2JokeXHs9Xql0LqEerr+YjxxKlTgGst7DkHGQ4sYLBY7iDuIcIyTy5/WlRnMhjpgbNhNGfi0h1pSFuwRVsrcuod4wlAgUFXW5YnxEgwzgbzm3xpavINCQtAZkiaGxWF7dwZreNB5orCRe5nAicko1CkWmOXf7X3p9pvQWGb5KZ6ZwJdAsXHTAn4FQjfyGehmFmzOG0lxaeZwSVDFM07MZyzCBInZZdDExrQCzYFbDMKGp8cVPXQ0zoXabQv0Tjy8EAmNRrrkUsUAoNeUMcCayKGjyOcV58acxZ9KtIkYmksQrJyELDA4ms+fLivebO41qhRqjbYN2xvpKeOGx6QggN2MBL3phJBiRNAugGvRlFTVYFayxVRc5g22IZHMVgXuMqgFlMlIFrlfPNE0Tp4MJgeMdBqCtCYhp3BCVti0IgRUJCoU5V8t++1WCDZaNMbC0tGJEyRMY2oCSNRyv+2A3ZpJqNrlgDtQ39vccjl4YwFgR8Tn1nDaIyDARDAxuSvUg8BKQvZ79Rmkb2i6GN+ysNviIqEWqvkFgjeq1rZuSe2/ASMw3hzcENq5jYh9a/Fal2ayfZyoWBcJXLX2jeCJQKiSUxA2DMBtpBDFbOoJsGGrIrVV5ojBvHuI5WtMJmG5Xfh30NqZRlIdgGjXNcgiQvKkJbtIZg3MHiMhCbiErTNzVvwjNa2n8NnkVCgiqWhnydFrknoNk4v3L4CF230lxDEMSz1uEWihAEW50TNV1QjqEUAlpssbagGg19XfX17OCYshdrU6OXaGJ/8/swlhGBMqxCEkbCBUvOtht+OUsOsz5GO/oUam7hM9W1ymhaTngYXL38WLKRmaAJzbUnNwOhMnCFUk+ASPa0Ynu6dm/UOLKxLQDtCym2pddIE2gwxNGdjkI29ZAbOzSQ727rXtQYNtNDbKI2qoAYVECNpjJZMl4gfey5Y2eSw4DokNDEaVn1V9OwPqHEPI5MLhFdb3MA6xo5wYean2bklzuWnC6vYKEIuMzC8IQbQtt3EXiKJHkMBZMLFEQBEQprLqcWtbZOFqbYbCIqInHqfdmSRw+hm8HH/F3JFOFCQ6KSWjQ')))"
        },
        "Environment": {
          "Variables": {
            "commit_id": "43bd8069fd3ca13efa8df6a40294a9dc76511898\n",
            "security_group": {
              "Ref": "DBSecurityGroup"
            },
            "td_stack_name": {
              "Ref": "AWS::StackName"
            }
          }
        },
        "Handler": "index.handler",
        "MemorySize": 1024,
        "Role": {
          "Fn::GetAtt": [
            "DBMppRole",
            "Arn"
          ]
        },
        "Runtime": "python3.11",
        "Timeout": 300
      },
      "Type": "AWS::Lambda::Function"
    },
    "DBValidateHsnCount": {
      "Properties": {
        "ServiceToken": {
          "Fn::GetAtt": [
            "ValidateHsnCountFunction",
            "Arn"
          ]
        },
        "hsn_node_count": {
          "Ref": "DBHsnNodeCount"
        },
        "max_nodes": 128,
        "node_count": {
          "Ref": "DBNodeCount"
        },
        "region": {
          "Ref": "AWS::Region"
        }
      },
      "Type": "AWS::CloudFormation::CustomResource"
    },
    "EcosystemSecurityGroup": {
      "DependsOn": [
        "DBValidateHsnCount"
      ],
      "Properties": {
        "GroupDescription": "Security group for Teradata Ecosystem",
        "SecurityGroupIngress": [],
        "VpcId": {
          "Ref": "VPC"
        }
      },
      "Type": "AWS::EC2::SecurityGroup"
    },
    "EcosystemSecurityGroupSelfRule": {
      "Properties": {
        "GroupId": {
          "Fn::GetAtt": [
            "EcosystemSecurityGroup",
            "GroupId"
          ]
        },
        "IpProtocol": "-1",
        "SourceSecurityGroupId": {
          "Fn::GetAtt": [
            "EcosystemSecurityGroup",
            "GroupId"
          ]
        }
      },
      "Type": "AWS::EC2::SecurityGroupIngress"
    },
    "PSIMAutoscalingGroup": {
      "CreationPolicy": {
        "ResourceSignal": {
          "Count": {
            "Ref": "PSIMNodeCount"
          },
          "Timeout": "PT30M"
        }
      },
      "Properties": {
        "DesiredCapacity": {
          "Ref": "PSIMNodeCount"
        },
        "HealthCheckGracePeriod": 3600,
        "LaunchTemplate": {
          "LaunchTemplateId": {
            "Ref": "PSIMLaunchTemplate"
          },
          "Version": {
            "Fn::GetAtt": [
              "PSIMLaunchTemplate",
              "LatestVersionNumber"
            ]
          }
        },
        "MaxSize": {
          "Ref": "PSIMNodeCount"
        },
        "MinSize": {
          "Ref": "PSIMNodeCount"
        },
        "Tags": {
          "Fn::GetAtt": [
            "ParseTagsLambdaExecutionPsimAsg",
            "autoscaling_tags"
          ]
        },
        "VPCZoneIdentifier": [
          {
            "Ref": "PublicSubnet"
          }
        ]
      },
      "Type": "AWS::AutoScaling::AutoScalingGroup"
    },
    "PSIMInstanceProfile": {
      "Properties": {
        "Path": "/",
        "Roles": [
          {
            "Ref": "PSIMRole"
          }
        ]
      },
      "Type": "AWS::IAM::InstanceProfile"
    },
    "PSIMLaunchTemplate": {
      "Properties": {
        "LaunchTemplateData": {
          "BlockDeviceMappings": [
            {
              "DeviceName": "/dev/sda1",
              "Ebs": {
                "VolumeType": "gp3"
              }
            }
          ],
          "IamInstanceProfile": {
            "Arn": {
              "Fn::GetAtt": [
                "PSIMInstanceProfile",
                "Arn"
              ]
            }
          },
          "ImageId": {
            "Fn::FindInMap": [
              "PSIMAMIs",
              {
                "Ref": "AWS::Region"
              },
              "AMI"
            ]
          },
          "InstanceType": {
            "Ref": "PSIMInstanceType"
          },
          "KeyName": {
            "Ref": "KeyName"
          },
          "SecurityGroupIds": [
            {
              "Fn::GetAtt": [
                "PSIMSecurityGroup",
                "GroupId"
              ]
            },
            {
              "Fn::GetAtt": [
                "EcosystemSecurityGroup",
                "GroupId"
              ]
            }
          ],
          "UserData": {
            "Fn::Base64": {
              "Fn::Join": [
                "",
                [
                  "#!/bin/bash\n",
                  "PROXYSERVER=",
                  {
                    "Ref": "ProxyServerURL"
                  },
                  "\n",
                  "[[ -n $PROXYSERVER ]] && CFNPARAM=\" --http-proxy $PROXYSERVER --https-proxy $PROXYSERVER\" || CFNPARAM= \n",
                  "[[ -n $PROXYSERVER ]] && echo 'Configuring System to use Proxy Server...[RUNNING]' || echo 'Skipping Proxy Server Configuration...[DONE]' \n",
                  "[[ -n $PROXYSERVER ]] && echo \"OK\" | yast2 proxy set {http,https,ftp}=$PROXYSERVER noproxy=localhost,127.0.0.1,169.254.169.254,169.254.169.123,169.254.170.2 \n",
                  "[[ -n $PROXYSERVER ]] && echo \"OK\" | yast2 proxy enable \n",
                  "source /etc/profile\n",
                  "\n",
                  "region=`curl -k http://169.254.169.254/latest/dynamic/instance-identity/document | python -c 'import json,sys;obj=json.load(sys.stdin);print(obj[\"region\"]);'`\n",
                  "psim_tag=`python -c \"import boto3;ec2 = boto3.client('ec2', '${region}');tags = ec2.describe_instances(Filters=[{'Name': 'tag:teradata:type','Values': ['psim',],},],);count=1;\n",
                  "for instances in tags['Reservations']:\n",
                  "   for i in instances['Instances']:\n",
                  "      state=i['State']\n",
                  "      instance_state=state['Name']\n",
                  "      instance_id=i['InstanceId']\n",
                  "      for t in i['Tags']:\n",
                  "          if t['Key']=='Name' and instance_state == 'running':\n",
                  "              instance_name=t['Value']\n",
                  "              print(instance_name)\n",
                  "              if '-PSIM-01' in instance_name or '-PSIM-02' in instance_name:\n",
                  "                  continue\n",
                  "              instance_name=instance_name+'-0'+str(count)\n",
                  "              result=ec2.create_tags(Resources=[instance_id,],Tags=[{'Key': 'Name','Value': instance_name}])\n",
                  "              print(result)\n",
                  "              count=count+1\"`\n",
                  "/usr/local/bin/tdc-disable-autoscale\n",
                  "/usr/local/bin/tdc-ecosystem-ssh --enable\n",
                  "if command -v tdc-cfn-signal &> /dev/null\n",
                  "then\n",
                  "tdc-cfn-signal -e 0",
                  " --stack ",
                  {
                    "Ref": "AWS::StackName"
                  },
                  " --region ",
                  {
                    "Ref": "AWS::Region"
                  },
                  " --resource ",
                  "PSIMAutoscalingGroup",
                  "\nelse\n",
                  "cfn-signal -e 0",
                  " --stack ",
                  {
                    "Ref": "AWS::StackName"
                  },
                  " --region ",
                  {
                    "Ref": "AWS::Region"
                  },
                  " --resource ",
                  "PSIMAutoscalingGroup",
                  "\nfi\n"
                ]
              ]
            }
          }
        },
        "LaunchTemplateName": {
          "Fn::Join": [
            "-",
            [
              {
                "Ref": "AWS::StackName"
              },
              "PSIMLaunchTemplate"
            ]
          ]
        }
      },
      "Type": "AWS::EC2::LaunchTemplate"
    },
    "PSIMRole": {
      "Properties": {
        "AssumeRolePolicyDocument": {
          "Statement": [
            {
              "Action": [
                "sts:AssumeRole"
              ],
              "Effect": "Allow",
              "Principal": {
                "Service": [
                  "ec2.amazonaws.com"
                ]
              }
            }
          ],
          "Version": "2012-10-17"
        },
        "Policies": [
          {
            "PolicyDocument": {
              "Statement": [
                {
                  "Action": [
                    "ec2:DescribeNetworkInterfaces",
                    "ec2:CreateTags",
                    "ec2:DescribeTags",
                    "ec2:CreateVolume",
                    "ec2:DescribeInstances",
                    "ec2:DescribeInstanceStatus",
                    "ec2:ModifyInstanceAttribute",
                    "ec2:CreateImage",
                    "ec2:DeregisterImage",
                    "ec2:DescribeImages",
                    "ec2:RunInstances",
                    "ec2:TerminateInstances",
                    "ec2:StopInstances",
                    "ec2:StartInstances",
                    "iam:PassRole",
                    "autoscaling:DescribeAutoScalingGroups",
                    "autoscaling:DescribeLaunchConfigurations",
                    "autoscaling:DetachInstances",
                    "autoscaling:AttachInstances",
                    "autoscaling:SuspendProcesses",
                    "autoscaling:UpdateAutoscalingGroup",
                    "cloudformation:SignalResource"
                  ],
                  "Effect": "Allow",
                  "Resource": "*"
                }
              ],
              "Version": "2012-10-17"
            },
            "PolicyName": "smmpp"
          }
        ]
      },
      "Type": "AWS::IAM::Role"
    },
    "PSIMSecurityGroup": {
      "Properties": {
        "GroupDescription": "Security group for Teradata PSIM",
        "SecurityGroupIngress": [
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "22",
            "IpProtocol": "tcp",
            "ToPort": "22"
          },
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "1080",
            "IpProtocol": "tcp",
            "ToPort": "1080"
          },
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "1443",
            "IpProtocol": "tcp",
            "ToPort": "1443"
          },
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "5988",
            "IpProtocol": "tcp",
            "ToPort": "5999"
          },
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "7700",
            "IpProtocol": "tcp",
            "ToPort": "7730"
          },
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "7754",
            "IpProtocol": "tcp",
            "ToPort": "7759"
          },
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "7759",
            "IpProtocol": "udp",
            "ToPort": "7759"
          },
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "9981",
            "IpProtocol": "tcp",
            "ToPort": "9981"
          },
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "61618",
            "IpProtocol": "tcp",
            "ToPort": "61618"
          }
        ],
        "VpcId": {
          "Ref": "VPC"
        }
      },
      "Type": "AWS::EC2::SecurityGroup"
    },
    "PSIMSecurityGroupSelfRule": {
      "Properties": {
        "GroupId": {
          "Fn::GetAtt": [
            "PSIMSecurityGroup",
            "GroupId"
          ]
        },
        "IpProtocol": "-1",
        "SourceSecurityGroupId": {
          "Fn::GetAtt": [
            "PSIMSecurityGroup",
            "GroupId"
          ]
        }
      },
      "Type": "AWS::EC2::SecurityGroupIngress"
    },
    "ParseTagsLambda": {
      "Properties": {
        "Code": {
          "ZipFile": "import os\nimport re\nimport logging\nfrom time import sleep\nimport urllib3\nimport json\n\nhttp = urllib3.PoolManager()\n\nSUCCESS = \"SUCCESS\"\nFAILED = \"FAILED\"\n\n\ndef retry_cfn_response(logger, event, context, responseStatus, responseData, physicalResourceId=None, noEcho=False, reason=None):\n    responseUrl = event['ResponseURL']\n\n    logger.info(responseUrl)\n\n    responseBody = {\n        'Status' : responseStatus,\n        'Reason' : reason or \"See the details in CloudWatch Log Stream: {}\".format(context.log_stream_name),\n        'PhysicalResourceId' : physicalResourceId or context.log_stream_name,\n        'StackId' : event['StackId'],\n        'RequestId' : event['RequestId'],\n        'LogicalResourceId' : event['LogicalResourceId'],\n        'NoEcho' : noEcho,\n        'Data' : responseData\n    }\n\n    json_responseBody = json.dumps(responseBody)\n\n    logger.info(\"Response body:\")\n    logger.info(json_responseBody)\n\n    headers = {\n        'content-type' : '',\n        'content-length' : str(len(json_responseBody))\n    }\n\n    tries = 10\n    while tries:\n        try:\n            response = http.request('PUT', responseUrl, headers=headers, body=json_responseBody)\n            status = response.status\n            logger.info(\"Status code: %s\", status)\n            if 200 == status:\n                return True\n        except Exception as e:\n            logger.exception(\"Failed executing HTTP request\")\n            sleep(10)\n        tries -= 1\n    return False\n\n\n\n_TAG_PARAM_STRING_EVENT_KEY = \"tags_param\"\n_EXISTING_TAGS_EVENT_KEY = \"existing_tags\"\n\n_RESPONSE_AUTOSCALING_TAG_KEY = \"autoscaling_tags\"\n_RESPONSE_INSTANCE_TAG_KEY = \"instance_tags\"\n\n\ndef handler(event, context):\n    response_dict = {}\n\n    logger = logging.getLogger()\n    logger.setLevel(logging.INFO)\n\n    try:\n        if event.get('RequestType') == 'Delete':\n            retry_cfn_response(logger, event, context, SUCCESS, responseData={})\n            return\n\n        logger.info(\"event {0}\".format(event))\n        response_dict = {\n            _RESPONSE_AUTOSCALING_TAG_KEY: [],\n            _RESPONSE_INSTANCE_TAG_KEY: []\n        }\n\n        try:\n            existing_tags = event['ResourceProperties'][_EXISTING_TAGS_EVENT_KEY]\n            for tag_dict in existing_tags:\n                response_dict[_RESPONSE_AUTOSCALING_TAG_KEY].append(tag_dict)\n                response_dict[_RESPONSE_INSTANCE_TAG_KEY].append(tag_dict)\n        except:\n            logger.exception(\"exception hit adding existing tags\")\n\n        tags_string = os.environ.get(_TAG_PARAM_STRING_EVENT_KEY, \"\")\n\n        # parse custom key string and generate list of key value pairs\n        result = re.findall(\"\\s*([^,]+)\\s*:\\s*([^,]+)\\s*\", tags_string)\n\n        # generate autoscaling and instance tag dicts\n        for key, value in result:\n            response_dict[_RESPONSE_AUTOSCALING_TAG_KEY].append(\n                {\n                    \"Key\": key,\n                    \"Value\": value,\n                    \"PropagateAtLaunch\": \"true\"\n                }\n            )\n            response_dict[_RESPONSE_INSTANCE_TAG_KEY].append(\n                {\n                    \"Key\": key,\n                    \"Value\": value,\n                }\n            )\n\n    finally:\n        logger.info(\"response dict {0}\".format(response_dict))\n        retry_cfn_response(logger, event, context, SUCCESS, responseData=response_dict)"
        },
        "Environment": {
          "Variables": {
            "tags_param": {
              "Ref": "CustomTagParam"
            }
          }
        },
        "Handler": "index.handler",
        "Role": {
          "Fn::GetAtt": [
            "CustomTagIamRole",
            "Arn"
          ]
        },
        "Runtime": "python3.11",
        "Timeout": 30
      },
      "Type": "AWS::Lambda::Function"
    },
    "ParseTagsLambdaExecutionHsnAsg": {
      "Properties": {
        "ServiceToken": {
          "Fn::GetAtt": [
            "ParseTagsLambda",
            "Arn"
          ]
        },
        "existing_tags": [
          {
            "Key": "Name",
            "PropagateAtLaunch": "true",
            "Value": {
              "Fn::Join": [
                "-",
                [
                  {
                    "Ref": "AWS::StackName"
                  },
                  "HSN"
                ]
              ]
            }
          },
          {
            "Key": "teradata:stack",
            "PropagateAtLaunch": "true",
            "Value": {
              "Ref": "AWS::StackName"
            }
          },
          {
            "Key": "HSN",
            "PropagateAtLaunch": "true",
            "Value": "Configuring"
          }
        ]
      },
      "Type": "AWS::CloudFormation::CustomResource"
    },
    "ParseTagsLambdaExecutionPsimAsg": {
      "Properties": {
        "ServiceToken": {
          "Fn::GetAtt": [
            "ParseTagsLambda",
            "Arn"
          ]
        },
        "existing_tags": [
          {
            "Key": "Name",
            "PropagateAtLaunch": "true",
            "Value": {
              "Fn::Join": [
                "-",
                [
                  {
                    "Ref": "AWS::StackName"
                  },
                  "PSIM"
                ]
              ]
            }
          },
          {
            "Key": "teradata:stack",
            "PropagateAtLaunch": "true",
            "Value": {
              "Ref": "AWS::StackName"
            }
          },
          {
            "Key": "teradata:type",
            "PropagateAtLaunch": "true",
            "Value": "psim"
          }
        ]
      },
      "Type": "AWS::CloudFormation::CustomResource"
    },
    "ParseTagsLambdaExecutionTpaAsg": {
      "Properties": {
        "ServiceToken": {
          "Fn::GetAtt": [
            "ParseTagsLambda",
            "Arn"
          ]
        },
        "existing_tags": [
          {
            "Key": "Name",
            "PropagateAtLaunch": "true",
            "Value": {
              "Fn::Join": [
                "-",
                [
                  {
                    "Ref": "AWS::StackName"
                  },
                  "DBS"
                ]
              ]
            }
          },
          {
            "Key": "teradata:stack",
            "PropagateAtLaunch": "true",
            "Value": {
              "Ref": "AWS::StackName"
            }
          },
          {
            "Key": "teradata:type",
            "PropagateAtLaunch": "true",
            "Value": "tpa"
          }
        ]
      },
      "Type": "AWS::CloudFormation::CustomResource"
    },
    "ParseTagsLambdaExecutionVp": {
      "Properties": {
        "ServiceToken": {
          "Fn::GetAtt": [
            "ParseTagsLambda",
            "Arn"
          ]
        },
        "existing_tags": [
          {
            "Key": "Name",
            "Value": {
              "Fn::Join": [
                "-",
                [
                  {
                    "Ref": "AWS::StackName"
                  },
                  "Viewpoint"
                ]
              ]
            }
          },
          {
            "Key": "teradata:stack",
            "Value": {
              "Ref": "AWS::StackName"
            }
          },
          {
            "Key": "teradata:type",
            "Value": "vp"
          }
        ]
      },
      "Type": "AWS::CloudFormation::CustomResource"
    },
    "VPInstance": {
      "CreationPolicy": {
        "ResourceSignal": {
          "Count": 1,
          "Timeout": "PT1H"
        }
      },
      "DependsOn": [
        "DBAutoscalingGroup",
        "PSIMAutoscalingGroup"
      ],
      "Properties": {
        "BlockDeviceMappings": [
          {
            "DeviceName": "/dev/sda1",
            "Ebs": {
              "VolumeType": "gp3"
            }
          },
          {
            "DeviceName": "/dev/sdb",
            "Ebs": {
              "VolumeType": "gp3"
            }
          }
        ],
        "IamInstanceProfile": {
          "Ref": "DBMppInstanceProfile"
        },
        "ImageId": {
          "Fn::FindInMap": [
            "VPAMIs",
            {
              "Ref": "AWS::Region"
            },
            "AMI"
          ]
        },
        "InstanceType": {
          "Ref": "VPInstanceType"
        },
        "KeyName": {
          "Ref": "KeyName"
        },
        "Monitoring": true,
        "SecurityGroupIds": [
          {
            "Ref": "VPSecurityGroup"
          },
          {
            "Ref": "EcosystemSecurityGroup"
          }
        ],
        "SubnetId": {
          "Ref": "PublicSubnet"
        },
        "Tags": {
          "Fn::GetAtt": [
            "ParseTagsLambdaExecutionVp",
            "instance_tags"
          ]
        },
        "UserData": {
          "Fn::Base64": {
            "Fn::Join": [
              "",
              [
                "#!/bin/bash\n",
                "PROXYSERVER=",
                {
                  "Ref": "ProxyServerURL"
                },
                "\n",
                "[[ -n $PROXYSERVER ]] && CFNPARAM=\" --http-proxy $PROXYSERVER --https-proxy $PROXYSERVER\" || CFNPARAM= \n",
                "[[ -n $PROXYSERVER ]] && echo 'Configuring System to use Proxy Server...[RUNNING]' || echo 'Skipping Proxy Server Configuration...[DONE]' \n",
                "[[ -n $PROXYSERVER ]] && echo \"OK\" | yast2 proxy set {http,https,ftp}=$PROXYSERVER noproxy=localhost,127.0.0.1,169.254.169.254,169.254.169.123,169.254.170.2 \n",
                "[[ -n $PROXYSERVER ]] && echo \"OK\" | yast2 proxy enable \n",
                "source /etc/profile\n",
                "if [ -n '",
                {
                  "Ref": "Timezone"
                },
                "' ]; then\n    tdc-timezone '",
                {
                  "Ref": "Timezone"
                },
                "'\n",
                "fi\n",
                "/usr/local/bin/tdc-ecosystem-ssh --enable\n",
                "check_error_signal()\n",
                "{\n",
                "    RC=$?\n",
                "    if [ ${RC} -ne 0 ]; then\n",
                "    ",
                "file=\"/usr/local/bin/imdsv2\"\n\n",
                "# Check if the directory exists\n",
                "if [ -e \"${file}\" ]; then ",
                "\n",
                "    export command=${file}\n",
                "else",
                "\n",
                "    export command=\"curl -s\"\n",
                "fi",
                "\n",
                "instance_id=$(${command} http://169.254.169.254/latest/meta-data/instance-id; echo)\n",
                "    tdc-log-base",
                " --file /var/log/cloud-init-output.log",
                " --region ",
                {
                  "Ref": "AWS::Region"
                },
                " --group Teradata/DBS/",
                {
                  "Ref": "AWS::StackName"
                },
                " --stream cloud-init-output.log.error",
                "-",
                "${instance_id}",
                "\n",
                "    ",
                "if command -v tdc-cfn-signal &> /dev/null\n",
                "then\n",
                "tdc-cfn-signal -e ${RC}",
                " --stack ",
                {
                  "Ref": "AWS::StackName"
                },
                " --region ",
                {
                  "Ref": "AWS::Region"
                },
                " --resource ",
                "VPInstance",
                "\nelse\n",
                "cfn-signal -e ${RC}",
                " --stack ",
                {
                  "Ref": "AWS::StackName"
                },
                " --region ",
                {
                  "Ref": "AWS::Region"
                },
                " --resource ",
                "VPInstance",
                "\nfi\n",
                "        exit ${RC}\n",
                "    fi\n",
                "}\n",
                "SLESVERSION=\n",
                "if [ -e /etc/SuSE-release ]; then\n",
                "    SLESVERSION=$(cat /etc/SuSE-release | grep VERSION | awk '{print $3}')\n",
                "elif [ -e /etc/os-release ]; then\n",
                "    SLESVERSION=$(source /etc/os-release; echo ${VERSION:0:2})\n",
                "else\n",
                "    echo \"Unknown OS\"\n",
                "    exit 1\n",
                "fi\n",
                "\n",
                "if [ \"${SLESVERSION}\" = \"15\" ]; then python_cmd=\"python3.11\"; else python_cmd=\"python3\"; fi\n",
                "cd /var/opt/teradata/tdc-orchestration || exit 1\n",
                "/usr/bin/env ${python_cmd} aws_generate_inventory.py",
                "\n",
                "check_error_signal\n",
                "\n",
                "/usr/bin/env ${python_cmd} aws_generate_facts.py",
                " --inventory hosts --output group_vars/all\n",
                "check_error_signal\n",
                "\n",
                "sed -i \"s/version: \\\"{{ tdversion }}\\\"/version: \\\"16.20\\\"/g\" /var/opt/teradata/tdc-orchestration/roles/configure_vp_tpa/tasks/main.yml\n",
                "sed -i \"s/60/180/g\" /var/opt/teradata/tdc-orchestration/roles/configure_vp_vp/tasks/main.yml\n",
                "sed -i.bak -e '26,29d' /var/opt/teradata/tdc-orchestration/cleanup.yml \n",
                "sed -i.bak \"s/retries = 6/retries = 30/g\" /var/opt/teradata/tdc-orchestration/ansible.cfg \n",
                "ansible-playbook  -i hosts site.yml",
                " -e system_name='",
                {
                  "Ref": "DBSystemName"
                },
                "'",
                " -e dbc_pass='",
                {
                  "Fn::GetAtt": [
                    "VPPWDEncrypt",
                    "db_dbc_pwd"
                  ]
                },
                "'",
                " -e ntp_server_list='",
                {
                  "Ref": "NTPServers"
                },
                "'",
                " -e system_nickname='",
                {
                  "Ref": "EcoVPSystemNickname"
                },
                "'",
                " -e sm_admin_pass='",
                {
                  "Fn::GetAtt": [
                    "VPPWDEncrypt",
                    "cm_pwd"
                  ]
                },
                "'",
                " -e sm_rest_pass='",
                {
                  "Fn::GetAtt": [
                    "VPPWDEncrypt",
                    "cm_rest_pwd"
                  ]
                },
                "'",
                " -e siteid='",
                {
                  "Ref": "PSIMSiteid"
                },
                "'",
                " -e encrypted_passwords='True'",
                "\n",
                "if command -v tdc-cfn-signal &> /dev/null\n",
                "then\n",
                "tdc-cfn-signal -e $?",
                " --stack ",
                {
                  "Ref": "AWS::StackName"
                },
                " --region ",
                {
                  "Ref": "AWS::Region"
                },
                " --resource ",
                "VPInstance",
                "\nelse\n",
                "cfn-signal -e $?",
                " --stack ",
                {
                  "Ref": "AWS::StackName"
                },
                " --region ",
                {
                  "Ref": "AWS::Region"
                },
                " --resource ",
                "VPInstance",
                "\nfi\n"
              ]
            ]
          }
        }
      },
      "Type": "AWS::EC2::Instance"
    },
    "VPPWDEncrypt": {
      "Properties": {
        "ServiceToken": {
          "Fn::GetAtt": [
            "VPPWDEncryptFunction",
            "Arn"
          ]
        },
        "action": "encrypt",
        "cm_pwd": {
          "Ref": "PSIMPassword"
        },
        "cm_rest_pwd": {
          "Ref": "PSIMRESTPassword"
        },
        "db_dbc_pwd": {
          "Ref": "DBSystemPassword"
        },
        "region": {
          "Ref": "AWS::Region"
        }
      },
      "Type": "AWS::CloudFormation::CustomResource"
    },
    "VPPWDEncryptFunction": {
      "Properties": {
        "Code": {
          "ZipFile": "import cfnresponse\nimport bz2\nimport base64\nexec(bz2.decompress(base64.b64decode('QlpoOTFBWSZTWdGglP0AAg1fgEAwQuf/2j///oq////qUAVY1Zey47cx2dGNB2CUSmymRtE1TeBNEm9RiRtJ+ppPKeTRqMgaAEoUwgNGpompo9G1NTynlND1AGg0AAeoJERGgmkaR6aZT1EyAeoaeoP1T0mNJp+qaBoOMmTJiMTACZMEyAGjCMAQwCSU00BJpnqJk00aDaTQ2oADTQaAAYEJDY2xgwaGhtMaTGNg+W1YPuhQN8FARLOEvZs1UtG18vdT34Y83+sM+F8+p17KmF5f7H8DwcE3wI/i+13+0KD16YZVvpbtwqMsx41pywmfsofiIquwM6bPFklG1T308cR8WKvHpSi11DQr+EORwnzUxv19fHDyU4vH9l2+KWwkiZZEkuKuf+pE6c7aevTVSjlRXXXdbRQjho9LTmW7JjnAzSVvNI2vQamMcWZ9JBxBPe2AUd62HDdrXBMovE8GeETFkvPp5csRE2Lu2twY/TzNSY1cRaXMy4mZXbUN6DL1cks3m0PSnqbUZ4fmO1yS/GNUq8Gh+/U84b1Xcua+tdZbBpIaSLAbXYHBh3OZpUPzV4xZzxy1mSvrdzVM1nyWijbJJTuy4lBbjjHNcz4pZuQ4KtLtt/g6uFDpWUHqlyxsUVnwaTM2Oa1QcKqmtUSbtq1c0/uow9eE2W27qDJgNNV9OZmQ6qV7JcTve0e+P2QXWt7ruuyy073GGO4Vv1oB7KrNWh2hei0slE6IwqTKSs9d6GkH4iZOk7rUd0K4uJOYtgpMcPNkh4zFivAVHxJLqPO1+s2rMVTerLJ4eu04MeWX7/VKypdFwyY52qY7bQSX14L336c3uf0ifxMteOtuAZfpUhx4QVrd6Vf0O19Bd87nFNPWU2GvTd9bmhoFXPjU9Xa4JgCpvQesNYjohhiCcposVvlYfTesCn4c3gbVJXazJuMzdJZeOYdaMOrFgYqd/JgcFKEx2MRVqj6in/FmgCtYA6Tiet4mYhETIeLFhbqSDRCGyFUbhS+EWmOvQdr5EqT9CckrYPTfYaexVVUT9vSxCfVFIDvVWcezLZdOKuV06QzIZCHdE/V2R1pIvz55dJgYHtiPriGFbeRrHKeFUURtWLqByH+fBL+ZLuBIcugg070LimosMNy9zq1KcnNVzplBeiCDc6m4JmAPoQ1csjDcHewt5q3ZwRefjnQvNGXKKpvg1RIz815bbNw5Oh5EKTFIhOUHaQqSwxxk1FklZRGI9ERbQeNXsxSgYUE8uPXcWhMmWcTxROSJguIwDR4BYgJZycyPjfUyTF3IxAmjScnqWgIVzqTQFupic0kHQtQhlHrZbco19HguBeV1YOknVeCpsLAGlcyZCKAROFspDXZXYSFOlWCjGLz55Azc9oqZjX0+cZTjAxF4oqzmSCe6kl2wD6KWMr5nvofgSp55e6bVDhepXR8840RilCUsR3H9Cw3DqjBkWLzKACiwz2cb0BVJiub0D5dQDgfL0HVnvXlO2g2h5V+TNMaTaeBxQGCXnuNOpxDIdV6JIWmhZpRukCHQ1jtIQv36BBMKVp1MDJS39hwUAMUkRDhprehys89qz8+AqCqPwXaXQQyj4lsjIaU7evfvRy6U3ZMv+5rYIyCFl2e4NzmxLrpQqTulmqQ2l+HkoxMaTaZS5ePq+NRuyLmgIYb7qGZt7DZw6V0eOIHLxjo8WhXvoNkOBsrrBnZckR30IgHJKbbfSY2PU0Z9fpqy5UdLXalo5GMizgGBMkl6nQFQlu4ZEmhxqlDkGCd8iuiKF9doFVdqNmi0icdeLl0kJAxpkiCZzBus5W2aJKITKzjcDpC+rZAYP0UfR/i7kinChIaNBKfo')))"
        },
        "Environment": {
          "Variables": {
            "commit_id": "43bd8069fd3ca13efa8df6a40294a9dc76511898\n"
          }
        },
        "Handler": "index.handler",
        "MemorySize": 1024,
        "Role": {
          "Fn::GetAtt": [
            "DBMppRole",
            "Arn"
          ]
        },
        "Runtime": "python3.11",
        "Timeout": 300
      },
      "Type": "AWS::Lambda::Function"
    },
    "VPPWDEncryptKeyDelete": {
      "DependsOn": [
        "VPInstance"
      ],
      "Properties": {
        "ServiceToken": {
          "Fn::GetAtt": [
            "VPPWDEncryptFunction",
            "Arn"
          ]
        },
        "action": "delete_key",
        "key": {
          "Fn::GetAtt": [
            "VPPWDEncrypt",
            "key_id"
          ]
        }
      },
      "Type": "AWS::CloudFormation::CustomResource"
    },
    "VPSecurityGroup": {
      "Properties": {
        "GroupDescription": "Security group for Teradata Viewpoint",
        "SecurityGroupIngress": [
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "22",
            "IpProtocol": "tcp",
            "ToPort": "22"
          },
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "80",
            "IpProtocol": "tcp",
            "ToPort": "80"
          },
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "443",
            "IpProtocol": "tcp",
            "ToPort": "443"
          },
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "5432",
            "IpProtocol": "tcp",
            "ToPort": "5432"
          },
          {
            "CidrIp": {
              "Ref": "SecurityGroupAccess"
            },
            "FromPort": "61616",
            "IpProtocol": "tcp",
            "ToPort": "61616"
          }
        ],
        "VpcId": {
          "Ref": "VPC"
        }
      },
      "Type": "AWS::EC2::SecurityGroup"
    },
    "ValidateHsnCountFunction": {
      "Properties": {
        "Code": {
          "ZipFile": "import logging\nfrom time import sleep\nimport urllib3\nimport json\n\nhttp = urllib3.PoolManager()\n\nSUCCESS = \"SUCCESS\"\nFAILED = \"FAILED\"\n\n\ndef retry_cfn_response(logger, event, context, responseStatus, responseData, physicalResourceId=None, noEcho=False, reason=None):\n    responseUrl = event['ResponseURL']\n\n    logger.info(responseUrl)\n\n    responseBody = {\n        'Status' : responseStatus,\n        'Reason' : reason or \"See the details in CloudWatch Log Stream: {}\".format(context.log_stream_name),\n        'PhysicalResourceId' : physicalResourceId or context.log_stream_name,\n        'StackId' : event['StackId'],\n        'RequestId' : event['RequestId'],\n        'LogicalResourceId' : event['LogicalResourceId'],\n        'NoEcho' : noEcho,\n        'Data' : responseData\n    }\n\n    json_responseBody = json.dumps(responseBody)\n\n    logger.info(\"Response body:\")\n    logger.info(json_responseBody)\n\n    headers = {\n        'content-type' : '',\n        'content-length' : str(len(json_responseBody))\n    }\n\n    tries = 10\n    while tries:\n        try:\n            response = http.request('PUT', responseUrl, headers=headers, body=json_responseBody)\n            status = response.status\n            logger.info(\"Status code: %s\", status)\n            if 200 == status:\n                return True\n        except Exception as e:\n            logger.exception(\"Failed executing HTTP request\")\n            sleep(10)\n        tries -= 1\n    return False\n\nlogger = logging.getLogger()\nlogger.setLevel(logging.INFO)\n\n\ndef handler(event, context):\n    hsn_count = int(event['ResourceProperties']['hsn_node_count'])\n    node_count = int(event['ResourceProperties']['node_count'])\n    max_node_count = int(event['ResourceProperties']['max_nodes'])\n    response_dict = dict()\n\n    try:\n        if event['RequestType'] == 'Delete':\n            retry_cfn_response(logger, event, context, SUCCESS, responseData={})\n            return\n\n        logger.info('Validating Hot Standby Node count')\n        logger.info('HSNs: {0}, db node count: {1}, max count: {2}'.format(hsn_count, node_count, max_node_count))\n\n        valid_size = hsn_count <= node_count\n\n        if valid_size:\n            logger.info(\"HSN count is allowed\")\n            retry_cfn_response(logger, event, context, SUCCESS, responseData=response_dict)\n            return True\n        else:\n            logger.info(\"HSN count is not allowed, should be between 0 and {0}\".format(node_count))\n            retry_cfn_response(logger, event, context, FAILED, responseData={})\n            return False\n\n    except Exception as e:\n        logging.error('Failed to generate key. Error: %s' % str(e))\n        logging.exception('error')\n        retry_cfn_response(logger, event, context, FAILED, responseData={})\n        return False\n\n\n\n"
        },
        "Environment": {
          "Variables": {
            "commit_id": "43bd8069fd3ca13efa8df6a40294a9dc76511898\n"
          }
        },
        "Handler": "index.handler",
        "MemorySize": 1024,
        "Role": {
          "Fn::GetAtt": [
            "DBMppRole",
            "Arn"
          ]
        },
        "Runtime": "python3.11",
        "Timeout": 20
      },
      "Type": "AWS::Lambda::Function"
    },
    "ViewPointInstanceProfile": {
      "Properties": {
        "Path": "/",
        "Roles": [
          {
            "Ref": "ViewPointInstanceRole"
          }
        ]
      },
      "Type": "AWS::IAM::InstanceProfile"
    },
    "ViewPointInstanceRole": {
      "Properties": {
        "AssumeRolePolicyDocument": {
          "Statement": [
            {
              "Action": [
                "sts:AssumeRole"
              ],
              "Effect": "Allow",
              "Principal": {
                "Service": [
                  "ec2.amazonaws.com",
                  {
                    "Fn::Join": [
                      ".",
                      [
                        "states",
                        {
                          "Ref": "AWS::Region"
                        },
                        "amazonaws.com"
                      ]
                    ]
                  },
                  "lambda.amazonaws.com"
                ]
              }
            }
          ],
          "Version": "2012-10-17"
        },
        "Policies": [
          {
            "PolicyDocument": {
              "Statement": [
                {
                  "Action": [
                    "ec2:DescribeSubnets",
                    "ec2:DescribeNetworkInterfaces",
                    "ec2:CreateNetworkInterface",
                    "ec2:AttachNetworkInterface",
                    "ec2:DetachNetworkInterface",
                    "ec2:ModifyNetworkInterfaceAttribute",
                    "ec2:AllocateAddress",
                    "ec2:AssociateAddress",
                    "ec2:DisassociateAddress",
                    "ec2:DeleteTags",
                    "ec2:DescribeTags",
                    "ec2:CreateTags",
                    "ec2:DescribeInstances",
                    "ec2:DescribeInstanceStatus",
                    "ec2:ReleaseAddress",
                    "ec2:DeleteNetworkInterface",
                    "tag:GetResources",
                    "s3:HeadBucket",
                    "s3:ListAllMyBuckets",
                    "s3:ListBucket",
                    "s3:GetObject",
                    "s3:GetBucketTagging",
                    "ec2:DescribeInstances",
                    "lambda:CreateFunction",
                    "lambda:DeleteFunction",
                    "lambda:InvokeFunction",
                    "secretsmanager:GetSecretValue",
                    "iam:GetRole",
                    "iam:PassRole",
                    "cloudformation:SignalResource",
                    "ssm:GetParametersByPath"
                  ],
                  "Effect": "Allow",
                  "Resource": "*"
                }
              ],
              "Version": "2012-10-17"
            },
            "PolicyName": "RestInstancePolicy"
          }
        ]
      },
      "Type": "AWS::IAM::Role"
    }
  },
  "Rules": {
    "OTFAcknowledgementRequired": {
      "RuleCondition": {
        "Fn::Equals": [
          {
            "Ref": "DBInstanceStorageType"
          },
          "r6id.12xlarge-EBS"
        ]
      },
      "Assertions": [
        {
          "Assert": {
            "Fn::Equals": [
              {
                "Ref": "OTFFeatureAcknowledgement"
              },
              "yes"
            ]
          },
          "AssertDescription": "NOTE: Select instance type r6id.12xlarge to enable the Teradata Externally Managed OTF (Native Iceberg Reads)."
        }
      ]
    },
    "OTFAcknowledgementNotApplicable": {
      "RuleCondition": {
        "Fn::Not": [
          {
            "Fn::Equals": [
              {
                "Ref": "DBInstanceStorageType"
              },
              "r6id.12xlarge-EBS"
            ]
          }
        ]
      },
      "Assertions": [
        {
          "Assert": {
            "Fn::Equals": [
              {
                "Ref": "OTFFeatureAcknowledgement"
              },
              "no"
            ]
          },
          "AssertDescription": "NOTE: Select instance type r6id.12xlarge to enable the Teradata Externally Managed OTF (Native Iceberg Reads)."
        }
      ]
    }
  }
}