/// <summary> /// <para> Returns the description for the specified stack; if no stack name was specified, then it returns the description for all the stacks /// created. </para> /// </summary> /// /// <param name="describeStacksRequest">Container for the necessary parameters to execute the DescribeStacks service method on /// AmazonCloudFormation.</param> /// /// <returns>The response from the DescribeStacks service method, as returned by AmazonCloudFormation.</returns> /// public DescribeStacksResponse DescribeStacks(DescribeStacksRequest describeStacksRequest) { IRequest <DescribeStacksRequest> request = new DescribeStacksRequestMarshaller().Marshall(describeStacksRequest); DescribeStacksResponse response = Invoke <DescribeStacksRequest, DescribeStacksResponse> (request, this.signer, DescribeStacksResponseUnmarshaller.GetInstance()); return(response); }
internal static bool IsStackInState(IAmazonCloudFormation client, string stackName, HashSet <StackStatus> desiredStates, bool throwOnError) { try { var request = new DescribeStacksRequest { StackName = stackName }; #if DESKTOP var response = client.DescribeStacks(request); #elif CORECLR var response = client.DescribeStacksAsync(request).GetAwaiter().GetResult(); #else #error "Unknown build edition" #endif return(IsStackInState(response.Stacks[0].StackStatus, desiredStates)); } catch (Exception exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } if (throwOnError) { throw; } } return(false); }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; var request = new DescribeStacksRequest { StackName = cmdletContext.StackName }; CmdletOutput output; var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); var stack = response.Stacks.FirstOrDefault(); WriteVerbose("DescribeStacks query on stack yielded current status " + stack.StackStatus); output = new CmdletOutput { PipelineOutput = stack, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return(output); }
/// <summary> /// Initiates the asynchronous execution of the DescribeStacks operation. /// <seealso cref="Amazon.CloudFormation.IAmazonCloudFormation.DescribeStacks"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DescribeStacks operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <DescribeStacksResponse> DescribeStacksAsync(DescribeStacksRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new DescribeStacksRequestMarshaller(); var unmarshaller = DescribeStacksResponseUnmarshaller.GetInstance(); return(Invoke <IRequest, DescribeStacksRequest, DescribeStacksResponse>(request, marshaller, unmarshaller, signer, cancellationToken)); }
public FoundationTemplateUtil(Amazon.Runtime.AWSCredentials credentials) { //IAmazonCloudFormation stackbuilder = new AmazonCloudFormationClient(credentials); IAmazonCloudFormation stackbuilder = new AmazonCloudFormationClient(); AmazonCloudFormationRequest request = new DescribeStacksRequest(); var response = stackbuilder.DescribeStacks(new DescribeStacksRequest()); foreach (var stack in response.Stacks) { Console.WriteLine("Stack: {0}", stack.StackName); Console.WriteLine(" Status: {0}", stack.StackStatus); Console.WriteLine(" Created: {0}", stack.CreationTime); var ps = stack.Parameters; if (ps.Any()) { Console.WriteLine(" Parameters:"); foreach (var p in ps) { Console.WriteLine(" {0} = {1}", p.ParameterKey, p.ParameterValue); } } } //AWSRegion euWest1 = AWSRegion.SetRegionFromName(RegionEndpoint.EUWest1); Console.WriteLine("==========================================="); Console.WriteLine("Getting Started with AWS CloudFormation"); Console.WriteLine("===========================================\n"); String stackName = "CloudFormationSampleStack"; String logicalResourceName = "SampleNotificationTopic"; //C:\Bitbucket\Analytics\MetaDataStore\F2B\main-bastion-json.template\main-bastion-json.template try { // Create a stack CreateStackRequest createRequest = new CreateStackRequest(); createRequest.StackName = stackName; //createRequest.StackPolicyBody = ; //createRequest. //Clou //createRequest.StackPolicyBody = convertStreamToString(CloudFormationSample.class.getResourceAsStream("CloudFormationSample.template")); //Console.WriteLine("Creating a stack called " + createRequest.getStackName() + "."); //stackbuilder.createStack(createRequest); //// Wait for stack to be created //// Note that you could use SNS notifications on the CreateStack call to track the progress of the stack creation //Console.WriteLine("Stack creation completed, the stack " + stackName + " completed with " + waitForCompletion(stackbuilder, stackName); } catch { } }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonCloudFormationConfig config = new AmazonCloudFormationConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonCloudFormationClient client = new AmazonCloudFormationClient(creds, config); DescribeStacksResponse resp = new DescribeStacksResponse(); do { DescribeStacksRequest req = new DescribeStacksRequest { NextToken = resp.NextToken }; resp = client.DescribeStacks(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Stacks) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
internal DescribeStacksResponse DescribeStacks(DescribeStacksRequest request) { var marshaller = new DescribeStacksRequestMarshaller(); var unmarshaller = DescribeStacksResponseUnmarshaller.Instance; return(Invoke <DescribeStacksRequest, DescribeStacksResponse>(request, marshaller, unmarshaller)); }
/// <summary> /// Initiates the asynchronous execution of the DescribeStacks operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DescribeStacks operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <DescribeStacksResponse> DescribeStacksAsync(DescribeStacksRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new DescribeStacksRequestMarshaller(); var unmarshaller = DescribeStacksResponseUnmarshaller.Instance; return(InvokeAsync <DescribeStacksRequest, DescribeStacksResponse>(request, marshaller, unmarshaller, cancellationToken)); }
public async Task <string> DeleteStack(string stackName, AsyncCallback callBack) { var getRequest = new DescribeStacksRequest() { StackName = stackName }; var request = new DeleteStackRequest() { StackName = stackName }; var response = await client.DeleteStackAsync(request); await Task.Delay(1000); callBack(null); if (response.HttpStatusCode != System.Net.HttpStatusCode.OK) { return(response.HttpStatusCode.ToString()); } // client.describestack while (true) { await Task.Delay(5000); try { var getResponse = await client.DescribeStacksAsync(getRequest); if (getResponse.Stacks == null || getResponse.Stacks.Count == 0) { return("DELETE_COMPLETE"); } var stack = getResponse.Stacks[0]; if (stack.StackStatus == StackStatus.DELETE_FAILED) { return("DELETE_FAILED"); } else if (stack.StackStatus == StackStatus.DELETE_COMPLETE) { return("DELETE_COMPLETE"); } else { continue; } } catch (Amazon.CloudFormation.AmazonCloudFormationException ex) { if (ex.Message.Trim() == $"Stack with id {stackName} does not exist".Trim()) { return("DELETE_COMPLETE"); } throw ex; } } }
public override void Load() { var request = new DescribeStacksRequest() { StackName = _stack }; var response = _client.DescribeStacksAsync(request).GetAwaiter().GetResult(); _outputs = response.Stacks.FirstOrDefault()?.Outputs.Where(t => !string.IsNullOrEmpty(t.ExportName)).ToList(); }
public static async Task CreateQueuesForEndpoint(string endpointName, string templatePath, TimeSpan?maxTimeToLive = null, string queueNamePrefix = null, bool includeRetries = false, string delayedDeliveryMethod = "Native") { using (var client = ClientFactory.CreateCloudFormationClient()) { var endpointNameWithPrefix = QueueNameHelper.GetSqsQueueName(endpointName, queueNamePrefix); var request = new CreateStackRequest { StackName = endpointNameWithPrefix, Parameters = new List <Parameter> { new Parameter { ParameterKey = "EndpointName", ParameterValue = endpointNameWithPrefix }, new Parameter { ParameterKey = "MaxTimeToLive", ParameterValue = Convert.ToInt32((maxTimeToLive ?? QueueCreationUtils.DefaultTimeToLive).TotalSeconds).ToString() }, new Parameter { ParameterKey = "IncludeRetries", ParameterValue = includeRetries.ToString() }, new Parameter { ParameterKey = "DelayedDeliveryMethod", ParameterValue = delayedDeliveryMethod }, }, TemplateBody = CloudFormationHelper.ConvertToValidJson(templatePath) }; await client.CreateStackAsync(request) .ConfigureAwait(false); var describeRequest = new DescribeStacksRequest { StackName = endpointNameWithPrefix }; StackStatus currentStatus = string.Empty; while (currentStatus != StackStatus.CREATE_COMPLETE) { var response = await client.DescribeStacksAsync(describeRequest) .ConfigureAwait(false); var stack = response.Stacks.SingleOrDefault(); currentStatus = stack?.StackStatus; await Task.Delay(1000); } } }
//--- Methods --- public async Task <IEnumerable <TierModuleDetails> > GetModuleDetailsAsync() { var prefix = Settings.TierPrefix; var stacks = new List <Stack>(); var request = new DescribeStacksRequest(); do { var response = await Settings.CfnClient.DescribeStacksAsync(request); stacks.AddRange(response.Stacks.Where(summary => { // NOTE (2019-06-18, bjorg): empty string output values are returned as `null` values; so we need to first detect // if an output key exists and then default to empty string when it is null to properly compare it. var lambdaSharpTier = summary.Outputs.FirstOrDefault(output => output.OutputKey == "LambdaSharpTier"); if (lambdaSharpTier == null) { return((prefix.Length > 0) && summary.StackName.StartsWith(prefix, StringComparison.Ordinal)); } return((lambdaSharpTier.OutputValue ?? "") == Settings.Tier); })); request.NextToken = response.NextToken; } while(request.NextToken != null); // convert stacks to module details return(stacks.Select(stack => new TierModuleDetails { StackName = stack.StackName, ModuleDeploymentName = stack.StackName.Substring(prefix.Length), StackStatus = stack.StackStatus.ToString(), DeploymentDate = (stack.LastUpdatedTime > stack.CreationTime) ? stack.LastUpdatedTime : stack.CreationTime, Stack = stack, ModuleReference = GetShortModuleReference(stack.GetModuleVersionText() ?? ""), CoreServices = stack.Parameters .FirstOrDefault(parameter => parameter.ParameterKey == "LambdaSharpCoreServices") ?.ParameterValue, HasDefaultSecretKeyParameter = stack.Parameters.Any(parameter => parameter.ParameterKey == "LambdaSharpCoreDefaultSecretKey"), IsRoot = stack.RootId == null }) .Where(module => !module.ModuleReference.StartsWith("LambdaSharp.Core", StringComparison.Ordinal)) .OrderBy(module => module.DeploymentDate) .ToList()); // local functions string GetShortModuleReference(string moduleReference) { if (moduleReference.EndsWith("@" + Settings.DeploymentBucketName, StringComparison.Ordinal)) { return(moduleReference.Substring(0, moduleReference.Length - Settings.DeploymentBucketName.Length - 1)); } return(moduleReference); } }
DescribeStacksResponse GetStack(string stackName, string nextToken = null) { DescribeStacksResponse result = null; using (AmazonCloudFormationClient CFclient = new AmazonCloudFormationClient()) { DescribeStacksRequest rq = new DescribeStacksRequest(); rq.StackName = stackName; rq.NextToken = nextToken; result = CFclient.DescribeStacks(rq); } return(result); }
/// <summary> /// <para>Returns the description for the specified stack; if no stack name was specified, then it returns the description for all the stacks /// created.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DescribeStacks service method on /// AmazonCloudFormation.</param> /// /// <returns>The response from the DescribeStacks service method, as returned by AmazonCloudFormation.</returns> public DescribeStacksResponse DescribeStacks(DescribeStacksRequest request) { var task = DescribeStacksAsync(request); try { return(task.Result); } catch (AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return(null); } }
/// <summary> /// 本接口(DescribeStacks)用于查询一个或多个资源栈的详细信息。 /// /// - 可以根据资源栈ID来查询感兴趣的资源栈信息 /// - 若参数为空,返回当前用户一定数量(Limit所指定的数量,默认为20)的资源栈 /// </summary> /// <param name="req"><see cref="DescribeStacksRequest"/></param> /// <returns><see cref="DescribeStacksResponse"/></returns> public DescribeStacksResponse DescribeStacksSync(DescribeStacksRequest req) { JsonResponseModel <DescribeStacksResponse> rsp = null; try { var strResp = this.InternalRequestSync(req, "DescribeStacks"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <DescribeStacksResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
protected override async Task <bool> PerformActionAsync() { const int TIMESTAMP_WIDTH = 20; const int STACK_NAME_WIDTH = 30; const int STACK_STATUS_WIDTH = 20; this.Logger.WriteLine("Name".PadRight(STACK_NAME_WIDTH) + " " + "Status".PadRight(STACK_STATUS_WIDTH) + " " + "Created".PadRight(TIMESTAMP_WIDTH) + " " + "Last Modifed".PadRight(TIMESTAMP_WIDTH) ); this.Logger.WriteLine($"{new string('-', STACK_NAME_WIDTH)} {new string('-', STACK_STATUS_WIDTH)} {new string('-', TIMESTAMP_WIDTH)} {new string('-', TIMESTAMP_WIDTH)}"); var request = new DescribeStacksRequest(); DescribeStacksResponse response = null; do { if (response != null) { request.NextToken = response.NextToken; } try { response = await this.CloudFormationClient.DescribeStacksAsync(request); } catch (Exception e) { throw new LambdaToolsException("Error listing AWS Serverless applications: " + e.Message, LambdaToolsException.LambdaErrorCode.CloudFormationDescribeStack, e); } foreach (var stack in response.Stacks) { if (stack.Tags.Any(x => string.Equals(x.Key, LambdaConstants.SERVERLESS_TAG_NAME))) { this.Logger.WriteLine( stack.StackName.PadRight(STACK_NAME_WIDTH) + " " + stack.StackStatus.ToString().PadRight(STACK_STATUS_WIDTH) + " " + stack.CreationTime.ToString("g").PadRight(STACK_STATUS_WIDTH) + " " + stack.LastUpdatedTime.ToString("g").PadRight(TIMESTAMP_WIDTH) ); } } } while (!string.IsNullOrEmpty(response.NextToken)); return(true); }
public async Task List(Settings settings) { // fetch all stacks var prefix = $"{settings.Tier}-"; var stacks = new List <Stack>(); var request = new DescribeStacksRequest(); do { var response = await settings.CfnClient.DescribeStacksAsync(request); stacks.AddRange(response.Stacks.Where(summary => summary.StackName.StartsWith(prefix, StringComparison.Ordinal))); request.NextToken = response.NextToken; } while(request.NextToken != null); // sort and format output if (stacks.Any()) { // gather summaries var summaries = stacks.Select(stack => new { ModuleName = stack.StackName.Substring(prefix.Length), StackStatus = stack.StackStatus.ToString(), Date = (stack.LastUpdatedTime > stack.CreationTime) ? stack.LastUpdatedTime : stack.CreationTime, Description = stack.Description, ModuleReference = stack.Outputs.FirstOrDefault(o => o.OutputKey == "Module")?.OutputValue }).OrderBy(summary => summary.Date).ToList(); var moduleNameWidth = summaries.Max(stack => stack.ModuleName.Length) + 4; var moduleReferenceWidth = summaries.Max(stack => stack.ModuleReference.Length + 4); var statusWidth = summaries.Max(stack => stack.StackStatus.Length) + 4; Console.WriteLine(); Console.WriteLine($"Found {stacks.Count:N0} modules for deployment tier '{settings.Tier}'"); Console.WriteLine(); Console.WriteLine($"{"NAME".PadRight(moduleNameWidth)}{"MODULE".PadRight(moduleReferenceWidth)}{"STATUS".PadRight(statusWidth)}DATE"); foreach (var summary in summaries) { Console.WriteLine($"{summary.ModuleName.PadRight(moduleNameWidth)}{summary.ModuleReference.PadRight(moduleReferenceWidth)}{summary.StackStatus.PadRight(statusWidth)}{summary.Date:yyyy-MM-dd HH:mm:ss}"); } } else { Console.WriteLine(); Console.WriteLine($"Found no modules for deployment tier '{settings.Tier}'"); } }
public async Task <DescribeStacksResponse> GetStackListPage(string nextToken = null) { DescribeStacksResponse response = null; if (nextToken != null) { var request = new DescribeStacksRequest() { NextToken = nextToken }; response = await client.DescribeStacksAsync(request); } else { response = await client.DescribeStacksAsync(); } return(response); }
private async Task <ChangeSetType> GetChangeSetType(DeployContext context, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); try { var request = new DescribeStacksRequest { StackName = context.StackName }; var response = await cloudformation.DescribeStacksAsync(request, cancellationToken); return(response.Stacks.Any() ? ChangeSetType.UPDATE : ChangeSetType.UPDATE); } catch { return(ChangeSetType.CREATE); } }
//private ListStackResourcesResponse ListStackResources(string stackName, AmazonCloudFormationClient cfClient, string nextToken = null) //{ // ListStackResourcesRequest lr = new ListStackResourcesRequest(); // lr.StackName = stackName; // lr.NextToken = nextToken; // ListStackResourcesResponse liveStackResources = cfClient.ListStackResources(lr); // return liveStackResources; //} private void ProcessLiveStack(string stackName, AmazonCloudFormationClient cfClient, AmazonEC2Client ec2Client, RichTextBox rtb, CFStack stack) { Dictionary <string, string> secGroupMap = new Dictionary <string, string>(); DescribeSecurityGroupsRequest secGroupRequestAll = new DescribeSecurityGroupsRequest(); //Get all security group Id's and cf logicalId's (if any) DescribeSecurityGroupsResponse secGroupResponseAll = ec2Client.DescribeSecurityGroups(secGroupRequestAll); foreach (SecurityGroup sg in secGroupResponseAll.SecurityGroups) { string value = "none"; foreach (Amazon.EC2.Model.Tag tag in sg.Tags) { if (tag.Key.Contains("aws:cloudformation:logical-id")) { value = tag.Value; } } secGroupMap.Add(sg.GroupId, value); } //Get Live Stack DescribeStacksRequest cfRequest = new DescribeStacksRequest(); cfRequest.StackName = stackName; DescribeStacksResponse liveStack = cfClient.DescribeStacks(cfRequest); stack.Description = liveStack.Stacks[0].Description; //Get Stack Resouces //Need to use ListStackResourcesRequest to be able to get stacks with more than 100 resources ListStackResourcesRequest lr = new ListStackResourcesRequest(); lr.StackName = stackName; ListStackResourcesResponse liveStackResources = cfClient.ListStackResources(lr); ProcessLiveStackResourcess(liveStackResources, stack, ec2Client, secGroupMap, stackName, cfClient); stack.Resources.Sort((a, b) => a.LogicalId.CompareTo(b.LogicalId)); WriteOutput(stack, rtb, source1_CB.Text, templateOrStack1_TB.Text); }
public static async Task CreateQueue(string queueName, string templatePath, TimeSpan?maxTimeToLive = null, string queueNamePrefix = null) { using (var client = ClientFactory.CreateCloudFormationClient()) { var sqsQueueName = QueueNameHelper.GetSqsQueueName(queueName, queueNamePrefix); var request = new CreateStackRequest { StackName = sqsQueueName, Parameters = new List <Parameter> { new Parameter { ParameterKey = "QueueName", ParameterValue = sqsQueueName }, new Parameter { ParameterKey = "MaxTimeToLive", ParameterValue = Convert.ToInt32((maxTimeToLive ?? DefaultTimeToLive).TotalSeconds).ToString() } }, TemplateBody = CloudFormationHelper.ConvertToValidJson(templatePath) }; await client.CreateStackAsync(request) .ConfigureAwait(false); var describeRequest = new DescribeStacksRequest { StackName = sqsQueueName }; StackStatus currentStatus = string.Empty; while (currentStatus != StackStatus.CREATE_COMPLETE) { var response = await client.DescribeStacksAsync(describeRequest) .ConfigureAwait(false); var stack = response.Stacks.SingleOrDefault(); currentStatus = stack?.StackStatus; await Task.Delay(1000); } } }
private async Task <bool> DoesStackExist(DeployStackContext context, IAmazonCloudFormation cloudformationClient) { try { // if this throws, assume the stack does not exist. var describeStacksRequest = new DescribeStacksRequest { StackName = context.StackName }; var describeStacksResponse = await cloudformationClient.DescribeStacksAsync(describeStacksRequest); logger.LogInformation($"Got describe stacks response: {Serialize(describeStacksResponse)}"); return(describeStacksResponse.Stacks.Count() != 0); } catch (Exception e) { logger.LogError($"Describe stacks failure: {e.Message}\n{e.StackTrace}"); } return(false); }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonOpsWorksConfig config = new AmazonOpsWorksConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonOpsWorksClient client = new AmazonOpsWorksClient(creds, config); DescribeStacksResponse resp = new DescribeStacksResponse(); DescribeStacksRequest req = new DescribeStacksRequest { }; resp = client.DescribeStacks(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Stacks) { AddObject(obj); } }
public static async Task <Stack> GetExistingStackAsync(IAmazonCloudFormation cloudformation, string stackName) { try { var request = new DescribeStacksRequest { StackName = stackName }; var response = await cloudformation.DescribeStacksAsync(request).ConfigureAwait(false); if (response.Stacks.Count != 1) { return(null); } return(response.Stacks[0]); } catch (AmazonCloudFormationException) { return(null); } }
public static async Task DeleteQueuesForEndpoint(string endpointName, string queueNamePrefix = null) { using (var client = ClientFactory.CreateCloudFormationClient()) { var endpointNameWithPrefix = QueueNameHelper.GetSqsQueueName(endpointName, queueNamePrefix); var request = new DeleteStackRequest { StackName = endpointNameWithPrefix, }; await client.DeleteStackAsync(request) .ConfigureAwait(false); var describeRequest = new DescribeStacksRequest { StackName = endpointNameWithPrefix }; StackStatus currentStatus = string.Empty; while (currentStatus != StackStatus.DELETE_IN_PROGRESS) // in progress is enough, no need to wait for completion { try { var response = await client.DescribeStacksAsync(describeRequest) .ConfigureAwait(false); var stack = response.Stacks.SingleOrDefault(); currentStatus = stack?.StackStatus; await Task.Delay(1000); } catch (AmazonCloudFormationException) { Console.WriteLine("Stack does not exist"); return; } } } }
public void CreateCloudFormationOnAWS() { try { Log.Info(Program.LogPath, "Creating Cloud Information"); var describeStacksRequest = new DescribeStacksRequest(); var changeSetName = "changeset" + Program.PostfixExpression; var changeSetType = ChangeSetType.CREATE; if (CheckStackIsExist(CloudFormationClient, StackName)) { changeSetType = ChangeSetType.UPDATE; } var createChangeSetRequest = new CreateChangeSetRequest { ChangeSetName = changeSetName, StackName = StackName, //TemplateBody = ServerlessTemplateBody, TemplateURL = TemplateUrl, ChangeSetType = changeSetType, Capabilities = new List <string> { "CAPABILITY_IAM" }, }; var createChangeSetResponse = CloudFormationClient.CreateChangeSet(createChangeSetRequest); WaitForChangeSet(CloudFormationClient, StackName, changeSetName); var executeChangeSetResponse = CloudFormationClient.ExecuteChangeSet(new ExecuteChangeSetRequest { ChangeSetName = changeSetName, StackName = StackName, }); WaitForStack(CloudFormationClient, StackName); var generatedStack = GetStack(CloudFormationClient, StackName); Log.Info(Program.LogPath, "Output URL is : " + generatedStack.Outputs.Find(x => x.OutputKey == "ApiURL").OutputValue); Log.Info(Program.LogPath, "Creating Cloud Information Finished"); } catch (Exception ex) { Log.Error(Program.LogPath.FullName, "Creating Cloud Information Error : " + ex.Message); } }
public Stack GetStack(string stackName) { var describeStacksRequest = new DescribeStacksRequest { StackName = stackName }; DescribeStacksResponse response; try { response = _cloudFormationClient.DescribeStacks(describeStacksRequest); } catch (AmazonCloudFormationException exception) { if (exception.Message.Contains(_nonExistenceMarker)) { return(null); } throw; } return(response.Stacks.FirstOrDefault()); }
public static async Task DeleteQueue(string queueName, string queueNamePrefix = null) { using (var client = ClientFactory.CreateCloudFormationClient()) { var sqsQueueName = QueueNameHelper.GetSqsQueueName(queueName, queueNamePrefix); var request = new DeleteStackRequest { StackName = sqsQueueName, }; await client.DeleteStackAsync(request) .ConfigureAwait(false); var describeRequest = new DescribeStacksRequest { StackName = sqsQueueName }; StackStatus currentStatus = string.Empty; while (currentStatus != StackStatus.DELETE_COMPLETE) { try { var response = await client.DescribeStacksAsync(describeRequest) .ConfigureAwait(false); var stack = response.Stacks.SingleOrDefault(); currentStatus = stack?.StackStatus; } catch (AmazonCloudFormationException) { Console.WriteLine("Stack does not exist"); return; } } } }
public DescribeStacksResponse DescribeStacks(DescribeStacksRequest request) { AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); return(DescribeStacksWithOptions(request, runtime)); }
public async Task <DescribeStacksResponse> DescribeStacksAsync(DescribeStacksRequest request) { AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); return(await DescribeStacksWithOptionsAsync(request, runtime)); }