Ejemplo n.º 1
0
        public void EnsureStackExists()
        {
            if (_hasCreatedStack)
            {
                return;
            }

            _awsConfiguration = new AwsConfiguration
            {
                AssumeRoleTrustDocument = Roles.Path("code-deploy-trust.json"),
                IamRolePolicyDocument   = Roles.Path("code-deploy-policy.json"),
                Bucket      = "aws-deployment-tools-tests",
                RoleName    = "CodeDeployRole",
                AwsEndpoint = TestConfiguration.AwsEndpoint,
                Credentials = new TestSuiteCredentials()
            };

            _deployer = new Deployer(_awsConfiguration);

            DeletePreviousTestStack();
            _stack = _deployer.CreateStack(new StackTemplate
            {
                StackName    = StackName,
                TemplatePath = CloudFormationTemplates.Path("example-windows-vpc.template")
            });
            _hasCreatedStack = true;
        }
Ejemplo n.º 2
0
        public void ThrowsWhenStackFailsToDetele()
        {
            var stackName         = "AwsToolsRemovalThrowsWhenStackFailsToDeteleTest";
            var securityGroupName = "AwsToolsRemovalThrowsWhenStackFailsToDeteleTest";

            SetUp(stackName);

            var deployer = new Deployer(_awsConfiguration);

            try
            {
                deployer.CreateStack(new StackTemplate
                {
                    StackName    = stackName,
                    TemplatePath = CloudFormationTemplates.Path("example-basic-vpc.template")
                });
                CreateSecurityGroup(securityGroupName, stackName);

                TestDelegate act = () => deployer.DeleteStack(stackName);

                Assert.Throws <FailedToDeleteStackException>(act);
            }
            finally
            {
                DeleteSecurityGroup(securityGroupName, stackName);
                DeletePreviousTestStack(stackName);
            }
        }
Ejemplo n.º 3
0
        public void CreatesStackWithParameters()
        {
            var stackName = "ProvisioningTest-CreatesStackWithParameters";

            SetUp(stackName);
            try
            {
                var deployer = new Deployer(_awsConfiguration);

                deployer.CreateStack(new StackTemplate
                {
                    StackName     = stackName,
                    TemplatePath  = CloudFormationTemplates.Path("example-parameters.template"),
                    ParameterPath = CloudFormationTemplates.Path("example-parameters.parameters")
                });

                var status = StackStatus.CREATE_IN_PROGRESS;
                while (status == StackStatus.CREATE_IN_PROGRESS)
                {
                    var stack =
                        _cloudFormationClient.DescribeStacks(new DescribeStacksRequest {
                        StackName = stackName
                    })
                        .Stacks.First();
                    status = stack.StackStatus;
                    if (status == StackStatus.CREATE_IN_PROGRESS)
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(10));
                    }
                }

                var vpcId =
                    _cloudFormationClient.DescribeStackResource(new DescribeStackResourceRequest
                {
                    LogicalResourceId = "vpc1",
                    StackName         = stackName
                }).StackResourceDetail.PhysicalResourceId;
                var vpc = _ec2Client.DescribeVpcs(new DescribeVpcsRequest {
                    VpcIds = new List <string> {
                        vpcId
                    }
                }).Vpcs.First();
                var vpcName = vpc.Tags.First(tag => tag.Key == "Name").Value;

                Assert.AreEqual(status, StackStatus.CREATE_COMPLETE);
                Assert.AreEqual("TestVpcName", vpcName);
            }
            finally
            {
                DeleteTestStack(stackName);
            }
        }
Ejemplo n.º 4
0
        public void CreatingStackCapturesOutputs()
        {
            var deployer = new Deployer(new AwsConfiguration
            {
                AwsEndpoint = TestConfiguration.AwsEndpoint,
                Credentials = new TestSuiteCredentials(),
                Bucket      = "aws-deployment-tools-tests"
            });
            var stack = deployer.CreateStack(new StackTemplate
            {
                StackName    = _stackName,
                TemplatePath = CloudFormationTemplates.Path("stack-outputs.template")
            });

            Assert.That(stack.Outputs["outputA"], Is.EqualTo("123"));
            Assert.That(stack.Outputs["outputB"], Is.EqualTo("456"));
        }
Ejemplo n.º 5
0
        public void DeletesExistingStack()
        {
            var stackName = "AwsToolsRemovalDeletesExistingStackTest";

            SetUp(stackName);

            var deployer = new Deployer(_awsConfiguration);

            deployer.CreateStack(new StackTemplate
            {
                StackName    = stackName,
                TemplatePath = CloudFormationTemplates.Path("example-basic-vpc.template")
            });

            deployer.DeleteStack(stackName);

            var status = StackStatus.DELETE_IN_PROGRESS;

            status = WaitForStackDeleted(status, stackName);

            Assert.AreEqual(StackStatus.DELETE_COMPLETE, status);
        }
Ejemplo n.º 6
0
        public void CreatesVirtualPrivateCloudWithWindowsMachines()
        {
            string stackName = "ProvisioningTest-CreatesVirtualPrivateCloudWithWindowsMachines";

            SetUp(stackName);

            try
            {
                var deployer = new Deployer(_awsConfiguration);

                deployer.CreateStack(new StackTemplate
                {
                    StackName    = stackName,
                    TemplatePath = CloudFormationTemplates.Path("example-windows-vpc.template")
                });

                var status = StackStatus.CREATE_IN_PROGRESS;
                while (status == StackStatus.CREATE_IN_PROGRESS)
                {
                    var stack =
                        _cloudFormationClient.DescribeStacks(new DescribeStacksRequest {
                        StackName = stackName
                    })
                        .Stacks.First();
                    status = stack.StackStatus;
                    if (status == StackStatus.CREATE_IN_PROGRESS)
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(10));
                    }
                }

                Assert.AreEqual(status, StackStatus.CREATE_COMPLETE);
            }
            finally
            {
                DeleteTestStack(stackName);
            }
        }
Ejemplo n.º 7
0
        public void EnsureStackExists()
        {
            if (_hasCreatedStack)
            {
                return;
            }

            _awsConfiguration = new AwsConfiguration
            {
                AssumeRoleTrustDocument = Roles.Path("code-deploy-trust.json"),
                IamRolePolicyDocument   = Roles.Path("code-deploy-policy.json"),
                Bucket      = "aws-deployment-tools-tests",
                RoleName    = "CodeDeployRole",
                AwsEndpoint = TestConfiguration.AwsEndpoint,
                Credentials = new TestSuiteCredentials()
            };

            _iamClient = new AmazonIdentityManagementServiceClient(
                new AmazonIdentityManagementServiceConfig
            {
                RegionEndpoint = _awsConfiguration.AwsEndpoint,
                ProxyHost      = _awsConfiguration.ProxyHost,
                ProxyPort      = _awsConfiguration.ProxyPort
            });

            DeletePreviousTestStack();

            _deployer = new Deployer(_awsConfiguration);

            _stack = _deployer.CreateStack(new StackTemplate
            {
                StackName    = StackName,
                TemplatePath = CloudFormationTemplates.Path("example-windows-vpc-autoscaling-group.template")
            });
            _hasCreatedStack = true;
        }