public static List <Stack> GetActiveStacks() { AmazonCloudFormationClient client = new AmazonCloudFormationClient(RegionEndpoint.USEast1); ListStacksRequest listStacksRequest = new ListStacksRequest(); listStacksRequest.StackStatusFilter.Add("CREATE_IN_PROGRESS"); listStacksRequest.StackStatusFilter.Add("CREATE_FAILED"); listStacksRequest.StackStatusFilter.Add("CREATE_COMPLETE"); listStacksRequest.StackStatusFilter.Add("ROLLBACK_IN_PROGRESS"); listStacksRequest.StackStatusFilter.Add("ROLLBACK_FAILED"); listStacksRequest.StackStatusFilter.Add("ROLLBACK_COMPLETE"); listStacksRequest.StackStatusFilter.Add("DELETE_IN_PROGRESS"); listStacksRequest.StackStatusFilter.Add("DELETE_FAILED"); listStacksRequest.StackStatusFilter.Add("UPDATE_IN_PROGRESS"); listStacksRequest.StackStatusFilter.Add("UPDATE_COMPLETE_CLEANUP_IN_PROGRESS"); listStacksRequest.StackStatusFilter.Add("UPDATE_COMPLETE"); listStacksRequest.StackStatusFilter.Add("UPDATE_ROLLBACK_IN_PROGRESS"); listStacksRequest.StackStatusFilter.Add("UPDATE_ROLLBACK_FAILED"); listStacksRequest.StackStatusFilter.Add("UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS"); listStacksRequest.StackStatusFilter.Add("UPDATE_ROLLBACK_COMPLETE"); var response = client.ListStacks(listStacksRequest); List <Stack> returnValue = new List <Stack>(); response.StackSummaries.ForEach(s => returnValue.Add(new Stack(s.StackName))); return(returnValue); }
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); ListStackResourcesResponse resp = new ListStackResourcesResponse(); do { ListStackResourcesRequest req = new ListStackResourcesRequest { NextToken = resp.NextToken }; resp = client.ListStackResources(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.StackResourceSummaries) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
public static async Task Main(string[] args) { Stack stack = new Stack("test"); var cfg = stack.LaunchConfiguration("lc") .Metadata.Init.Config("config1"); cfg.Command("print1").Command("print \"hello world\""); string json = stack.ToJson(); AmazonCloudFormationClient client = new AmazonCloudFormationClient(RegionEndpoint.EUWest1); try { var result = await client.ValidateTemplateAsync(new ValidateTemplateRequest() { TemplateBody = json }); Console.WriteLine("CF format OK"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } Console.ReadKey(); }
public static async Task <StackStatus> GetStackStatus(string stackName) { var client = new AmazonCloudFormationClient(); DescribeStacksResponse describeStacksResponse = await client.DescribeStacksAsync(new DescribeStacksRequest { StackName = stackName }); return(describeStacksResponse.Stacks.First().StackStatus); }
public static CreateStackResponse CreateStack(string templateUri, string awsCredentialsAccessKey, string awsCredentialsSecretKey) { AmazonCloudFormationClient client = new AmazonCloudFormationClient(RegionEndpoint.USEast1); CreateStackRequest request = new CreateStackRequest { DisableRollback = true, TemplateURL = templateUri, StackName = new Uri(templateUri).Segments[new Uri(templateUri).Segments.Length - 1].Replace(".template", string.Empty).Replace('.', '-'), }; request.Capabilities.Add("CAPABILITY_IAM"); try { var response = client.CreateStack(request); if (response.HttpStatusCode < HttpStatusCode.OK || response.HttpStatusCode >= HttpStatusCode.MultipleChoices) { throw new Exception(response.ToString()); } return(response); } catch (Amazon.Runtime.Internal.HttpErrorResponseException ex) { throw new Exception(ex.Message); } }
static void WaitForStack(AmazonCloudFormationClient amazonCloudFormationClient, string stackName) { var stack = GetStack(amazonCloudFormationClient, stackName); var status = stack.StackStatus; string statusReason = null; while (status == StackStatus.CREATE_IN_PROGRESS || status == StackStatus.UPDATE_IN_PROGRESS || status == StackStatus.UPDATE_ROLLBACK_IN_PROGRESS || status == StackStatus.ROLLBACK_IN_PROGRESS || status == StackStatus.UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS || status == StackStatus.UPDATE_COMPLETE_CLEANUP_IN_PROGRESS || status == StackStatus.REVIEW_IN_PROGRESS) { stack = GetStack(amazonCloudFormationClient, stackName); status = stack.StackStatus; statusReason = stack.StackStatusReason; Log.Info(Program.LogPath, $"Stack '{stackName}' status is {status} because {statusReason} at {DateTime.Now.TimeOfDay}"); if (status == StackStatus.CREATE_IN_PROGRESS || status == StackStatus.UPDATE_IN_PROGRESS) { Thread.Sleep(TimeSpan.FromSeconds(10)); } } if (status != StackStatus.CREATE_COMPLETE && status != StackStatus.UPDATE_COMPLETE && status != StackStatus.ROLLBACK_COMPLETE && status != StackStatus.UPDATE_ROLLBACK_COMPLETE) { var eventsResponse = amazonCloudFormationClient.DescribeStackEvents(new DescribeStackEventsRequest { StackName = stackName }); throw new FailedToCreateStackException(stackName, RegionEndpoint.GetBySystemName(Program.AWSLambdaToolsJsonConfig.Region), status.Value, statusReason, eventsResponse.StackEvents); } }
public static async Task <string> GetStackOutputValue(string stackName, string key) { var client = new AmazonCloudFormationClient(); DescribeStacksResponse describeStacksResponse = await client.DescribeStacksAsync(new DescribeStacksRequest { StackName = stackName }); return(describeStacksResponse.Stacks.First().Outputs.First(output => output.OutputKey == key).OutputValue); }
public CloudFormationHelper(string profile, string region, string color) : base(profile, region, color) { //client = new AmazonRDSClient(credentials, AwsCommon.GetRetionEndpoint(region)); client = new AmazonCloudFormationClient( CredentiaslManager.GetCredential(profile), AwsCommon.GetRetionEndpoint(region)); }
public static void DeleteStack(RegionEndpoint awsEndpoint, string stackName) { var codeDeployClient = new AmazonCodeDeployClient(awsEndpoint); var apps = codeDeployClient.ListApplications().Applications.Where(name => name.StartsWith("HelloWorld")); foreach (var app in apps) { codeDeployClient.DeleteApplication(new DeleteApplicationRequest { ApplicationName = app }); } var cloudFormationClient = new AmazonCloudFormationClient(awsEndpoint); try { cloudFormationClient.DeleteStack(new DeleteStackRequest { StackName = stackName }); var testStackStatus = StackStatus.DELETE_IN_PROGRESS; while (testStackStatus == StackStatus.DELETE_IN_PROGRESS) { Thread.Sleep(TimeSpan.FromSeconds(10)); var stacksStatus = cloudFormationClient.DescribeStacks(new DescribeStacksRequest { StackName = stackName }); testStackStatus = stacksStatus.Stacks.First(s => s.StackName == stackName).StackStatus; } } catch (AmazonCloudFormationException) { } }
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 WebAppWithDockerFileTests() { _httpHelper = new HttpHelper(); var cloudFormationClient = new AmazonCloudFormationClient(); _cloudFormationHelper = new CloudFormationHelper(cloudFormationClient); var ecsClient = new AmazonECSClient(); _ecsHelper = new ECSHelper(ecsClient); var serviceCollection = new ServiceCollection(); serviceCollection.AddCustomServices(); serviceCollection.AddTestServices(); var serviceProvider = serviceCollection.BuildServiceProvider(); _app = serviceProvider.GetService <App>(); Assert.NotNull(_app); _interactiveService = serviceProvider.GetService <InMemoryInteractiveService>(); Assert.NotNull(_interactiveService); _testAppManager = new TestAppManager(); }
public AwsStackConfigurationProvider(string stack, AWSCredentials credential, RegionEndpoint region = null) { _stack = stack; _client = region == null ? new AmazonCloudFormationClient(credential): new AmazonCloudFormationClient(credential, region); }
public async Task DeployStepFunctionWithTemplateSubstitution() { var cfClient = new AmazonCloudFormationClient(RegionEndpoint.USEast2); var s3Client = new AmazonS3Client(RegionEndpoint.USEast2); var bucketName = "deploy-step-functions-" + DateTime.Now.Ticks; await s3Client.PutBucketAsync(bucketName); try { var assembly = this.GetType().GetTypeInfo().Assembly; var fullPath = Path.GetFullPath(Path.GetDirectoryName(assembly.Location) + "../../../../../TemplateSubstitutionTestProjects/StateMachineDefinitionStringTest"); var command = new DeployServerlessCommand(new TestToolLogger(), fullPath, new string[0]); command.Configuration = "Release"; command.TargetFramework = "netcoreapp1.0"; command.StackName = "DeployStepFunctionWithTemplateSubstitution-" + DateTime.Now.Ticks; command.S3Bucket = bucketName; command.WaitForStackToComplete = true; command.TemplateParameters = new Dictionary <string, string> { { "NonExisting", "Parameter" } }; var created = await command.ExecuteAsync(); try { Assert.True(created); var describeResponse = await cfClient.DescribeStacksAsync(new DescribeStacksRequest { StackName = command.StackName }); Assert.Equal(StackStatus.CREATE_COMPLETE, describeResponse.Stacks[0].StackStatus); } finally { if (created) { try { var deleteCommand = new DeleteServerlessCommand(new ConsoleToolLogger(), fullPath, new string[0]); deleteCommand.StackName = command.StackName; await deleteCommand.ExecuteAsync(); } catch { // Bury exception because we don't want to lose any exceptions during the deploy stage. } } } } finally { await AmazonS3Util.DeleteS3BucketWithObjectsAsync(s3Client, bucketName); } }
public DataPipelineTest(string stackName = "chapter6-data-pipeline") { if (string.IsNullOrEmpty(stackName)) { throw new ArgumentNullException(nameof(stackName)); } _stackName = stackName; _cloudFormationClient = new AmazonCloudFormationClient(); }
static void TestParentChildTemplates() { string bucket_Name = QSS3BucketName; string templateName = QSS3KeyPrefix + TdwUtils.cfClassPathParentSubnet.Replace("tdw_cf_template\\", ""); string stack_name = templateName.Replace("-", ""); stack_name = stack_name.Replace(".template", ""); string dataPath = null; byte[] dataBytes = null; PutObjectRequest request = null; PutObjectResponse response = null; AmazonS3Client s3Client = new AmazonS3Client(); bucket_Name = TdwUtils.CreateBucket(s3Client, QSS3BucketName); GetObjectRequest getObjectRequest = new GetObjectRequest { BucketName = bucket_Name, Key = templateName, }; string data = null; using (GetObjectResponse getObjectResponse = s3Client.GetObject(getObjectRequest)) { using (var stream = getObjectResponse.ResponseStream) using (var reader = new StreamReader(stream)) { data = reader.ReadToEnd(); } } Amazon.CloudFormation.AmazonCloudFormationClient cfClient = new AmazonCloudFormationClient(); try { DeleteStackRequest deleteRequest = new DeleteStackRequest() { StackName = stack_name }; cfClient.DeleteStack(deleteRequest); } catch (Exception ex) { ex = null; } List <string> CfCapabilities = new List <string>(); CfCapabilities.Add("CAPABILITY_IAM"); CreateStackRequest stackRequest = new CreateStackRequest() { StackName = stack_name, TemplateBody = data, Capabilities = CfCapabilities }; CreateStackResponse stackResponse = cfClient.CreateStack(stackRequest); }
async Task ValidateCloudFormation(Func <AmazonCloudFormationClient, Task> execute) { var credentials = new BasicAWSCredentials(ExternalVariables.Get(ExternalVariable.AwsAcessKey), ExternalVariables.Get(ExternalVariable.AwsSecretKey)); var config = new AmazonCloudFormationConfig { AllowAutoRedirect = true, RegionEndpoint = RegionEndpoint.GetBySystemName(region) }; using (var client = new AmazonCloudFormationClient(credentials, config)) { await execute(client); } }
ListStacksResponse GetStackSummaries(string nextToken = null) { ListStacksResponse result = null; using (AmazonCloudFormationClient CFclient = new AmazonCloudFormationClient()) { ListStacksRequest rq = new ListStacksRequest(); rq.NextToken = nextToken; result = CFclient.ListStacks(rq); } return(result); }
public async Task <CPSCloudResourceSummaryModel> GetSummary(string organization, string project, string service, List <string> environments, string feature, CPSAuthCredentialModel authCredential) { CPSCloudResourceSummaryModel summaryModel = new CPSCloudResourceSummaryModel(); try { AmazonCloudFormationClient client = new AmazonCloudFormationClient(authCredential.AccessId, authCredential.AccessSecret, Amazon.RegionEndpoint.GetBySystemName(authCredential.AccessRegion)); foreach (var environmentName in environments) { string stackName = $"{organization}{project}{service}{environmentName}{feature}".ToLower(); try { var stacksResponse = await client.DescribeStacksAsync(new DescribeStacksRequest() { StackName = stackName }); if (stacksResponse.HttpStatusCode == System.Net.HttpStatusCode.OK) { var stack = stacksResponse.Stacks.FirstOrDefault(); if (stack != null) { var environment = summaryModel.AddEnvironment(environmentName, stack.StackStatus.Value); if (stack.Outputs != null) { foreach (var output in stack.Outputs) { string key = output.OutputKey.First().ToString().ToUpper() + output.OutputKey.Substring(1); environment.AddProperty(key, output.OutputValue); } } } else { summaryModel.AddEnvironment(environmentName, "NO_DEPLOYED_YET"); } } } catch (System.Exception ex) { summaryModel.AddEnvironment(environmentName, "NO_DEPLOYED_YET"); } } } catch (System.Exception) { } return(summaryModel); }
public static async Task CreateCloudformationStack(string stackName, string templatePath, List <Parameter> parameters, bool disableRollBack = false) { var client = new AmazonCloudFormationClient(); await client.CreateStackAsync(new CreateStackRequest { StackName = stackName, TemplateBody = File.ReadAllText(templatePath), Parameters = parameters, Capabilities = DefaultCapabilities, DisableRollback = disableRollBack }); await WaitForStackStatus(stackName, StackStatus.CREATE_COMPLETE); }
protected IAmazonCloudFormation CreateClient(AWSCredentials credentials, RegionEndpoint region) { var config = new AmazonCloudFormationConfig { RegionEndpoint = region }; Amazon.PowerShell.Utils.Common.PopulateConfig(this, config); this.CustomizeClientConfig(config); var client = new AmazonCloudFormationClient(credentials, config); client.BeforeRequestEvent += RequestEventHandler; client.AfterResponseEvent += ResponseEventHandler; return(client); }
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); }
public async Task <bool> ValidateCredentials(string accessId, string accessName, string accessSecret, string accessAppId, string accessAppSecret, string accessDirectory, string accessRegion) { try { AmazonCloudFormationClient client = new AmazonCloudFormationClient(accessId, accessSecret, Amazon.RegionEndpoint.GetBySystemName(accessRegion)); var stacks = await client.ListStacksAsync(); return(true); } catch (Exception ex) { return(false); } }
private IAmazonCloudFormation CreateCloudFormationClient() { // If the client is being created then the LambdaTools // is not being invoked from the VS toolkit. The toolkit will pass in // its configured client. SetUserAgentString(); AmazonCloudFormationConfig config = new AmazonCloudFormationConfig(); config.RegionEndpoint = DetermineAWSRegion(); var client = new AmazonCloudFormationClient(DetermineAWSCredentials(), config); return(client); }
/// <summary> /// Checks if the CloudFormation template is valid using the AWS API /// </summary> /// <param name="template"></param> /// <returns>bool</returns> public static bool IsTemplateValid(string jsonString, ref AmazonCloudFormationClient cfClient) { bool result = false; if (jsonString != null || jsonString != "") { ValidateTemplateRequest validateRequest = new ValidateTemplateRequest(); validateRequest.TemplateBody = jsonString; ValidateTemplateResponse validateResponse = cfClient.ValidateTemplate(validateRequest); if (validateResponse.HttpStatusCode == HttpStatusCode.OK) { result = true; } } return(result); }
public async Task DeleteService(string name, CPSAuthModel auth) { try { AmazonCloudFormationClient cloudFormationClient = new AmazonCloudFormationClient(auth.AccessId, auth.AccessSecret, Amazon.RegionEndpoint.GetBySystemName(auth.AccessRegion)); var responseCloudFormationClient = await cloudFormationClient.DeleteStackAsync(new DeleteStackRequest() { StackName = name.ToLower() }); string bucketName = name.ToLower(); AmazonS3Client s3Client = new AmazonS3Client(auth.AccessId, auth.AccessSecret, Amazon.RegionEndpoint.GetBySystemName(auth.AccessRegion)); ListObjectsResponse response = await s3Client.ListObjectsAsync(new ListObjectsRequest() { BucketName = bucketName }); if (response.S3Objects.Count > 0) { List <KeyVersion> keys = response.S3Objects.Select(obj => new KeyVersion() { Key = obj.Key }).ToList(); DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest { BucketName = bucketName, Objects = keys }; await s3Client.DeleteObjectsAsync(deleteObjectsRequest); } //Delete Bucket DeleteBucketRequest request = new DeleteBucketRequest { BucketName = bucketName }; await s3Client.DeleteBucketAsync(request); } catch (Exception ex) { TelemetryClientManager.Instance.TrackException(ex); Console.WriteLine(ex.ToString()); } }
static void WaitForChangeSet(AmazonCloudFormationClient amazonCloudFormationClient, string stackName, string changeSetName) { var status = ChangeSetStatus.CREATE_PENDING; while (status != ChangeSetStatus.CREATE_COMPLETE) { var changeSet = amazonCloudFormationClient.DescribeChangeSet(new DescribeChangeSetRequest { StackName = stackName, ChangeSetName = changeSetName }); status = changeSet.Status; Log.Info(Program.LogPath, $"Changeset '{changeSetName}' (In Stack : {stackName}) status is {changeSet.Status} at {DateTime.Now.TimeOfDay}"); if (status != ChangeSetStatus.CREATE_COMPLETE) { Thread.Sleep(TimeSpan.FromSeconds(10)); } } }
public ServerModeTests() { var cloudFormationClient = new AmazonCloudFormationClient(Amazon.RegionEndpoint.USWest2); _cloudFormationHelper = new CloudFormationHelper(cloudFormationClient); var serviceCollection = new ServiceCollection(); serviceCollection.AddCustomServices(); serviceCollection.AddTestServices(); _serviceProvider = serviceCollection.BuildServiceProvider(); _awsRegion = "us-west-2"; _testAppManager = new TestAppManager(); }
private IAmazonCloudFormation CreateCloudFormationClient() { // If the CloudFormation client is being created then the LambdaTools // is not being invoked from the VS toolkit. The toolkit will pass in // its configured CloudFormation client. SetUserAgentString(); AmazonCloudFormationConfig config = new AmazonCloudFormationConfig(); var regionName = this.GetStringValueOrDefault(this.Region, DefinedCommandOptions.ARGUMENT_AWS_REGION, true); config.RegionEndpoint = RegionEndpoint.GetBySystemName(regionName); var client = new AmazonCloudFormationClient(DetermineAWSCredentials(), config); return(client); }
public async Task DeployMultiProject() { var assembly = this.GetType().GetTypeInfo().Assembly; var fullPath = Path.GetFullPath(Path.GetDirectoryName(assembly.Location) + "../../../../../../testapps/MPDeployServerless/CurrentDirectoryTest"); var command = new DeployServerlessCommand(new TestToolLogger(_testOutputHelper), fullPath, new string[] { }); command.StackName = "DeployMultiProject-" + DateTime.Now.Ticks; command.S3Bucket = this._testFixture.Bucket; command.WaitForStackToComplete = true; command.DisableInteractive = true; command.ProjectLocation = fullPath; var created = await command.ExecuteAsync(); try { Assert.True(created); using (var cfClient = new AmazonCloudFormationClient(RegionEndpoint.USEast1)) { var stack = (await cfClient.DescribeStacksAsync(new DescribeStacksRequest { StackName = command.StackName })).Stacks[0]; var apiUrl = stack.Outputs.FirstOrDefault(x => string.Equals(x.OutputKey, "ApiURL"))?.OutputValue; Assert.NotNull(apiUrl); Assert.Equal("CurrentProjectTest", await GetRestContent(apiUrl, "current")); Assert.Equal("SecondCurrentProjectTest", await GetRestContent(apiUrl, "current2")); Assert.Equal("SiblingProjectTest", await GetRestContent(apiUrl, "sibling")); Assert.Equal("SingleFileNodeFunction", await GetRestContent(apiUrl, "singlenode")); Assert.Equal("DirectoryNodeFunction", await GetRestContent(apiUrl, "directorynode")); } } finally { if (created) { var deleteCommand = new DeleteServerlessCommand(new TestToolLogger(_testOutputHelper), fullPath, new string[0]); deleteCommand.StackName = command.StackName; await deleteCommand.ExecuteAsync(); } } }
//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); }