AWS code-library documentation change
Summary
Significant restructuring of Auto Scaling code examples documentation. Removed 'Basics' section and associated code examples for creating groups/metrics collection. Added 'Actions' section focusing on AttachLoadBalancerTargetGroups method. Updated code examples and GitHub references.
Security assessment
The changes appear to be documentation restructuring and code example updates without any mention of security vulnerabilities, patches, or security-related configurations. The focus is on API usage examples rather than security controls.
Diff
diff --git a/code-library/latest/ug/csharp_3_auto-scaling_code_examples.md b/code-library/latest/ug/csharp_3_auto-scaling_code_examples.md index 04c27970b..29d61e263 100644 --- a//code-library/latest/ug/csharp_3_auto-scaling_code_examples.md +++ b//code-library/latest/ug/csharp_3_auto-scaling_code_examples.md @@ -5 +5 @@ -BasicsActionsScenarios +ActionsScenarios @@ -13,2 +12,0 @@ The following code examples show you how to perform actions and implement common -_Basics_ are code examples that show you how to perform the essential operations within a service. - @@ -21,52 +18,0 @@ Each example includes a link to the complete source code, where you can find ins -**Get started** - -The following code examples show how to get started using Auto Scaling. - -**SDK for .NET** - - -###### Note - -There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/AutoScaling#code-examples). - - - namespace AutoScalingActions; - - using Amazon.AutoScaling; - - public class HelloAutoScaling - { - /// <summary> - /// Hello Amazon EC2 Auto Scaling. List EC2 Auto Scaling groups. - /// </summary> - /// <param name="args"></param> - /// <returns>Async Task.</returns> - static async Task Main(string[] args) - { - var client = new AmazonAutoScalingClient(); - - Console.WriteLine("Welcome to Amazon EC2 Auto Scaling."); - Console.WriteLine("Let's get a description of your Auto Scaling groups."); - - var response = await client.DescribeAutoScalingGroupsAsync(); - - response.AutoScalingGroups.ForEach(autoScalingGroup => - { - Console.WriteLine($"{autoScalingGroup.AutoScalingGroupName}\t{autoScalingGroup.AvailabilityZones}"); - }); - - if (response.AutoScalingGroups.Count == 0) - { - Console.WriteLine("Sorry, you don't have any Amazon EC2 Auto Scaling groups."); - } - } - } - - - - - * For API details, see [DescribeAutoScalingGroups](https://docs.aws.amazon.com/goto/DotNetSDKV3/autoscaling-2011-01-01/DescribeAutoScalingGroups) in _AWS SDK for .NET API Reference_. - - - - @@ -75,2 +20,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - * Basics - @@ -84,17 +28 @@ There's more on GitHub. Find the complete example and learn how to set up and ru -## Basics - -The following code example shows how to: - - * Create an Amazon EC2 Auto Scaling group with a launch template and Availability Zones, and get information about running instances. - - * Enable Amazon CloudWatch metrics collection. - - * Update the group's desired capacity and wait for an instance to start. - - * Terminate an instance in the group. - - * List scaling activities that occur in response to user requests and capacity changes. - - * Get statistics for CloudWatch metrics, then clean up resources. - - +## Actions @@ -101,0 +30 @@ The following code example shows how to: +The following code example shows how to use `AttachLoadBalancerTargetGroups`. @@ -108,447 +37 @@ The following code example shows how to: -There's more on GitHub. Find the complete example and learn how to set up and run in the [AWS Code Examples Repository](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv3/AutoScaling#code-examples). - - - global using Amazon.AutoScaling; - global using Amazon.AutoScaling.Model; - global using Amazon.CloudWatch; - global using AutoScalingActions; - global using Microsoft.Extensions.DependencyInjection; - global using Microsoft.Extensions.Hosting; - global using Microsoft.Extensions.Logging; - global using Microsoft.Extensions.Logging.Console; - global using Microsoft.Extensions.Logging.Debug; - - - - using Amazon.EC2; - using Microsoft.Extensions.Configuration; - using Host = Microsoft.Extensions.Hosting.Host; - - namespace AutoScalingBasics; - - public class AutoScalingBasics - { - - static async Task Main(string[] args) - { - // Set up dependency injection for Amazon EC2 Auto Scaling, Amazon - // CloudWatch, and Amazon EC2. - using var host = Host.CreateDefaultBuilder(args) - .ConfigureLogging(logging => - logging.AddFilter("System", LogLevel.Debug) - .AddFilter<DebugLoggerProvider>("Microsoft", LogLevel.Information) - .AddFilter<ConsoleLoggerProvider>("Microsoft", LogLevel.Trace)) - .ConfigureServices((_, services) => - services.AddAWSService<IAmazonAutoScaling>() - .AddAWSService<IAmazonCloudWatch>() - .AddAWSService<IAmazonEC2>() - .AddTransient<AutoScalingWrapper>() - .AddTransient<CloudWatchWrapper>() - .AddTransient<EC2Wrapper>() - .AddTransient<UIWrapper>() - ) - .Build(); - - - var autoScalingWrapper = host.Services.GetRequiredService<AutoScalingWrapper>(); - var cloudWatchWrapper = host.Services.GetRequiredService<CloudWatchWrapper>(); - var ec2Wrapper = host.Services.GetRequiredService<EC2Wrapper>(); - var uiWrapper = host.Services.GetRequiredService<UIWrapper>(); - - var configuration = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("settings.json") // Load test settings from .json file. - .AddJsonFile("settings.local.json", - true) // Optionally load local settings. - .Build(); - - var imageId = configuration["ImageId"]; - var instanceType = configuration["InstanceType"]; - var launchTemplateName = configuration["LaunchTemplateName"]; - - launchTemplateName += Guid.NewGuid().ToString(); - - // The name of the Auto Scaling group. - var groupName = configuration["GroupName"]; - - uiWrapper.DisplayTitle("Auto Scaling Basics"); - uiWrapper.DisplayAutoScalingBasicsDescription(); - - // Create the launch template and save the template Id to use when deleting the - // launch template at the end of the application. - var launchTemplateId = await ec2Wrapper.CreateLaunchTemplateAsync(imageId!, instanceType!, launchTemplateName); - - // Confirm that the template was created by asking for a description of it. - await ec2Wrapper.DescribeLaunchTemplateAsync(launchTemplateName); - - uiWrapper.PressEnter(); - - var availabilityZones = await ec2Wrapper.ListAvailabilityZonesAsync(); - - Console.WriteLine($"Creating an Auto Scaling group named {groupName}."); - await autoScalingWrapper.CreateAutoScalingGroupAsync( - groupName!, - launchTemplateName, - availabilityZones.First().ZoneName); - - // Keep checking the details of the new group until its lifecycle state - // is "InService". - Console.WriteLine($"Waiting for the Auto Scaling group to be active."); - - List<AutoScalingInstanceDetails> instanceDetails; - - do - { - instanceDetails = await autoScalingWrapper.DescribeAutoScalingInstancesAsync(groupName!); - } - while (instanceDetails.Count <= 0); - - Console.WriteLine($"Auto scaling group {groupName} successfully created."); - Console.WriteLine($"{instanceDetails.Count} instances were created for the group."); - - // Display the details of the Auto Scaling group. - instanceDetails.ForEach(detail => - { - Console.WriteLine($"Group name: {detail.AutoScalingGroupName}"); - }); - - uiWrapper.PressEnter(); - - uiWrapper.DisplayTitle("Metrics collection"); - Console.WriteLine($"Enable metrics collection for {groupName}"); - await autoScalingWrapper.EnableMetricsCollectionAsync(groupName!);