public void RecordSetMappedToEipTest()
        {
            Template template  = StackTest.GetNewBlankTemplateWithVpc($"Vpc{this.TestContext.TestName}");
            var      DMZSubnet = new Subnet(template.Vpcs.First(), "10.0.0.0/20", AvailabilityZone.UsEast1A, true);

            template.Resources.Add("DMZSubnet", DMZSubnet);

            Instance testBox = new Instance(DMZSubnet, InstanceTypes.T2Micro, "ami-60b6c60a", OperatingSystem.Linux);

            template.Resources.Add("testbox", testBox);
            var eip    = testBox.AddElasticIp();
            var target = RecordSet.AddByHostedZoneName(template, "test", "getthebuybox.com.", "test.test.getthebuybox.com.", RecordSet.RecordSetTypeEnum.A);

            target.TTL           = "60";
            target.RecordSetType = RecordSet.RecordSetTypeEnum.A.ToString();
            target.AddResourceRecord(new ReferenceProperty(eip));
            StackTest.CreateTestStack(template, this.TestContext);
        }
        public void RecordSetByNewHostZoneTest()
        {
            Template   template = StackTest.GetNewBlankTemplateWithVpc($"Vpc{this.TestContext.TestName}");
            HostedZone hz       = new HostedZone("zeta.yadayada.software.");

            template.Resources.Add("hostedZoneRecordSetByNewHostZoneTest", hz);
            hz.AddVpc(template.Vpcs.First(), Region.UsEast1);
            var target = RecordSet.AddByHostedZone(template, "test", hz, "test.zeta.yadayada.software.", RecordSet.RecordSetTypeEnum.A);

            target.TTL           = "60";
            target.RecordSetType = RecordSet.RecordSetTypeEnum.A.ToString();
            var DMZSubnet = new Subnet(template.Vpcs.First(), "10.0.0.0/20", AvailabilityZone.UsEast1A, true);

            template.Resources.Add("DMZSubnet", DMZSubnet);

            Instance testBox = new Instance(DMZSubnet, InstanceTypes.T2Micro, "ami-60b6c60a", OperatingSystem.Linux);

            template.Resources.Add("testbox", testBox);
            var eip = testBox.AddElasticIp();

            target.AddResourceRecord(eip);
            StackTest.CreateTestStack(template, this.TestContext);
        }
        private static Template GetTestEnvironmentTemplate(string domain)
        {
            Template returnTemplate = new Template(domain, "TestApp1YadayadaSoftwareComVpc", "StackTestApp1YadayadaSoftwareCom", domain.Replace('.', '-'), "10.1.0.0/16");

            Vpc vpc = returnTemplate.Vpcs.Last();

            Subnet subnetDmz = new Subnet(vpc, "10.0.0.0/24", AvailabilityZone.UsEast1A, true);

            returnTemplate.Resources.Add("subnetDmz", subnetDmz);
            Instance instanceWebServer = new Instance(subnetDmz, InstanceTypes.C4Large, StackTest.UsEastWindows2012R2Ami, OperatingSystem.Windows, false);

            returnTemplate.Resources.Add("instanceWebServer", instanceWebServer);
            instanceWebServer.Packages.Add(new InternetInformationServerPackage(null, "gtbb", "yadayada_iis"));

            SecurityGroup securityGroupLoadBalancer = new SecurityGroup("Security Group for ELB", vpc);

            securityGroupLoadBalancer.AddIngress(PredefinedCidr.TheWorld, Protocol.Tcp, Ports.Ssl);
            securityGroupLoadBalancer.AddIngress(PredefinedCidr.TheWorld, Protocol.Tcp, Ports.Http);
            returnTemplate.Resources.Add(securityGroupLoadBalancer.LogicalId, securityGroupLoadBalancer);

            LoadBalancer loadBalancer = new LoadBalancer();

            loadBalancer.HealthCheck.Target             = "HTTP:80/healthcheck.htm";
            loadBalancer.HealthCheck.HealthyThreshold   = 2.ToString();
            loadBalancer.HealthCheck.Interval           = 300.ToString();
            loadBalancer.HealthCheck.Timeout            = 10.ToString();
            loadBalancer.HealthCheck.UnhealthyThreshold = 10.ToString();



            loadBalancer.Subnets.Add(new ReferenceProperty(subnetDmz));
            loadBalancer.SecurityGroups.Add(securityGroupLoadBalancer);

            LoadBalancer.Listener listenerHttps = new LoadBalancer.Listener((int)Ports.Ssl, (int)Ports.Http, "https");
            listenerHttps.SSLCertificateId = "arn:aws:acm:us-east-1:570182474766:certificate/ec3dcdfd-cc6d-4af7-8119-290bf134fa4f";
            loadBalancer.Instances.Add(new ReferenceProperty(instanceWebServer));
            loadBalancer.Listeners.Add(listenerHttps);

            LoadBalancer.Listener listenerHttp = new LoadBalancer.Listener((int)Ports.Http, (int)Ports.Http, "http");
            loadBalancer.Instances.Add(new ReferenceProperty(instanceWebServer));
            loadBalancer.Listeners.Add(listenerHttp);

            returnTemplate.Resources.Add("LoadBalancer", loadBalancer);

            SecurityGroup securityGroupElbToWebServer = new SecurityGroup("Allows Elb To Web Server", vpc);

            returnTemplate.Resources.Add(securityGroupElbToWebServer.LogicalId, securityGroupElbToWebServer);
            securityGroupElbToWebServer.AddIngress(securityGroupLoadBalancer, Protocol.Tcp, Ports.Http);
            instanceWebServer.SecurityGroupIds.Add(new  ReferenceProperty(securityGroupElbToWebServer));

            instanceWebServer.AddElasticIp();
            SecurityGroup securityGroupRdpFromFairfaxToWebServer = new SecurityGroup("Allows RDP access from Fairfax", vpc);

            returnTemplate.Resources.Add(securityGroupRdpFromFairfaxToWebServer.LogicalId, securityGroupRdpFromFairfaxToWebServer);
            securityGroupRdpFromFairfaxToWebServer.AddIngress(new Fairfax(), Protocol.All, Ports.RemoteDesktopProtocol);
            instanceWebServer.SecurityGroupIds.Add(new ReferenceProperty(securityGroupRdpFromFairfaxToWebServer));

            RecordSet recordSetElasticLoadBalancer = RecordSet.AddByHostedZoneName(returnTemplate,
                                                                                   $"www.{domain}.".Replace(".", string.Empty),
                                                                                   "yadayadasoftware.com.",
                                                                                   $"www.{domain}.", RecordSet.RecordSetTypeEnum.CNAME);

            recordSetElasticLoadBalancer.AddResourceRecord(new FnGetAtt(loadBalancer, FnGetAttAttribute.AwsElasticLoadBalancingLoadBalancer));

            loadBalancer.DependsOn.Add(instanceWebServer.Packages.Last().WaitCondition.LogicalId);

            return(returnTemplate);
        }