Esempio n. 1
0
        public async Task DeployCallsCreateStackIfNotExists()
        {
            cloudformationClient
            .DescribeStacksAsync(Arg.Is <DescribeStacksRequest>(req =>
                                                                req.StackName == stackName
                                                                ))
            .Returns(new DescribeStacksResponse
            {
                Stacks = new List <Stack>()
            });

            cloudformationClient
            .CreateStackAsync(Arg.Any <CreateStackRequest>())
            .Returns(new CreateStackResponse {
            });

            var cloudformationFactory = Substitute.For <IAwsFactory <IAmazonCloudFormation> >();
            var logger        = Substitute.For <ILogger <DeployStackFacade> >();
            var stackDeployer = new DeployStackFacade(cloudformationFactory, logger);

            cloudformationFactory.Create().Returns(cloudformationClient);

            await stackDeployer.Deploy(new DeployStackContext
            {
                StackName          = stackName,
                Template           = exampleTemplate,
                NotificationArn    = notificationArn,
                Tags               = tags,
                PassRoleArn        = roleArn,
                Parameters         = parameters,
                ClientRequestToken = clientRequestToken
            });

            await cloudformationClient
            .Received()
            .CreateStackAsync(Arg.Is <CreateStackRequest>(req =>
                                                          req.StackName == stackName &&
                                                          req.TemplateBody == exampleTemplate &&
                                                          req.RoleARN == roleArn &&
                                                          req.NotificationARNs.Contains(notificationArn) &&
                                                          tags.All(req.Tags.Contains) &&
                                                          req.ClientRequestToken == clientRequestToken &&
                                                          req.Parameters.Any(parameter => parameter.ParameterKey == "GithubToken" && parameter.ParameterValue == "this is definitely the token") &&
                                                          req.Capabilities.Any(capability => capability == "CAPABILITY_IAM") &&
                                                          req.Capabilities.Any(capability => capability == "CAPABILITY_NAMED_IAM") &&
                                                          req.OnFailure == DELETE
                                                          ));
        }
Esempio n. 2
0
 private Amazon.CloudFormation.Model.CreateStackResponse CallAWSServiceOperation(IAmazonCloudFormation client, Amazon.CloudFormation.Model.CreateStackRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS CloudFormation", "CreateStack");
     try
     {
         #if DESKTOP
         return(client.CreateStack(request));
         #elif CORECLR
         return(client.CreateStackAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
Esempio n. 3
0
        private Task Commit(CreateStackRequest r)
        {
            Func <Task> f = () => _cloudformation.CreateStackAsync(r);

            return(Commit(f, r.StackName, StackStatus.CREATE_COMPLETE));
        }