public void CreateStack(string stackName, string configurationTemplate) { var key = string.Format("{0}-{1}", stackName, Guid.NewGuid()); // The configuration template is trimmed of the trailing slash because the slash is necessary // creating a lifecycle rule (which was actually the purpose of the convention in the first place) // but will result in a blank-named folder when uploading a file to AWS. var prefixedBucket = string.Format("{0}/{1}", _bucket, Conventions.ConfigurationTemplateBucketPrefix.TrimEnd(new [] { '/' })); var url = _storageService.UploadFile(prefixedBucket, key, Encoding.UTF8.GetBytes(configurationTemplate)); var request = new CreateStackRequest { StackName = stackName, TemplateURL = url, DisableRollback = true }; _cloudFormationClient.CreateStack(request); }
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; } }