From 684706797c1887a3905e2b996ffb1a169f937e55 Mon Sep 17 00:00:00 2001 From: Irene Smith <73654695+irenepsmith@users.noreply.github.com> Date: Tue, 4 Apr 2023 07:56:15 -0400 Subject: [PATCH 1/9] Dotnet AutoScaling updates (#4593) * Go unit and integration tests and Dockerfile (#4625) * Updating C# run instructions for WriteMe. (#4620) * Adding CODEOWNERS file (#4623) * Adding CODEOWNERS file * Update .github/CODEOWNERS.txt Co-authored-by: Liz Kellebrew-Davies <35241259+lkdavies@users.noreply.github.com> --------- Co-authored-by: Liz Kellebrew-Davies <35241259+lkdavies@users.noreply.github.com> * Dotnet top level solution (#4614) * Add initial solution file with all projects * Update top level solution. * Fixing up some test issues. * Fixing up failing tests and missing configurations. * Updates to failing autoscale tests * Updating for failing tests and setup. * Updating failing tests * Revert "Updates to failing autoscale tests" This reverts commit 511623c0708652543360f42a32e8e0997bdcbb12. * Updates to wording. * Wrote run_all_tests.bat batch file to run all tests on Windows. Wrote run_all_tests.sh Bash script, updated Dockerfile, and updated README. * Update gov2/README.md Co-authored-by: ford prior <108086978+ford-at-aws@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Liz Kellebrew-Davies <35241259+lkdavies@users.noreply.github.com> --------- Co-authored-by: Irene Smith <73654695+irenepsmith@users.noreply.github.com> Co-authored-by: Rachel Hagerman <110480692+rlhagerm@users.noreply.github.com> Co-authored-by: Liz Kellebrew-Davies <35241259+lkdavies@users.noreply.github.com> Co-authored-by: ford prior <108086978+ford-at-aws@users.noreply.github.com> * Updating AutoScaling examples All reviewer comments implemented. * Removed unnecessary using from Hello Auto Scaling. * Update services.yaml Removed extra blank line --------- Co-authored-by: Laren-AWS <57545972+Laren-AWS@users.noreply.github.com> Co-authored-by: Rachel Hagerman <110480692+rlhagerm@users.noreply.github.com> Co-authored-by: Liz Kellebrew-Davies <35241259+lkdavies@users.noreply.github.com> Co-authored-by: ford prior <108086978+ford-at-aws@users.noreply.github.com> --- .doc_gen/metadata/auto-scaling_metadata.yaml | 52 ++- .doc_gen/metadata/services.yaml | 4 +- .../Actions/AutoScalingActions.csproj | 20 + .../AutoScaling/Actions/AutoScalingWrapper.cs | 357 +++++++++++++++++ .../AutoScaling/Actions/CloudWatchWrapper.cs | 89 +++++ dotnetv3/AutoScaling/Actions/EC2Wrapper.cs | 98 +++++ .../AutoScaling/Actions/HelloAutoScaling.cs | 38 ++ dotnetv3/AutoScaling/AutoScalingExamples.sln | 48 +++ dotnetv3/AutoScaling/README.md | 142 +++++-- .../AutoScalingBasics/AutoScalingBasics.cs | 228 +++++++++++ .../AutoScalingBasics.csproj | 33 ++ .../Scenarios/AutoScalingBasics/UIWrapper.cs | 115 ++++++ .../Scenarios/AutoScalingBasics/Usings.cs | 16 + .../Scenarios/AutoScalingBasics/settings.json | 8 + .../AutoScaling/Tests/AutoScalingTests.csproj | 40 ++ .../Tests/AutoScalingWrapperTests.cs | 323 +++++++++++++++ dotnetv3/AutoScaling/Tests/Usings.cs | 21 + dotnetv3/AutoScaling/Tests/testsettings.json | 7 + .../AutoScale_Basics/AutoScale_Basics.sln | 31 -- .../AutoScale_Basics/AutoScaleBasics.cs | 256 ------------ .../AutoScale_Basics/AutoScaleMethods.cs | 377 ------------------ .../AutoScale_Basics/AutoScale_Basics.csproj | 21 - .../AutoScale_Basics/CloudWatchMethods.cs | 82 ---- .../AutoScale_Basics/EC2Methods.cs | 99 ----- .../AutoScale_Basics/GlobalUsings.cs | 10 - .../AutoScaleMethodsTests.cs | 109 ----- .../AutoScale_BasicsTests.csproj | 25 -- .../CloudWatchMethodsTests.cs | 35 -- .../AutoScale_BasicsTests/EC2MethodsTests.cs | 42 -- 29 files changed, 1591 insertions(+), 1135 deletions(-) create mode 100644 dotnetv3/AutoScaling/Actions/AutoScalingActions.csproj create mode 100644 dotnetv3/AutoScaling/Actions/AutoScalingWrapper.cs create mode 100644 dotnetv3/AutoScaling/Actions/CloudWatchWrapper.cs create mode 100644 dotnetv3/AutoScaling/Actions/EC2Wrapper.cs create mode 100644 dotnetv3/AutoScaling/Actions/HelloAutoScaling.cs create mode 100644 dotnetv3/AutoScaling/AutoScalingExamples.sln create mode 100644 dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.cs create mode 100644 dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.csproj create mode 100644 dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/UIWrapper.cs create mode 100644 dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/Usings.cs create mode 100644 dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/settings.json create mode 100644 dotnetv3/AutoScaling/Tests/AutoScalingTests.csproj create mode 100644 dotnetv3/AutoScaling/Tests/AutoScalingWrapperTests.cs create mode 100644 dotnetv3/AutoScaling/Tests/Usings.cs create mode 100644 dotnetv3/AutoScaling/Tests/testsettings.json delete mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics.sln delete mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleBasics.cs delete mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs delete mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScale_Basics.csproj delete mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/CloudWatchMethods.cs delete mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/EC2Methods.cs delete mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/GlobalUsings.cs delete mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScaleMethodsTests.cs delete mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScale_BasicsTests.csproj delete mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/CloudWatchMethodsTests.cs delete mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/EC2MethodsTests.cs diff --git a/.doc_gen/metadata/auto-scaling_metadata.yaml b/.doc_gen/metadata/auto-scaling_metadata.yaml index 566358f8e04..31711b8c824 100644 --- a/.doc_gen/metadata/auto-scaling_metadata.yaml +++ b/.doc_gen/metadata/auto-scaling_metadata.yaml @@ -1,4 +1,21 @@ # zexi 0.4.0 +auto-scaling_Hello: + title: Hello &AS; + title_abbrev: Hello &AS; + synopsis: get started using &AS;. + category: Hello + languages: + .NET: + versions: + - sdk_version: 3 + github: dotnetv3/AutoScaling + sdkguide: + excerpts: + - description: + snippet_tags: + - AutoScaling.dotnetv3.AutoScalingActions.HelloAutoScaling + services: + auto-scaling: {DescribeAutoScalingGroups} auto-scaling_CreateAutoScalingGroup: title: Create an &AS; group using an &AWS; SDK title_abbrev: Create a group @@ -12,7 +29,7 @@ auto-scaling_CreateAutoScalingGroup: excerpts: - description: snippet_tags: - - AutoScale.dotnetv3.AutoScale_Basics.CreateAutoScalingGroup + - AutoScaling.dotnetv3.AutoScalingActions.CreateAutoScalingGroup Kotlin: versions: - sdk_version: 1 @@ -72,7 +89,7 @@ auto-scaling_DeleteAutoScalingGroup: excerpts: - description: snippet_tags: - - AutoScale.dotnetv3.AutoScale_Basics.DeleteAutoScalingGroup + - AutoScaling.dotnetv3.AutoScalingActions.DeleteAutoScalingGroup Kotlin: versions: - sdk_version: 1 @@ -131,7 +148,7 @@ auto-scaling_DescribeAutoScalingGroups: excerpts: - description: snippet_tags: - - AutoScale.dotnetv3.AutoScale_Basics.DescribeAutoScalingInstances + - AutoScaling.dotnetv3.AutoScalingActions.DescribeAutoScalingInstances Kotlin: versions: - sdk_version: 1 @@ -206,7 +223,7 @@ auto-scaling_UpdateAutoScalingGroup: excerpts: - description: snippet_tags: - - AutoScale.dotnetv3.AutoScale_Basics.UpdateAutoScalingGroup + - AutoScaling.dotnetv3.AutoScalingActions.UpdateAutoScalingGroup Python: versions: - sdk_version: 3 @@ -267,7 +284,7 @@ auto-scaling_TerminateInstanceInAutoScalingGroup: excerpts: - description: snippet_tags: - - AutoScale.dotnetv3.AutoScale_Basics.TerminateInstanceInAutoScalingGroup + - AutoScaling.dotnetv3.AutoScalingActions.TerminateInstanceInAutoScalingGroup Python: versions: - sdk_version: 3 @@ -321,7 +338,7 @@ auto-scaling_SetDesiredCapacity: excerpts: - description: snippet_tags: - - AutoScale.dotnetv3.AutoScale_Basics.SetDesiredCapacity + - AutoScaling.dotnetv3.AutoScalingActions.SetDesiredCapacity Python: versions: - sdk_version: 3 @@ -375,7 +392,7 @@ auto-scaling_DescribeAutoScalingInstances: excerpts: - description: snippet_tags: - - AutoScale.dotnetv3.AutoScale_Basics.DescribeAutoScalingInstances + - AutoScaling.dotnetv3.AutoScalingActions.DescribeAutoScalingInstances Python: versions: - sdk_version: 3 @@ -429,7 +446,7 @@ auto-scaling_DescribeScalingActivities: excerpts: - description: snippet_tags: - - AutoScale.dotnetv3.AutoScale_Basics.DescribeScalingActivities + - AutoScaling.dotnetv3.AutoScalingActions.DescribeScalingActivities Python: versions: - sdk_version: 3 @@ -483,7 +500,7 @@ auto-scaling_EnableMetricsCollection: excerpts: - description: snippet_tags: - - AutoScale.dotnetv3.AutoScale_Basics.EnableMetricsCollection + - AutoScaling.dotnetv3.AutoScalingActions.EnableMetricsCollection Python: versions: - sdk_version: 3 @@ -537,7 +554,7 @@ auto-scaling_DisableMetricsCollection: excerpts: - description: snippet_tags: - - AutoScale.dotnetv3.AutoScale_Basics.DisableMetricsCollection + - AutoScaling.dotnetv3.AutoScalingActions.DisableMetricsCollection Python: versions: - sdk_version: 3 @@ -583,14 +600,17 @@ auto-scaling_Scenario_GroupsAndInstances: excerpts: - description: snippet_tags: - - AutoScale.dotnetv3.AutoScale_Basics.global-usings - - AutoScale.dotnetv3.AutoScale_Basics.main + - AutoScaling.dotnetv3.AutoScalingBasics.Usings + - AutoScaling.dotnetv3.AutoScalingBasics + - AutoScaling.dotnetv3.AutoScalingBasics.UIWrapper - description: Define functions that are called by the scenario to - manage launch templates and metrics. These functions wrap - &EC2; and &CW; actions. + manage launch templates and metrics. These functions wrap &AS;, + &EC2;, and &CW; actions. snippet_tags: - - AutoScale.dotnetv3.AutoScale_Basics.EC2Methods - - AutoScale.dotnetv3.AutoScale_Basics.CloudWatchMethods + - AutoScaling.dotnetv3.AutoScalingActions.Usings + - AutoScaling.dotnetv3.AutoScalingActions.AutoScalingWrapper + - AutoScaling.dotnetv3.AutoScalingActions.EC2Wrapper + - AutoScaling.dotnetv3.AutoScalingActions.CloudWatchWrapper Kotlin: versions: - sdk_version: 1 diff --git a/.doc_gen/metadata/services.yaml b/.doc_gen/metadata/services.yaml index 76a8c7079e9..ea7b72cc683 100644 --- a/.doc_gen/metadata/services.yaml +++ b/.doc_gen/metadata/services.yaml @@ -90,11 +90,11 @@ aurora: api_ref: AmazonRDS/latest/APIReference/Welcome.html auto-scaling: long: '&ASlong;' - short: '&ASlong;' + short: '&AS;' sort: EC2 Auto Scaling expanded: long: Amazon EC2 Auto Scaling - short: Amazon EC2 Auto Scaling + short: Auto Scaling blurb: automatically scales EC2 instances, either with scaling policies or with scheduled scaling. guide: diff --git a/dotnetv3/AutoScaling/Actions/AutoScalingActions.csproj b/dotnetv3/AutoScaling/Actions/AutoScalingActions.csproj new file mode 100644 index 00000000000..734fffce190 --- /dev/null +++ b/dotnetv3/AutoScaling/Actions/AutoScalingActions.csproj @@ -0,0 +1,20 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + + + + + + diff --git a/dotnetv3/AutoScaling/Actions/AutoScalingWrapper.cs b/dotnetv3/AutoScaling/Actions/AutoScalingWrapper.cs new file mode 100644 index 00000000000..768fccb1f60 --- /dev/null +++ b/dotnetv3/AutoScaling/Actions/AutoScalingWrapper.cs @@ -0,0 +1,357 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +// snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.AutoScalingWrapper] +using LaunchTemplateSpecification = Amazon.AutoScaling.Model.LaunchTemplateSpecification; + +namespace AutoScalingActions; + +using Amazon.AutoScaling; +using Amazon.AutoScaling.Model; + +/// +/// A class that includes methods to perform Amazon EC2 Auto Scaling +/// actions. +/// +public class AutoScalingWrapper +{ + private readonly IAmazonAutoScaling _amazonAutoScaling; + + /// + /// Constructor for the AutoScalingWrapper class. + /// + /// The injected Amazon EC2 Auto Scaling client. + public AutoScalingWrapper(IAmazonAutoScaling amazonAutoScaling) + { + _amazonAutoScaling = amazonAutoScaling; + } + + // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.CreateAutoScalingGroup] + + /// + /// Create a new Amazon EC2 Auto Scaling group. + /// + /// The name to use for the new Auto Scaling + /// group. + /// The name of the Amazon EC2 Auto Scaling + /// launch template to use to create instances in the group. + /// The AWS Identity and Access + /// Management (IAM) service-linked role that provides the permissions + /// for the Amazon EC2 Auto Scaling group. + /// A Boolean value indicating the success of the action. + public async Task CreateAutoScalingGroupAsync( + string groupName, + string launchTemplateName, + string availabilityZone, + string serviceLinkedRoleARN) + { + var templateSpecification = new LaunchTemplateSpecification + { + LaunchTemplateName = launchTemplateName, + }; + + var zoneList = new List + { + availabilityZone, + }; + + var request = new CreateAutoScalingGroupRequest + { + AutoScalingGroupName = groupName, + AvailabilityZones = zoneList, + LaunchTemplate = templateSpecification, + MaxSize = 6, + MinSize = 1, + ServiceLinkedRoleARN = serviceLinkedRoleARN, + }; + + var response = await _amazonAutoScaling.CreateAutoScalingGroupAsync(request); + Console.WriteLine($"{groupName} Auto Scaling Group created"); + return response.HttpStatusCode == System.Net.HttpStatusCode.OK; + } + + // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.CreateAutoScalingGroup] + + // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.DescribeAccountLimits] + + /// + /// Retrieve information about Amazon EC2 Auto Scaling quotas to the + /// active AWS account. + /// + /// A Boolean value indicating the success of the action. + public async Task DescribeAccountLimitsAsync() + { + var response = await _amazonAutoScaling.DescribeAccountLimitsAsync(); + Console.WriteLine("The maximum number of Auto Scaling groups is " + response.MaxNumberOfAutoScalingGroups); + Console.WriteLine("The current number of Auto Scaling groups is " + response.NumberOfAutoScalingGroups); + return response.HttpStatusCode == System.Net.HttpStatusCode.OK; + } + + // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.DescribeAccountLimits] + + // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.DescribeScalingActivities] + + /// + /// Retrieve a list of the Amazon EC2 Auto Scaling activities for an + /// Amazon EC2 Auto Scaling group. + /// + /// The name of the Amazon EC2 Auto Scaling group. + /// A list of Amazon EC2 Auto Scaling activities. + public async Task> DescribeScalingActivitiesAsync( + string groupName) + { + var scalingActivitiesRequest = new DescribeScalingActivitiesRequest + { + AutoScalingGroupName = groupName, + MaxRecords = 10, + }; + + var response = await _amazonAutoScaling.DescribeScalingActivitiesAsync(scalingActivitiesRequest); + return response.Activities; + } + + // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.DescribeScalingActivities] + + // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.DescribeAutoScalingInstances] + + /// + /// Get data about the instances in an Amazon EC2 Auto Scaling group. + /// + /// The name of the Amazon EC2 Auto Scaling group. + /// A list of Amazon EC2 Auto Scaling details. + public async Task> DescribeAutoScalingInstancesAsync( + string groupName) + { + var groups = await DescribeAutoScalingGroupsAsync(groupName); + var instanceIds = new List(); + groups.ForEach(group => + { + if (group.AutoScalingGroupName == groupName) + { + group.Instances.ForEach(instance => + { + instanceIds.Add(instance.InstanceId); + }); + } + }); + + var scalingGroupsRequest = new DescribeAutoScalingInstancesRequest + { + MaxRecords = 10, + InstanceIds = instanceIds, + }; + + var response = await _amazonAutoScaling.DescribeAutoScalingInstancesAsync(scalingGroupsRequest); + var instanceDetails = response.AutoScalingInstances; + + return instanceDetails; + } + + // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.DescribeAutoScalingInstances] + + // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.DescribeAutoScalingGroups] + + /// + /// Retrieve a list of information about Amazon EC2 Auto Scaling groups. + /// + /// The name of the Amazon EC2 Auto Scaling group. + /// A list of Amazon EC2 Auto Scaling groups. + public async Task?> DescribeAutoScalingGroupsAsync( + string groupName) + { + var groupList = new List + { + groupName, + }; + + var request = new DescribeAutoScalingGroupsRequest + { + AutoScalingGroupNames = groupList, + }; + + var response = await _amazonAutoScaling.DescribeAutoScalingGroupsAsync(request); + var groups = response.AutoScalingGroups; + + return groups; + } + + // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.DescribeAutoScalingGroups] + + // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.DeleteAutoScalingGroup] + /// + /// Delete an Auto Scaling group. + /// + /// The name of the Amazon EC2 Auto Scaling group. + /// A Boolean value indicating the success of the action. + public async Task DeleteAutoScalingGroupAsync( + string groupName) + { + var deleteAutoScalingGroupRequest = new DeleteAutoScalingGroupRequest + { + AutoScalingGroupName = groupName, + ForceDelete = true, + }; + + var response = await _amazonAutoScaling.DeleteAutoScalingGroupAsync(deleteAutoScalingGroupRequest); + if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) + { + Console.WriteLine($"You successfully deleted {groupName}"); + return true; + } + + Console.WriteLine($"Couldn't delete {groupName}."); + return false; + } + + // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.DeleteAutoScalingGroup] + + // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.DisableMetricsCollection] + /// + /// Disable the collection of metric data for an Amazon EC2 Auto Scaling + /// group. + /// + /// The name of the Auto Scaling group. + /// A Boolean value that indicates the success or failure of + /// the operation. + public async Task DisableMetricsCollectionAsync(string groupName) + { + var request = new DisableMetricsCollectionRequest + { + AutoScalingGroupName = groupName, + }; + + var response = await _amazonAutoScaling.DisableMetricsCollectionAsync(request); + return response.HttpStatusCode == System.Net.HttpStatusCode.OK; + } + + // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.DisableMetricsCollection] + + // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.EnableMetricsCollection] + /// + /// Enable the collection of metric data for an Auto Scaling group. + /// + /// The name of the Auto Scaling group. + /// A Boolean value indicating the success of the action. + public async Task EnableMetricsCollectionAsync(string groupName) + { + var listMetrics = new List + { + "GroupMaxSize", + }; + + var collectionRequest = new EnableMetricsCollectionRequest + { + AutoScalingGroupName = groupName, + Metrics = listMetrics, + Granularity = "1Minute", + }; + + var response = await _amazonAutoScaling.EnableMetricsCollectionAsync(collectionRequest); + return response.HttpStatusCode == System.Net.HttpStatusCode.OK; + } + + // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.EnableMetricsCollection] + + // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.SetDesiredCapacity] + /// + /// Set the desired capacity of an Auto Scaling group. + /// + /// The name of the Auto Scaling group. + /// The desired capacity for the Auto + /// Scaling group. + /// A Boolean value indicating the success of the action. + public async Task SetDesiredCapacityAsync( + string groupName, + int desiredCapacity) + { + var capacityRequest = new SetDesiredCapacityRequest + { + AutoScalingGroupName = groupName, + DesiredCapacity = desiredCapacity, + }; + + var response = await _amazonAutoScaling.SetDesiredCapacityAsync(capacityRequest); + Console.WriteLine($"You have set the DesiredCapacity to {desiredCapacity}."); + + return response.HttpStatusCode == System.Net.HttpStatusCode.OK; + } + + // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.SetDesiredCapacity] + + // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.TerminateInstanceInAutoScalingGroup] + /// + /// Terminate all instances in the Auto Scaling group in preparation for + /// deleting the group. + /// + /// The instance Id of the instance to terminate. + /// A Boolean value that indicates the success or failure of + /// the operation. + public async Task TerminateInstanceInAutoScalingGroupAsync( + string instanceId) + { + var request = new TerminateInstanceInAutoScalingGroupRequest + { + InstanceId = instanceId, + ShouldDecrementDesiredCapacity = false, + }; + + var response = await _amazonAutoScaling.TerminateInstanceInAutoScalingGroupAsync(request); + + if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) + { + Console.WriteLine($"You have terminated the instance: {instanceId}"); + return true; + } + + Console.WriteLine($"Could not terminate {instanceId}"); + return false; + } + + // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.TerminateInstanceInAutoScalingGroup] + + // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.UpdateAutoScalingGroup] + /// + /// Update the capacity of an Auto Scaling group. + /// + /// The name of the Auto Scaling group. + /// The name of the EC2 launch template. + /// The Amazon Resource Name (ARN) + /// of the AWS Identity and Access Management (IAM) service-linked role. + /// The maximum number of instances that can be + /// created for the Auto Scaling group. + /// A Boolean value indicating the success of the action. + public async Task UpdateAutoScalingGroupAsync( + string groupName, + string launchTemplateName, + string serviceLinkedRoleARN, + int maxSize) + { + var templateSpecification = new LaunchTemplateSpecification + { + LaunchTemplateName = launchTemplateName, + }; + + var groupRequest = new UpdateAutoScalingGroupRequest + { + MaxSize = maxSize, + ServiceLinkedRoleARN = serviceLinkedRoleARN, + AutoScalingGroupName = groupName, + LaunchTemplate = templateSpecification, + }; + + var response = await _amazonAutoScaling.UpdateAutoScalingGroupAsync(groupRequest); + if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) + { + Console.WriteLine($"You successfully updated the Auto Scaling group {groupName}."); + return true; + } + else + { + return false; + } + } + + // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.UpdateAutoScalingGroup] +} + +// snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.AutoScalingWrapper] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Actions/CloudWatchWrapper.cs b/dotnetv3/AutoScaling/Actions/CloudWatchWrapper.cs new file mode 100644 index 00000000000..7861eed210f --- /dev/null +++ b/dotnetv3/AutoScaling/Actions/CloudWatchWrapper.cs @@ -0,0 +1,89 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +// snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.CloudWatchWrapper] +namespace AutoScalingActions; + +using Amazon.CloudWatch; +using Amazon.CloudWatch.Model; + +/// +/// Contains methods to access Amazon CloudWatch metrics for the +/// Amazon EC2 Auto Scaling basics scenario. +/// +public class CloudWatchWrapper +{ + private readonly IAmazonCloudWatch _amazonCloudWatch; + + /// + /// Constructor for the CloudWatchWrapper. + /// + /// The injected CloudWatch client. + public CloudWatchWrapper(IAmazonCloudWatch amazonCloudWatch) + { + _amazonCloudWatch = amazonCloudWatch; + } + + /// + /// Retrieve the metrics information collection for the Auto Scaling group. + /// + /// The name of the Auto Scaling group. + /// A list of Metrics collected for the Auto Scaling group. + public async Task> GetCloudWatchMetricsAsync(string groupName) + { + var filter = new DimensionFilter + { + Name = "AutoScalingGroupName", + Value = $"{groupName}", + }; + + var request = new ListMetricsRequest + { + MetricName = "AutoScalingGroupName", + Dimensions = new List { filter }, + Namespace = "AWS/AutoScaling", + }; + + var response = await _amazonCloudWatch.ListMetricsAsync(request); + + return response.Metrics; + } + + /// + /// Retrieve the metric data collected for an Amazon EC2 Auto Scaling group. + /// + /// The name of the Amazon EC2 Auto Scaling group. + /// A list of data points. + public async Task> GetMetricStatisticsAsync(string groupName) + { + var metricDimensions = new List + { + new Dimension + { + Name = "AutoScalingGroupName", + Value = $"{groupName}", + }, + }; + + // The start time will be yesterday. + var startTime = DateTime.UtcNow.AddDays(-1); + + var request = new GetMetricStatisticsRequest + { + MetricName = "AutoScalingGroupName", + Dimensions = metricDimensions, + Namespace = "AWS/AutoScaling", + Period = 60, // 60 seconds. + Statistics = new List() { "Minimum" }, + StartTimeUtc = startTime, + EndTimeUtc = DateTime.UtcNow, + }; + + var response = await _amazonCloudWatch.GetMetricStatisticsAsync(request); + + return response.Datapoints; + } + +} + +// snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.CloudWatchWrapper] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Actions/EC2Wrapper.cs b/dotnetv3/AutoScaling/Actions/EC2Wrapper.cs new file mode 100644 index 00000000000..d3d9ed51c44 --- /dev/null +++ b/dotnetv3/AutoScaling/Actions/EC2Wrapper.cs @@ -0,0 +1,98 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +// snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.EC2Wrapper] +namespace AutoScalingActions; + +using Amazon.EC2; +using Amazon.EC2.Model; + +public class EC2Wrapper +{ + private readonly IAmazonEC2 _amazonEc2; + + /// + /// Constructor for the EC2Wrapper class. + /// + /// The injected Amazon EC2 client. + public EC2Wrapper(IAmazonEC2 amazonEc2) + { + _amazonEc2 = amazonEc2; + } + + /// + /// Create a new Amazon EC2 launch template. + /// + /// The image Id to use for instances launched + /// using the Amazon EC2 launch template. + /// The type of EC2 instances to create. + /// The name of the launch template. + /// Returns the TemplateID of the new launch template. + public async Task CreateLaunchTemplateAsync( + string imageId, + string instanceType, + string launchTemplateName) + { + var request = new CreateLaunchTemplateRequest + { + LaunchTemplateData = new RequestLaunchTemplateData + { + ImageId = imageId, + InstanceType = instanceType, + }, + LaunchTemplateName = launchTemplateName, + }; + + var response = await _amazonEc2.CreateLaunchTemplateAsync(request); + + return response.LaunchTemplate.LaunchTemplateId; + } + + /// + /// Delete an Amazon EC2 launch template. + /// + /// The TemplateId of the launch template to + /// delete. + /// The name of the EC2 launch template that was deleted. + public async Task DeleteLaunchTemplateAsync(string launchTemplateId) + { + var request = new DeleteLaunchTemplateRequest + { + LaunchTemplateId = launchTemplateId, + }; + + var response = await _amazonEc2.DeleteLaunchTemplateAsync(request); + return response.LaunchTemplate.LaunchTemplateName; + } + + /// + /// Retrieve information about an EC2 launch template. + /// + /// The name of the EC2 launch template. + /// A Boolean value that indicates the success or failure of + /// the operation. + public async Task DescribeLaunchTemplateAsync(string launchTemplateName) + { + var request = new DescribeLaunchTemplatesRequest + { + LaunchTemplateNames = new List { launchTemplateName, }, + }; + + var response = await _amazonEc2.DescribeLaunchTemplatesAsync(request); + + if (response.LaunchTemplates is not null) + { + response.LaunchTemplates.ForEach(template => + { + Console.Write($"{template.LaunchTemplateName}\t"); + Console.WriteLine(template.LaunchTemplateId); + }); + + return true; + } + + return false; + } +} + +// snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.EC2Wrapper] diff --git a/dotnetv3/AutoScaling/Actions/HelloAutoScaling.cs b/dotnetv3/AutoScaling/Actions/HelloAutoScaling.cs new file mode 100644 index 00000000000..b8e5694fbe3 --- /dev/null +++ b/dotnetv3/AutoScaling/Actions/HelloAutoScaling.cs @@ -0,0 +1,38 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +// snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.HelloAutoScaling] + +namespace AutoScalingActions; + +using Amazon.AutoScaling; + +public class HelloAutoScaling +{ + /// + /// Hello Amazon EC2 Auto Scaling. List EC2 Auto Scaling groups. + /// + /// + /// Async Task. + 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."); + } + } +} + +// snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.HelloAutoScaling] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/AutoScalingExamples.sln b/dotnetv3/AutoScaling/AutoScalingExamples.sln new file mode 100644 index 00000000000..79b71e61df9 --- /dev/null +++ b/dotnetv3/AutoScaling/AutoScalingExamples.sln @@ -0,0 +1,48 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32630.192 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Actions", "Actions", "{7907FB6A-1353-4735-95DC-EEC5DF8C0649}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scenarios", "Scenarios", "{B987097B-189C-4D0B-99BC-E67CD705BCA0}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{5455D423-2AFC-4BC6-B79D-9DC4270D8F7D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoScalingActions", "Actions\AutoScalingActions.csproj", "{796910FA-6E94-460B-8CB4-97DF01B9ADC8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoScalingBasics", "Scenarios\AutoScalingBasics\AutoScalingBasics.csproj", "{B1731AE1-381F-4044-BEBE-269FF7E24B1F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoScalingTests", "Tests\AutoScalingTests.csproj", "{6046A2FC-6A39-4C2D-8DD9-AA3740B17B88}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {796910FA-6E94-460B-8CB4-97DF01B9ADC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {796910FA-6E94-460B-8CB4-97DF01B9ADC8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {796910FA-6E94-460B-8CB4-97DF01B9ADC8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {796910FA-6E94-460B-8CB4-97DF01B9ADC8}.Release|Any CPU.Build.0 = Release|Any CPU + {B1731AE1-381F-4044-BEBE-269FF7E24B1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1731AE1-381F-4044-BEBE-269FF7E24B1F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1731AE1-381F-4044-BEBE-269FF7E24B1F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1731AE1-381F-4044-BEBE-269FF7E24B1F}.Release|Any CPU.Build.0 = Release|Any CPU + {6046A2FC-6A39-4C2D-8DD9-AA3740B17B88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6046A2FC-6A39-4C2D-8DD9-AA3740B17B88}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6046A2FC-6A39-4C2D-8DD9-AA3740B17B88}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6046A2FC-6A39-4C2D-8DD9-AA3740B17B88}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {796910FA-6E94-460B-8CB4-97DF01B9ADC8} = {7907FB6A-1353-4735-95DC-EEC5DF8C0649} + {B1731AE1-381F-4044-BEBE-269FF7E24B1F} = {B987097B-189C-4D0B-99BC-E67CD705BCA0} + {6046A2FC-6A39-4C2D-8DD9-AA3740B17B88} = {5455D423-2AFC-4BC6-B79D-9DC4270D8F7D} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {870D888D-5C8B-4057-8722-F73ECF38E513} + EndGlobalSection +EndGlobal diff --git a/dotnetv3/AutoScaling/README.md b/dotnetv3/AutoScaling/README.md index 0fa89be3cbf..90af403e931 100644 --- a/dotnetv3/AutoScaling/README.md +++ b/dotnetv3/AutoScaling/README.md @@ -1,60 +1,142 @@ -# Amazon EC2 Auto Scaling code examples for the SDK for .NET + +# Auto Scaling code examples for the SDK for .NET ## Overview -The code examples in this section show how to use the AWS SDK for .NET with Amazon EC2 Auto Scaling to create and manage Amazon EC2 -Auto Scaling groups and instances. -Amazon EC2 Auto Scaling automatically scales EC2 instances, either with scaling -policies or with scheduled scaling. +Shows how to use the AWS SDK for .NET to work with Amazon EC2 Auto Scaling (Auto Scaling). + + + + +*Auto Scaling automatically scales EC2 instances, either with scaling policies or with scheduled scaling.* + +## ⚠ Important -## ⚠️ Important * Running this code might result in charges to your AWS account. * Running the tests might result in charges to your AWS account. * We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege). * This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services). + + + ## Code examples +### Get started + +* [Hello Auto Scaling](Actions/HelloAutoScaling.cs#L4) (`DescribeAutoScalingGroups`) + ### Single actions + Code excerpts that show you how to call individual service functions. -* [Create a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`CreateAutoScalingGroupAsync`) -* [Delete a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`DeleteAutoScalingGroupAsync`) -* [Disable metrics collection for a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`DisableMetricsCollectionAsync`) -* [Enable metrics collection for a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`EnableMetricsCollectionAsync`) -* [Get information about account limits](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`DescribeAccountLimitsAsync`) -* [Get information about groups](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`DescribeAutoScalingGroupsAsync`) -* [Get information about instances](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`DescribeAutoScalingInstancesAsync`) -* [Get information about scaling activities](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`DescribeScalingActivitiesAsync`) -* [Set the desired capacity of a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`SetDesiredCapacityAsync`) -* [Terminate an instance in a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`TerminateInstanceInAutoScalingGroupAsync`) -* [Update a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`UpdateAutoScalingGroupAsync`) +* [Create a group](Actions/AutoScalingWrapper.cs#L29) (`CreateAutoScalingGroup`) +* [Delete a group](Actions/AutoScalingWrapper.cs#L180) (`DeleteAutoScalingGroup`) +* [Disable metrics collection for a group](Actions/AutoScalingWrapper.cs#L208) (`DisableMetricsCollection`) +* [Enable metrics collection for a group](Actions/AutoScalingWrapper.cs#L229) (`EnableMetricsCollection`) +* [Get information about groups](Actions/AutoScalingWrapper.cs#L115) (`DescribeAutoScalingGroups`) +* [Get information about instances](Actions/AutoScalingWrapper.cs#L115) (`DescribeAutoScalingInstances`) +* [Get information about scaling activities](Actions/AutoScalingWrapper.cs#L92) (`DescribeScalingActivities`) +* [Set the desired capacity of a group](Actions/AutoScalingWrapper.cs#L255) (`SetDesiredCapacity`) +* [Terminate an instance in a group](Actions/AutoScalingWrapper.cs#L281) (`TerminateInstanceInAutoScalingGroup`) +* [Update a group](Actions/AutoScalingWrapper.cs#L312) (`UpdateAutoScalingGroup`) ### Scenarios -Code examples that show you how to accomplish a specific task by calling multiple functions within the same service. -* [Auto Scaling basics](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) +Code examples that show you how to accomplish a specific task by calling multiple +functions within the same service. + +* [Manage groups and instances](Scenarios/AutoScalingBasics/UIWrapper.cs) ## Run the examples ### Prerequisites -* To find prerequisites for running these examples, see the - [README](../README.md#Prerequisites) in the dotnetv3 folder. -After the example compiles, you can run it from the command line. To do so, -navigate to the folder that contains the .csproj file and run the following -command: + +For prerequisites, see the [README](../README.md#Prerequisites) in the `dotnetv3` folder. + + + + + + +### Instructions + + + + + +#### Hello Auto Scaling + +This example shows you how to get started using Auto Scaling. + + +#### Manage groups and instances + +This example shows you how to do the following: + +* 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. + +Before you compile the .NET application, you can optionally set configuration values +in the settings.json file. Alternatively, add a settings.local.json file with +your local settings, which will be loaded automatically when the application runs. + +After the example compiles, you can run it from the command line. To do so, navigate to +the folder that contains the .csproj file and run the following command: ``` dotnet run ``` - Alternatively, you can run the example from within your IDE. + +### Configuration Settings + +This example uses several configuration settings that are stored in _settings.json_ +to change the existing values. + +**Note:** The image Id, instance type, and availability zone must be available in the AWS Region used by the account +used to run the scenario. In order to get valid settings, see: [Find a Linux AMI](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html) + +* **GroupName** - The name to use for the autoscaling group. +* **ImageId** - The image Id to use with the AutoScaling template. The AMI-ID column of the Amazon EC2 image locator table. +* **InstanceType** - The instance type to use with the template. The Instance Type column of the Amazon EC2 image locator table. +* **LaunchTemplateName** - The name of the launch template. +* **AvailabilityZone** - The availability zone for the launch template. The Zone column of the Amazon EC2 image locator table. +* **ServiceLinkedRoleArn** - The Amazon Resource Name (ARN) of a serivce-linked role that will be used + to create the AutoScaling group. + + + +### Tests + +⚠ Running tests might result in charges to your AWS account. + + +To find instructions for running these tests, see the [README](../README.md#Tests) +in the `dotnetv3` folder. + + + + + + ## Additional resources -* [Amazon EC2 Auto Scaling User Guide](https://docs.aws.amazon.com/autoscaling/ec2/userguide/index.html) -* [Amazon EC2 Auto Scaling API Reference](https://docs.aws.amazon.com/autoscaling/ec2/APIReference/Welcome.html) -* [AWS SDK for .NET Amazon EC2 Auto Scaling](https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/AutoScaling/NAutoScaling.html) -* [AWS SDK for .NET Developer Guide](https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/welcome.html) -Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 +* [Auto Scaling User Guide](https://docs.aws.amazon.com/autoscaling/ec2/userguide/what-is-amazon-ec2-auto-scaling.html) +* [Auto Scaling API Reference](https://docs.aws.amazon.com/autoscaling/ec2/APIReference/Welcome.html) +* [SDK for .NET Auto Scaling reference](https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/Auto-scaling/NAuto-scaling.html) + + + + +--- + +Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.cs b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.cs new file mode 100644 index 00000000000..3edaab9129f --- /dev/null +++ b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.cs @@ -0,0 +1,228 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +// snippet-start:[AutoScaling.dotnetv3.AutoScalingBasics] + +using Amazon.EC2; +using Amazon.EC2.Model; +using Microsoft.Extensions.Configuration; + +namespace AutoScalingBasics; + +public class AutoScalingBasics +{ + private static ILogger logger = null!; + + 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("Microsoft", LogLevel.Information) + .AddFilter("Microsoft", LogLevel.Trace)) + .ConfigureServices((_, services) => + services.AddAWSService() + .AddAWSService() + .AddAWSService() + .AddTransient() + .AddTransient() + .AddTransient() + .AddTransient() + ) + .Build(); + + logger = LoggerFactory.Create(builder => { builder.AddConsole(); }) + .CreateLogger(); + + var autoScalingWrapper = host.Services.GetRequiredService(); + var cloudWatchWrapper = host.Services.GetRequiredService(); + var ec2Wrapper = host.Services.GetRequiredService(); + var uiWrapper = host.Services.GetRequiredService(); + + 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"]; + var availabilityZone = configuration["AvailabilityZone"]; + + // The name of the Auto Scaling group. + var groupName = configuration["GroupName"]; + + // The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) service-linked role. + var serviceLinkedRoleARN = configuration["ServiceLinkedRoleArn"]; + + 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(); + + Console.WriteLine($"Creating an Auto Scaling group named {groupName}."); + var success = await autoScalingWrapper.CreateAutoScalingGroupAsync( + groupName, + launchTemplateName, + availabilityZone, + serviceLinkedRoleARN); + + // 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 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); + + // Show the metrics that are collected for the group. + + // Update the maximum size of the group to three instances. + Console.WriteLine("--- Update the Auto Scaling group to increase max size to 3 ---"); + int maxSize = 3; + await autoScalingWrapper.UpdateAutoScalingGroupAsync(groupName, launchTemplateName, serviceLinkedRoleARN, maxSize); + + Console.WriteLine("--- Describe all Auto Scaling groups to show the current state of the group ---"); + var groups = await autoScalingWrapper.DescribeAutoScalingGroupsAsync(groupName); + + uiWrapper.DisplayGroupDetails(groups); + + uiWrapper.PressEnter(); + + uiWrapper.DisplayTitle("Describe account limits"); + await autoScalingWrapper.DescribeAccountLimitsAsync(); + + uiWrapper.WaitABit(60, "Waiting for the resources to be ready."); + + uiWrapper.DisplayTitle("Set desired capacity"); + int desiredCapacity = 2; + await autoScalingWrapper.SetDesiredCapacityAsync(groupName, desiredCapacity); + + Console.WriteLine("Get the two instance Id values"); + + // Empty the group before getting the details again. + groups.Clear(); + groups = await autoScalingWrapper.DescribeAutoScalingGroupsAsync(groupName); + if (groups is not null) + { + foreach (AutoScalingGroup group in groups) + { + Console.WriteLine($"The group name is {group.AutoScalingGroupName}"); + Console.WriteLine($"The group ARN is {group.AutoScalingGroupARN}"); + var instances = group.Instances; + foreach (Instance instance in instances) + { + Console.WriteLine($"The instance id is {instance.InstanceId}"); + Console.WriteLine($"The lifecycle state is {instance.LifecycleState}"); + } + } + } + + uiWrapper.DisplayTitle("Scaling Activities"); + Console.WriteLine("Let's list the scaling activities that have occurred for the group."); + var activities = await autoScalingWrapper.DescribeScalingActivitiesAsync(groupName); + if (activities is not null) + { + activities.ForEach(activity => + { + Console.WriteLine($"The activity Id is {activity.ActivityId}"); + Console.WriteLine($"The activity details are {activity.Details}"); + }); + } + + // Display the Amazon CloudWatch metrics that have been collected. + var metrics = await cloudWatchWrapper.GetCloudWatchMetricsAsync(groupName); + Console.WriteLine($"Metrics collected for {groupName}:"); + metrics.ForEach(metric => + { + Console.Write($"Metric name: {metric.MetricName}\t"); + Console.WriteLine($"Namespace: {metric.Namespace}"); + }); + + var dataPoints = await cloudWatchWrapper.GetMetricStatisticsAsync(groupName); + Console.WriteLine("Details for the metrics collected:"); + dataPoints.ForEach(detail => + { + Console.WriteLine(detail); + }); + + // Disable metrics collection. + Console.WriteLine("Disabling the collection of metrics for {groupName}."); + success = await autoScalingWrapper.DisableMetricsCollectionAsync(groupName); + + if (success) + { + Console.WriteLine($"Successfully stopped metrics collection for {groupName}."); + } + else + { + Console.WriteLine($"Could not stop metrics collection for {groupName}."); + } + + // Terminate all instances in the group. + uiWrapper.DisplayTitle("Terminating Auto Scaling instances"); + Console.WriteLine("Now terminating all instances in the Auto Scaling group."); + + if (groups is not null) + { + groups.ForEach(group => + { + // Only delete instances in the AutoScaling group we created. + if (group.AutoScalingGroupName == groupName) + { + group.Instances.ForEach(async instance => + { + await autoScalingWrapper.TerminateInstanceInAutoScalingGroupAsync(instance.InstanceId); + }); + } + }); + } + + // After all instances are terminated, delete the group. + uiWrapper.DisplayTitle("Clean up resources"); + Console.WriteLine("Deleting the Auto Scaling group."); + await autoScalingWrapper.DeleteAutoScalingGroupAsync(groupName); + + // Delete the launch template. + var deletedLaunchTemplateName = await ec2Wrapper.DeleteLaunchTemplateAsync(launchTemplateId); + + if (deletedLaunchTemplateName == launchTemplateName) + { + Console.WriteLine("Successfully deleted the launch template."); + } + + Console.WriteLine("The demo is now concluded."); + } +} + +// snippet-end:[AutoScaling.dotnetv3.AutoScalingBasics] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.csproj b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.csproj new file mode 100644 index 00000000000..d2b8e5ae3b7 --- /dev/null +++ b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.csproj @@ -0,0 +1,33 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + settings.json + + + + + + + + diff --git a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/UIWrapper.cs b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/UIWrapper.cs new file mode 100644 index 00000000000..45dfdf2e5c0 --- /dev/null +++ b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/UIWrapper.cs @@ -0,0 +1,115 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +// snippet-start:[AutoScaling.dotnetv3.AutoScalingBasics.UIWrapper] +namespace AutoScalingBasics; + +/// +/// A class to provide user interface methods for the EC2 AutoScaling Basics +/// scenario. +/// +public class UIWrapper +{ + public readonly string SepBar = new('-', Console.WindowWidth); + + /// + /// Describe the steps in the EC2 AutoScaling Basics scenario. + /// + public void DisplayAutoScalingBasicsDescription() + { + Console.WriteLine("This code example performs the following operations:"); + Console.WriteLine(" 1. Creates an Amazon EC2 launch template."); + Console.WriteLine(" 2. Creates an Auto Scaling group."); + Console.WriteLine(" 3. Shows the details of the new Auto Scaling group"); + Console.WriteLine(" to show that only one instance was created."); + Console.WriteLine(" 4. Enables metrics collection."); + Console.WriteLine(" 5. Updates the Auto Scaling group to increase the"); + Console.WriteLine(" capacity to three."); + Console.WriteLine(" 6. Describes Auto Scaling groups again to show the"); + Console.WriteLine(" current state of the group."); + Console.WriteLine(" 7. Changes the desired capacity of the Auto Scaling"); + Console.WriteLine(" group to use an additional instance."); + Console.WriteLine(" 8. Shows that there are now instances in the group."); + Console.WriteLine(" 9. Lists the scaling activities that have occurred for the group."); + Console.WriteLine("10. Displays the Amazon CloudWatch metrics that have"); + Console.WriteLine(" been collected."); + Console.WriteLine("11. Disables metrics collection."); + Console.WriteLine("12. Terminates all instances in the Auto Scaling group."); + Console.WriteLine("13. Deletes the Auto Scaling group."); + Console.WriteLine("14. Deletes the Amazon EC2 launch template."); + PressEnter(); + } + + /// + /// Display information about the Amazon Ec2 AutoScaling groups passed + /// in the list of AutoScalingGroup objects. + /// + /// A list of AutoScalingGroup objects. + public void DisplayGroupDetails(List groups) + { + if (groups is null) + return; + + groups.ForEach(group => + { + Console.WriteLine($"Group name:\t{group.AutoScalingGroupName}"); + Console.WriteLine($"Group created:\t{group.CreatedTime}"); + Console.WriteLine($"Maximum number of instances:\t{group.MaxSize}"); + Console.WriteLine($"Desired number of instances:\t{group.DesiredCapacity}"); + }); + } + + /// + /// Display a message and wait until the user presses enter. + /// + public void PressEnter() + { + Console.Write("\nPress to continue. "); + _ = Console.ReadLine(); + Console.WriteLine(); + } + + /// + /// Pad a string with spaces to center it on the console display. + /// + /// The string to be centered. + /// The padded string. + public string CenterString(string strToCenter) + { + var padAmount = (Console.WindowWidth - strToCenter.Length) / 2; + var leftPad = new string(' ', padAmount); + return $"{leftPad}{strToCenter}"; + } + + /// + /// Display a line of hyphens, the centered text of the title and another + /// line of hyphens. + /// + /// The string to be displayed. + public void DisplayTitle(string strTitle) + { + Console.WriteLine(SepBar); + Console.WriteLine(CenterString(strTitle)); + Console.WriteLine(SepBar); + } + + /// + /// Display a countdown and wait for a number of seconds. + /// + /// The number of seconds to wait. + public void WaitABit(int numSeconds, string msg) + { + Console.WriteLine(msg); + + // Wait for the requested number of seconds. + for (int i = numSeconds; i > 0; i--) + { + System.Threading.Thread.Sleep(1000); + Console.Write($"{i}..."); + } + + PressEnter(); + } +} + +// snippet-end:[AutoScaling.dotnetv3.AutoScalingBasics.UIWrapper] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/Usings.cs b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/Usings.cs new file mode 100644 index 00000000000..a4a69321c66 --- /dev/null +++ b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/Usings.cs @@ -0,0 +1,16 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +// snippet-start:[AutoScaling.dotnetv3.AutoScalingBasics.Usings] +global using Amazon.AutoScaling; +global using Amazon.AutoScaling.Model; +global using Amazon.CloudWatch; +global using Amazon.CloudWatch.Model; +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; +global using AutoScalingActions; + +// snippet-end:[AutoScaling.dotnetv3.AutoScalingBasics.Usings] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/settings.json b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/settings.json new file mode 100644 index 00000000000..b7336a46cb8 --- /dev/null +++ b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/settings.json @@ -0,0 +1,8 @@ +{ + "GroupName": "mvp-group-name", + "ImageId": "ami-05803413c51f242b7", + "InstanceType": "t2.micro", + "LaunchTemplateName": "AutoScaleLaunchTemplate", + "AvailabilityZone": "availability zone matching ImageId", + "ServiceLinkedRoleArn": "" +} diff --git a/dotnetv3/AutoScaling/Tests/AutoScalingTests.csproj b/dotnetv3/AutoScaling/Tests/AutoScalingTests.csproj new file mode 100644 index 00000000000..0d130e6c9e1 --- /dev/null +++ b/dotnetv3/AutoScaling/Tests/AutoScalingTests.csproj @@ -0,0 +1,40 @@ + + + + net6.0 + enable + enable + + false + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + PreserveNewest + + + PreserveNewest + testsettings.json + + + + + + + + diff --git a/dotnetv3/AutoScaling/Tests/AutoScalingWrapperTests.cs b/dotnetv3/AutoScaling/Tests/AutoScalingWrapperTests.cs new file mode 100644 index 00000000000..605157c5220 --- /dev/null +++ b/dotnetv3/AutoScaling/Tests/AutoScalingWrapperTests.cs @@ -0,0 +1,323 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +using Amazon.AutoScaling; +using Amazon.AutoScaling.Model; +using Amazon.EC2; +using AutoScalingActions; + +namespace AutoScalingTests +{ + public class AutoScalingWrapperTests + { + private readonly IConfiguration _configuration; + private readonly AmazonAutoScalingClient _autoScalingClient; + private readonly AutoScalingWrapper _autoScalingWrapper; + private readonly AmazonEC2Client _ec2Client; + private readonly EC2Wrapper _ec2Wrapper; + private readonly AmazonCloudWatchClient _cloudWatchClient; + private readonly CloudWatchWrapper _cloudWatchWrapper; + + private readonly string? _groupName; + private readonly string? _imageId; + private readonly string? _instanceType; + private readonly string? _launchTemplateName; + private readonly string? _availabilityZone; + + // the Amazon Resource Name (ARN) of the IAM service linked role. + private readonly string? _serviceLinkedRoleArn; + private readonly string? _nameGuid; + + private static string? _launchTemplateId; + private static List? _groups; + public static string? InstanceId; + + /// + /// Constructor for the test class. + /// + public AutoScalingWrapperTests() + { + _configuration = new ConfigurationBuilder() + .SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("testsettings.json") // Load test settings from .json file. + .AddJsonFile("testsettings.local.json", + true) // Optionally load local settings. + .Build(); + + // Values needed for testing purposes. + _autoScalingClient = new AmazonAutoScalingClient(); + _autoScalingWrapper = new AutoScalingWrapper(_autoScalingClient); + _ec2Client = new AmazonEC2Client(); + _ec2Wrapper = new EC2Wrapper(_ec2Client); + _cloudWatchClient = new AmazonCloudWatchClient(); + _cloudWatchWrapper = new CloudWatchWrapper(_cloudWatchClient); + + _nameGuid = new Guid().ToString(); + _imageId = _configuration["ImageId"]; + _instanceType = _configuration["InstanceType"]; + _launchTemplateName = $"{_configuration["LaunchTemplateName"]}-{_nameGuid}"; + _availabilityZone = _configuration["AvailabilityZone"]; + + // The name of the Auto Scaling group. + _groupName = $"{_configuration["GroupName"]}-{_nameGuid}"; + + // The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) service-linked role. + _serviceLinkedRoleArn = _configuration["ServiceLinkedRoleArn"]; + } + + /// + /// Test the CreateLaunchTemplateAsync method. The call should return + /// a LaunchTemplate Id. + /// + /// Async Task. + [Fact()] + [Order(1)] + [Trait("Category", "Integration")] + public async Task CreateLaunchTemplateAsyncTest() + { + _launchTemplateId = await _ec2Wrapper.CreateLaunchTemplateAsync(_imageId, _instanceType, _launchTemplateName); + Assert.NotNull(_launchTemplateId); + } + + /// + /// Test the DescribeLaunchTemplateAsync method. The method should succeed. + /// + /// Async Task. + [Fact()] + [Order(2)] + [Trait("Category", "Integration")] + public async Task DescribeLaunchTemplateAsyncTest() + { + var success = await _ec2Wrapper.DescribeLaunchTemplateAsync(_launchTemplateName); + Assert.True(success); + } + + /// + /// Test the CreateAutoScalingGroupAsync method. The method call should + /// create an Auto Scaling group and return true. + /// + /// Async Task. + [Fact()] + [Order(3)] + [Trait("Category", "Integration")] + public async Task CreateAutoScalingGroupTest() + { + var success = await _autoScalingWrapper.CreateAutoScalingGroupAsync(_groupName, _launchTemplateName, _serviceLinkedRoleArn); + Assert.True(success, $"Couldn't create the Auto Scaling group {_groupName}."); + } + + /// + /// Test the DescribeAutoScalingInstancesAsync method. The call should + /// return information about instances in the logging group and the + /// value should not be null. + /// + /// Async Task. + [Fact()] + [Order(4)] + [Trait("Category", "Integration")] + public async Task DescribeAutoScalingInstancesAsyncTest() + { + var instanceDetails = await _autoScalingWrapper.DescribeAutoScalingInstancesAsync(_groupName); + Assert.NotNull(instanceDetails); + } + + /// + /// Test the EnableMetricsCollectionAsync method, which should succeed. + /// + /// Async Task. + [Fact()] + [Order(5)] + [Trait("Category", "Integration")] + public async Task EnableMetricsCollectionAsyncTest() + { + var success = await _autoScalingWrapper.EnableMetricsCollectionAsync(_groupName); + Assert.True(success, $"Couldn't enable metrics collection for {_groupName}."); + } + + /// + /// Test the SetDesiredCapacity method by sending a different + /// value for maximum capacity. It confirms success by retrieving + /// the list of Auto Scaling groups and checking the value of + /// DesiredCapacity. + /// + /// Async Task. + [Fact()] + [Order(6)] + [Trait("Category", "Integration")] + public async Task SetDesiredCapacityAsyncTest() + { + var newMax = 3; + var success = await _autoScalingWrapper.SetDesiredCapacityAsync(_groupName, newMax); + Assert.True(success, "Couldn't set the desired capacity."); + _groups = await _autoScalingWrapper.DescribeAutoScalingGroupsAsync(_groupName); + _groups.ForEach(group => + { + if (group.AutoScalingGroupName == _groupName) + { + Assert.Equal(newMax, group.DesiredCapacity); + } + }); + } + + /// + /// Test the UpdateAutoScalingGroup method by changing the maximum + /// capacity. After the change is made, the DescribeAutoScalingGroupsAsync + /// method checks the capacity for the group. + /// + /// Async Task. + [Fact()] + [Order(7)] + [Trait("Category", "Integration")] + public async Task UpdateAutoScalingGroupTest() + { + var newMax = 3; + var success = await _autoScalingWrapper.UpdateAutoScalingGroupAsync(_groupName, _launchTemplateName, _serviceLinkedRoleArn, newMax); + Assert.True(success, $"Couldn't update the Auto Scaling group: {_groupName}."); + _groups = await _autoScalingWrapper.DescribeAutoScalingGroupsAsync(_groupName); + _groups.ForEach(group => + { + if (group.AutoScalingGroupName == _groupName) + { + Assert.Equal(newMax, group.DesiredCapacity); + } + }); + } + + /// + /// Test the DescribeAutoScalingGroupsAsync method. + /// + /// Async Task. + [Fact()] + [Order(8)] + [Trait("Category", "Integration")] + public async Task DescribeAutoScalingGroupsAsyncTest() + { + var details = await _autoScalingWrapper.DescribeAutoScalingGroupsAsync(_groupName); + Assert.True(details.Count > 0, $"Couldn't find that Auto Scaling group {_groupName}."); + } + + /// + /// Test the DescribeAutoScalingActivitiesAsync method. The method + /// should return a non-null collection of activities. + /// + /// Async Task. + [Fact()] + [Order(9)] + [Trait("Category", "Integration")] + public async Task DescribeScalingActivitiesAsyncTest() + { + var activities = await _autoScalingWrapper.DescribeScalingActivitiesAsync(_groupName); + Assert.NotNull(activities); + } + + /// + /// Test the GetCloudWatchMetricsAsync method. The metrics collection + /// should not be null. + /// + /// Async Task. + [Fact()] + [Order(10)] + [Trait("Category", "Integration")] + public async Task GetCloudWatchMetricsAsyncTest() + { + var metrics = await _cloudWatchWrapper.GetCloudWatchMetricsAsync(_groupName); + Assert.NotNull(metrics); + } + + /// + /// Test the GetMetricStatisticsAsync method. The data points + /// collection should not be null. + /// + /// Async Task. + [Fact()] + [Order(11)] + [Trait("Category", "Integration")] + public async Task GetMetricStatisticsAsyncTest() + { + var dataPoints = await _cloudWatchWrapper.GetMetricStatisticsAsync(_groupName); + Assert.NotNull(dataPoints); + } + + /// + /// Test the DisableMetricsCollectionAsync method. The method should + /// succeed. + /// + /// Async Task. + [Fact()] + [Order(12)] + [Trait("Category", "Integration")] + public async Task DisableMetricsCollectionAsyncTest() + { + var success = await _autoScalingWrapper.DisableMetricsCollectionAsync(_groupName); + Assert.True(success); + } + + /// + /// Test the TerminateInstanceAutoScalingGroupsAsync method to + /// terminate all instances created during the test. It should + /// be successful. + /// + /// Async Task. + [Fact()] + [Order(13)] + [Trait("Category", "Integration")] + public async Task TerminateInstanceInAutoScalingGroupAsyncTest() + { + foreach (var group in _groups) + { + if (group.AutoScalingGroupName == _groupName) + { + foreach (Amazon.AutoScaling.Model.Instance instance in group.Instances) + { + var success = await _autoScalingWrapper.TerminateInstanceInAutoScalingGroupAsync(instance.InstanceId); + Assert.True(success, "Could not terminate the instance."); + }; + } + }; + } + + /// + /// Test the DeleteAutoScalingGroupAsync method to delete the group + /// created for testing. The call should be successful. + /// + /// Async Task. + [Fact()] + [Order(14)] + [Trait("Category", "Integration")] + public async Task DeleteAutoScalingGroupTest() + { + var success = await _autoScalingWrapper.DeleteAutoScalingGroupAsync(_groupName); + Assert.True(success, "Could not delete the group."); + } + + /// + /// Test the DeleteLaunchTemplateAsync method by deleting the template + /// created for testing purposes. If successful, the value returned + /// should be equal to the name of the launch template created by the + /// test class. + /// + /// Async Task. + [Fact()] + [Order(15)] + [Trait("Category", "Integration")] + public async Task DeleteLaunchTemplateAsyncTest() + { + var templateName = await _ec2Wrapper.DeleteLaunchTemplateAsync(_launchTemplateId); + Assert.Equal(_launchTemplateName, templateName); + } + + /// + /// Test the DescribeAccountLimitsAsync method. It doesn't matter when + /// this runs, since it is retrieving information that should be + /// available at any time. + /// + /// Async Task. + [Fact()] + [Trait("Category", "Integration")] + public async Task DescribeAccountLimitsTest() + { + var success = await _autoScalingWrapper.DescribeAccountLimitsAsync(); + Assert.True(success, "Couldn't retrieve account limits."); + } + } +} \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Tests/Usings.cs b/dotnetv3/AutoScaling/Tests/Usings.cs new file mode 100644 index 00000000000..8dbb18ff915 --- /dev/null +++ b/dotnetv3/AutoScaling/Tests/Usings.cs @@ -0,0 +1,21 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +global using Amazon; +global using Amazon.CloudWatch.Model; +global using Amazon.CloudWatch; +global using Amazon.EC2.Model; +global using Amazon.EC2; +global using Microsoft.Extensions.Configuration; +global using Microsoft.Extensions.Hosting; +global using Microsoft.Extensions.DependencyInjection; +global using Xunit; +global using Xunit.Extensions.Ordering; +global using AutoScalingActions; + +// Optional. +[assembly: CollectionBehavior(DisableTestParallelization = true)] +// Optional. +[assembly: TestCaseOrderer("Xunit.Extensions.Ordering.TestCaseOrderer", "Xunit.Extensions.Ordering")] +// Optional. +[assembly: TestCollectionOrderer("Xunit.Extensions.Ordering.CollectionOrderer", "Xunit.Extensions.Ordering")] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Tests/testsettings.json b/dotnetv3/AutoScaling/Tests/testsettings.json new file mode 100644 index 00000000000..75c3df7ae48 --- /dev/null +++ b/dotnetv3/AutoScaling/Tests/testsettings.json @@ -0,0 +1,7 @@ +{ + "GroupName": "test-group-name", + "ImageId": "ami-05803413c51f242b7", + "InstanceType": "t2.micro", + "LaunchTemplateName": "AutoScaleLaunchTemplate", + "ServiceLinkedRoleArn": "" +} diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics.sln b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics.sln deleted file mode 100644 index 833cd1c2533..00000000000 --- a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.2.32616.157 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoScale_Basics", "AutoScale_Basics\AutoScale_Basics.csproj", "{891E079C-B295-4439-8718-C8FF16F0D2AD}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoScale_BasicsTests", "AutoScale_BasicsTests\AutoScale_BasicsTests.csproj", "{357D5324-29A5-45C8-9702-573A2E3BDC31}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {891E079C-B295-4439-8718-C8FF16F0D2AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {891E079C-B295-4439-8718-C8FF16F0D2AD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {891E079C-B295-4439-8718-C8FF16F0D2AD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {891E079C-B295-4439-8718-C8FF16F0D2AD}.Release|Any CPU.Build.0 = Release|Any CPU - {357D5324-29A5-45C8-9702-573A2E3BDC31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {357D5324-29A5-45C8-9702-573A2E3BDC31}.Debug|Any CPU.Build.0 = Debug|Any CPU - {357D5324-29A5-45C8-9702-573A2E3BDC31}.Release|Any CPU.ActiveCfg = Release|Any CPU - {357D5324-29A5-45C8-9702-573A2E3BDC31}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {50392892-4D6A-41F4-8A5E-6C0495AF4CA1} - EndGlobalSection -EndGlobal diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleBasics.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleBasics.cs deleted file mode 100644 index 938475ace7a..00000000000 --- a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleBasics.cs +++ /dev/null @@ -1,256 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -/* - Before running this AWS SDK for .NET (v3) code example, set up your - development environment, including your credentials. - - For more information, see the following documentation: - - https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-setup.html - - This example creates an Amazon Elastic Compute Cloud (Amazon EC2) launch - template. You can also use the Amazon EC2 console. For more information, see - the following: - - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html#create-launch-template - - This code example performs the following operations: - 1. Creates an Amazon EC2 launch template - 2. Creates an Amazon EC2 Auto Scaling group. - 3. Shows the details of the new Auto Scaling group to show that only - one instance was created. - 4. Enables metrics collection. - 5. Updates the Auto Scaling group to increase the max size to three. - 6. Describes Auto Scaling groups again to show the current state of the - group. - 7. Changes the desired capacity of the Auto Scaling group to two. - 9. Retrieves the details of the group and shows the number of instances. - 10. Lists the scaling activities that have occurred for the group. - 11. Displays the Amazon CloudWatch metrics that have been collected. - 12. Terminates an instance in the Auto Scaling group. - 13. Disables metrics collection. - 13. Deletes the Auto Scaling group. - 14. Deletes the Amazon EC2 launch template. -*/ - -// snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.main] -var imageId = "ami-05803413c51f242b7"; -var instanceType = "t2.micro"; -var launchTemplateName = "AutoScaleLaunchTemplate"; - -// The name of the Auto Scaling group. -var groupName = "AutoScaleExampleGroup"; - -// The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) service-linked role. -var serviceLinkedRoleARN = ""; - -var client = new AmazonAutoScalingClient(RegionEndpoint.USEast2); - -Console.WriteLine("Auto Scaling Basics"); -DisplayDescription(); - -// 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 EC2Methods.CreateLaunchTemplateAsync(imageId, instanceType, launchTemplateName); - -// Confirm that the template was created by asking for a description of it. -await EC2Methods.DescribeLaunchTemplateAsync(launchTemplateName); - -PressEnter(); - -Console.WriteLine($"--- Creating an Auto Scaling group named {groupName}. ---"); -var success = await AutoScaleMethods.CreateAutoScalingGroup( - client, - groupName, - launchTemplateName, - serviceLinkedRoleARN); - -// 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 instanceDetails; - -do -{ - instanceDetails = await AutoScaleMethods.DescribeAutoScalingInstancesAsync(client, 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}"); -}); - -PressEnter(); - -Console.WriteLine($"\n--- Enable metrics collection for {groupName}"); -await AutoScaleMethods.EnableMetricsCollectionAsync(client, groupName); - -// Show the metrics that are collected for the group. - -// Update the maximum size of the group to three instances. -Console.WriteLine("--- Update the Auto Scaling group to increase max size to 3 ---"); -int maxSize = 3; -await AutoScaleMethods.UpdateAutoScalingGroupAsync(client, groupName, launchTemplateName, serviceLinkedRoleARN, maxSize); - -Console.WriteLine("--- Describe all Auto Scaling groups to show the current state of the group ---"); -var groups = await AutoScaleMethods.DescribeAutoScalingGroupsAsync(client, groupName); - -DisplayGroupDetails(groups); - -PressEnter(); - -Console.WriteLine("--- Describe account limits ---"); -await AutoScaleMethods.DescribeAccountLimitsAsync(client); - -Console.WriteLine("Wait 1 min for the resources, including the instance. Otherwise, an empty instance Id is returned"); -System.Threading.Thread.Sleep(60000); - -Console.WriteLine("--- Set desired capacity to 2 ---"); -int desiredCapacity = 2; -await AutoScaleMethods.SetDesiredCapacityAsync(client, groupName, desiredCapacity); - -Console.WriteLine("--- Get the two instance Id values and state ---"); - -// Empty the group before getting the details again. -groups.Clear(); -groups = await AutoScaleMethods.DescribeAutoScalingGroupsAsync(client, groupName); -if (groups is not null) -{ - foreach (AutoScalingGroup group in groups) - { - Console.WriteLine($"The group name is {group.AutoScalingGroupName}"); - Console.WriteLine($"The group ARN is {group.AutoScalingGroupARN}"); - var instances = group.Instances; - foreach (Instance instance in instances) - { - Console.WriteLine($"The instance id is {instance.InstanceId}"); - Console.WriteLine($"The lifecycle state is {instance.LifecycleState}"); - } - } -} - -Console.WriteLine("**** List the scaling activities that have occurred for the group"); -var activities = await AutoScaleMethods.DescribeAutoScalingActivitiesAsync(client, groupName); -if (activities is not null) -{ - activities.ForEach(activity => - { - Console.WriteLine($"The activity Id is {activity.ActivityId}"); - Console.WriteLine($"The activity details are {activity.Details}"); - }); -} - -// Display the Amazon CloudWatch metrics that have been collected. -var metrics = await CloudWatchMethods.GetCloudWatchMetricsAsync(groupName); -Console.WriteLine($"Metrics collected for {groupName}:"); -metrics.ForEach(metric => -{ - Console.Write($"Metric name: {metric.MetricName}\t"); - Console.WriteLine($"Namespace: {metric.Namespace}"); -}); - -var dataPoints = await CloudWatchMethods.GetMetricStatisticsAsync(groupName); -Console.WriteLine("Details for the metrics collected:"); -dataPoints.ForEach(detail => -{ - Console.WriteLine(detail); -}); - -// Disable metrics collection. -Console.WriteLine("Disabling the collection of metrics for {groupName}."); -success = await AutoScaleMethods.DisableMetricsCollectionAsync(client, groupName); - -if (success) -{ - Console.WriteLine($"Successfully stopped metrics collection for {groupName}."); -} -else -{ - Console.WriteLine($"Could not stop metrics collection for {groupName}."); -} - -// Terminate all instances in the group. -Console.WriteLine("--- Now terminating all instances in the AWS Auto Scaling group ---"); - -if (groups is not null) -{ - groups.ForEach(group => - { - // Only delete instances in the AutoScaling group we created. - if (group.AutoScalingGroupName == groupName) - { - group.Instances.ForEach(async instance => - { - await AutoScaleMethods.TerminateInstanceInAutoScalingGroupAsync(client, instance.InstanceId); - }); - } - }); -} - -// After all instances are terminated, delete the group. -Console.WriteLine("--- Deleting the Auto Scaling group ---"); -await AutoScaleMethods.DeleteAutoScalingGroupAsync(client, groupName); - -// Delete the launch template. -var deletedLaunchTemplateName = await EC2Methods.DeleteLaunchTemplateAsync(launchTemplateId); - -if (deletedLaunchTemplateName == launchTemplateName) -{ - Console.WriteLine("Successfully deleted the launch template."); -} - -Console.WriteLine("The demo is now concluded."); - -void DisplayDescription() -{ - Console.WriteLine("This code example performs the following operations:"); - Console.WriteLine(" 1. Creates an Amazon EC2 launch template."); - Console.WriteLine(" 2. Creates an Auto Scaling group."); - Console.WriteLine(" 3. Shows the details of the new Auto Scaling group"); - Console.WriteLine(" to show that only one instance was created."); - Console.WriteLine(" 4. Enables metrics collection."); - Console.WriteLine(" 5. Updates the AWS Auto Scaling group to increase the"); - Console.WriteLine(" capacity to three."); - Console.WriteLine(" 6. Describes Auto Scaling groups again to show the"); - Console.WriteLine(" current state of the group."); - Console.WriteLine(" 7. Changes the desired capacity of the Auto Scaling"); - Console.WriteLine(" group to use an additional instance."); - Console.WriteLine(" 8. Shows that there are now instances in the group."); - Console.WriteLine(" 9. Lists the scaling activities that have occurred for the group."); - Console.WriteLine("10. Displays the Amazon CloudWatch metrics that have"); - Console.WriteLine(" been collected."); - Console.WriteLine("11. Disables metrics collection."); - Console.WriteLine("12. Terminates all instances in the Auto Scaling group."); - Console.WriteLine("13. Deletes the Auto Scaling group."); - Console.WriteLine("14. Deletes the Amazon EC2 launch template."); -} - -void DisplayGroupDetails(List groups) -{ - if (groups is null) - return; - - groups.ForEach(group => - { - Console.WriteLine($"Group name:\t{group.AutoScalingGroupName}"); - Console.WriteLine($"Group created:\t{group.CreatedTime}"); - Console.WriteLine($"Maximum number of instances:\t{group.MaxSize}"); - Console.WriteLine($"Desired number of instances:\t{group.DesiredCapacity}"); - }); -} - -void PressEnter() -{ - Console.WriteLine("Press to continue."); - _ = Console.ReadLine(); - Console.WriteLine("\n\n"); -} - -// snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.main] diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs deleted file mode 100644 index e4a507ea27e..00000000000 --- a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs +++ /dev/null @@ -1,377 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -namespace AutoScale_Basics -{ - /// - /// This class contains methods that perform EC2 Auto Scaling operations - /// used in the AutoScal_Basics scenario. - /// - public class AutoScaleMethods - { - // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.CreateAutoScalingGroup] - - /// - /// Creates a new Amazon EC2 Auto Scaling group. - /// - /// The initialized Amazon EC2 Auto Scaling - /// client object. - /// The name to use for the new Auto Scaling - /// group. - /// The name of the Amazon EC2 launch template - /// to use to create instances in the group. - /// The AWS Identity and Access - /// Management (IAM) service-linked role that provides the permissions - /// to use with the Auso Scaling group. - /// A Boolean value that indicates the success or failure of - /// the operation. - public static async Task CreateAutoScalingGroup( - AmazonAutoScalingClient client, - string groupName, - string launchTemplateName, - string serviceLinkedRoleARN) - { - var templateSpecification = new LaunchTemplateSpecification - { - LaunchTemplateName = launchTemplateName, - }; - - var zoneList = new List - { - "us-east-2a", - }; - - var request = new CreateAutoScalingGroupRequest - { - AutoScalingGroupName = groupName, - AvailabilityZones = zoneList, - LaunchTemplate = templateSpecification, - MaxSize = 1, - MinSize = 1, - ServiceLinkedRoleARN = serviceLinkedRoleARN, - }; - - var response = await client.CreateAutoScalingGroupAsync(request); - Console.WriteLine(groupName + " Auto Scaling Group created"); - return response.HttpStatusCode == System.Net.HttpStatusCode.OK; - } - - // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.CreateAutoScalingGroup] - - // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.DescribeAccountLimits] - - /// - /// Retrieves information about limits to the active AWS Account. - /// - /// The initialized Amazon EC2 Auto Scaling - /// client object. - /// A Boolean value that indicates the success or failure of - /// the operation. - public static async Task DescribeAccountLimitsAsync(AmazonAutoScalingClient client) - { - var response = await client.DescribeAccountLimitsAsync(); - Console.WriteLine("The max number of auto scaling groups is " + response.MaxNumberOfAutoScalingGroups); - Console.WriteLine("The current number of auto scaling groups is " + response.NumberOfAutoScalingGroups); - return response.HttpStatusCode == System.Net.HttpStatusCode.OK; - } - - // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.DescribeAccountLimits] - - // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.DescribeScalingActivities] - - /// - /// Retrieves a list of the Auto Scaling activities for an Auto Scaling group. - /// - /// The initialized Amazon EC2 Auto Scaling - /// client object. - /// The name of the Auto Scaling group. - /// A list of Auto Scaling activities. - public static async Task> DescribeAutoScalingActivitiesAsync( - AmazonAutoScalingClient client, - string groupName) - { - var scalingActivitiesRequest = new DescribeScalingActivitiesRequest - { - AutoScalingGroupName = groupName, - MaxRecords = 10, - }; - - var response = await client.DescribeScalingActivitiesAsync(scalingActivitiesRequest); - return response.Activities; - } - - // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.DescribeScalingActivities] - - // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.DescribeAutoScalingInstances] - - /// - /// Gets data about the instances in an Amazon EC2 Auto Scaling group. - /// - /// The initialized Amazon EC2 Auto Scaling - /// client object. - /// The name of the Auto Scaling group. - /// A list of Auto Scaling details. - public static async Task> DescribeAutoScalingInstancesAsync( - AmazonAutoScalingClient client, - string groupName) - { - var groups = await DescribeAutoScalingGroupsAsync(client, groupName); - var instanceIds = new List(); - groups.ForEach(group => - { - if (group.AutoScalingGroupName == groupName) - { - group.Instances.ForEach(instance => - { - instanceIds.Add(instance.InstanceId); - }); - } - }); - - var scalingGroupsRequest = new DescribeAutoScalingInstancesRequest - { - MaxRecords = 10, - InstanceIds = instanceIds, - }; - - var response = await client.DescribeAutoScalingInstancesAsync(scalingGroupsRequest); - var instanceDetails = response.AutoScalingInstances; - - return instanceDetails; - } - - // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.DescribeAutoScalingInstances] - - // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.DescribeAutoScalingGroups] - - /// - /// Retrieves a list of information about EC2 Auto Scaling groups. - /// - /// The initialized Amazon EC2 Auto Scaling - /// client object. - /// The name of the Auto Scaling group. - /// A list of Auto Scaling groups. - public static async Task> DescribeAutoScalingGroupsAsync( - AmazonAutoScalingClient client, - string groupName) - { - var groupList = new List - { - groupName, - }; - - var request = new DescribeAutoScalingGroupsRequest - { - AutoScalingGroupNames = groupList, - }; - - var response = await client.DescribeAutoScalingGroupsAsync(request); - var groups = response.AutoScalingGroups; - - return groups; - } - - // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.DescribeAutoScalingGroups] - - // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.DisableMetricsCollection] - - /// - /// Disables the collection of metric data for an Auto Scaling group. - /// - /// The initialized Amazon EC2 Auto Scaling - /// client object. - /// The name of the Auto Scaling group. - /// A Boolean value that indicates the success or failure of - /// the operation. - public static async Task DisableMetricsCollectionAsync(AmazonAutoScalingClient client, string groupName) - { - var request = new DisableMetricsCollectionRequest - { - AutoScalingGroupName = groupName, - }; - - var response = await client.DisableMetricsCollectionAsync(request); - return response.HttpStatusCode == System.Net.HttpStatusCode.OK; - } - - // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.DisableMetricsCollection] - - // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.DeleteAutoScalingGroup] - - /// - /// Deletes an Auto Scaling group. - /// - /// The initialized Amazon EC2 Auto Scaling - /// client object. - /// The name of the Auto Scaling group. - /// A Boolean value that indicates the success or failure of - /// the operation. - public static async Task DeleteAutoScalingGroupAsync( - AmazonAutoScalingClient autoScalingClient, - string groupName) - { - var deleteAutoScalingGroupRequest = new DeleteAutoScalingGroupRequest - { - AutoScalingGroupName = groupName, - ForceDelete = true, - }; - - var response = await autoScalingClient.DeleteAutoScalingGroupAsync(deleteAutoScalingGroupRequest); - if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) - { - Console.WriteLine($"You successfully deleted {groupName}"); - return true; - } - - Console.WriteLine($"Couldn't delete {groupName}."); - return false; - } - - // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.DeleteAutoScalingGroup] - - // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.EnableMetricsCollection] - - /// - /// Enables the collection of metric data for an Auto Scaling group. - /// - /// The initialized Amazon EC2 Auto Scaling - /// client object. - /// The name of the Auto Scaling group. - /// A Boolean value that indicates the success or failure of - /// the operation. - public static async Task EnableMetricsCollectionAsync(AmazonAutoScalingClient client, string groupName) - { - var listMetrics = new List - { - "GroupMaxSize", - }; - - var collectionRequest = new EnableMetricsCollectionRequest - { - AutoScalingGroupName = groupName, - Metrics = listMetrics, - Granularity = "1Minute", - }; - - var response = await client.EnableMetricsCollectionAsync(collectionRequest); - return response.HttpStatusCode == System.Net.HttpStatusCode.OK; - } - - // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.EnableMetricsCollection] - - // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.SetDesiredCapacity] - - /// - /// Sets the desired capacity of an Auto Scaling group. - /// - /// The initialized Amazon EC2 Auto Scaling - /// client object. - /// The name of the Auto Scaling group. - /// The desired capacity for the Auto - /// Scaling group. - /// A Boolean value that indicates the success or failure of - /// the operation. - public static async Task SetDesiredCapacityAsync( - AmazonAutoScalingClient client, - string groupName, - int desiredCapacity) - { - var capacityRequest = new SetDesiredCapacityRequest - { - AutoScalingGroupName = groupName, - DesiredCapacity = desiredCapacity, - }; - - var response = await client.SetDesiredCapacityAsync(capacityRequest); - Console.WriteLine($"You have set the DesiredCapacity to {desiredCapacity}."); - - return response.HttpStatusCode == System.Net.HttpStatusCode.OK; - } - - // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.SetDesiredCapacity] - - // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.TerminateInstanceInAutoScalingGroup] - - /// - /// Terminates all instances in the Auto Scaling group in preparation for - /// deleting the group. - /// - /// The initialized Amazon EC2 Auto Scaling - /// client object. - /// The instance Id of the instance to terminate. - /// A Boolean value that indicates the success or failure of - /// the operation. - public static async Task TerminateInstanceInAutoScalingGroupAsync( - AmazonAutoScalingClient client, - string instanceId) - { - var request = new TerminateInstanceInAutoScalingGroupRequest - { - InstanceId = instanceId, - ShouldDecrementDesiredCapacity = false, - }; - - var response = await client.TerminateInstanceInAutoScalingGroupAsync(request); - - if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) - { - Console.WriteLine($"You have terminated the instance {instanceId}"); - return true; - } - - Console.WriteLine($"Could not terminate {instanceId}"); - return false; - } - - // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.TerminateInstanceInAutoScalingGroup] - - // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.UpdateAutoScalingGroup] - - /// - /// Updates the capacity of an Auto Scaling group. - /// - /// The initialized Amazon EC2 Auto Scaling - /// client object. - /// The name of the Auto Scaling group. - /// The name of the EC2 launch template. - /// The Amazon Resource Name (ARN) - /// of the AWS Identity and Access Management (IAM) service-linked role. - /// The maximum number of instances that can be - /// created for the Auto Scaling group. - /// A Boolean value that indicates the success or failure of - /// the update operation. - public static async Task UpdateAutoScalingGroupAsync( - AmazonAutoScalingClient client, - string groupName, - string launchTemplateName, - string serviceLinkedRoleARN, - int maxSize) - { - var templateSpecification = new LaunchTemplateSpecification - { - LaunchTemplateName = launchTemplateName, - }; - - var groupRequest = new UpdateAutoScalingGroupRequest - { - MaxSize = maxSize, - ServiceLinkedRoleARN = serviceLinkedRoleARN, - AutoScalingGroupName = groupName, - LaunchTemplate = templateSpecification, - }; - - var response = await client.UpdateAutoScalingGroupAsync(groupRequest); - if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) - { - Console.WriteLine($"You successfully updated the Auto Scaling group {groupName}."); - return true; - } - else - { - return false; - } - } - - // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.UpdateAutoScalingGroup] - } -} diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScale_Basics.csproj b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScale_Basics.csproj deleted file mode 100644 index 8bb9e75c1b5..00000000000 --- a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScale_Basics.csproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - Exe - net6.0 - enable - enable - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/CloudWatchMethods.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/CloudWatchMethods.cs deleted file mode 100644 index 5c5b4726eef..00000000000 --- a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/CloudWatchMethods.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -namespace AutoScale_Basics -{ - // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.CloudWatchMethods] - using Amazon.CloudWatch; - using Amazon.CloudWatch.Model; - - /// - /// The method of this class display the metrics collected for the Amazon - /// EC2 Auto Scaling group created by the Amazon EC2 Auto Scaling scenario. - /// - public class CloudWatchMethods - { - /// - /// Retrieves the metrics information collection for the Auto Scaling group. - /// - /// The name of the Auto Scaling group. - /// A list of Metrics collected for the Auto Scaling group. - public static async Task> GetCloudWatchMetricsAsync(string groupName) - { - var client = new AmazonCloudWatchClient(); - - var filter = new DimensionFilter - { - Name = "AutoScalingGroupName", - Value = $"{groupName}", - }; - - var request = new ListMetricsRequest - { - MetricName = "AutoScalingGroupName", - Dimensions = new List { filter }, - Namespace = "AWS/AutoScaling", - }; - - var response = await client.ListMetricsAsync(request); - - return response.Metrics; - } - - /// - /// Retrieves the metric data collected for an Amazon EC2 Auto Scaling group. - /// - /// The name of the Amazon EC2 Auto Scaling group. - /// A list of data points. - public static async Task> GetMetricStatisticsAsync(string groupName) - { - var client = new AmazonCloudWatchClient(); - - var metricDimensions = new List - { - new Dimension - { - Name = "AutoScalingGroupName", - Value = $"{groupName}", - }, - }; - - // The start time will be yesterday. - var startTime = DateTime.UtcNow.AddDays(-1); - - var request = new GetMetricStatisticsRequest - { - MetricName = "AutoScalingGroupName", - Dimensions = metricDimensions, - Namespace = "AWS/AutoScaling", - Period = 60, // 60 seconds - Statistics = new List() { "Minimum" }, - StartTimeUtc = startTime, - EndTimeUtc = DateTime.UtcNow, - }; - - var response = await client.GetMetricStatisticsAsync(request); - - return response.Datapoints; - } - - // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.CloudWatchMethods] - } -} diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/EC2Methods.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/EC2Methods.cs deleted file mode 100644 index e0e0d1cda17..00000000000 --- a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/EC2Methods.cs +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -namespace AutoScale_Basics -{ - // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.EC2Methods] - using Amazon.EC2; - using Amazon.EC2.Model; - - /// - /// The methods in this class create and delete an Amazon Elastic Compute - /// Cloud (Amazon EC2) launch template for use by the Amazon EC2 Auto - /// Scaling scenario. - /// - public class EC2Methods - { - /// - /// Create a new Amazon EC2 launch template. - /// - /// The image Id to use for instances launched - /// using the Amazon EC2 launch template. - /// The type of EC2 instances to create. - /// The name of the launch template. - /// Returns the TemplaceID of the new launch template. - public static async Task CreateLaunchTemplateAsync( - string imageId, - string instanceType, - string launchTemplateName) - { - var client = new AmazonEC2Client(); - - var request = new CreateLaunchTemplateRequest - { - LaunchTemplateData = new RequestLaunchTemplateData - { - ImageId = imageId, - InstanceType = instanceType, - }, - LaunchTemplateName = launchTemplateName, - }; - - var response = await client.CreateLaunchTemplateAsync(request); - - return response.LaunchTemplate.LaunchTemplateId; - } - - /// - /// Deletes an Amazon EC2 launch template. - /// - /// The TemplateId of the launch template to - /// delete. - /// The name of the EC2 launch template that was deleted. - public static async Task DeleteLaunchTemplateAsync(string launchTemplateId) - { - var client = new AmazonEC2Client(); - - var request = new DeleteLaunchTemplateRequest - { - LaunchTemplateId = launchTemplateId, - }; - - var response = await client.DeleteLaunchTemplateAsync(request); - return response.LaunchTemplate.LaunchTemplateName; - } - - /// - /// Retrieves a information about an EC2 launch template. - /// - /// The name of the EC2 launch template. - /// A Boolean value that indicates the success or failure of - /// the operation. - public static async Task DescribeLaunchTemplateAsync(string launchTemplateName) - { - var client = new AmazonEC2Client(); - - var request = new DescribeLaunchTemplatesRequest - { - LaunchTemplateNames = new List { launchTemplateName, }, - }; - - var response = await client.DescribeLaunchTemplatesAsync(request); - - if (response.LaunchTemplates != null) - { - response.LaunchTemplates.ForEach(template => - { - Console.Write($"{template.LaunchTemplateName}\t"); - Console.WriteLine(template.LaunchTemplateId); - }); - - return true; - } - - return false; - } - } - - // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.EC2Methods] -} diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/GlobalUsings.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/GlobalUsings.cs deleted file mode 100644 index 4d083b079ce..00000000000 --- a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/GlobalUsings.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.global-usings] -global using Amazon; -global using Amazon.AutoScaling; -global using Amazon.AutoScaling.Model; -global using AutoScale_Basics; - -// snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.global-usings] diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScaleMethodsTests.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScaleMethodsTests.cs deleted file mode 100644 index de41d447454..00000000000 --- a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScaleMethodsTests.cs +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Amazon.AutoScaling; - -namespace AutoScale_Basics.Tests -{ - [TestClass()] - public class AutoScaleMethodsTests - { - private readonly string _GroupName = "test-group-name"; - private readonly AmazonAutoScalingClient _Client = new AmazonAutoScalingClient(); - - // the Amazon Resource Name (ARN) of the IAM service linked role. - private readonly string _ServiceLinkedRoleArn = ""; - - private readonly string _LaunchTemplateName = "AutoScaleLaunchTemplateTest"; - - [TestMethod()] - [TestProperty("Category", "Integration")] - public async Task DeleteAutoScalingGroupTest() - { - var success = await AutoScaleMethods.DeleteAutoScalingGroupAsync(_Client, _GroupName); - Assert.IsTrue(success, "Could not delete the group."); - } - - [TestMethod()] - [TestProperty("Category", "Integration")] - public async Task DeleteAutoScalingGroupGroupNonexistentTest() - { - var success = await AutoScaleMethods.DeleteAutoScalingGroupAsync(_Client, "NonExistentGroup"); - Assert.IsFalse(success, "Deleted a non-existent Auto Scaling group."); - } - - [TestMethod()] - [TestProperty("Category", "Integration")] - public async Task TerminateInstanceInAutoScalingGroupTest() - { - var instanceId = string.Empty; - var success = await AutoScaleMethods.TerminateInstanceInAutoScalingGroupAsync(_Client, instanceId); - Assert.IsTrue(success, "Could not terminate the instance."); - } - - [TestMethod()] - [TestProperty("Category", "Integration")] - public async Task DescribeScalingActivitiesTest() - { - var activities = await AutoScaleMethods.DescribeAutoScalingActivitiesAsync(_Client, _GroupName); - Assert.IsTrue(activities.Count > 0, "Can't find any auto scaling activities for the group."); - } - - [TestMethod()] - [TestProperty("Category", "Integration")] - public async Task SetDesiredCapacityTest() - { - var success = await AutoScaleMethods.SetDesiredCapacityAsync(_Client, _GroupName, 3); - Assert.IsTrue(success, "Couldn't set the desired capacity."); - var groups = await AutoScaleMethods.DescribeAutoScalingGroupsAsync(_Client, _GroupName); - groups.ForEach(group => - { - if (group.AutoScalingGroupName == _GroupName) - { - Assert.AreEqual(3, group.DesiredCapacity, "Capacity was not set properly."); - } - }); - } - - [TestMethod()] - [TestProperty("Category", "Integration")] - public async Task DescribeAccountLimitsTest() - { - var success = await AutoScaleMethods.DescribeAccountLimitsAsync(_Client); - Assert.IsTrue(success, "Couldn't retrieve account limits."); - } - - [TestMethod()] - [TestProperty("Category", "Integration")] - public async Task DescribeAutoScalingGroupsTest() - { - var details = await AutoScaleMethods.DescribeAutoScalingGroupsAsync(_Client, _GroupName); - Assert.IsTrue(details.Count > 0, "Couldn't find that Auto Scaling group."); - } - - [TestMethod()] - [TestProperty("Category", "Integration")] - public async Task EnableMetricsCollectionTest() - { - var success = await AutoScaleMethods.EnableMetricsCollectionAsync(_Client, _GroupName); - Assert.IsTrue(success, $"Couldn't enable metrics collection for {_GroupName}."); - } - - [TestMethod()] - [TestProperty("Category", "Integration")] - public async Task UpdateAutoScalingGroupTest() - { - var success = await AutoScaleMethods.UpdateAutoScalingGroupAsync(_Client, _GroupName, _LaunchTemplateName, _ServiceLinkedRoleArn, 3); - Assert.IsTrue(success, $"Couldn't update the Auto Scaling group: {_GroupName}."); - } - - [TestMethod()] - [TestProperty("Category", "Integration")] - public async Task CreateAutoScalingGroupTest() - { - var success = await AutoScaleMethods.CreateAutoScalingGroup(_Client, _GroupName, _LaunchTemplateName, _ServiceLinkedRoleArn); - Assert.IsTrue(success, "Couldn't create the Auto Scaling group."); - } - } -} \ No newline at end of file diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScale_BasicsTests.csproj b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScale_BasicsTests.csproj deleted file mode 100644 index 85db5cae209..00000000000 --- a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScale_BasicsTests.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - net6.0 - enable - enable - - false - - - - - - - - - - - - - - - - - diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/CloudWatchMethodsTests.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/CloudWatchMethodsTests.cs deleted file mode 100644 index 84ecfaf4215..00000000000 --- a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/CloudWatchMethodsTests.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -using Microsoft.VisualStudio.TestTools.UnitTesting; -using AutoScale_Basics; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AutoScale_Basics.Tests -{ - [TestClass()] - public class CloudWatchMethodsTests - { - private string _GroupName = "test-group-name"; - - [TestMethod()] - [TestProperty("Category", "Integration")] - public void GetCloudWatchMetricsAsyncTest() - { - var metrics = CloudWatchMethods.GetCloudWatchMetricsAsync(_GroupName); - Assert.IsNotNull(metrics, "No metrics were returned."); - } - - [TestMethod()] - [TestProperty("Category", "Integration")] - public void GetMetricStatisticsAsyncTest() - { - var metricStatistics = CloudWatchMethods.GetMetricStatisticsAsync(_GroupName); - Assert.IsNotNull(metricStatistics, "No statistics returned."); - } - } -} \ No newline at end of file diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/EC2MethodsTests.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/EC2MethodsTests.cs deleted file mode 100644 index c946c27231b..00000000000 --- a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/EC2MethodsTests.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -using AutoScale_Basics; -using Amazon.EC2; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace AutoScale_Basics.Tests -{ - [TestClass()] - public class EC2MethodsTests - { - private static readonly string imageId = "ami-05803413c51f242b7"; - private static readonly string instanceType = "t2.micro"; - private static readonly string launchTemplateName = "AutoScaleLaunchTemplateTest"; - private static string launchTemplateId = string.Empty; - - [TestMethod()] - [TestProperty("Category", "Integration")] - public async Task CreateLaunchTemplateAsyncTest() - { - launchTemplateId = await EC2Methods.CreateLaunchTemplateAsync(imageId, instanceType, launchTemplateName); - Assert.IsTrue(launchTemplateId != String.Empty, "Couldn't create launch template."); - } - - [TestMethod()] - [TestProperty("Category", "Integration")] - public async Task DeleteLaunchTemplateAsyncTest() - { - var deletedLaunchTemplateName = await EC2Methods.DeleteLaunchTemplateAsync(launchTemplateId); - Assert.IsTrue(deletedLaunchTemplateName == launchTemplateName, "Could not delete the launch template."); - } - - [TestMethod()] - [TestProperty("Category", "Integration")] - public async Task DescribeLaunchTemplateAsyncTest() - { - var success = await EC2Methods.DescribeLaunchTemplateAsync(launchTemplateName); - Assert.IsTrue(success, "Couldn't find any launch templates with the name {templateName}"); - } - } -} \ No newline at end of file From bfb9b52252a3da912e8d32f00f99fc16ad030c39 Mon Sep 17 00:00:00 2001 From: Brian Murray <40031786+brmur@users.noreply.github.com> Date: Tue, 4 Apr 2023 13:56:53 +0100 Subject: [PATCH 2/9] Revert "Dotnet AutoScaling updates" (#4642) Revert "Dotnet AutoScaling updates (#4593)" This reverts commit 684706797c1887a3905e2b996ffb1a169f937e55. --- .doc_gen/metadata/auto-scaling_metadata.yaml | 52 +-- .doc_gen/metadata/services.yaml | 4 +- .../Actions/AutoScalingActions.csproj | 20 - .../AutoScaling/Actions/AutoScalingWrapper.cs | 357 ----------------- .../AutoScaling/Actions/CloudWatchWrapper.cs | 89 ----- dotnetv3/AutoScaling/Actions/EC2Wrapper.cs | 98 ----- .../AutoScaling/Actions/HelloAutoScaling.cs | 38 -- dotnetv3/AutoScaling/AutoScalingExamples.sln | 48 --- dotnetv3/AutoScaling/README.md | 142 ++----- .../AutoScalingBasics/AutoScalingBasics.cs | 228 ----------- .../AutoScalingBasics.csproj | 33 -- .../Scenarios/AutoScalingBasics/UIWrapper.cs | 115 ------ .../Scenarios/AutoScalingBasics/Usings.cs | 16 - .../Scenarios/AutoScalingBasics/settings.json | 8 - .../AutoScaling/Tests/AutoScalingTests.csproj | 40 -- .../Tests/AutoScalingWrapperTests.cs | 323 --------------- dotnetv3/AutoScaling/Tests/Usings.cs | 21 - dotnetv3/AutoScaling/Tests/testsettings.json | 7 - .../AutoScale_Basics/AutoScale_Basics.sln | 31 ++ .../AutoScale_Basics/AutoScaleBasics.cs | 256 ++++++++++++ .../AutoScale_Basics/AutoScaleMethods.cs | 377 ++++++++++++++++++ .../AutoScale_Basics/AutoScale_Basics.csproj | 21 + .../AutoScale_Basics/CloudWatchMethods.cs | 82 ++++ .../AutoScale_Basics/EC2Methods.cs | 99 +++++ .../AutoScale_Basics/GlobalUsings.cs | 10 + .../AutoScaleMethodsTests.cs | 109 +++++ .../AutoScale_BasicsTests.csproj | 25 ++ .../CloudWatchMethodsTests.cs | 35 ++ .../AutoScale_BasicsTests/EC2MethodsTests.cs | 42 ++ 29 files changed, 1135 insertions(+), 1591 deletions(-) delete mode 100644 dotnetv3/AutoScaling/Actions/AutoScalingActions.csproj delete mode 100644 dotnetv3/AutoScaling/Actions/AutoScalingWrapper.cs delete mode 100644 dotnetv3/AutoScaling/Actions/CloudWatchWrapper.cs delete mode 100644 dotnetv3/AutoScaling/Actions/EC2Wrapper.cs delete mode 100644 dotnetv3/AutoScaling/Actions/HelloAutoScaling.cs delete mode 100644 dotnetv3/AutoScaling/AutoScalingExamples.sln delete mode 100644 dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.cs delete mode 100644 dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.csproj delete mode 100644 dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/UIWrapper.cs delete mode 100644 dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/Usings.cs delete mode 100644 dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/settings.json delete mode 100644 dotnetv3/AutoScaling/Tests/AutoScalingTests.csproj delete mode 100644 dotnetv3/AutoScaling/Tests/AutoScalingWrapperTests.cs delete mode 100644 dotnetv3/AutoScaling/Tests/Usings.cs delete mode 100644 dotnetv3/AutoScaling/Tests/testsettings.json create mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics.sln create mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleBasics.cs create mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs create mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScale_Basics.csproj create mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/CloudWatchMethods.cs create mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/EC2Methods.cs create mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/GlobalUsings.cs create mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScaleMethodsTests.cs create mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScale_BasicsTests.csproj create mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/CloudWatchMethodsTests.cs create mode 100644 dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/EC2MethodsTests.cs diff --git a/.doc_gen/metadata/auto-scaling_metadata.yaml b/.doc_gen/metadata/auto-scaling_metadata.yaml index 31711b8c824..566358f8e04 100644 --- a/.doc_gen/metadata/auto-scaling_metadata.yaml +++ b/.doc_gen/metadata/auto-scaling_metadata.yaml @@ -1,21 +1,4 @@ # zexi 0.4.0 -auto-scaling_Hello: - title: Hello &AS; - title_abbrev: Hello &AS; - synopsis: get started using &AS;. - category: Hello - languages: - .NET: - versions: - - sdk_version: 3 - github: dotnetv3/AutoScaling - sdkguide: - excerpts: - - description: - snippet_tags: - - AutoScaling.dotnetv3.AutoScalingActions.HelloAutoScaling - services: - auto-scaling: {DescribeAutoScalingGroups} auto-scaling_CreateAutoScalingGroup: title: Create an &AS; group using an &AWS; SDK title_abbrev: Create a group @@ -29,7 +12,7 @@ auto-scaling_CreateAutoScalingGroup: excerpts: - description: snippet_tags: - - AutoScaling.dotnetv3.AutoScalingActions.CreateAutoScalingGroup + - AutoScale.dotnetv3.AutoScale_Basics.CreateAutoScalingGroup Kotlin: versions: - sdk_version: 1 @@ -89,7 +72,7 @@ auto-scaling_DeleteAutoScalingGroup: excerpts: - description: snippet_tags: - - AutoScaling.dotnetv3.AutoScalingActions.DeleteAutoScalingGroup + - AutoScale.dotnetv3.AutoScale_Basics.DeleteAutoScalingGroup Kotlin: versions: - sdk_version: 1 @@ -148,7 +131,7 @@ auto-scaling_DescribeAutoScalingGroups: excerpts: - description: snippet_tags: - - AutoScaling.dotnetv3.AutoScalingActions.DescribeAutoScalingInstances + - AutoScale.dotnetv3.AutoScale_Basics.DescribeAutoScalingInstances Kotlin: versions: - sdk_version: 1 @@ -223,7 +206,7 @@ auto-scaling_UpdateAutoScalingGroup: excerpts: - description: snippet_tags: - - AutoScaling.dotnetv3.AutoScalingActions.UpdateAutoScalingGroup + - AutoScale.dotnetv3.AutoScale_Basics.UpdateAutoScalingGroup Python: versions: - sdk_version: 3 @@ -284,7 +267,7 @@ auto-scaling_TerminateInstanceInAutoScalingGroup: excerpts: - description: snippet_tags: - - AutoScaling.dotnetv3.AutoScalingActions.TerminateInstanceInAutoScalingGroup + - AutoScale.dotnetv3.AutoScale_Basics.TerminateInstanceInAutoScalingGroup Python: versions: - sdk_version: 3 @@ -338,7 +321,7 @@ auto-scaling_SetDesiredCapacity: excerpts: - description: snippet_tags: - - AutoScaling.dotnetv3.AutoScalingActions.SetDesiredCapacity + - AutoScale.dotnetv3.AutoScale_Basics.SetDesiredCapacity Python: versions: - sdk_version: 3 @@ -392,7 +375,7 @@ auto-scaling_DescribeAutoScalingInstances: excerpts: - description: snippet_tags: - - AutoScaling.dotnetv3.AutoScalingActions.DescribeAutoScalingInstances + - AutoScale.dotnetv3.AutoScale_Basics.DescribeAutoScalingInstances Python: versions: - sdk_version: 3 @@ -446,7 +429,7 @@ auto-scaling_DescribeScalingActivities: excerpts: - description: snippet_tags: - - AutoScaling.dotnetv3.AutoScalingActions.DescribeScalingActivities + - AutoScale.dotnetv3.AutoScale_Basics.DescribeScalingActivities Python: versions: - sdk_version: 3 @@ -500,7 +483,7 @@ auto-scaling_EnableMetricsCollection: excerpts: - description: snippet_tags: - - AutoScaling.dotnetv3.AutoScalingActions.EnableMetricsCollection + - AutoScale.dotnetv3.AutoScale_Basics.EnableMetricsCollection Python: versions: - sdk_version: 3 @@ -554,7 +537,7 @@ auto-scaling_DisableMetricsCollection: excerpts: - description: snippet_tags: - - AutoScaling.dotnetv3.AutoScalingActions.DisableMetricsCollection + - AutoScale.dotnetv3.AutoScale_Basics.DisableMetricsCollection Python: versions: - sdk_version: 3 @@ -600,17 +583,14 @@ auto-scaling_Scenario_GroupsAndInstances: excerpts: - description: snippet_tags: - - AutoScaling.dotnetv3.AutoScalingBasics.Usings - - AutoScaling.dotnetv3.AutoScalingBasics - - AutoScaling.dotnetv3.AutoScalingBasics.UIWrapper + - AutoScale.dotnetv3.AutoScale_Basics.global-usings + - AutoScale.dotnetv3.AutoScale_Basics.main - description: Define functions that are called by the scenario to - manage launch templates and metrics. These functions wrap &AS;, - &EC2;, and &CW; actions. + manage launch templates and metrics. These functions wrap + &EC2; and &CW; actions. snippet_tags: - - AutoScaling.dotnetv3.AutoScalingActions.Usings - - AutoScaling.dotnetv3.AutoScalingActions.AutoScalingWrapper - - AutoScaling.dotnetv3.AutoScalingActions.EC2Wrapper - - AutoScaling.dotnetv3.AutoScalingActions.CloudWatchWrapper + - AutoScale.dotnetv3.AutoScale_Basics.EC2Methods + - AutoScale.dotnetv3.AutoScale_Basics.CloudWatchMethods Kotlin: versions: - sdk_version: 1 diff --git a/.doc_gen/metadata/services.yaml b/.doc_gen/metadata/services.yaml index ea7b72cc683..76a8c7079e9 100644 --- a/.doc_gen/metadata/services.yaml +++ b/.doc_gen/metadata/services.yaml @@ -90,11 +90,11 @@ aurora: api_ref: AmazonRDS/latest/APIReference/Welcome.html auto-scaling: long: '&ASlong;' - short: '&AS;' + short: '&ASlong;' sort: EC2 Auto Scaling expanded: long: Amazon EC2 Auto Scaling - short: Auto Scaling + short: Amazon EC2 Auto Scaling blurb: automatically scales EC2 instances, either with scaling policies or with scheduled scaling. guide: diff --git a/dotnetv3/AutoScaling/Actions/AutoScalingActions.csproj b/dotnetv3/AutoScaling/Actions/AutoScalingActions.csproj deleted file mode 100644 index 734fffce190..00000000000 --- a/dotnetv3/AutoScaling/Actions/AutoScalingActions.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - Exe - net6.0 - enable - enable - - - - - - - - - - - - - diff --git a/dotnetv3/AutoScaling/Actions/AutoScalingWrapper.cs b/dotnetv3/AutoScaling/Actions/AutoScalingWrapper.cs deleted file mode 100644 index 768fccb1f60..00000000000 --- a/dotnetv3/AutoScaling/Actions/AutoScalingWrapper.cs +++ /dev/null @@ -1,357 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.AutoScalingWrapper] -using LaunchTemplateSpecification = Amazon.AutoScaling.Model.LaunchTemplateSpecification; - -namespace AutoScalingActions; - -using Amazon.AutoScaling; -using Amazon.AutoScaling.Model; - -/// -/// A class that includes methods to perform Amazon EC2 Auto Scaling -/// actions. -/// -public class AutoScalingWrapper -{ - private readonly IAmazonAutoScaling _amazonAutoScaling; - - /// - /// Constructor for the AutoScalingWrapper class. - /// - /// The injected Amazon EC2 Auto Scaling client. - public AutoScalingWrapper(IAmazonAutoScaling amazonAutoScaling) - { - _amazonAutoScaling = amazonAutoScaling; - } - - // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.CreateAutoScalingGroup] - - /// - /// Create a new Amazon EC2 Auto Scaling group. - /// - /// The name to use for the new Auto Scaling - /// group. - /// The name of the Amazon EC2 Auto Scaling - /// launch template to use to create instances in the group. - /// The AWS Identity and Access - /// Management (IAM) service-linked role that provides the permissions - /// for the Amazon EC2 Auto Scaling group. - /// A Boolean value indicating the success of the action. - public async Task CreateAutoScalingGroupAsync( - string groupName, - string launchTemplateName, - string availabilityZone, - string serviceLinkedRoleARN) - { - var templateSpecification = new LaunchTemplateSpecification - { - LaunchTemplateName = launchTemplateName, - }; - - var zoneList = new List - { - availabilityZone, - }; - - var request = new CreateAutoScalingGroupRequest - { - AutoScalingGroupName = groupName, - AvailabilityZones = zoneList, - LaunchTemplate = templateSpecification, - MaxSize = 6, - MinSize = 1, - ServiceLinkedRoleARN = serviceLinkedRoleARN, - }; - - var response = await _amazonAutoScaling.CreateAutoScalingGroupAsync(request); - Console.WriteLine($"{groupName} Auto Scaling Group created"); - return response.HttpStatusCode == System.Net.HttpStatusCode.OK; - } - - // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.CreateAutoScalingGroup] - - // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.DescribeAccountLimits] - - /// - /// Retrieve information about Amazon EC2 Auto Scaling quotas to the - /// active AWS account. - /// - /// A Boolean value indicating the success of the action. - public async Task DescribeAccountLimitsAsync() - { - var response = await _amazonAutoScaling.DescribeAccountLimitsAsync(); - Console.WriteLine("The maximum number of Auto Scaling groups is " + response.MaxNumberOfAutoScalingGroups); - Console.WriteLine("The current number of Auto Scaling groups is " + response.NumberOfAutoScalingGroups); - return response.HttpStatusCode == System.Net.HttpStatusCode.OK; - } - - // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.DescribeAccountLimits] - - // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.DescribeScalingActivities] - - /// - /// Retrieve a list of the Amazon EC2 Auto Scaling activities for an - /// Amazon EC2 Auto Scaling group. - /// - /// The name of the Amazon EC2 Auto Scaling group. - /// A list of Amazon EC2 Auto Scaling activities. - public async Task> DescribeScalingActivitiesAsync( - string groupName) - { - var scalingActivitiesRequest = new DescribeScalingActivitiesRequest - { - AutoScalingGroupName = groupName, - MaxRecords = 10, - }; - - var response = await _amazonAutoScaling.DescribeScalingActivitiesAsync(scalingActivitiesRequest); - return response.Activities; - } - - // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.DescribeScalingActivities] - - // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.DescribeAutoScalingInstances] - - /// - /// Get data about the instances in an Amazon EC2 Auto Scaling group. - /// - /// The name of the Amazon EC2 Auto Scaling group. - /// A list of Amazon EC2 Auto Scaling details. - public async Task> DescribeAutoScalingInstancesAsync( - string groupName) - { - var groups = await DescribeAutoScalingGroupsAsync(groupName); - var instanceIds = new List(); - groups.ForEach(group => - { - if (group.AutoScalingGroupName == groupName) - { - group.Instances.ForEach(instance => - { - instanceIds.Add(instance.InstanceId); - }); - } - }); - - var scalingGroupsRequest = new DescribeAutoScalingInstancesRequest - { - MaxRecords = 10, - InstanceIds = instanceIds, - }; - - var response = await _amazonAutoScaling.DescribeAutoScalingInstancesAsync(scalingGroupsRequest); - var instanceDetails = response.AutoScalingInstances; - - return instanceDetails; - } - - // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.DescribeAutoScalingInstances] - - // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.DescribeAutoScalingGroups] - - /// - /// Retrieve a list of information about Amazon EC2 Auto Scaling groups. - /// - /// The name of the Amazon EC2 Auto Scaling group. - /// A list of Amazon EC2 Auto Scaling groups. - public async Task?> DescribeAutoScalingGroupsAsync( - string groupName) - { - var groupList = new List - { - groupName, - }; - - var request = new DescribeAutoScalingGroupsRequest - { - AutoScalingGroupNames = groupList, - }; - - var response = await _amazonAutoScaling.DescribeAutoScalingGroupsAsync(request); - var groups = response.AutoScalingGroups; - - return groups; - } - - // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.DescribeAutoScalingGroups] - - // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.DeleteAutoScalingGroup] - /// - /// Delete an Auto Scaling group. - /// - /// The name of the Amazon EC2 Auto Scaling group. - /// A Boolean value indicating the success of the action. - public async Task DeleteAutoScalingGroupAsync( - string groupName) - { - var deleteAutoScalingGroupRequest = new DeleteAutoScalingGroupRequest - { - AutoScalingGroupName = groupName, - ForceDelete = true, - }; - - var response = await _amazonAutoScaling.DeleteAutoScalingGroupAsync(deleteAutoScalingGroupRequest); - if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) - { - Console.WriteLine($"You successfully deleted {groupName}"); - return true; - } - - Console.WriteLine($"Couldn't delete {groupName}."); - return false; - } - - // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.DeleteAutoScalingGroup] - - // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.DisableMetricsCollection] - /// - /// Disable the collection of metric data for an Amazon EC2 Auto Scaling - /// group. - /// - /// The name of the Auto Scaling group. - /// A Boolean value that indicates the success or failure of - /// the operation. - public async Task DisableMetricsCollectionAsync(string groupName) - { - var request = new DisableMetricsCollectionRequest - { - AutoScalingGroupName = groupName, - }; - - var response = await _amazonAutoScaling.DisableMetricsCollectionAsync(request); - return response.HttpStatusCode == System.Net.HttpStatusCode.OK; - } - - // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.DisableMetricsCollection] - - // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.EnableMetricsCollection] - /// - /// Enable the collection of metric data for an Auto Scaling group. - /// - /// The name of the Auto Scaling group. - /// A Boolean value indicating the success of the action. - public async Task EnableMetricsCollectionAsync(string groupName) - { - var listMetrics = new List - { - "GroupMaxSize", - }; - - var collectionRequest = new EnableMetricsCollectionRequest - { - AutoScalingGroupName = groupName, - Metrics = listMetrics, - Granularity = "1Minute", - }; - - var response = await _amazonAutoScaling.EnableMetricsCollectionAsync(collectionRequest); - return response.HttpStatusCode == System.Net.HttpStatusCode.OK; - } - - // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.EnableMetricsCollection] - - // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.SetDesiredCapacity] - /// - /// Set the desired capacity of an Auto Scaling group. - /// - /// The name of the Auto Scaling group. - /// The desired capacity for the Auto - /// Scaling group. - /// A Boolean value indicating the success of the action. - public async Task SetDesiredCapacityAsync( - string groupName, - int desiredCapacity) - { - var capacityRequest = new SetDesiredCapacityRequest - { - AutoScalingGroupName = groupName, - DesiredCapacity = desiredCapacity, - }; - - var response = await _amazonAutoScaling.SetDesiredCapacityAsync(capacityRequest); - Console.WriteLine($"You have set the DesiredCapacity to {desiredCapacity}."); - - return response.HttpStatusCode == System.Net.HttpStatusCode.OK; - } - - // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.SetDesiredCapacity] - - // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.TerminateInstanceInAutoScalingGroup] - /// - /// Terminate all instances in the Auto Scaling group in preparation for - /// deleting the group. - /// - /// The instance Id of the instance to terminate. - /// A Boolean value that indicates the success or failure of - /// the operation. - public async Task TerminateInstanceInAutoScalingGroupAsync( - string instanceId) - { - var request = new TerminateInstanceInAutoScalingGroupRequest - { - InstanceId = instanceId, - ShouldDecrementDesiredCapacity = false, - }; - - var response = await _amazonAutoScaling.TerminateInstanceInAutoScalingGroupAsync(request); - - if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) - { - Console.WriteLine($"You have terminated the instance: {instanceId}"); - return true; - } - - Console.WriteLine($"Could not terminate {instanceId}"); - return false; - } - - // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.TerminateInstanceInAutoScalingGroup] - - // snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.UpdateAutoScalingGroup] - /// - /// Update the capacity of an Auto Scaling group. - /// - /// The name of the Auto Scaling group. - /// The name of the EC2 launch template. - /// The Amazon Resource Name (ARN) - /// of the AWS Identity and Access Management (IAM) service-linked role. - /// The maximum number of instances that can be - /// created for the Auto Scaling group. - /// A Boolean value indicating the success of the action. - public async Task UpdateAutoScalingGroupAsync( - string groupName, - string launchTemplateName, - string serviceLinkedRoleARN, - int maxSize) - { - var templateSpecification = new LaunchTemplateSpecification - { - LaunchTemplateName = launchTemplateName, - }; - - var groupRequest = new UpdateAutoScalingGroupRequest - { - MaxSize = maxSize, - ServiceLinkedRoleARN = serviceLinkedRoleARN, - AutoScalingGroupName = groupName, - LaunchTemplate = templateSpecification, - }; - - var response = await _amazonAutoScaling.UpdateAutoScalingGroupAsync(groupRequest); - if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) - { - Console.WriteLine($"You successfully updated the Auto Scaling group {groupName}."); - return true; - } - else - { - return false; - } - } - - // snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.UpdateAutoScalingGroup] -} - -// snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.AutoScalingWrapper] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Actions/CloudWatchWrapper.cs b/dotnetv3/AutoScaling/Actions/CloudWatchWrapper.cs deleted file mode 100644 index 7861eed210f..00000000000 --- a/dotnetv3/AutoScaling/Actions/CloudWatchWrapper.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.CloudWatchWrapper] -namespace AutoScalingActions; - -using Amazon.CloudWatch; -using Amazon.CloudWatch.Model; - -/// -/// Contains methods to access Amazon CloudWatch metrics for the -/// Amazon EC2 Auto Scaling basics scenario. -/// -public class CloudWatchWrapper -{ - private readonly IAmazonCloudWatch _amazonCloudWatch; - - /// - /// Constructor for the CloudWatchWrapper. - /// - /// The injected CloudWatch client. - public CloudWatchWrapper(IAmazonCloudWatch amazonCloudWatch) - { - _amazonCloudWatch = amazonCloudWatch; - } - - /// - /// Retrieve the metrics information collection for the Auto Scaling group. - /// - /// The name of the Auto Scaling group. - /// A list of Metrics collected for the Auto Scaling group. - public async Task> GetCloudWatchMetricsAsync(string groupName) - { - var filter = new DimensionFilter - { - Name = "AutoScalingGroupName", - Value = $"{groupName}", - }; - - var request = new ListMetricsRequest - { - MetricName = "AutoScalingGroupName", - Dimensions = new List { filter }, - Namespace = "AWS/AutoScaling", - }; - - var response = await _amazonCloudWatch.ListMetricsAsync(request); - - return response.Metrics; - } - - /// - /// Retrieve the metric data collected for an Amazon EC2 Auto Scaling group. - /// - /// The name of the Amazon EC2 Auto Scaling group. - /// A list of data points. - public async Task> GetMetricStatisticsAsync(string groupName) - { - var metricDimensions = new List - { - new Dimension - { - Name = "AutoScalingGroupName", - Value = $"{groupName}", - }, - }; - - // The start time will be yesterday. - var startTime = DateTime.UtcNow.AddDays(-1); - - var request = new GetMetricStatisticsRequest - { - MetricName = "AutoScalingGroupName", - Dimensions = metricDimensions, - Namespace = "AWS/AutoScaling", - Period = 60, // 60 seconds. - Statistics = new List() { "Minimum" }, - StartTimeUtc = startTime, - EndTimeUtc = DateTime.UtcNow, - }; - - var response = await _amazonCloudWatch.GetMetricStatisticsAsync(request); - - return response.Datapoints; - } - -} - -// snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.CloudWatchWrapper] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Actions/EC2Wrapper.cs b/dotnetv3/AutoScaling/Actions/EC2Wrapper.cs deleted file mode 100644 index d3d9ed51c44..00000000000 --- a/dotnetv3/AutoScaling/Actions/EC2Wrapper.cs +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.EC2Wrapper] -namespace AutoScalingActions; - -using Amazon.EC2; -using Amazon.EC2.Model; - -public class EC2Wrapper -{ - private readonly IAmazonEC2 _amazonEc2; - - /// - /// Constructor for the EC2Wrapper class. - /// - /// The injected Amazon EC2 client. - public EC2Wrapper(IAmazonEC2 amazonEc2) - { - _amazonEc2 = amazonEc2; - } - - /// - /// Create a new Amazon EC2 launch template. - /// - /// The image Id to use for instances launched - /// using the Amazon EC2 launch template. - /// The type of EC2 instances to create. - /// The name of the launch template. - /// Returns the TemplateID of the new launch template. - public async Task CreateLaunchTemplateAsync( - string imageId, - string instanceType, - string launchTemplateName) - { - var request = new CreateLaunchTemplateRequest - { - LaunchTemplateData = new RequestLaunchTemplateData - { - ImageId = imageId, - InstanceType = instanceType, - }, - LaunchTemplateName = launchTemplateName, - }; - - var response = await _amazonEc2.CreateLaunchTemplateAsync(request); - - return response.LaunchTemplate.LaunchTemplateId; - } - - /// - /// Delete an Amazon EC2 launch template. - /// - /// The TemplateId of the launch template to - /// delete. - /// The name of the EC2 launch template that was deleted. - public async Task DeleteLaunchTemplateAsync(string launchTemplateId) - { - var request = new DeleteLaunchTemplateRequest - { - LaunchTemplateId = launchTemplateId, - }; - - var response = await _amazonEc2.DeleteLaunchTemplateAsync(request); - return response.LaunchTemplate.LaunchTemplateName; - } - - /// - /// Retrieve information about an EC2 launch template. - /// - /// The name of the EC2 launch template. - /// A Boolean value that indicates the success or failure of - /// the operation. - public async Task DescribeLaunchTemplateAsync(string launchTemplateName) - { - var request = new DescribeLaunchTemplatesRequest - { - LaunchTemplateNames = new List { launchTemplateName, }, - }; - - var response = await _amazonEc2.DescribeLaunchTemplatesAsync(request); - - if (response.LaunchTemplates is not null) - { - response.LaunchTemplates.ForEach(template => - { - Console.Write($"{template.LaunchTemplateName}\t"); - Console.WriteLine(template.LaunchTemplateId); - }); - - return true; - } - - return false; - } -} - -// snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.EC2Wrapper] diff --git a/dotnetv3/AutoScaling/Actions/HelloAutoScaling.cs b/dotnetv3/AutoScaling/Actions/HelloAutoScaling.cs deleted file mode 100644 index b8e5694fbe3..00000000000 --- a/dotnetv3/AutoScaling/Actions/HelloAutoScaling.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// snippet-start:[AutoScaling.dotnetv3.AutoScalingActions.HelloAutoScaling] - -namespace AutoScalingActions; - -using Amazon.AutoScaling; - -public class HelloAutoScaling -{ - /// - /// Hello Amazon EC2 Auto Scaling. List EC2 Auto Scaling groups. - /// - /// - /// Async Task. - 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."); - } - } -} - -// snippet-end:[AutoScaling.dotnetv3.AutoScalingActions.HelloAutoScaling] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/AutoScalingExamples.sln b/dotnetv3/AutoScaling/AutoScalingExamples.sln deleted file mode 100644 index 79b71e61df9..00000000000 --- a/dotnetv3/AutoScaling/AutoScalingExamples.sln +++ /dev/null @@ -1,48 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.2.32630.192 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Actions", "Actions", "{7907FB6A-1353-4735-95DC-EEC5DF8C0649}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scenarios", "Scenarios", "{B987097B-189C-4D0B-99BC-E67CD705BCA0}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{5455D423-2AFC-4BC6-B79D-9DC4270D8F7D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoScalingActions", "Actions\AutoScalingActions.csproj", "{796910FA-6E94-460B-8CB4-97DF01B9ADC8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoScalingBasics", "Scenarios\AutoScalingBasics\AutoScalingBasics.csproj", "{B1731AE1-381F-4044-BEBE-269FF7E24B1F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoScalingTests", "Tests\AutoScalingTests.csproj", "{6046A2FC-6A39-4C2D-8DD9-AA3740B17B88}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {796910FA-6E94-460B-8CB4-97DF01B9ADC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {796910FA-6E94-460B-8CB4-97DF01B9ADC8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {796910FA-6E94-460B-8CB4-97DF01B9ADC8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {796910FA-6E94-460B-8CB4-97DF01B9ADC8}.Release|Any CPU.Build.0 = Release|Any CPU - {B1731AE1-381F-4044-BEBE-269FF7E24B1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B1731AE1-381F-4044-BEBE-269FF7E24B1F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B1731AE1-381F-4044-BEBE-269FF7E24B1F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B1731AE1-381F-4044-BEBE-269FF7E24B1F}.Release|Any CPU.Build.0 = Release|Any CPU - {6046A2FC-6A39-4C2D-8DD9-AA3740B17B88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6046A2FC-6A39-4C2D-8DD9-AA3740B17B88}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6046A2FC-6A39-4C2D-8DD9-AA3740B17B88}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6046A2FC-6A39-4C2D-8DD9-AA3740B17B88}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {796910FA-6E94-460B-8CB4-97DF01B9ADC8} = {7907FB6A-1353-4735-95DC-EEC5DF8C0649} - {B1731AE1-381F-4044-BEBE-269FF7E24B1F} = {B987097B-189C-4D0B-99BC-E67CD705BCA0} - {6046A2FC-6A39-4C2D-8DD9-AA3740B17B88} = {5455D423-2AFC-4BC6-B79D-9DC4270D8F7D} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {870D888D-5C8B-4057-8722-F73ECF38E513} - EndGlobalSection -EndGlobal diff --git a/dotnetv3/AutoScaling/README.md b/dotnetv3/AutoScaling/README.md index 90af403e931..0fa89be3cbf 100644 --- a/dotnetv3/AutoScaling/README.md +++ b/dotnetv3/AutoScaling/README.md @@ -1,142 +1,60 @@ - -# Auto Scaling code examples for the SDK for .NET +# Amazon EC2 Auto Scaling code examples for the SDK for .NET ## Overview +The code examples in this section show how to use the AWS SDK for .NET with Amazon EC2 Auto Scaling to create and manage Amazon EC2 +Auto Scaling groups and instances. -Shows how to use the AWS SDK for .NET to work with Amazon EC2 Auto Scaling (Auto Scaling). - - - - -*Auto Scaling automatically scales EC2 instances, either with scaling policies or with scheduled scaling.* - -## ⚠ Important +Amazon EC2 Auto Scaling automatically scales EC2 instances, either with scaling +policies or with scheduled scaling. +## ⚠️ Important * Running this code might result in charges to your AWS account. * Running the tests might result in charges to your AWS account. * We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege). * This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services). - - - ## Code examples -### Get started - -* [Hello Auto Scaling](Actions/HelloAutoScaling.cs#L4) (`DescribeAutoScalingGroups`) - ### Single actions - Code excerpts that show you how to call individual service functions. -* [Create a group](Actions/AutoScalingWrapper.cs#L29) (`CreateAutoScalingGroup`) -* [Delete a group](Actions/AutoScalingWrapper.cs#L180) (`DeleteAutoScalingGroup`) -* [Disable metrics collection for a group](Actions/AutoScalingWrapper.cs#L208) (`DisableMetricsCollection`) -* [Enable metrics collection for a group](Actions/AutoScalingWrapper.cs#L229) (`EnableMetricsCollection`) -* [Get information about groups](Actions/AutoScalingWrapper.cs#L115) (`DescribeAutoScalingGroups`) -* [Get information about instances](Actions/AutoScalingWrapper.cs#L115) (`DescribeAutoScalingInstances`) -* [Get information about scaling activities](Actions/AutoScalingWrapper.cs#L92) (`DescribeScalingActivities`) -* [Set the desired capacity of a group](Actions/AutoScalingWrapper.cs#L255) (`SetDesiredCapacity`) -* [Terminate an instance in a group](Actions/AutoScalingWrapper.cs#L281) (`TerminateInstanceInAutoScalingGroup`) -* [Update a group](Actions/AutoScalingWrapper.cs#L312) (`UpdateAutoScalingGroup`) +* [Create a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`CreateAutoScalingGroupAsync`) +* [Delete a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`DeleteAutoScalingGroupAsync`) +* [Disable metrics collection for a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`DisableMetricsCollectionAsync`) +* [Enable metrics collection for a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`EnableMetricsCollectionAsync`) +* [Get information about account limits](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`DescribeAccountLimitsAsync`) +* [Get information about groups](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`DescribeAutoScalingGroupsAsync`) +* [Get information about instances](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`DescribeAutoScalingInstancesAsync`) +* [Get information about scaling activities](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`DescribeScalingActivitiesAsync`) +* [Set the desired capacity of a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`SetDesiredCapacityAsync`) +* [Terminate an instance in a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`TerminateInstanceInAutoScalingGroupAsync`) +* [Update a group](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) (`UpdateAutoScalingGroupAsync`) ### Scenarios +Code examples that show you how to accomplish a specific task by calling multiple functions within the same service. -Code examples that show you how to accomplish a specific task by calling multiple -functions within the same service. - -* [Manage groups and instances](Scenarios/AutoScalingBasics/UIWrapper.cs) +* [Auto Scaling basics](scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs) ## Run the examples ### Prerequisites +* To find prerequisites for running these examples, see the + [README](../README.md#Prerequisites) in the dotnetv3 folder. - -For prerequisites, see the [README](../README.md#Prerequisites) in the `dotnetv3` folder. - - - - - - -### Instructions - - - - - -#### Hello Auto Scaling - -This example shows you how to get started using Auto Scaling. - - -#### Manage groups and instances - -This example shows you how to do the following: - -* 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. - -Before you compile the .NET application, you can optionally set configuration values -in the settings.json file. Alternatively, add a settings.local.json file with -your local settings, which will be loaded automatically when the application runs. - -After the example compiles, you can run it from the command line. To do so, navigate to -the folder that contains the .csproj file and run the following command: +After the example compiles, you can run it from the command line. To do so, +navigate to the folder that contains the .csproj file and run the following +command: ``` dotnet run ``` -Alternatively, you can run the example from within your IDE. - - -### Configuration Settings - -This example uses several configuration settings that are stored in _settings.json_ -to change the existing values. - -**Note:** The image Id, instance type, and availability zone must be available in the AWS Region used by the account -used to run the scenario. In order to get valid settings, see: [Find a Linux AMI](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html) - -* **GroupName** - The name to use for the autoscaling group. -* **ImageId** - The image Id to use with the AutoScaling template. The AMI-ID column of the Amazon EC2 image locator table. -* **InstanceType** - The instance type to use with the template. The Instance Type column of the Amazon EC2 image locator table. -* **LaunchTemplateName** - The name of the launch template. -* **AvailabilityZone** - The availability zone for the launch template. The Zone column of the Amazon EC2 image locator table. -* **ServiceLinkedRoleArn** - The Amazon Resource Name (ARN) of a serivce-linked role that will be used - to create the AutoScaling group. - - - -### Tests -⚠ Running tests might result in charges to your AWS account. - - -To find instructions for running these tests, see the [README](../README.md#Tests) -in the `dotnetv3` folder. - - - - - +Alternatively, you can run the example from within your IDE. ## Additional resources +* [Amazon EC2 Auto Scaling User Guide](https://docs.aws.amazon.com/autoscaling/ec2/userguide/index.html) +* [Amazon EC2 Auto Scaling API Reference](https://docs.aws.amazon.com/autoscaling/ec2/APIReference/Welcome.html) +* [AWS SDK for .NET Amazon EC2 Auto Scaling](https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/AutoScaling/NAutoScaling.html) +* [AWS SDK for .NET Developer Guide](https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/welcome.html) -* [Auto Scaling User Guide](https://docs.aws.amazon.com/autoscaling/ec2/userguide/what-is-amazon-ec2-auto-scaling.html) -* [Auto Scaling API Reference](https://docs.aws.amazon.com/autoscaling/ec2/APIReference/Welcome.html) -* [SDK for .NET Auto Scaling reference](https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/Auto-scaling/NAuto-scaling.html) - - - - ---- - -Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. - -SPDX-License-Identifier: Apache-2.0 \ No newline at end of file +Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 diff --git a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.cs b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.cs deleted file mode 100644 index 3edaab9129f..00000000000 --- a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.cs +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// snippet-start:[AutoScaling.dotnetv3.AutoScalingBasics] - -using Amazon.EC2; -using Amazon.EC2.Model; -using Microsoft.Extensions.Configuration; - -namespace AutoScalingBasics; - -public class AutoScalingBasics -{ - private static ILogger logger = null!; - - 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("Microsoft", LogLevel.Information) - .AddFilter("Microsoft", LogLevel.Trace)) - .ConfigureServices((_, services) => - services.AddAWSService() - .AddAWSService() - .AddAWSService() - .AddTransient() - .AddTransient() - .AddTransient() - .AddTransient() - ) - .Build(); - - logger = LoggerFactory.Create(builder => { builder.AddConsole(); }) - .CreateLogger(); - - var autoScalingWrapper = host.Services.GetRequiredService(); - var cloudWatchWrapper = host.Services.GetRequiredService(); - var ec2Wrapper = host.Services.GetRequiredService(); - var uiWrapper = host.Services.GetRequiredService(); - - 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"]; - var availabilityZone = configuration["AvailabilityZone"]; - - // The name of the Auto Scaling group. - var groupName = configuration["GroupName"]; - - // The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) service-linked role. - var serviceLinkedRoleARN = configuration["ServiceLinkedRoleArn"]; - - 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(); - - Console.WriteLine($"Creating an Auto Scaling group named {groupName}."); - var success = await autoScalingWrapper.CreateAutoScalingGroupAsync( - groupName, - launchTemplateName, - availabilityZone, - serviceLinkedRoleARN); - - // 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 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); - - // Show the metrics that are collected for the group. - - // Update the maximum size of the group to three instances. - Console.WriteLine("--- Update the Auto Scaling group to increase max size to 3 ---"); - int maxSize = 3; - await autoScalingWrapper.UpdateAutoScalingGroupAsync(groupName, launchTemplateName, serviceLinkedRoleARN, maxSize); - - Console.WriteLine("--- Describe all Auto Scaling groups to show the current state of the group ---"); - var groups = await autoScalingWrapper.DescribeAutoScalingGroupsAsync(groupName); - - uiWrapper.DisplayGroupDetails(groups); - - uiWrapper.PressEnter(); - - uiWrapper.DisplayTitle("Describe account limits"); - await autoScalingWrapper.DescribeAccountLimitsAsync(); - - uiWrapper.WaitABit(60, "Waiting for the resources to be ready."); - - uiWrapper.DisplayTitle("Set desired capacity"); - int desiredCapacity = 2; - await autoScalingWrapper.SetDesiredCapacityAsync(groupName, desiredCapacity); - - Console.WriteLine("Get the two instance Id values"); - - // Empty the group before getting the details again. - groups.Clear(); - groups = await autoScalingWrapper.DescribeAutoScalingGroupsAsync(groupName); - if (groups is not null) - { - foreach (AutoScalingGroup group in groups) - { - Console.WriteLine($"The group name is {group.AutoScalingGroupName}"); - Console.WriteLine($"The group ARN is {group.AutoScalingGroupARN}"); - var instances = group.Instances; - foreach (Instance instance in instances) - { - Console.WriteLine($"The instance id is {instance.InstanceId}"); - Console.WriteLine($"The lifecycle state is {instance.LifecycleState}"); - } - } - } - - uiWrapper.DisplayTitle("Scaling Activities"); - Console.WriteLine("Let's list the scaling activities that have occurred for the group."); - var activities = await autoScalingWrapper.DescribeScalingActivitiesAsync(groupName); - if (activities is not null) - { - activities.ForEach(activity => - { - Console.WriteLine($"The activity Id is {activity.ActivityId}"); - Console.WriteLine($"The activity details are {activity.Details}"); - }); - } - - // Display the Amazon CloudWatch metrics that have been collected. - var metrics = await cloudWatchWrapper.GetCloudWatchMetricsAsync(groupName); - Console.WriteLine($"Metrics collected for {groupName}:"); - metrics.ForEach(metric => - { - Console.Write($"Metric name: {metric.MetricName}\t"); - Console.WriteLine($"Namespace: {metric.Namespace}"); - }); - - var dataPoints = await cloudWatchWrapper.GetMetricStatisticsAsync(groupName); - Console.WriteLine("Details for the metrics collected:"); - dataPoints.ForEach(detail => - { - Console.WriteLine(detail); - }); - - // Disable metrics collection. - Console.WriteLine("Disabling the collection of metrics for {groupName}."); - success = await autoScalingWrapper.DisableMetricsCollectionAsync(groupName); - - if (success) - { - Console.WriteLine($"Successfully stopped metrics collection for {groupName}."); - } - else - { - Console.WriteLine($"Could not stop metrics collection for {groupName}."); - } - - // Terminate all instances in the group. - uiWrapper.DisplayTitle("Terminating Auto Scaling instances"); - Console.WriteLine("Now terminating all instances in the Auto Scaling group."); - - if (groups is not null) - { - groups.ForEach(group => - { - // Only delete instances in the AutoScaling group we created. - if (group.AutoScalingGroupName == groupName) - { - group.Instances.ForEach(async instance => - { - await autoScalingWrapper.TerminateInstanceInAutoScalingGroupAsync(instance.InstanceId); - }); - } - }); - } - - // After all instances are terminated, delete the group. - uiWrapper.DisplayTitle("Clean up resources"); - Console.WriteLine("Deleting the Auto Scaling group."); - await autoScalingWrapper.DeleteAutoScalingGroupAsync(groupName); - - // Delete the launch template. - var deletedLaunchTemplateName = await ec2Wrapper.DeleteLaunchTemplateAsync(launchTemplateId); - - if (deletedLaunchTemplateName == launchTemplateName) - { - Console.WriteLine("Successfully deleted the launch template."); - } - - Console.WriteLine("The demo is now concluded."); - } -} - -// snippet-end:[AutoScaling.dotnetv3.AutoScalingBasics] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.csproj b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.csproj deleted file mode 100644 index d2b8e5ae3b7..00000000000 --- a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/AutoScalingBasics.csproj +++ /dev/null @@ -1,33 +0,0 @@ - - - - Exe - net6.0 - enable - enable - - - - - - - - - - - - - - PreserveNewest - - - PreserveNewest - settings.json - - - - - - - - diff --git a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/UIWrapper.cs b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/UIWrapper.cs deleted file mode 100644 index 45dfdf2e5c0..00000000000 --- a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/UIWrapper.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// snippet-start:[AutoScaling.dotnetv3.AutoScalingBasics.UIWrapper] -namespace AutoScalingBasics; - -/// -/// A class to provide user interface methods for the EC2 AutoScaling Basics -/// scenario. -/// -public class UIWrapper -{ - public readonly string SepBar = new('-', Console.WindowWidth); - - /// - /// Describe the steps in the EC2 AutoScaling Basics scenario. - /// - public void DisplayAutoScalingBasicsDescription() - { - Console.WriteLine("This code example performs the following operations:"); - Console.WriteLine(" 1. Creates an Amazon EC2 launch template."); - Console.WriteLine(" 2. Creates an Auto Scaling group."); - Console.WriteLine(" 3. Shows the details of the new Auto Scaling group"); - Console.WriteLine(" to show that only one instance was created."); - Console.WriteLine(" 4. Enables metrics collection."); - Console.WriteLine(" 5. Updates the Auto Scaling group to increase the"); - Console.WriteLine(" capacity to three."); - Console.WriteLine(" 6. Describes Auto Scaling groups again to show the"); - Console.WriteLine(" current state of the group."); - Console.WriteLine(" 7. Changes the desired capacity of the Auto Scaling"); - Console.WriteLine(" group to use an additional instance."); - Console.WriteLine(" 8. Shows that there are now instances in the group."); - Console.WriteLine(" 9. Lists the scaling activities that have occurred for the group."); - Console.WriteLine("10. Displays the Amazon CloudWatch metrics that have"); - Console.WriteLine(" been collected."); - Console.WriteLine("11. Disables metrics collection."); - Console.WriteLine("12. Terminates all instances in the Auto Scaling group."); - Console.WriteLine("13. Deletes the Auto Scaling group."); - Console.WriteLine("14. Deletes the Amazon EC2 launch template."); - PressEnter(); - } - - /// - /// Display information about the Amazon Ec2 AutoScaling groups passed - /// in the list of AutoScalingGroup objects. - /// - /// A list of AutoScalingGroup objects. - public void DisplayGroupDetails(List groups) - { - if (groups is null) - return; - - groups.ForEach(group => - { - Console.WriteLine($"Group name:\t{group.AutoScalingGroupName}"); - Console.WriteLine($"Group created:\t{group.CreatedTime}"); - Console.WriteLine($"Maximum number of instances:\t{group.MaxSize}"); - Console.WriteLine($"Desired number of instances:\t{group.DesiredCapacity}"); - }); - } - - /// - /// Display a message and wait until the user presses enter. - /// - public void PressEnter() - { - Console.Write("\nPress to continue. "); - _ = Console.ReadLine(); - Console.WriteLine(); - } - - /// - /// Pad a string with spaces to center it on the console display. - /// - /// The string to be centered. - /// The padded string. - public string CenterString(string strToCenter) - { - var padAmount = (Console.WindowWidth - strToCenter.Length) / 2; - var leftPad = new string(' ', padAmount); - return $"{leftPad}{strToCenter}"; - } - - /// - /// Display a line of hyphens, the centered text of the title and another - /// line of hyphens. - /// - /// The string to be displayed. - public void DisplayTitle(string strTitle) - { - Console.WriteLine(SepBar); - Console.WriteLine(CenterString(strTitle)); - Console.WriteLine(SepBar); - } - - /// - /// Display a countdown and wait for a number of seconds. - /// - /// The number of seconds to wait. - public void WaitABit(int numSeconds, string msg) - { - Console.WriteLine(msg); - - // Wait for the requested number of seconds. - for (int i = numSeconds; i > 0; i--) - { - System.Threading.Thread.Sleep(1000); - Console.Write($"{i}..."); - } - - PressEnter(); - } -} - -// snippet-end:[AutoScaling.dotnetv3.AutoScalingBasics.UIWrapper] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/Usings.cs b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/Usings.cs deleted file mode 100644 index a4a69321c66..00000000000 --- a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/Usings.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// snippet-start:[AutoScaling.dotnetv3.AutoScalingBasics.Usings] -global using Amazon.AutoScaling; -global using Amazon.AutoScaling.Model; -global using Amazon.CloudWatch; -global using Amazon.CloudWatch.Model; -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; -global using AutoScalingActions; - -// snippet-end:[AutoScaling.dotnetv3.AutoScalingBasics.Usings] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/settings.json b/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/settings.json deleted file mode 100644 index b7336a46cb8..00000000000 --- a/dotnetv3/AutoScaling/Scenarios/AutoScalingBasics/settings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "GroupName": "mvp-group-name", - "ImageId": "ami-05803413c51f242b7", - "InstanceType": "t2.micro", - "LaunchTemplateName": "AutoScaleLaunchTemplate", - "AvailabilityZone": "availability zone matching ImageId", - "ServiceLinkedRoleArn": "" -} diff --git a/dotnetv3/AutoScaling/Tests/AutoScalingTests.csproj b/dotnetv3/AutoScaling/Tests/AutoScalingTests.csproj deleted file mode 100644 index 0d130e6c9e1..00000000000 --- a/dotnetv3/AutoScaling/Tests/AutoScalingTests.csproj +++ /dev/null @@ -1,40 +0,0 @@ - - - - net6.0 - enable - enable - - false - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - PreserveNewest - - - PreserveNewest - testsettings.json - - - - - - - - diff --git a/dotnetv3/AutoScaling/Tests/AutoScalingWrapperTests.cs b/dotnetv3/AutoScaling/Tests/AutoScalingWrapperTests.cs deleted file mode 100644 index 605157c5220..00000000000 --- a/dotnetv3/AutoScaling/Tests/AutoScalingWrapperTests.cs +++ /dev/null @@ -1,323 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -using Amazon.AutoScaling; -using Amazon.AutoScaling.Model; -using Amazon.EC2; -using AutoScalingActions; - -namespace AutoScalingTests -{ - public class AutoScalingWrapperTests - { - private readonly IConfiguration _configuration; - private readonly AmazonAutoScalingClient _autoScalingClient; - private readonly AutoScalingWrapper _autoScalingWrapper; - private readonly AmazonEC2Client _ec2Client; - private readonly EC2Wrapper _ec2Wrapper; - private readonly AmazonCloudWatchClient _cloudWatchClient; - private readonly CloudWatchWrapper _cloudWatchWrapper; - - private readonly string? _groupName; - private readonly string? _imageId; - private readonly string? _instanceType; - private readonly string? _launchTemplateName; - private readonly string? _availabilityZone; - - // the Amazon Resource Name (ARN) of the IAM service linked role. - private readonly string? _serviceLinkedRoleArn; - private readonly string? _nameGuid; - - private static string? _launchTemplateId; - private static List? _groups; - public static string? InstanceId; - - /// - /// Constructor for the test class. - /// - public AutoScalingWrapperTests() - { - _configuration = new ConfigurationBuilder() - .SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("testsettings.json") // Load test settings from .json file. - .AddJsonFile("testsettings.local.json", - true) // Optionally load local settings. - .Build(); - - // Values needed for testing purposes. - _autoScalingClient = new AmazonAutoScalingClient(); - _autoScalingWrapper = new AutoScalingWrapper(_autoScalingClient); - _ec2Client = new AmazonEC2Client(); - _ec2Wrapper = new EC2Wrapper(_ec2Client); - _cloudWatchClient = new AmazonCloudWatchClient(); - _cloudWatchWrapper = new CloudWatchWrapper(_cloudWatchClient); - - _nameGuid = new Guid().ToString(); - _imageId = _configuration["ImageId"]; - _instanceType = _configuration["InstanceType"]; - _launchTemplateName = $"{_configuration["LaunchTemplateName"]}-{_nameGuid}"; - _availabilityZone = _configuration["AvailabilityZone"]; - - // The name of the Auto Scaling group. - _groupName = $"{_configuration["GroupName"]}-{_nameGuid}"; - - // The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) service-linked role. - _serviceLinkedRoleArn = _configuration["ServiceLinkedRoleArn"]; - } - - /// - /// Test the CreateLaunchTemplateAsync method. The call should return - /// a LaunchTemplate Id. - /// - /// Async Task. - [Fact()] - [Order(1)] - [Trait("Category", "Integration")] - public async Task CreateLaunchTemplateAsyncTest() - { - _launchTemplateId = await _ec2Wrapper.CreateLaunchTemplateAsync(_imageId, _instanceType, _launchTemplateName); - Assert.NotNull(_launchTemplateId); - } - - /// - /// Test the DescribeLaunchTemplateAsync method. The method should succeed. - /// - /// Async Task. - [Fact()] - [Order(2)] - [Trait("Category", "Integration")] - public async Task DescribeLaunchTemplateAsyncTest() - { - var success = await _ec2Wrapper.DescribeLaunchTemplateAsync(_launchTemplateName); - Assert.True(success); - } - - /// - /// Test the CreateAutoScalingGroupAsync method. The method call should - /// create an Auto Scaling group and return true. - /// - /// Async Task. - [Fact()] - [Order(3)] - [Trait("Category", "Integration")] - public async Task CreateAutoScalingGroupTest() - { - var success = await _autoScalingWrapper.CreateAutoScalingGroupAsync(_groupName, _launchTemplateName, _serviceLinkedRoleArn); - Assert.True(success, $"Couldn't create the Auto Scaling group {_groupName}."); - } - - /// - /// Test the DescribeAutoScalingInstancesAsync method. The call should - /// return information about instances in the logging group and the - /// value should not be null. - /// - /// Async Task. - [Fact()] - [Order(4)] - [Trait("Category", "Integration")] - public async Task DescribeAutoScalingInstancesAsyncTest() - { - var instanceDetails = await _autoScalingWrapper.DescribeAutoScalingInstancesAsync(_groupName); - Assert.NotNull(instanceDetails); - } - - /// - /// Test the EnableMetricsCollectionAsync method, which should succeed. - /// - /// Async Task. - [Fact()] - [Order(5)] - [Trait("Category", "Integration")] - public async Task EnableMetricsCollectionAsyncTest() - { - var success = await _autoScalingWrapper.EnableMetricsCollectionAsync(_groupName); - Assert.True(success, $"Couldn't enable metrics collection for {_groupName}."); - } - - /// - /// Test the SetDesiredCapacity method by sending a different - /// value for maximum capacity. It confirms success by retrieving - /// the list of Auto Scaling groups and checking the value of - /// DesiredCapacity. - /// - /// Async Task. - [Fact()] - [Order(6)] - [Trait("Category", "Integration")] - public async Task SetDesiredCapacityAsyncTest() - { - var newMax = 3; - var success = await _autoScalingWrapper.SetDesiredCapacityAsync(_groupName, newMax); - Assert.True(success, "Couldn't set the desired capacity."); - _groups = await _autoScalingWrapper.DescribeAutoScalingGroupsAsync(_groupName); - _groups.ForEach(group => - { - if (group.AutoScalingGroupName == _groupName) - { - Assert.Equal(newMax, group.DesiredCapacity); - } - }); - } - - /// - /// Test the UpdateAutoScalingGroup method by changing the maximum - /// capacity. After the change is made, the DescribeAutoScalingGroupsAsync - /// method checks the capacity for the group. - /// - /// Async Task. - [Fact()] - [Order(7)] - [Trait("Category", "Integration")] - public async Task UpdateAutoScalingGroupTest() - { - var newMax = 3; - var success = await _autoScalingWrapper.UpdateAutoScalingGroupAsync(_groupName, _launchTemplateName, _serviceLinkedRoleArn, newMax); - Assert.True(success, $"Couldn't update the Auto Scaling group: {_groupName}."); - _groups = await _autoScalingWrapper.DescribeAutoScalingGroupsAsync(_groupName); - _groups.ForEach(group => - { - if (group.AutoScalingGroupName == _groupName) - { - Assert.Equal(newMax, group.DesiredCapacity); - } - }); - } - - /// - /// Test the DescribeAutoScalingGroupsAsync method. - /// - /// Async Task. - [Fact()] - [Order(8)] - [Trait("Category", "Integration")] - public async Task DescribeAutoScalingGroupsAsyncTest() - { - var details = await _autoScalingWrapper.DescribeAutoScalingGroupsAsync(_groupName); - Assert.True(details.Count > 0, $"Couldn't find that Auto Scaling group {_groupName}."); - } - - /// - /// Test the DescribeAutoScalingActivitiesAsync method. The method - /// should return a non-null collection of activities. - /// - /// Async Task. - [Fact()] - [Order(9)] - [Trait("Category", "Integration")] - public async Task DescribeScalingActivitiesAsyncTest() - { - var activities = await _autoScalingWrapper.DescribeScalingActivitiesAsync(_groupName); - Assert.NotNull(activities); - } - - /// - /// Test the GetCloudWatchMetricsAsync method. The metrics collection - /// should not be null. - /// - /// Async Task. - [Fact()] - [Order(10)] - [Trait("Category", "Integration")] - public async Task GetCloudWatchMetricsAsyncTest() - { - var metrics = await _cloudWatchWrapper.GetCloudWatchMetricsAsync(_groupName); - Assert.NotNull(metrics); - } - - /// - /// Test the GetMetricStatisticsAsync method. The data points - /// collection should not be null. - /// - /// Async Task. - [Fact()] - [Order(11)] - [Trait("Category", "Integration")] - public async Task GetMetricStatisticsAsyncTest() - { - var dataPoints = await _cloudWatchWrapper.GetMetricStatisticsAsync(_groupName); - Assert.NotNull(dataPoints); - } - - /// - /// Test the DisableMetricsCollectionAsync method. The method should - /// succeed. - /// - /// Async Task. - [Fact()] - [Order(12)] - [Trait("Category", "Integration")] - public async Task DisableMetricsCollectionAsyncTest() - { - var success = await _autoScalingWrapper.DisableMetricsCollectionAsync(_groupName); - Assert.True(success); - } - - /// - /// Test the TerminateInstanceAutoScalingGroupsAsync method to - /// terminate all instances created during the test. It should - /// be successful. - /// - /// Async Task. - [Fact()] - [Order(13)] - [Trait("Category", "Integration")] - public async Task TerminateInstanceInAutoScalingGroupAsyncTest() - { - foreach (var group in _groups) - { - if (group.AutoScalingGroupName == _groupName) - { - foreach (Amazon.AutoScaling.Model.Instance instance in group.Instances) - { - var success = await _autoScalingWrapper.TerminateInstanceInAutoScalingGroupAsync(instance.InstanceId); - Assert.True(success, "Could not terminate the instance."); - }; - } - }; - } - - /// - /// Test the DeleteAutoScalingGroupAsync method to delete the group - /// created for testing. The call should be successful. - /// - /// Async Task. - [Fact()] - [Order(14)] - [Trait("Category", "Integration")] - public async Task DeleteAutoScalingGroupTest() - { - var success = await _autoScalingWrapper.DeleteAutoScalingGroupAsync(_groupName); - Assert.True(success, "Could not delete the group."); - } - - /// - /// Test the DeleteLaunchTemplateAsync method by deleting the template - /// created for testing purposes. If successful, the value returned - /// should be equal to the name of the launch template created by the - /// test class. - /// - /// Async Task. - [Fact()] - [Order(15)] - [Trait("Category", "Integration")] - public async Task DeleteLaunchTemplateAsyncTest() - { - var templateName = await _ec2Wrapper.DeleteLaunchTemplateAsync(_launchTemplateId); - Assert.Equal(_launchTemplateName, templateName); - } - - /// - /// Test the DescribeAccountLimitsAsync method. It doesn't matter when - /// this runs, since it is retrieving information that should be - /// available at any time. - /// - /// Async Task. - [Fact()] - [Trait("Category", "Integration")] - public async Task DescribeAccountLimitsTest() - { - var success = await _autoScalingWrapper.DescribeAccountLimitsAsync(); - Assert.True(success, "Couldn't retrieve account limits."); - } - } -} \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Tests/Usings.cs b/dotnetv3/AutoScaling/Tests/Usings.cs deleted file mode 100644 index 8dbb18ff915..00000000000 --- a/dotnetv3/AutoScaling/Tests/Usings.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -global using Amazon; -global using Amazon.CloudWatch.Model; -global using Amazon.CloudWatch; -global using Amazon.EC2.Model; -global using Amazon.EC2; -global using Microsoft.Extensions.Configuration; -global using Microsoft.Extensions.Hosting; -global using Microsoft.Extensions.DependencyInjection; -global using Xunit; -global using Xunit.Extensions.Ordering; -global using AutoScalingActions; - -// Optional. -[assembly: CollectionBehavior(DisableTestParallelization = true)] -// Optional. -[assembly: TestCaseOrderer("Xunit.Extensions.Ordering.TestCaseOrderer", "Xunit.Extensions.Ordering")] -// Optional. -[assembly: TestCollectionOrderer("Xunit.Extensions.Ordering.CollectionOrderer", "Xunit.Extensions.Ordering")] \ No newline at end of file diff --git a/dotnetv3/AutoScaling/Tests/testsettings.json b/dotnetv3/AutoScaling/Tests/testsettings.json deleted file mode 100644 index 75c3df7ae48..00000000000 --- a/dotnetv3/AutoScaling/Tests/testsettings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "GroupName": "test-group-name", - "ImageId": "ami-05803413c51f242b7", - "InstanceType": "t2.micro", - "LaunchTemplateName": "AutoScaleLaunchTemplate", - "ServiceLinkedRoleArn": "" -} diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics.sln b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics.sln new file mode 100644 index 00000000000..833cd1c2533 --- /dev/null +++ b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32616.157 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoScale_Basics", "AutoScale_Basics\AutoScale_Basics.csproj", "{891E079C-B295-4439-8718-C8FF16F0D2AD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoScale_BasicsTests", "AutoScale_BasicsTests\AutoScale_BasicsTests.csproj", "{357D5324-29A5-45C8-9702-573A2E3BDC31}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {891E079C-B295-4439-8718-C8FF16F0D2AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {891E079C-B295-4439-8718-C8FF16F0D2AD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {891E079C-B295-4439-8718-C8FF16F0D2AD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {891E079C-B295-4439-8718-C8FF16F0D2AD}.Release|Any CPU.Build.0 = Release|Any CPU + {357D5324-29A5-45C8-9702-573A2E3BDC31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {357D5324-29A5-45C8-9702-573A2E3BDC31}.Debug|Any CPU.Build.0 = Debug|Any CPU + {357D5324-29A5-45C8-9702-573A2E3BDC31}.Release|Any CPU.ActiveCfg = Release|Any CPU + {357D5324-29A5-45C8-9702-573A2E3BDC31}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {50392892-4D6A-41F4-8A5E-6C0495AF4CA1} + EndGlobalSection +EndGlobal diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleBasics.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleBasics.cs new file mode 100644 index 00000000000..938475ace7a --- /dev/null +++ b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleBasics.cs @@ -0,0 +1,256 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +/* + Before running this AWS SDK for .NET (v3) code example, set up your + development environment, including your credentials. + + For more information, see the following documentation: + + https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-setup.html + + This example creates an Amazon Elastic Compute Cloud (Amazon EC2) launch + template. You can also use the Amazon EC2 console. For more information, see + the following: + + https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html#create-launch-template + + This code example performs the following operations: + 1. Creates an Amazon EC2 launch template + 2. Creates an Amazon EC2 Auto Scaling group. + 3. Shows the details of the new Auto Scaling group to show that only + one instance was created. + 4. Enables metrics collection. + 5. Updates the Auto Scaling group to increase the max size to three. + 6. Describes Auto Scaling groups again to show the current state of the + group. + 7. Changes the desired capacity of the Auto Scaling group to two. + 9. Retrieves the details of the group and shows the number of instances. + 10. Lists the scaling activities that have occurred for the group. + 11. Displays the Amazon CloudWatch metrics that have been collected. + 12. Terminates an instance in the Auto Scaling group. + 13. Disables metrics collection. + 13. Deletes the Auto Scaling group. + 14. Deletes the Amazon EC2 launch template. +*/ + +// snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.main] +var imageId = "ami-05803413c51f242b7"; +var instanceType = "t2.micro"; +var launchTemplateName = "AutoScaleLaunchTemplate"; + +// The name of the Auto Scaling group. +var groupName = "AutoScaleExampleGroup"; + +// The Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) service-linked role. +var serviceLinkedRoleARN = ""; + +var client = new AmazonAutoScalingClient(RegionEndpoint.USEast2); + +Console.WriteLine("Auto Scaling Basics"); +DisplayDescription(); + +// 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 EC2Methods.CreateLaunchTemplateAsync(imageId, instanceType, launchTemplateName); + +// Confirm that the template was created by asking for a description of it. +await EC2Methods.DescribeLaunchTemplateAsync(launchTemplateName); + +PressEnter(); + +Console.WriteLine($"--- Creating an Auto Scaling group named {groupName}. ---"); +var success = await AutoScaleMethods.CreateAutoScalingGroup( + client, + groupName, + launchTemplateName, + serviceLinkedRoleARN); + +// 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 instanceDetails; + +do +{ + instanceDetails = await AutoScaleMethods.DescribeAutoScalingInstancesAsync(client, 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}"); +}); + +PressEnter(); + +Console.WriteLine($"\n--- Enable metrics collection for {groupName}"); +await AutoScaleMethods.EnableMetricsCollectionAsync(client, groupName); + +// Show the metrics that are collected for the group. + +// Update the maximum size of the group to three instances. +Console.WriteLine("--- Update the Auto Scaling group to increase max size to 3 ---"); +int maxSize = 3; +await AutoScaleMethods.UpdateAutoScalingGroupAsync(client, groupName, launchTemplateName, serviceLinkedRoleARN, maxSize); + +Console.WriteLine("--- Describe all Auto Scaling groups to show the current state of the group ---"); +var groups = await AutoScaleMethods.DescribeAutoScalingGroupsAsync(client, groupName); + +DisplayGroupDetails(groups); + +PressEnter(); + +Console.WriteLine("--- Describe account limits ---"); +await AutoScaleMethods.DescribeAccountLimitsAsync(client); + +Console.WriteLine("Wait 1 min for the resources, including the instance. Otherwise, an empty instance Id is returned"); +System.Threading.Thread.Sleep(60000); + +Console.WriteLine("--- Set desired capacity to 2 ---"); +int desiredCapacity = 2; +await AutoScaleMethods.SetDesiredCapacityAsync(client, groupName, desiredCapacity); + +Console.WriteLine("--- Get the two instance Id values and state ---"); + +// Empty the group before getting the details again. +groups.Clear(); +groups = await AutoScaleMethods.DescribeAutoScalingGroupsAsync(client, groupName); +if (groups is not null) +{ + foreach (AutoScalingGroup group in groups) + { + Console.WriteLine($"The group name is {group.AutoScalingGroupName}"); + Console.WriteLine($"The group ARN is {group.AutoScalingGroupARN}"); + var instances = group.Instances; + foreach (Instance instance in instances) + { + Console.WriteLine($"The instance id is {instance.InstanceId}"); + Console.WriteLine($"The lifecycle state is {instance.LifecycleState}"); + } + } +} + +Console.WriteLine("**** List the scaling activities that have occurred for the group"); +var activities = await AutoScaleMethods.DescribeAutoScalingActivitiesAsync(client, groupName); +if (activities is not null) +{ + activities.ForEach(activity => + { + Console.WriteLine($"The activity Id is {activity.ActivityId}"); + Console.WriteLine($"The activity details are {activity.Details}"); + }); +} + +// Display the Amazon CloudWatch metrics that have been collected. +var metrics = await CloudWatchMethods.GetCloudWatchMetricsAsync(groupName); +Console.WriteLine($"Metrics collected for {groupName}:"); +metrics.ForEach(metric => +{ + Console.Write($"Metric name: {metric.MetricName}\t"); + Console.WriteLine($"Namespace: {metric.Namespace}"); +}); + +var dataPoints = await CloudWatchMethods.GetMetricStatisticsAsync(groupName); +Console.WriteLine("Details for the metrics collected:"); +dataPoints.ForEach(detail => +{ + Console.WriteLine(detail); +}); + +// Disable metrics collection. +Console.WriteLine("Disabling the collection of metrics for {groupName}."); +success = await AutoScaleMethods.DisableMetricsCollectionAsync(client, groupName); + +if (success) +{ + Console.WriteLine($"Successfully stopped metrics collection for {groupName}."); +} +else +{ + Console.WriteLine($"Could not stop metrics collection for {groupName}."); +} + +// Terminate all instances in the group. +Console.WriteLine("--- Now terminating all instances in the AWS Auto Scaling group ---"); + +if (groups is not null) +{ + groups.ForEach(group => + { + // Only delete instances in the AutoScaling group we created. + if (group.AutoScalingGroupName == groupName) + { + group.Instances.ForEach(async instance => + { + await AutoScaleMethods.TerminateInstanceInAutoScalingGroupAsync(client, instance.InstanceId); + }); + } + }); +} + +// After all instances are terminated, delete the group. +Console.WriteLine("--- Deleting the Auto Scaling group ---"); +await AutoScaleMethods.DeleteAutoScalingGroupAsync(client, groupName); + +// Delete the launch template. +var deletedLaunchTemplateName = await EC2Methods.DeleteLaunchTemplateAsync(launchTemplateId); + +if (deletedLaunchTemplateName == launchTemplateName) +{ + Console.WriteLine("Successfully deleted the launch template."); +} + +Console.WriteLine("The demo is now concluded."); + +void DisplayDescription() +{ + Console.WriteLine("This code example performs the following operations:"); + Console.WriteLine(" 1. Creates an Amazon EC2 launch template."); + Console.WriteLine(" 2. Creates an Auto Scaling group."); + Console.WriteLine(" 3. Shows the details of the new Auto Scaling group"); + Console.WriteLine(" to show that only one instance was created."); + Console.WriteLine(" 4. Enables metrics collection."); + Console.WriteLine(" 5. Updates the AWS Auto Scaling group to increase the"); + Console.WriteLine(" capacity to three."); + Console.WriteLine(" 6. Describes Auto Scaling groups again to show the"); + Console.WriteLine(" current state of the group."); + Console.WriteLine(" 7. Changes the desired capacity of the Auto Scaling"); + Console.WriteLine(" group to use an additional instance."); + Console.WriteLine(" 8. Shows that there are now instances in the group."); + Console.WriteLine(" 9. Lists the scaling activities that have occurred for the group."); + Console.WriteLine("10. Displays the Amazon CloudWatch metrics that have"); + Console.WriteLine(" been collected."); + Console.WriteLine("11. Disables metrics collection."); + Console.WriteLine("12. Terminates all instances in the Auto Scaling group."); + Console.WriteLine("13. Deletes the Auto Scaling group."); + Console.WriteLine("14. Deletes the Amazon EC2 launch template."); +} + +void DisplayGroupDetails(List groups) +{ + if (groups is null) + return; + + groups.ForEach(group => + { + Console.WriteLine($"Group name:\t{group.AutoScalingGroupName}"); + Console.WriteLine($"Group created:\t{group.CreatedTime}"); + Console.WriteLine($"Maximum number of instances:\t{group.MaxSize}"); + Console.WriteLine($"Desired number of instances:\t{group.DesiredCapacity}"); + }); +} + +void PressEnter() +{ + Console.WriteLine("Press to continue."); + _ = Console.ReadLine(); + Console.WriteLine("\n\n"); +} + +// snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.main] diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs new file mode 100644 index 00000000000..e4a507ea27e --- /dev/null +++ b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScaleMethods.cs @@ -0,0 +1,377 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +namespace AutoScale_Basics +{ + /// + /// This class contains methods that perform EC2 Auto Scaling operations + /// used in the AutoScal_Basics scenario. + /// + public class AutoScaleMethods + { + // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.CreateAutoScalingGroup] + + /// + /// Creates a new Amazon EC2 Auto Scaling group. + /// + /// The initialized Amazon EC2 Auto Scaling + /// client object. + /// The name to use for the new Auto Scaling + /// group. + /// The name of the Amazon EC2 launch template + /// to use to create instances in the group. + /// The AWS Identity and Access + /// Management (IAM) service-linked role that provides the permissions + /// to use with the Auso Scaling group. + /// A Boolean value that indicates the success or failure of + /// the operation. + public static async Task CreateAutoScalingGroup( + AmazonAutoScalingClient client, + string groupName, + string launchTemplateName, + string serviceLinkedRoleARN) + { + var templateSpecification = new LaunchTemplateSpecification + { + LaunchTemplateName = launchTemplateName, + }; + + var zoneList = new List + { + "us-east-2a", + }; + + var request = new CreateAutoScalingGroupRequest + { + AutoScalingGroupName = groupName, + AvailabilityZones = zoneList, + LaunchTemplate = templateSpecification, + MaxSize = 1, + MinSize = 1, + ServiceLinkedRoleARN = serviceLinkedRoleARN, + }; + + var response = await client.CreateAutoScalingGroupAsync(request); + Console.WriteLine(groupName + " Auto Scaling Group created"); + return response.HttpStatusCode == System.Net.HttpStatusCode.OK; + } + + // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.CreateAutoScalingGroup] + + // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.DescribeAccountLimits] + + /// + /// Retrieves information about limits to the active AWS Account. + /// + /// The initialized Amazon EC2 Auto Scaling + /// client object. + /// A Boolean value that indicates the success or failure of + /// the operation. + public static async Task DescribeAccountLimitsAsync(AmazonAutoScalingClient client) + { + var response = await client.DescribeAccountLimitsAsync(); + Console.WriteLine("The max number of auto scaling groups is " + response.MaxNumberOfAutoScalingGroups); + Console.WriteLine("The current number of auto scaling groups is " + response.NumberOfAutoScalingGroups); + return response.HttpStatusCode == System.Net.HttpStatusCode.OK; + } + + // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.DescribeAccountLimits] + + // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.DescribeScalingActivities] + + /// + /// Retrieves a list of the Auto Scaling activities for an Auto Scaling group. + /// + /// The initialized Amazon EC2 Auto Scaling + /// client object. + /// The name of the Auto Scaling group. + /// A list of Auto Scaling activities. + public static async Task> DescribeAutoScalingActivitiesAsync( + AmazonAutoScalingClient client, + string groupName) + { + var scalingActivitiesRequest = new DescribeScalingActivitiesRequest + { + AutoScalingGroupName = groupName, + MaxRecords = 10, + }; + + var response = await client.DescribeScalingActivitiesAsync(scalingActivitiesRequest); + return response.Activities; + } + + // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.DescribeScalingActivities] + + // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.DescribeAutoScalingInstances] + + /// + /// Gets data about the instances in an Amazon EC2 Auto Scaling group. + /// + /// The initialized Amazon EC2 Auto Scaling + /// client object. + /// The name of the Auto Scaling group. + /// A list of Auto Scaling details. + public static async Task> DescribeAutoScalingInstancesAsync( + AmazonAutoScalingClient client, + string groupName) + { + var groups = await DescribeAutoScalingGroupsAsync(client, groupName); + var instanceIds = new List(); + groups.ForEach(group => + { + if (group.AutoScalingGroupName == groupName) + { + group.Instances.ForEach(instance => + { + instanceIds.Add(instance.InstanceId); + }); + } + }); + + var scalingGroupsRequest = new DescribeAutoScalingInstancesRequest + { + MaxRecords = 10, + InstanceIds = instanceIds, + }; + + var response = await client.DescribeAutoScalingInstancesAsync(scalingGroupsRequest); + var instanceDetails = response.AutoScalingInstances; + + return instanceDetails; + } + + // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.DescribeAutoScalingInstances] + + // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.DescribeAutoScalingGroups] + + /// + /// Retrieves a list of information about EC2 Auto Scaling groups. + /// + /// The initialized Amazon EC2 Auto Scaling + /// client object. + /// The name of the Auto Scaling group. + /// A list of Auto Scaling groups. + public static async Task> DescribeAutoScalingGroupsAsync( + AmazonAutoScalingClient client, + string groupName) + { + var groupList = new List + { + groupName, + }; + + var request = new DescribeAutoScalingGroupsRequest + { + AutoScalingGroupNames = groupList, + }; + + var response = await client.DescribeAutoScalingGroupsAsync(request); + var groups = response.AutoScalingGroups; + + return groups; + } + + // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.DescribeAutoScalingGroups] + + // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.DisableMetricsCollection] + + /// + /// Disables the collection of metric data for an Auto Scaling group. + /// + /// The initialized Amazon EC2 Auto Scaling + /// client object. + /// The name of the Auto Scaling group. + /// A Boolean value that indicates the success or failure of + /// the operation. + public static async Task DisableMetricsCollectionAsync(AmazonAutoScalingClient client, string groupName) + { + var request = new DisableMetricsCollectionRequest + { + AutoScalingGroupName = groupName, + }; + + var response = await client.DisableMetricsCollectionAsync(request); + return response.HttpStatusCode == System.Net.HttpStatusCode.OK; + } + + // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.DisableMetricsCollection] + + // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.DeleteAutoScalingGroup] + + /// + /// Deletes an Auto Scaling group. + /// + /// The initialized Amazon EC2 Auto Scaling + /// client object. + /// The name of the Auto Scaling group. + /// A Boolean value that indicates the success or failure of + /// the operation. + public static async Task DeleteAutoScalingGroupAsync( + AmazonAutoScalingClient autoScalingClient, + string groupName) + { + var deleteAutoScalingGroupRequest = new DeleteAutoScalingGroupRequest + { + AutoScalingGroupName = groupName, + ForceDelete = true, + }; + + var response = await autoScalingClient.DeleteAutoScalingGroupAsync(deleteAutoScalingGroupRequest); + if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) + { + Console.WriteLine($"You successfully deleted {groupName}"); + return true; + } + + Console.WriteLine($"Couldn't delete {groupName}."); + return false; + } + + // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.DeleteAutoScalingGroup] + + // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.EnableMetricsCollection] + + /// + /// Enables the collection of metric data for an Auto Scaling group. + /// + /// The initialized Amazon EC2 Auto Scaling + /// client object. + /// The name of the Auto Scaling group. + /// A Boolean value that indicates the success or failure of + /// the operation. + public static async Task EnableMetricsCollectionAsync(AmazonAutoScalingClient client, string groupName) + { + var listMetrics = new List + { + "GroupMaxSize", + }; + + var collectionRequest = new EnableMetricsCollectionRequest + { + AutoScalingGroupName = groupName, + Metrics = listMetrics, + Granularity = "1Minute", + }; + + var response = await client.EnableMetricsCollectionAsync(collectionRequest); + return response.HttpStatusCode == System.Net.HttpStatusCode.OK; + } + + // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.EnableMetricsCollection] + + // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.SetDesiredCapacity] + + /// + /// Sets the desired capacity of an Auto Scaling group. + /// + /// The initialized Amazon EC2 Auto Scaling + /// client object. + /// The name of the Auto Scaling group. + /// The desired capacity for the Auto + /// Scaling group. + /// A Boolean value that indicates the success or failure of + /// the operation. + public static async Task SetDesiredCapacityAsync( + AmazonAutoScalingClient client, + string groupName, + int desiredCapacity) + { + var capacityRequest = new SetDesiredCapacityRequest + { + AutoScalingGroupName = groupName, + DesiredCapacity = desiredCapacity, + }; + + var response = await client.SetDesiredCapacityAsync(capacityRequest); + Console.WriteLine($"You have set the DesiredCapacity to {desiredCapacity}."); + + return response.HttpStatusCode == System.Net.HttpStatusCode.OK; + } + + // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.SetDesiredCapacity] + + // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.TerminateInstanceInAutoScalingGroup] + + /// + /// Terminates all instances in the Auto Scaling group in preparation for + /// deleting the group. + /// + /// The initialized Amazon EC2 Auto Scaling + /// client object. + /// The instance Id of the instance to terminate. + /// A Boolean value that indicates the success or failure of + /// the operation. + public static async Task TerminateInstanceInAutoScalingGroupAsync( + AmazonAutoScalingClient client, + string instanceId) + { + var request = new TerminateInstanceInAutoScalingGroupRequest + { + InstanceId = instanceId, + ShouldDecrementDesiredCapacity = false, + }; + + var response = await client.TerminateInstanceInAutoScalingGroupAsync(request); + + if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) + { + Console.WriteLine($"You have terminated the instance {instanceId}"); + return true; + } + + Console.WriteLine($"Could not terminate {instanceId}"); + return false; + } + + // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.TerminateInstanceInAutoScalingGroup] + + // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.UpdateAutoScalingGroup] + + /// + /// Updates the capacity of an Auto Scaling group. + /// + /// The initialized Amazon EC2 Auto Scaling + /// client object. + /// The name of the Auto Scaling group. + /// The name of the EC2 launch template. + /// The Amazon Resource Name (ARN) + /// of the AWS Identity and Access Management (IAM) service-linked role. + /// The maximum number of instances that can be + /// created for the Auto Scaling group. + /// A Boolean value that indicates the success or failure of + /// the update operation. + public static async Task UpdateAutoScalingGroupAsync( + AmazonAutoScalingClient client, + string groupName, + string launchTemplateName, + string serviceLinkedRoleARN, + int maxSize) + { + var templateSpecification = new LaunchTemplateSpecification + { + LaunchTemplateName = launchTemplateName, + }; + + var groupRequest = new UpdateAutoScalingGroupRequest + { + MaxSize = maxSize, + ServiceLinkedRoleARN = serviceLinkedRoleARN, + AutoScalingGroupName = groupName, + LaunchTemplate = templateSpecification, + }; + + var response = await client.UpdateAutoScalingGroupAsync(groupRequest); + if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) + { + Console.WriteLine($"You successfully updated the Auto Scaling group {groupName}."); + return true; + } + else + { + return false; + } + } + + // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.UpdateAutoScalingGroup] + } +} diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScale_Basics.csproj b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScale_Basics.csproj new file mode 100644 index 00000000000..8bb9e75c1b5 --- /dev/null +++ b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/AutoScale_Basics.csproj @@ -0,0 +1,21 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/CloudWatchMethods.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/CloudWatchMethods.cs new file mode 100644 index 00000000000..5c5b4726eef --- /dev/null +++ b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/CloudWatchMethods.cs @@ -0,0 +1,82 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +namespace AutoScale_Basics +{ + // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.CloudWatchMethods] + using Amazon.CloudWatch; + using Amazon.CloudWatch.Model; + + /// + /// The method of this class display the metrics collected for the Amazon + /// EC2 Auto Scaling group created by the Amazon EC2 Auto Scaling scenario. + /// + public class CloudWatchMethods + { + /// + /// Retrieves the metrics information collection for the Auto Scaling group. + /// + /// The name of the Auto Scaling group. + /// A list of Metrics collected for the Auto Scaling group. + public static async Task> GetCloudWatchMetricsAsync(string groupName) + { + var client = new AmazonCloudWatchClient(); + + var filter = new DimensionFilter + { + Name = "AutoScalingGroupName", + Value = $"{groupName}", + }; + + var request = new ListMetricsRequest + { + MetricName = "AutoScalingGroupName", + Dimensions = new List { filter }, + Namespace = "AWS/AutoScaling", + }; + + var response = await client.ListMetricsAsync(request); + + return response.Metrics; + } + + /// + /// Retrieves the metric data collected for an Amazon EC2 Auto Scaling group. + /// + /// The name of the Amazon EC2 Auto Scaling group. + /// A list of data points. + public static async Task> GetMetricStatisticsAsync(string groupName) + { + var client = new AmazonCloudWatchClient(); + + var metricDimensions = new List + { + new Dimension + { + Name = "AutoScalingGroupName", + Value = $"{groupName}", + }, + }; + + // The start time will be yesterday. + var startTime = DateTime.UtcNow.AddDays(-1); + + var request = new GetMetricStatisticsRequest + { + MetricName = "AutoScalingGroupName", + Dimensions = metricDimensions, + Namespace = "AWS/AutoScaling", + Period = 60, // 60 seconds + Statistics = new List() { "Minimum" }, + StartTimeUtc = startTime, + EndTimeUtc = DateTime.UtcNow, + }; + + var response = await client.GetMetricStatisticsAsync(request); + + return response.Datapoints; + } + + // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.CloudWatchMethods] + } +} diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/EC2Methods.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/EC2Methods.cs new file mode 100644 index 00000000000..e0e0d1cda17 --- /dev/null +++ b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/EC2Methods.cs @@ -0,0 +1,99 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +namespace AutoScale_Basics +{ + // snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.EC2Methods] + using Amazon.EC2; + using Amazon.EC2.Model; + + /// + /// The methods in this class create and delete an Amazon Elastic Compute + /// Cloud (Amazon EC2) launch template for use by the Amazon EC2 Auto + /// Scaling scenario. + /// + public class EC2Methods + { + /// + /// Create a new Amazon EC2 launch template. + /// + /// The image Id to use for instances launched + /// using the Amazon EC2 launch template. + /// The type of EC2 instances to create. + /// The name of the launch template. + /// Returns the TemplaceID of the new launch template. + public static async Task CreateLaunchTemplateAsync( + string imageId, + string instanceType, + string launchTemplateName) + { + var client = new AmazonEC2Client(); + + var request = new CreateLaunchTemplateRequest + { + LaunchTemplateData = new RequestLaunchTemplateData + { + ImageId = imageId, + InstanceType = instanceType, + }, + LaunchTemplateName = launchTemplateName, + }; + + var response = await client.CreateLaunchTemplateAsync(request); + + return response.LaunchTemplate.LaunchTemplateId; + } + + /// + /// Deletes an Amazon EC2 launch template. + /// + /// The TemplateId of the launch template to + /// delete. + /// The name of the EC2 launch template that was deleted. + public static async Task DeleteLaunchTemplateAsync(string launchTemplateId) + { + var client = new AmazonEC2Client(); + + var request = new DeleteLaunchTemplateRequest + { + LaunchTemplateId = launchTemplateId, + }; + + var response = await client.DeleteLaunchTemplateAsync(request); + return response.LaunchTemplate.LaunchTemplateName; + } + + /// + /// Retrieves a information about an EC2 launch template. + /// + /// The name of the EC2 launch template. + /// A Boolean value that indicates the success or failure of + /// the operation. + public static async Task DescribeLaunchTemplateAsync(string launchTemplateName) + { + var client = new AmazonEC2Client(); + + var request = new DescribeLaunchTemplatesRequest + { + LaunchTemplateNames = new List { launchTemplateName, }, + }; + + var response = await client.DescribeLaunchTemplatesAsync(request); + + if (response.LaunchTemplates != null) + { + response.LaunchTemplates.ForEach(template => + { + Console.Write($"{template.LaunchTemplateName}\t"); + Console.WriteLine(template.LaunchTemplateId); + }); + + return true; + } + + return false; + } + } + + // snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.EC2Methods] +} diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/GlobalUsings.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/GlobalUsings.cs new file mode 100644 index 00000000000..4d083b079ce --- /dev/null +++ b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_Basics/GlobalUsings.cs @@ -0,0 +1,10 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +// snippet-start:[AutoScale.dotnetv3.AutoScale_Basics.global-usings] +global using Amazon; +global using Amazon.AutoScaling; +global using Amazon.AutoScaling.Model; +global using AutoScale_Basics; + +// snippet-end:[AutoScale.dotnetv3.AutoScale_Basics.global-usings] diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScaleMethodsTests.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScaleMethodsTests.cs new file mode 100644 index 00000000000..de41d447454 --- /dev/null +++ b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScaleMethodsTests.cs @@ -0,0 +1,109 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Amazon.AutoScaling; + +namespace AutoScale_Basics.Tests +{ + [TestClass()] + public class AutoScaleMethodsTests + { + private readonly string _GroupName = "test-group-name"; + private readonly AmazonAutoScalingClient _Client = new AmazonAutoScalingClient(); + + // the Amazon Resource Name (ARN) of the IAM service linked role. + private readonly string _ServiceLinkedRoleArn = ""; + + private readonly string _LaunchTemplateName = "AutoScaleLaunchTemplateTest"; + + [TestMethod()] + [TestProperty("Category", "Integration")] + public async Task DeleteAutoScalingGroupTest() + { + var success = await AutoScaleMethods.DeleteAutoScalingGroupAsync(_Client, _GroupName); + Assert.IsTrue(success, "Could not delete the group."); + } + + [TestMethod()] + [TestProperty("Category", "Integration")] + public async Task DeleteAutoScalingGroupGroupNonexistentTest() + { + var success = await AutoScaleMethods.DeleteAutoScalingGroupAsync(_Client, "NonExistentGroup"); + Assert.IsFalse(success, "Deleted a non-existent Auto Scaling group."); + } + + [TestMethod()] + [TestProperty("Category", "Integration")] + public async Task TerminateInstanceInAutoScalingGroupTest() + { + var instanceId = string.Empty; + var success = await AutoScaleMethods.TerminateInstanceInAutoScalingGroupAsync(_Client, instanceId); + Assert.IsTrue(success, "Could not terminate the instance."); + } + + [TestMethod()] + [TestProperty("Category", "Integration")] + public async Task DescribeScalingActivitiesTest() + { + var activities = await AutoScaleMethods.DescribeAutoScalingActivitiesAsync(_Client, _GroupName); + Assert.IsTrue(activities.Count > 0, "Can't find any auto scaling activities for the group."); + } + + [TestMethod()] + [TestProperty("Category", "Integration")] + public async Task SetDesiredCapacityTest() + { + var success = await AutoScaleMethods.SetDesiredCapacityAsync(_Client, _GroupName, 3); + Assert.IsTrue(success, "Couldn't set the desired capacity."); + var groups = await AutoScaleMethods.DescribeAutoScalingGroupsAsync(_Client, _GroupName); + groups.ForEach(group => + { + if (group.AutoScalingGroupName == _GroupName) + { + Assert.AreEqual(3, group.DesiredCapacity, "Capacity was not set properly."); + } + }); + } + + [TestMethod()] + [TestProperty("Category", "Integration")] + public async Task DescribeAccountLimitsTest() + { + var success = await AutoScaleMethods.DescribeAccountLimitsAsync(_Client); + Assert.IsTrue(success, "Couldn't retrieve account limits."); + } + + [TestMethod()] + [TestProperty("Category", "Integration")] + public async Task DescribeAutoScalingGroupsTest() + { + var details = await AutoScaleMethods.DescribeAutoScalingGroupsAsync(_Client, _GroupName); + Assert.IsTrue(details.Count > 0, "Couldn't find that Auto Scaling group."); + } + + [TestMethod()] + [TestProperty("Category", "Integration")] + public async Task EnableMetricsCollectionTest() + { + var success = await AutoScaleMethods.EnableMetricsCollectionAsync(_Client, _GroupName); + Assert.IsTrue(success, $"Couldn't enable metrics collection for {_GroupName}."); + } + + [TestMethod()] + [TestProperty("Category", "Integration")] + public async Task UpdateAutoScalingGroupTest() + { + var success = await AutoScaleMethods.UpdateAutoScalingGroupAsync(_Client, _GroupName, _LaunchTemplateName, _ServiceLinkedRoleArn, 3); + Assert.IsTrue(success, $"Couldn't update the Auto Scaling group: {_GroupName}."); + } + + [TestMethod()] + [TestProperty("Category", "Integration")] + public async Task CreateAutoScalingGroupTest() + { + var success = await AutoScaleMethods.CreateAutoScalingGroup(_Client, _GroupName, _LaunchTemplateName, _ServiceLinkedRoleArn); + Assert.IsTrue(success, "Couldn't create the Auto Scaling group."); + } + } +} \ No newline at end of file diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScale_BasicsTests.csproj b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScale_BasicsTests.csproj new file mode 100644 index 00000000000..85db5cae209 --- /dev/null +++ b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/AutoScale_BasicsTests.csproj @@ -0,0 +1,25 @@ + + + + net6.0 + enable + enable + + false + + + + + + + + + + + + + + + + + diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/CloudWatchMethodsTests.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/CloudWatchMethodsTests.cs new file mode 100644 index 00000000000..84ecfaf4215 --- /dev/null +++ b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/CloudWatchMethodsTests.cs @@ -0,0 +1,35 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +using Microsoft.VisualStudio.TestTools.UnitTesting; +using AutoScale_Basics; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AutoScale_Basics.Tests +{ + [TestClass()] + public class CloudWatchMethodsTests + { + private string _GroupName = "test-group-name"; + + [TestMethod()] + [TestProperty("Category", "Integration")] + public void GetCloudWatchMetricsAsyncTest() + { + var metrics = CloudWatchMethods.GetCloudWatchMetricsAsync(_GroupName); + Assert.IsNotNull(metrics, "No metrics were returned."); + } + + [TestMethod()] + [TestProperty("Category", "Integration")] + public void GetMetricStatisticsAsyncTest() + { + var metricStatistics = CloudWatchMethods.GetMetricStatisticsAsync(_GroupName); + Assert.IsNotNull(metricStatistics, "No statistics returned."); + } + } +} \ No newline at end of file diff --git a/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/EC2MethodsTests.cs b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/EC2MethodsTests.cs new file mode 100644 index 00000000000..c946c27231b --- /dev/null +++ b/dotnetv3/AutoScaling/scenarios/AutoScale_Basics/AutoScale_BasicsTests/EC2MethodsTests.cs @@ -0,0 +1,42 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +using AutoScale_Basics; +using Amazon.EC2; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace AutoScale_Basics.Tests +{ + [TestClass()] + public class EC2MethodsTests + { + private static readonly string imageId = "ami-05803413c51f242b7"; + private static readonly string instanceType = "t2.micro"; + private static readonly string launchTemplateName = "AutoScaleLaunchTemplateTest"; + private static string launchTemplateId = string.Empty; + + [TestMethod()] + [TestProperty("Category", "Integration")] + public async Task CreateLaunchTemplateAsyncTest() + { + launchTemplateId = await EC2Methods.CreateLaunchTemplateAsync(imageId, instanceType, launchTemplateName); + Assert.IsTrue(launchTemplateId != String.Empty, "Couldn't create launch template."); + } + + [TestMethod()] + [TestProperty("Category", "Integration")] + public async Task DeleteLaunchTemplateAsyncTest() + { + var deletedLaunchTemplateName = await EC2Methods.DeleteLaunchTemplateAsync(launchTemplateId); + Assert.IsTrue(deletedLaunchTemplateName == launchTemplateName, "Could not delete the launch template."); + } + + [TestMethod()] + [TestProperty("Category", "Integration")] + public async Task DescribeLaunchTemplateAsyncTest() + { + var success = await EC2Methods.DescribeLaunchTemplateAsync(launchTemplateName); + Assert.IsTrue(success, "Couldn't find any launch templates with the name {templateName}"); + } + } +} \ No newline at end of file From dd9ef3d901bc28058a1bbd8b39c0161f5915f861 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Apr 2023 11:09:31 -0700 Subject: [PATCH 3/9] Bump time from 0.2.0 to 0.2.2 in /ruby (#4626) * Bump time from 0.2.0 to 0.2.2 in /ruby Bumps [time](https://github.com/ruby/time) from 0.2.0 to 0.2.2. - [Release notes](https://github.com/ruby/time/releases) - [Commits](https://github.com/ruby/time/compare/v0.2.0...v0.2.2) --- updated-dependencies: - dependency-name: time dependency-type: indirect ... Signed-off-by: dependabot[bot] --- ruby/Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ruby/Gemfile.lock b/ruby/Gemfile.lock index 829267c4f02..07418765a1b 100644 --- a/ruby/Gemfile.lock +++ b/ruby/Gemfile.lock @@ -1350,7 +1350,7 @@ GEM aws-eventstream (~> 1, >= 1.0.2) cli-ui (2.1.0) concurrent-ruby (1.2.2) - date (3.2.2) + date (3.3.3) diff-lcs (1.5.0) i18n (1.12.0) concurrent-ruby (~> 1.0) @@ -1428,7 +1428,7 @@ GEM tilt (~> 2.0) stringio (3.0.2) tilt (2.0.11) - time (0.2.0) + time (0.2.2) date tzinfo (2.0.6) concurrent-ruby (~> 1.0) From 68d20e92f49aa5464beea01ee0f61bed77719de9 Mon Sep 17 00:00:00 2001 From: Corey Pyle Date: Tue, 4 Apr 2023 15:13:15 -0400 Subject: [PATCH 4/9] Update SPECIFICATION.md (#4595) --- resources/cdk/photo_asset_manager/SPECIFICATION.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/resources/cdk/photo_asset_manager/SPECIFICATION.md b/resources/cdk/photo_asset_manager/SPECIFICATION.md index ae59eaed4aa..4784725b87f 100644 --- a/resources/cdk/photo_asset_manager/SPECIFICATION.md +++ b/resources/cdk/photo_asset_manager/SPECIFICATION.md @@ -123,11 +123,9 @@ Each language will implement these Lambda functions. These functions handle the |Function |Trigger |Input example |Output example |Uses | |--- |--- |--- |--- |--- | |Upload|APIG PUT /upload |{"file_name": "maintain01.jpg"} |{"url": ""} |`StorageBucket` | -|DetectLabels|S3 PutObject jpeg | | |`StorageBucket` -`LabelsTable` | +|DetectLabels|S3 PutObject jpeg | | |`StorageBucket`, `LabelsTable` | |LabelsFn|APIG GET /labels | |{"labels": {"maintain": {"count": 5}, "lake": {"count": 3}}} |`LabelsTable` | -|PrepareDownload|APIG POST /download (event) |{"labels": ["Mountain", "Lake"]} |{} |`LabelsTable` -`WorkingBucket` | +|PrepareDownload|APIG POST /download (event) |{"labels": ["Mountain", "Lake"]} |{} |`LabelsTable`, `WorkingBucket` | **TIP**: The Java Lambdas were created during the building of this document. Refer to them for implementation insight. @@ -208,4 +206,4 @@ Each implementation will include a README describing the language-specific detai * `sns:Publish` on `arn:aws:sns:{REGION}:{ACCOUNT_ID}/{NAME}-SDKCodeExamplePAM-*`. ## Appendix B - Lambda triggers -* Storage bucket [OBJECT_CREATED] - When the user uploads a *.jpg/*.jpeg to the presigned URL in the storage bucket, the DetectLabelsFn function is invoked. \ No newline at end of file +* Storage bucket [OBJECT_CREATED] - When the user uploads a *.jpg/*.jpeg to the presigned URL in the storage bucket, the DetectLabelsFn function is invoked. From 9003a47ee9e88e182e06f3080aae7d18f97d8911 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Apr 2023 12:18:29 -0700 Subject: [PATCH 5/9] Bump uri from 0.11.0 to 0.12.1 in /ruby (#4627) * Bump uri from 0.11.0 to 0.12.1 in /ruby Bumps [uri](https://github.com/ruby/uri) from 0.11.0 to 0.12.1. - [Release notes](https://github.com/ruby/uri/releases) - [Commits](https://github.com/ruby/uri/compare/v0.11.0...v0.12.1) --- updated-dependencies: - dependency-name: uri dependency-type: indirect ... Signed-off-by: dependabot[bot] --- ruby/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby/Gemfile.lock b/ruby/Gemfile.lock index 07418765a1b..1c0ebdc9f10 100644 --- a/ruby/Gemfile.lock +++ b/ruby/Gemfile.lock @@ -1433,7 +1433,7 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.3.0) - uri (0.11.0) + uri (0.12.1) zip (2.0.2) PLATFORMS From 6c2c98b7118ceb9458765a144e5ddf883c331b62 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Apr 2023 12:23:27 -0700 Subject: [PATCH 6/9] Bump jackson-databind from 2.13.4.1 to 2.13.4.2 in /javav2/example_code/lookoutvision (#4621) * Bump jackson-databind in /javav2/example_code/lookoutvision Bumps [jackson-databind](https://github.com/FasterXML/jackson) from 2.13.4.1 to 2.13.4.2. - [Release notes](https://github.com/FasterXML/jackson/releases) - [Commits](https://github.com/FasterXML/jackson/commits) --- updated-dependencies: - dependency-name: com.fasterxml.jackson.core:jackson-databind dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- javav2/example_code/lookoutvision/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/javav2/example_code/lookoutvision/pom.xml b/javav2/example_code/lookoutvision/pom.xml index 846d9b52ff5..86dcf7ce20d 100644 --- a/javav2/example_code/lookoutvision/pom.xml +++ b/javav2/example_code/lookoutvision/pom.xml @@ -70,7 +70,7 @@ com.fasterxml.jackson.core jackson-databind - 2.14.0-rc1 + 2.13.4.2 software.amazon.awssdk @@ -89,7 +89,7 @@ com.fasterxml.jackson.core jackson-databind - 2.13.4.1 + 2.13.4.2 org.json From 4c9401bfee8c1d071747354f6134ecb57b8909e0 Mon Sep 17 00:00:00 2001 From: Laren-AWS <57545972+Laren-AWS@users.noreply.github.com> Date: Tue, 4 Apr 2023 13:06:37 -0700 Subject: [PATCH 7/9] Re-remove EMR cross-service examples (#4640) --- .doc_gen/metadata/cross_metadata.yaml | 31 --------------------------- 1 file changed, 31 deletions(-) diff --git a/.doc_gen/metadata/cross_metadata.yaml b/.doc_gen/metadata/cross_metadata.yaml index 7239e08ce22..228cb00b834 100644 --- a/.doc_gen/metadata/cross_metadata.yaml +++ b/.doc_gen/metadata/cross_metadata.yaml @@ -516,34 +516,3 @@ cross_LambdaForBrowser: services: lambda: dynamodb: -cross_ShortLivedEmrCluster: - title: Create a short-lived &EMR; cluster and run a step using an &AWS; SDK - title_abbrev: Create a short-lived &EMR; cluster and run a step - synopsis: create a short-lived &EMR; cluster that runs a step and automatically - terminates after the step completes. - languages: - Python: - versions: - - sdk_version: 3 - github: python/example_code/emr - block_content: cross_EmrShortLivedCluster_Python_block.xml - services: - ec2: - emr: - iam: - s3: -cross_LongLivedEmrCluster: - title: Create a long-lived &EMR; cluster and run steps using an &AWS; SDK - title_abbrev: Create a long-lived &EMR; cluster and run steps - synopsis: create a long-lived &EMR; cluster and run several steps. - languages: - Python: - versions: - - sdk_version: 3 - github: python/example_code/emr - block_content: cross_EmrLongLivedCluster_Python_block.xml - services: - ec2: - emr: - iam: - s3: From a34b1d025de62227592bf63cf39ad713aa2eb778 Mon Sep 17 00:00:00 2001 From: David Souther Date: Tue, 4 Apr 2023 16:09:48 -0700 Subject: [PATCH 8/9] Bump clap version for structops (clears up some audits) (#4641) --- rust_dev_preview/apigateway/Cargo.toml | 8 ++++---- .../apigateway/src/bin/get_rest_apis.rs | 6 +++--- .../apigatewaymanagement/Cargo.toml | 6 +++--- .../src/bin/post_to_connection.rs | 6 +++--- .../applicationautoscaling/Cargo.toml | 6 +++--- .../src/bin/describe-scaling-policies.rs | 6 +++--- rust_dev_preview/autoscaling/Cargo.toml | 6 +++--- .../src/bin/create-autoscaling-group.rs | 6 +++--- .../src/bin/delete-autoscaling-group.rs | 6 +++--- .../src/bin/list-autoscaling-groups.rs | 6 +++--- .../src/bin/update-autoscaling-group.rs | 6 +++--- rust_dev_preview/autoscalingplans/Cargo.toml | 8 ++++---- .../src/bin/describe-scaling-plans.rs | 6 +++--- rust_dev_preview/batch/Cargo.toml | 6 +++--- .../batch/src/bin/batch-helloworld.rs | 6 +++--- rust_dev_preview/cloudformation/Cargo.toml | 6 +++--- .../cloudformation/src/bin/create-stack.rs | 6 +++--- .../cloudformation/src/bin/delete-stack.rs | 6 +++--- .../cloudformation/src/bin/describe-stack.rs | 6 +++--- .../cloudformation/src/bin/list-stacks.rs | 6 +++--- rust_dev_preview/cloudwatch/Cargo.toml | 6 +++--- .../cloudwatch/src/bin/list-metrics.rs | 6 +++--- rust_dev_preview/cloudwatchlogs/Cargo.toml | 8 ++++---- .../cloudwatchlogs/src/bin/get-log-events.rs | 6 +++--- .../cloudwatchlogs/src/bin/list-log-groups.rs | 6 +++--- .../src/bin/list-log-streams.rs | 6 +++--- rust_dev_preview/cognitoidentity/Cargo.toml | 8 ++++---- .../src/bin/describe-identity-pool.rs | 6 +++--- .../src/bin/list-identity-pools.rs | 6 +++--- .../src/bin/list-pool-identities.rs | 6 +++--- .../cognitoidentityprovider/Cargo.toml | 8 ++++---- .../src/bin/list-user-pools.rs | 6 +++--- rust_dev_preview/cognitosync/Cargo.toml | 8 ++++---- .../src/bin/list-identity-pool-usage.rs | 6 +++--- rust_dev_preview/concurrency/Cargo.toml | 8 ++++---- rust_dev_preview/config/Cargo.toml | 6 +++--- .../config/src/bin/config-helloworld.rs | 6 +++--- .../src/bin/delete-configuration-recorder.rs | 6 +++--- .../config/src/bin/delete-delivery-channel.rs | 6 +++--- .../config/src/bin/enable-config.rs | 6 +++--- .../src/bin/list-configuration-recorders.rs | 6 +++--- .../config/src/bin/list-delivery-channels.rs | 6 +++--- .../config/src/bin/list-resources.rs | 6 +++--- .../config/src/bin/show-resource-history.rs | 6 +++--- .../cross_service/detect_faces/Cargo.toml | 8 ++++---- .../cross_service/detect_faces/src/main.rs | 6 +++--- .../cross_service/detect_labels/Cargo.toml | 12 +++++------ .../cross_service/detect_labels/src/main.rs | 6 +++--- .../cross_service/rest_ses/Cargo.toml | 19 +++++++++--------- .../cross_service/rest_ses/src/report.rs | 2 +- .../cross_service/telephone/Cargo.toml | 10 +++++----- .../cross_service/telephone/src/main.rs | 6 +++--- .../custom-root-certificates/Cargo.toml | 6 +++--- rust_dev_preview/dynamodb/Cargo.toml | 14 ++++++------- rust_dev_preview/dynamodb/src/bin/add-item.rs | 6 +++--- .../dynamodb/src/bin/are-more-tables.rs | 4 ++-- .../dynamodb/src/bin/create-table.rs | 6 +++--- rust_dev_preview/dynamodb/src/bin/crud.rs | 6 +++--- .../dynamodb/src/bin/delete-item.rs | 6 +++--- .../dynamodb/src/bin/delete-table.rs | 6 +++--- .../dynamodb/src/bin/dynamodb-helloworld.rs | 6 +++--- .../dynamodb/src/bin/list-items.rs | 6 +++--- .../dynamodb/src/bin/list-more-tables.rs | 4 ++-- .../dynamodb/src/bin/list-tables-local.rs | 4 ++-- .../dynamodb/src/bin/list-tables.rs | 4 ++-- .../dynamodb/src/bin/list10-tables.rs | 4 ++-- rust_dev_preview/dynamodb/src/bin/partiql.rs | 6 +++--- rust_dev_preview/dynamodb/src/lib.rs | 4 ++-- rust_dev_preview/ebs/Cargo.toml | 8 ++++---- .../ebs/src/bin/create-snapshot.rs | 6 +++--- .../ebs/src/bin/delete-snapshot.rs | 6 +++--- .../ebs/src/bin/get-snapshot-state.rs | 6 +++--- .../ebs/src/bin/list-snapshots.rs | 6 +++--- rust_dev_preview/ec2/Cargo.toml | 8 ++++---- .../ec2/src/bin/describe-instances.rs | 6 +++--- .../ec2/src/bin/ec2-helloworld.rs | 6 +++--- .../ec2/src/bin/list-all-instance-events.rs | 6 +++--- .../ec2/src/bin/monitor-instance.rs | 6 +++--- .../ec2/src/bin/reboot-instance.rs | 6 +++--- .../ec2/src/bin/start-instance.rs | 6 +++--- rust_dev_preview/ec2/src/bin/stop-instance.rs | 6 +++--- rust_dev_preview/ecr/Cargo.toml | 8 ++++---- .../ecr/src/bin/describe-repos.rs | 6 +++--- rust_dev_preview/ecr/src/bin/list-images.rs | 6 +++--- rust_dev_preview/ecs/Cargo.toml | 6 +++--- rust_dev_preview/ecs/src/bin/cluster.rs | 6 +++--- .../ecs/src/bin/describe-clusters.rs | 6 +++--- rust_dev_preview/eks/Cargo.toml | 8 ++++---- .../eks/src/bin/create-cluster.rs | 6 +++--- .../eks/src/bin/create-delete-cluster.rs | 6 +++--- rust_dev_preview/eks/src/bin/list-clusters.rs | 6 +++--- rust_dev_preview/firehose/Cargo.toml | 8 ++++---- .../firehose/src/bin/put-records-batch.rs | 6 +++--- rust_dev_preview/globalaccelerator/Cargo.toml | 6 +++--- .../src/bin/globalaccelerator-helloworld.rs | 6 +++--- rust_dev_preview/glue/Cargo.toml | 19 +++++++++--------- rust_dev_preview/greengrassv2/Cargo.toml | 8 ++++---- .../greengrassv2/src/bin/list-core-devices.rs | 6 +++--- rust_dev_preview/iam/Cargo.toml | 20 +++++++++---------- rust_dev_preview/iam/src/bin/create-role.rs | 6 +++--- rust_dev_preview/iot/Cargo.toml | 8 ++++---- .../iot/src/bin/describe-endpoint.rs | 6 +++--- rust_dev_preview/iot/src/bin/list-things.rs | 6 +++--- rust_dev_preview/kinesis/Cargo.toml | 6 +++--- .../kinesis/src/bin/create-stream.rs | 6 +++--- .../kinesis/src/bin/delete-stream.rs | 6 +++--- .../kinesis/src/bin/describe-stream.rs | 6 +++--- .../kinesis/src/bin/list-streams.rs | 6 +++--- .../kinesis/src/bin/put-record.rs | 6 +++--- rust_dev_preview/kms/Cargo.toml | 8 ++++---- rust_dev_preview/kms/src/bin/create-key.rs | 6 +++--- rust_dev_preview/kms/src/bin/decrypt.rs | 6 +++--- rust_dev_preview/kms/src/bin/encrypt.rs | 6 +++--- .../generate-data-key-without-plaintext.rs | 6 +++--- .../kms/src/bin/generate-data-key.rs | 6 +++--- .../kms/src/bin/generate-random.rs | 6 +++--- rust_dev_preview/kms/src/bin/list-keys.rs | 6 +++--- .../kms/src/bin/reencrypt-data.rs | 6 +++--- rust_dev_preview/lambda/Cargo.toml | 10 +++++----- .../lambda/src/bin/change-java-runtime.rs | 4 ++-- .../lambda/src/bin/invoke-function.rs | 4 ++-- .../src/bin/list-all-function-runtimes.rs | 6 +++--- .../lambda/src/bin/list-functions.rs | 4 ++-- rust_dev_preview/lambda/src/lib.rs | 6 +++--- rust_dev_preview/localstack/Cargo.toml | 6 +++--- rust_dev_preview/logging/logger/Cargo.toml | 6 +++--- rust_dev_preview/logging/logger/src/main.rs | 6 +++--- rust_dev_preview/logging/tracing/Cargo.toml | 6 +++--- rust_dev_preview/logging/tracing/src/main.rs | 6 +++--- rust_dev_preview/medialive/Cargo.toml | 6 +++--- .../medialive/src/bin/medialive-helloworld.rs | 6 +++--- rust_dev_preview/mediapackage/Cargo.toml | 6 +++--- .../mediapackage/src/bin/list-endpoints.rs | 6 +++--- .../src/bin/mediapackage-helloworld.rs | 6 +++--- rust_dev_preview/polly/Cargo.toml | 6 +++--- .../polly/src/bin/describe-voices.rs | 6 +++--- .../polly/src/bin/list-lexicons.rs | 6 +++--- .../polly/src/bin/polly-helloworld.rs | 6 +++--- rust_dev_preview/polly/src/bin/put-lexicon.rs | 6 +++--- .../src/bin/synthesize-speech-presigned.rs | 6 +++--- .../polly/src/bin/synthesize-speech.rs | 6 +++--- rust_dev_preview/qldb/Cargo.toml | 8 ++++---- .../qldb/src/bin/create-ledger.rs | 6 +++--- rust_dev_preview/qldb/src/bin/list-ledgers.rs | 6 +++--- .../qldb/src/bin/qldb-helloworld.rs | 6 +++--- rust_dev_preview/rds/Cargo.toml | 6 +++--- .../rds/src/bin/rds-helloworld.rs | 6 +++--- rust_dev_preview/rdsdata/Cargo.toml | 6 +++--- .../rdsdata/src/bin/rdsdata-helloworld.rs | 6 +++--- rust_dev_preview/route53/Cargo.toml | 6 +++--- .../route53/src/bin/route53-helloworld.rs | 6 +++--- rust_dev_preview/s3/Cargo.toml | 14 ++++++------- rust_dev_preview/s3/src/bin/copy-object.rs | 6 +++--- rust_dev_preview/s3/src/bin/create-bucket.rs | 6 +++--- rust_dev_preview/s3/src/bin/delete-object.rs | 6 +++--- rust_dev_preview/s3/src/bin/delete-objects.rs | 6 +++--- .../s3/src/bin/get-object-presigned.rs | 6 +++--- rust_dev_preview/s3/src/bin/list-buckets.rs | 6 +++--- .../s3/src/bin/list-object-versions.rs | 6 +++--- rust_dev_preview/s3/src/bin/list-objects.rs | 6 +++--- .../s3/src/bin/put-object-presigned.rs | 6 +++--- rust_dev_preview/s3/src/bin/s3-helloworld.rs | 6 +++--- .../s3/src/bin/select-object-content.rs | 6 +++--- rust_dev_preview/sagemaker/Cargo.toml | 8 ++++---- .../sagemaker/src/bin/list-training-jobs.rs | 6 +++--- .../sagemaker/src/bin/sagemaker-helloworld.rs | 6 +++--- rust_dev_preview/sdk-config/Cargo.toml | 6 +++--- .../sdk-config/src/bin/disable_retries.rs | 6 +++--- .../sdk-config/src/bin/set_retries.rs | 6 +++--- rust_dev_preview/secretsmanager/Cargo.toml | 6 +++--- .../secretsmanager/src/bin/create-secret.rs | 6 +++--- .../src/bin/get-secret-value.rs | 6 +++--- .../secretsmanager/src/bin/list-secrets.rs | 6 +++--- .../sending-presigned-requests/Cargo.toml | 8 ++++---- .../sending-presigned-requests/src/main.rs | 6 +++--- rust_dev_preview/ses/Cargo.toml | 6 +++--- .../ses/src/bin/create-contact-list.rs | 6 +++--- .../ses/src/bin/create-contact.rs | 6 +++--- .../ses/src/bin/is-email-verified.rs | 6 +++--- .../ses/src/bin/list-contact-lists.rs | 6 +++--- rust_dev_preview/ses/src/bin/list-contacts.rs | 6 +++--- rust_dev_preview/ses/src/bin/send-email.rs | 6 +++--- rust_dev_preview/sitewise/Cargo.toml | 8 ++++---- .../sitewise/src/bin/describe-asset.rs | 6 +++--- .../sitewise/src/bin/list-asset-models.rs | 6 +++--- .../sitewise/src/bin/list-assets.rs | 6 +++--- .../sitewise/src/bin/list-portals.rs | 6 +++--- rust_dev_preview/snowball/Cargo.toml | 6 +++--- .../snowball/src/bin/create-address.rs | 6 +++--- .../snowball/src/bin/describe-addresses.rs | 6 +++--- .../snowball/src/bin/list-jobs.rs | 6 +++--- rust_dev_preview/sns/Cargo.toml | 6 +++--- rust_dev_preview/sns/src/bin/create-topic.rs | 6 +++--- rust_dev_preview/sns/src/bin/list-topics.rs | 6 +++--- .../sns/src/bin/sns-hello-world.rs | 6 +++--- rust_dev_preview/sqs/Cargo.toml | 6 +++--- .../sqs/src/bin/sqs-hello-world.rs | 6 +++--- rust_dev_preview/ssm/Cargo.toml | 6 +++--- .../ssm/src/bin/create-parameter.rs | 6 +++--- .../ssm/src/bin/describe-parameters.rs | 6 +++--- rust_dev_preview/stepfunction/Cargo.toml | 6 +++--- .../stepfunction/src/bin/start-execution.rs | 6 +++--- .../stepfunction/src/bin/stop-execution.rs | 6 +++--- rust_dev_preview/sts/Cargo.toml | 8 ++++---- rust_dev_preview/sts/src/bin/assume-role.rs | 6 +++--- .../sts/src/bin/get-caller-identity.rs | 6 +++--- rust_dev_preview/test-utils/Cargo.toml | 8 ++++---- rust_dev_preview/testing/Cargo.toml | 14 ++++++------- rust_dev_preview/testing/src/intro.rs | 6 +++--- rust_dev_preview/tls/Cargo.toml | 6 +++--- .../transcribestreaming/Cargo.toml | 6 +++--- .../transcribestreaming/src/main.rs | 6 +++--- rust_dev_preview/webassembly/Cargo.toml | 14 ++++++------- 213 files changed, 692 insertions(+), 694 deletions(-) diff --git a/rust_dev_preview/apigateway/Cargo.toml b/rust_dev_preview/apigateway/Cargo.toml index 3c4191c4e30..e2630f299f7 100644 --- a/rust_dev_preview/apigateway/Cargo.toml +++ b/rust_dev_preview/apigateway/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-apigateway = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-types-convert = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-apigateway = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-types-convert = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "convert-chrono", ] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } thiserror = "1.0" tokio = { version = "1.20.1", features = ["full"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } \ No newline at end of file diff --git a/rust_dev_preview/apigateway/src/bin/get_rest_apis.rs b/rust_dev_preview/apigateway/src/bin/get_rest_apis.rs index 3c3ffb1ad1a..a384a81c56d 100644 --- a/rust_dev_preview/apigateway/src/bin/get_rest_apis.rs +++ b/rust_dev_preview/apigateway/src/bin/get_rest_apis.rs @@ -10,10 +10,10 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_apigateway::error::DisplayErrorContext; use aws_sdk_apigateway::{config::Region, meta::PKG_VERSION, Client}; use aws_smithy_types_convert::date_time::DateTimeExt; +use clap::Parser; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -57,7 +57,7 @@ async fn show_apis(client: &Client) -> Result<(), Error> { async fn main() { tracing_subscriber::fmt::init(); - if let Err(err) = run_example(Opt::from_args()).await { + if let Err(err) = run_example(Opt::parse()).await { eprintln!("Error: {}", DisplayErrorContext(err)); process::exit(1); } diff --git a/rust_dev_preview/apigatewaymanagement/Cargo.toml b/rust_dev_preview/apigatewaymanagement/Cargo.toml index 1f07cfd1eaa..f0bf90aab2d 100644 --- a/rust_dev_preview/apigatewaymanagement/Cargo.toml +++ b/rust_dev_preview/apigatewaymanagement/Cargo.toml @@ -10,9 +10,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-apigatewaymanagement = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-apigatewaymanagement = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } http = "0.2.5" tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/apigatewaymanagement/src/bin/post_to_connection.rs b/rust_dev_preview/apigatewaymanagement/src/bin/post_to_connection.rs index c94dc718c35..26403a41316 100644 --- a/rust_dev_preview/apigatewaymanagement/src/bin/post_to_connection.rs +++ b/rust_dev_preview/apigatewaymanagement/src/bin/post_to_connection.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_apigatewaymanagement::primitives::Blob; use aws_sdk_apigatewaymanagement::{config, config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] /// AWS apigatewaymanagenent must be used with a custom endpoint, which this example demonstrates how to set. /// /// Usage: @@ -83,7 +83,7 @@ async fn main() -> Result<(), Error> { stage, connection_id, data, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/applicationautoscaling/Cargo.toml b/rust_dev_preview/applicationautoscaling/Cargo.toml index 1957bdedc5e..04fc0154fc3 100644 --- a/rust_dev_preview/applicationautoscaling/Cargo.toml +++ b/rust_dev_preview/applicationautoscaling/Cargo.toml @@ -9,8 +9,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-applicationautoscaling = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-applicationautoscaling = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/applicationautoscaling/src/bin/describe-scaling-policies.rs b/rust_dev_preview/applicationautoscaling/src/bin/describe-scaling-policies.rs index e830287efe1..7ebc473c63c 100644 --- a/rust_dev_preview/applicationautoscaling/src/bin/describe-scaling-policies.rs +++ b/rust_dev_preview/applicationautoscaling/src/bin/describe-scaling-policies.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_applicationautoscaling::types::ServiceNamespace; use aws_sdk_applicationautoscaling::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -52,7 +52,7 @@ async fn show_policies(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/autoscaling/Cargo.toml b/rust_dev_preview/autoscaling/Cargo.toml index 167f693be3a..b652c43a4e6 100644 --- a/rust_dev_preview/autoscaling/Cargo.toml +++ b/rust_dev_preview/autoscaling/Cargo.toml @@ -7,8 +7,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-autoscaling = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-autoscaling = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/autoscaling/src/bin/create-autoscaling-group.rs b/rust_dev_preview/autoscaling/src/bin/create-autoscaling-group.rs index 9293ee7eeed..6ebbe26e1e7 100644 --- a/rust_dev_preview/autoscaling/src/bin/create-autoscaling-group.rs +++ b/rust_dev_preview/autoscaling/src/bin/create-autoscaling-group.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_autoscaling::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The name of the Amazon EC2 Auto Scaling group. #[structopt(short, long)] @@ -64,7 +64,7 @@ async fn main() -> Result<(), Error> { instance_id, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/autoscaling/src/bin/delete-autoscaling-group.rs b/rust_dev_preview/autoscaling/src/bin/delete-autoscaling-group.rs index c97510bfa83..9312d963ab2 100644 --- a/rust_dev_preview/autoscaling/src/bin/delete-autoscaling-group.rs +++ b/rust_dev_preview/autoscaling/src/bin/delete-autoscaling-group.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_autoscaling::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The name of the Amazon EC2 Auto Scaling group. #[structopt(short, long)] @@ -62,7 +62,7 @@ async fn main() -> Result<(), Error> { force, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/autoscaling/src/bin/list-autoscaling-groups.rs b/rust_dev_preview/autoscaling/src/bin/list-autoscaling-groups.rs index 37699f37da1..0ca22e3df09 100644 --- a/rust_dev_preview/autoscaling/src/bin/list-autoscaling-groups.rs +++ b/rust_dev_preview/autoscaling/src/bin/list-autoscaling-groups.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_autoscaling::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -57,7 +57,7 @@ async fn list_groups(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/autoscaling/src/bin/update-autoscaling-group.rs b/rust_dev_preview/autoscaling/src/bin/update-autoscaling-group.rs index b62e656f95a..a5a84361794 100644 --- a/rust_dev_preview/autoscaling/src/bin/update-autoscaling-group.rs +++ b/rust_dev_preview/autoscaling/src/bin/update-autoscaling-group.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_autoscaling::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The name of the Amazon EC2 Auto Scaling group. #[structopt(short, long)] @@ -62,7 +62,7 @@ async fn main() -> Result<(), Error> { max_size, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/autoscalingplans/Cargo.toml b/rust_dev_preview/autoscalingplans/Cargo.toml index d924854dbb1..33889c93bff 100644 --- a/rust_dev_preview/autoscalingplans/Cargo.toml +++ b/rust_dev_preview/autoscalingplans/Cargo.toml @@ -10,9 +10,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-sdk-autoscalingplans = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-sdk-autoscalingplans = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/autoscalingplans/src/bin/describe-scaling-plans.rs b/rust_dev_preview/autoscalingplans/src/bin/describe-scaling-plans.rs index 0c8e3db6862..36f89557d3d 100644 --- a/rust_dev_preview/autoscalingplans/src/bin/describe-scaling-plans.rs +++ b/rust_dev_preview/autoscalingplans/src/bin/describe-scaling-plans.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_autoscalingplans::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The region #[structopt(short, long)] @@ -47,7 +47,7 @@ async fn list_plans(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/batch/Cargo.toml b/rust_dev_preview/batch/Cargo.toml index ce823c1d5c2..0d023c2918c 100644 --- a/rust_dev_preview/batch/Cargo.toml +++ b/rust_dev_preview/batch/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-batch = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-batch = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/batch/src/bin/batch-helloworld.rs b/rust_dev_preview/batch/src/bin/batch-helloworld.rs index 9534d26fdf5..01fd24c2f0e 100644 --- a/rust_dev_preview/batch/src/bin/batch-helloworld.rs +++ b/rust_dev_preview/batch/src/bin/batch-helloworld.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_batch::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -50,7 +50,7 @@ async fn show_envs(client: &Client) -> Result<(), Error> { #[tokio::main] async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/cloudformation/Cargo.toml b/rust_dev_preview/cloudformation/Cargo.toml index 6aedb8ed596..3fb29d9d169 100644 --- a/rust_dev_preview/cloudformation/Cargo.toml +++ b/rust_dev_preview/cloudformation/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-cloudformation = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-cloudformation = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/cloudformation/src/bin/create-stack.rs b/rust_dev_preview/cloudformation/src/bin/create-stack.rs index 700cea061ae..f652373431a 100644 --- a/rust_dev_preview/cloudformation/src/bin/create-stack.rs +++ b/rust_dev_preview/cloudformation/src/bin/create-stack.rs @@ -7,10 +7,10 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cloudformation::{config::Region, meta::PKG_VERSION, Client, Error}; +use clap::Parser; use std::fs; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -66,7 +66,7 @@ async fn main() -> Result<(), Error> { stack_name, template_file, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/cloudformation/src/bin/delete-stack.rs b/rust_dev_preview/cloudformation/src/bin/delete-stack.rs index 45cf2222b3d..d7f35fe3baa 100644 --- a/rust_dev_preview/cloudformation/src/bin/delete-stack.rs +++ b/rust_dev_preview/cloudformation/src/bin/delete-stack.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cloudformation::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -52,7 +52,7 @@ async fn main() -> Result<(), Error> { region, stack_name, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/cloudformation/src/bin/describe-stack.rs b/rust_dev_preview/cloudformation/src/bin/describe-stack.rs index 043e014b064..2c05e3e4b2d 100644 --- a/rust_dev_preview/cloudformation/src/bin/describe-stack.rs +++ b/rust_dev_preview/cloudformation/src/bin/describe-stack.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cloudformation::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -63,7 +63,7 @@ async fn main() -> Result<(), Error> { region, stack_name, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/cloudformation/src/bin/list-stacks.rs b/rust_dev_preview/cloudformation/src/bin/list-stacks.rs index b21b6635af2..9314e6c5476 100644 --- a/rust_dev_preview/cloudformation/src/bin/list-stacks.rs +++ b/rust_dev_preview/cloudformation/src/bin/list-stacks.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cloudformation::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -46,7 +46,7 @@ async fn list_stacks(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/cloudwatch/Cargo.toml b/rust_dev_preview/cloudwatch/Cargo.toml index a6c8e3770da..fe53196f36d 100644 --- a/rust_dev_preview/cloudwatch/Cargo.toml +++ b/rust_dev_preview/cloudwatch/Cargo.toml @@ -11,8 +11,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-cloudwatch = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-cloudwatch = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/cloudwatch/src/bin/list-metrics.rs b/rust_dev_preview/cloudwatch/src/bin/list-metrics.rs index bfd24b5e47a..d8e99c5d91d 100644 --- a/rust_dev_preview/cloudwatch/src/bin/list-metrics.rs +++ b/rust_dev_preview/cloudwatch/src/bin/list-metrics.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cloudwatch::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -61,7 +61,7 @@ async fn show_metrics( /// * `[-v]` - Whether to display additional information. #[tokio::main] async fn main() -> Result<(), Error> { - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); if verbose { tracing_subscriber::fmt::init(); diff --git a/rust_dev_preview/cloudwatchlogs/Cargo.toml b/rust_dev_preview/cloudwatchlogs/Cargo.toml index 83c42a6cf98..e703211de4d 100644 --- a/rust_dev_preview/cloudwatchlogs/Cargo.toml +++ b/rust_dev_preview/cloudwatchlogs/Cargo.toml @@ -11,9 +11,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-cloudwatchlogs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-cloudwatchlogs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/cloudwatchlogs/src/bin/get-log-events.rs b/rust_dev_preview/cloudwatchlogs/src/bin/get-log-events.rs index 019b540d08e..d83ff815869 100644 --- a/rust_dev_preview/cloudwatchlogs/src/bin/get-log-events.rs +++ b/rust_dev_preview/cloudwatchlogs/src/bin/get-log-events.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cloudwatchlogs::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -67,7 +67,7 @@ async fn main() -> Result<(), Error> { group, stream, verbose, - } = Opt::from_args(); + } = Opt::parse(); if verbose { tracing_subscriber::fmt::init(); diff --git a/rust_dev_preview/cloudwatchlogs/src/bin/list-log-groups.rs b/rust_dev_preview/cloudwatchlogs/src/bin/list-log-groups.rs index 6884af54dc0..fb610b453a5 100644 --- a/rust_dev_preview/cloudwatchlogs/src/bin/list-log-groups.rs +++ b/rust_dev_preview/cloudwatchlogs/src/bin/list-log-groups.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cloudwatchlogs::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -48,7 +48,7 @@ async fn show_log_groups( /// * `[-v]` - Whether to display additional information. #[tokio::main] async fn main() -> Result<(), Error> { - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); if verbose { tracing_subscriber::fmt::init(); diff --git a/rust_dev_preview/cloudwatchlogs/src/bin/list-log-streams.rs b/rust_dev_preview/cloudwatchlogs/src/bin/list-log-streams.rs index 9e5b9f4a681..e2b888e5fdc 100644 --- a/rust_dev_preview/cloudwatchlogs/src/bin/list-log-streams.rs +++ b/rust_dev_preview/cloudwatchlogs/src/bin/list-log-streams.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cloudwatchlogs::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -64,7 +64,7 @@ async fn main() -> Result<(), Error> { group, prefix, verbose, - } = Opt::from_args(); + } = Opt::parse(); if verbose { tracing_subscriber::fmt::init(); diff --git a/rust_dev_preview/cognitoidentity/Cargo.toml b/rust_dev_preview/cognitoidentity/Cargo.toml index e2e2b513ea7..94e5a23cf34 100644 --- a/rust_dev_preview/cognitoidentity/Cargo.toml +++ b/rust_dev_preview/cognitoidentity/Cargo.toml @@ -10,13 +10,13 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-cognitoidentity = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-types-convert = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-cognitoidentity = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-types-convert = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "convert-chrono", ] } chrono = "0.4" -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } thiserror = "1.0" tokio = { version = "1.20.1", features = ["full"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/cognitoidentity/src/bin/describe-identity-pool.rs b/rust_dev_preview/cognitoidentity/src/bin/describe-identity-pool.rs index 2048830040a..265035ea2a3 100644 --- a/rust_dev_preview/cognitoidentity/src/bin/describe-identity-pool.rs +++ b/rust_dev_preview/cognitoidentity/src/bin/describe-identity-pool.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cognitoidentity::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -112,7 +112,7 @@ async fn main() -> Result<(), Error> { identity_pool_id, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/cognitoidentity/src/bin/list-identity-pools.rs b/rust_dev_preview/cognitoidentity/src/bin/list-identity-pools.rs index c7f54c422e5..a475b4e0d44 100644 --- a/rust_dev_preview/cognitoidentity/src/bin/list-identity-pools.rs +++ b/rust_dev_preview/cognitoidentity/src/bin/list-identity-pools.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cognitoidentity::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -54,7 +54,7 @@ async fn list_pools(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/cognitoidentity/src/bin/list-pool-identities.rs b/rust_dev_preview/cognitoidentity/src/bin/list-pool-identities.rs index 624725748a3..b4b3ad95433 100644 --- a/rust_dev_preview/cognitoidentity/src/bin/list-pool-identities.rs +++ b/rust_dev_preview/cognitoidentity/src/bin/list-pool-identities.rs @@ -9,11 +9,11 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cognitoidentity::error::DisplayErrorContext; use aws_sdk_cognitoidentity::{config::Region, meta::PKG_VERSION, Client}; use aws_smithy_types_convert::date_time::DateTimeExt; +use clap::Parser; use cognitoidentity_code_examples::Error; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -77,7 +77,7 @@ async fn list_identities(client: &Client, pool_id: &str) -> Result<(), Error> { async fn main() { tracing_subscriber::fmt::init(); - if let Err(err) = run_example(Opt::from_args()).await { + if let Err(err) = run_example(Opt::parse()).await { eprintln!("Error: {}", DisplayErrorContext(err)); process::exit(1); } diff --git a/rust_dev_preview/cognitoidentityprovider/Cargo.toml b/rust_dev_preview/cognitoidentityprovider/Cargo.toml index f1ef23556e5..a20655d1022 100644 --- a/rust_dev_preview/cognitoidentityprovider/Cargo.toml +++ b/rust_dev_preview/cognitoidentityprovider/Cargo.toml @@ -10,12 +10,12 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-cognitoidentityprovider = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-types-convert = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-cognitoidentityprovider = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-types-convert = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "convert-chrono", ] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } thiserror = "1.0" tokio = { version = "1.20.1", features = ["full"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } \ No newline at end of file diff --git a/rust_dev_preview/cognitoidentityprovider/src/bin/list-user-pools.rs b/rust_dev_preview/cognitoidentityprovider/src/bin/list-user-pools.rs index 79dc6368d4f..ec5f4ab9e9e 100644 --- a/rust_dev_preview/cognitoidentityprovider/src/bin/list-user-pools.rs +++ b/rust_dev_preview/cognitoidentityprovider/src/bin/list-user-pools.rs @@ -9,11 +9,11 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cognitoidentityprovider::error::DisplayErrorContext; use aws_sdk_cognitoidentityprovider::{config::Region, meta::PKG_VERSION, Client}; use aws_smithy_types_convert::date_time::DateTimeExt; +use clap::Parser; use cognitoidentityprovider_code_examples::Error; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -63,7 +63,7 @@ async fn show_pools(client: &Client) -> Result<(), Error> { async fn main() { tracing_subscriber::fmt::init(); - if let Err(err) = run_example(Opt::from_args()).await { + if let Err(err) = run_example(Opt::parse()).await { eprintln!("Error: {}", DisplayErrorContext(err)); process::exit(1); } diff --git a/rust_dev_preview/cognitosync/Cargo.toml b/rust_dev_preview/cognitosync/Cargo.toml index e7683a57f9d..85d38e466ee 100644 --- a/rust_dev_preview/cognitosync/Cargo.toml +++ b/rust_dev_preview/cognitosync/Cargo.toml @@ -10,12 +10,12 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-cognitosync = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-types-convert = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-cognitosync = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-types-convert = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "convert-chrono", ] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } thiserror = "1.0" tokio = { version = "1.20.1", features = ["full"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } \ No newline at end of file diff --git a/rust_dev_preview/cognitosync/src/bin/list-identity-pool-usage.rs b/rust_dev_preview/cognitosync/src/bin/list-identity-pool-usage.rs index af3e69a14fb..239c34a5d57 100644 --- a/rust_dev_preview/cognitosync/src/bin/list-identity-pool-usage.rs +++ b/rust_dev_preview/cognitosync/src/bin/list-identity-pool-usage.rs @@ -9,11 +9,11 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_cognitosync::error::DisplayErrorContext; use aws_sdk_cognitosync::{config::Region, meta::PKG_VERSION, Client}; use aws_smithy_types_convert::date_time::DateTimeExt; +use clap::Parser; use cognitosync_code_examples::Error; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -75,7 +75,7 @@ async fn show_pools(client: &Client) -> Result<(), Error> { async fn main() { tracing_subscriber::fmt::init(); - if let Err(err) = run_example(Opt::from_args()).await { + if let Err(err) = run_example(Opt::parse()).await { eprintln!("Error: {}", DisplayErrorContext(err)); process::exit(1); } diff --git a/rust_dev_preview/concurrency/Cargo.toml b/rust_dev_preview/concurrency/Cargo.toml index cd717ef254b..e979d64b953 100644 --- a/rust_dev_preview/concurrency/Cargo.toml +++ b/rust_dev_preview/concurrency/Cargo.toml @@ -14,14 +14,14 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -clap = { version = "~4.0.26", features = ["derive"] } +clap = { version = "4.2.1", features = ["derive"] } futures = "0.3.25" tokio = { version = "1.20.1", features = ["full"] } tracing = "0.1.37" tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } [dev-dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-sqs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-sqs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } fastrand = "1.8.0" diff --git a/rust_dev_preview/config/Cargo.toml b/rust_dev_preview/config/Cargo.toml index 4fdc4a389fe..0a6588be0da 100644 --- a/rust_dev_preview/config/Cargo.toml +++ b/rust_dev_preview/config/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/config/src/bin/config-helloworld.rs b/rust_dev_preview/config/src/bin/config-helloworld.rs index 48ac8254ae7..790232c13bc 100644 --- a/rust_dev_preview/config/src/bin/config-helloworld.rs +++ b/rust_dev_preview/config/src/bin/config-helloworld.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_config::types::ResourceType; use aws_sdk_config::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -68,7 +68,7 @@ async fn main() -> Result<(), Error> { resource_id, resource_type, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/config/src/bin/delete-configuration-recorder.rs b/rust_dev_preview/config/src/bin/delete-configuration-recorder.rs index ca308e3a139..e45ceb94c61 100644 --- a/rust_dev_preview/config/src/bin/delete-configuration-recorder.rs +++ b/rust_dev_preview/config/src/bin/delete-configuration-recorder.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_config::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -57,7 +57,7 @@ async fn main() -> Result<(), Error> { name, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/config/src/bin/delete-delivery-channel.rs b/rust_dev_preview/config/src/bin/delete-delivery-channel.rs index b4d46d113b1..0cb914e0239 100644 --- a/rust_dev_preview/config/src/bin/delete-delivery-channel.rs +++ b/rust_dev_preview/config/src/bin/delete-delivery-channel.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_config::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -55,7 +55,7 @@ async fn main() -> Result<(), Error> { channel, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/config/src/bin/enable-config.rs b/rust_dev_preview/config/src/bin/enable-config.rs index 1ff6a45898a..6398a74bdad 100644 --- a/rust_dev_preview/config/src/bin/enable-config.rs +++ b/rust_dev_preview/config/src/bin/enable-config.rs @@ -11,10 +11,10 @@ use aws_sdk_config::types::{ MaximumExecutionFrequency, RecordingGroup, ResourceType, }; use aws_sdk_config::{config::Region, meta::PKG_VERSION, Client, Error}; +use clap::Parser; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -175,7 +175,7 @@ async fn main() -> Result<(), Error> { sns_arn, type_, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/config/src/bin/list-configuration-recorders.rs b/rust_dev_preview/config/src/bin/list-configuration-recorders.rs index cfd68942bad..99d5771fe7e 100644 --- a/rust_dev_preview/config/src/bin/list-configuration-recorders.rs +++ b/rust_dev_preview/config/src/bin/list-configuration-recorders.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_config::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -52,7 +52,7 @@ async fn show_recorders(client: &Client) -> Result<(), Error> { #[tokio::main] async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/config/src/bin/list-delivery-channels.rs b/rust_dev_preview/config/src/bin/list-delivery-channels.rs index 27159e53e3c..ea76c87dff5 100644 --- a/rust_dev_preview/config/src/bin/list-delivery-channels.rs +++ b/rust_dev_preview/config/src/bin/list-delivery-channels.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_config::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -54,7 +54,7 @@ async fn show_channels(client: &Client) -> Result<(), Error> { #[tokio::main] async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/config/src/bin/list-resources.rs b/rust_dev_preview/config/src/bin/list-resources.rs index c3508de2b11..fea13fc8c34 100644 --- a/rust_dev_preview/config/src/bin/list-resources.rs +++ b/rust_dev_preview/config/src/bin/list-resources.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_config::types::ResourceType; use aws_sdk_config::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -65,7 +65,7 @@ async fn show_resources(verbose: bool, client: &Client) -> Result<(), Error> { #[tokio::main] async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/config/src/bin/show-resource-history.rs b/rust_dev_preview/config/src/bin/show-resource-history.rs index 5376e82d933..4e1fcadff04 100644 --- a/rust_dev_preview/config/src/bin/show-resource-history.rs +++ b/rust_dev_preview/config/src/bin/show-resource-history.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_config::types::ResourceType; use aws_sdk_config::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -66,7 +66,7 @@ async fn main() -> Result<(), Error> { id, resource_type, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/cross_service/detect_faces/Cargo.toml b/rust_dev_preview/cross_service/detect_faces/Cargo.toml index e1be51847cf..42433ba1b1f 100644 --- a/rust_dev_preview/cross_service/detect_faces/Cargo.toml +++ b/rust_dev_preview/cross_service/detect_faces/Cargo.toml @@ -10,9 +10,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-rekognition = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-rekognition = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/cross_service/detect_faces/src/main.rs b/rust_dev_preview/cross_service/detect_faces/src/main.rs index 840e02ad860..f0298b13ad1 100644 --- a/rust_dev_preview/cross_service/detect_faces/src/main.rs +++ b/rust_dev_preview/cross_service/detect_faces/src/main.rs @@ -5,9 +5,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::config::Region; +use clap::Parser; use std::error::Error; use std::path::Path; -use structopt::StructOpt; #[derive(Debug)] struct Person { @@ -17,7 +17,7 @@ struct Person { emotion: String, } -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The Amazon S3 bucket where we upload the picture. #[structopt(short, long)] @@ -153,7 +153,7 @@ async fn main() -> Result<(), Box> { filename, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); // Make sure filename ends with .jpg, .jpeg, or .png let mut content_type = String::new(); diff --git a/rust_dev_preview/cross_service/detect_labels/Cargo.toml b/rust_dev_preview/cross_service/detect_labels/Cargo.toml index 2ee546d4abe..e7bee3a390f 100644 --- a/rust_dev_preview/cross_service/detect_labels/Cargo.toml +++ b/rust_dev_preview/cross_service/detect_labels/Cargo.toml @@ -10,12 +10,12 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-rekognition = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-rekognition = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } kamadak-exif = "0.5.4" diff --git a/rust_dev_preview/cross_service/detect_labels/src/main.rs b/rust_dev_preview/cross_service/detect_labels/src/main.rs index 6dff78f3489..c5ae6be8d29 100644 --- a/rust_dev_preview/cross_service/detect_labels/src/main.rs +++ b/rust_dev_preview/cross_service/detect_labels/src/main.rs @@ -8,10 +8,10 @@ extern crate exif; use aws_config::meta::region::RegionProviderChain; use aws_sdk_dynamodb::config::Region; use aws_sdk_dynamodb::types::AttributeValue; +use clap::Parser; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The S3 bucket. #[structopt(short, long)] @@ -235,7 +235,7 @@ async fn main() -> Result<(), exif::Error> { region, table, verbose, - } = Opt::from_args(); + } = Opt::parse(); let dynamo_region = region.clone(); let s3_region = region.clone(); diff --git a/rust_dev_preview/cross_service/rest_ses/Cargo.toml b/rust_dev_preview/cross_service/rest_ses/Cargo.toml index 8d3b5349fa7..90d2607b91c 100644 --- a/rust_dev_preview/cross_service/rest_ses/Cargo.toml +++ b/rust_dev_preview/cross_service/rest_ses/Cargo.toml @@ -14,10 +14,10 @@ name = "rest_ses" [dependencies] actix-web = "4" actix-web-prom = "0.6.0" -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-cloudwatchlogs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-rdsdata = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-ses = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-cloudwatchlogs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-rdsdata = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-ses = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } chrono = { version = "0.4.22", default-features = false, features = [ "clock", "serde", @@ -27,8 +27,7 @@ config = "0.13.2" derive_more = "0.99.17" futures = "0.3.24" http = "0.2.8" -# newer versions of this crate aren't yet compatible with our MSRV -mail-builder = "=0.2.2" +mail-builder = "0.2.5" reqwest = "0.11.12" sdk-examples-test-utils = { path = "../../test-utils" } secrecy = { version = "0.8.0", features = ["serde"] } @@ -37,16 +36,16 @@ serde_json = "1.0.86" thiserror = "1.0.37" tokio = { version = "1", features = ["macros", "rt-multi-thread"] } tracing = "0.1.37" -tracing-actix-web = "0.6.1" +tracing-actix-web = "0.7.3" tracing-bunyan-formatter = "0.3.4" tracing-log = "0.1.3" tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] } uuid = { version = "1.2.1", features = ["v4", "serde"] } -xlsxwriter = "0.3.1" +xlsxwriter = "0.5.0" [dev-dependencies] -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["test-util"] } -aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = ["test-util"] } +aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } fake = { version = "2.5.0", features = ["uuid"] } once_cell = "1.15.0" rand = "0.8.5" diff --git a/rust_dev_preview/cross_service/rest_ses/src/report.rs b/rust_dev_preview/cross_service/rest_ses/src/report.rs index 2f3bd5d1b1c..8d8770f3f54 100644 --- a/rust_dev_preview/cross_service/rest_ses/src/report.rs +++ b/rust_dev_preview/cross_service/rest_ses/src/report.rs @@ -104,7 +104,7 @@ pub async fn send_report( const FONT_SIZE: f64 = 12.0; fn make_report(items: Vec) -> Result, ReportError> { let path = format!("{ATTACHMENT_NAME}.{}.xlsx", Uuid::new_v4()); - let workbook = Workbook::new(path.as_str()); + let workbook = Workbook::new(path.as_str()).map_err(ReportError::XslxError)?; let body_format = &workbook.add_format().set_font_size(FONT_SIZE); let date_format = &workbook diff --git a/rust_dev_preview/cross_service/telephone/Cargo.toml b/rust_dev_preview/cross_service/telephone/Cargo.toml index 5dfca69b140..b39c6807a51 100644 --- a/rust_dev_preview/cross_service/telephone/Cargo.toml +++ b/rust_dev_preview/cross_service/telephone/Cargo.toml @@ -7,13 +7,13 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-polly = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-transcribe = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-polly = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-transcribe = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } bytes = "1" reqwest = "0.11.4" serde_json = "1.0" -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/cross_service/telephone/src/main.rs b/rust_dev_preview/cross_service/telephone/src/main.rs index 331ef621052..93860d19a1d 100644 --- a/rust_dev_preview/cross_service/telephone/src/main.rs +++ b/rust_dev_preview/cross_service/telephone/src/main.rs @@ -7,14 +7,14 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_polly::config::Region; use aws_sdk_polly::types::{OutputFormat, VoiceId}; use aws_sdk_transcribe::types::{LanguageCode, Media, MediaFormat, TranscriptionJobStatus}; +use clap::Parser; use serde_json::{Result, Value}; use std::fs; use std::path::Path; use std::time::Duration; -use structopt::StructOpt; use tokio::io::AsyncWriteExt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -221,7 +221,7 @@ async fn main() -> Result<()> { job_name, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); // Copy the Region for each service client. let polly_region = region.clone(); diff --git a/rust_dev_preview/custom-root-certificates/Cargo.toml b/rust_dev_preview/custom-root-certificates/Cargo.toml index a961c5e711e..a0f2ef6df47 100644 --- a/rust_dev_preview/custom-root-certificates/Cargo.toml +++ b/rust_dev_preview/custom-root-certificates/Cargo.toml @@ -7,10 +7,10 @@ edition = "2021" description = "An example demonstrating setting a custom root certificate with rustls" [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } # bringing our own HTTPs so no need for the default features -aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false } +aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", default-features = false } tokio = { version = "1.21.2", features = ["full"] } rustls = "0.20.7" hyper-rustls = { version = "0.23.0", features = ["http2"] } diff --git a/rust_dev_preview/dynamodb/Cargo.toml b/rust_dev_preview/dynamodb/Cargo.toml index ccbd4255cf0..4c69d4f750f 100644 --- a/rust_dev_preview/dynamodb/Cargo.toml +++ b/rust_dev_preview/dynamodb/Cargo.toml @@ -11,18 +11,18 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "client-hyper", "rustls", "rt-tokio", ] } -aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "rt-tokio", ] } -aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } axum = "0.5.16" http = "0.2.5" futures = "0.3" @@ -32,7 +32,7 @@ sdk-examples-test-utils = { path = "../test-utils" } serde = {version = "1.0", features = ["derive"]} serde_json = "1" serde_dynamo = { version = "4", features = ["aws-sdk-dynamodb+0_22"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing = "0.1" thiserror = "1.0" tokio = { version = "1.20.1", features = ["full"] } diff --git a/rust_dev_preview/dynamodb/src/bin/add-item.rs b/rust_dev_preview/dynamodb/src/bin/add-item.rs index 07df3e65fbc..83f9a701fc3 100644 --- a/rust_dev_preview/dynamodb/src/bin/add-item.rs +++ b/rust_dev_preview/dynamodb/src/bin/add-item.rs @@ -6,6 +6,7 @@ #![allow(clippy::result_large_err)] use aws_sdk_dynamodb::{error::DisplayErrorContext, Client}; +use clap::Parser; use dynamodb_code_examples::{ make_config, scenario::add::{add_item, Item}, @@ -13,7 +14,6 @@ use dynamodb_code_examples::{ Opt as BaseOpt, }; use std::process; -use structopt::StructOpt; #[derive(thiserror::Error, Debug)] #[error( @@ -25,7 +25,7 @@ struct PermissionError { p_type: String, } -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The permission type of the user, standard_user or admin. #[structopt(short, long)] @@ -71,7 +71,7 @@ struct Opt { /// * `[-v]` - Whether to display additional information. #[tokio::main] async fn main() { - if let Err(err) = run_example(Opt::from_args()).await { + if let Err(err) = run_example(Opt::parse()).await { eprintln!("Error: {}", DisplayErrorContext(err)); process::exit(1); } diff --git a/rust_dev_preview/dynamodb/src/bin/are-more-tables.rs b/rust_dev_preview/dynamodb/src/bin/are-more-tables.rs index 3c1f1f986e2..5fce40cc924 100644 --- a/rust_dev_preview/dynamodb/src/bin/are-more-tables.rs +++ b/rust_dev_preview/dynamodb/src/bin/are-more-tables.rs @@ -6,8 +6,8 @@ #![allow(clippy::result_large_err)] use aws_sdk_dynamodb::{Client, Error}; +use clap::Parser; use dynamodb_code_examples::{make_config, scenario::list::list_tables_are_more, Opt}; -use structopt::StructOpt; /// Lists your DynamoDB tables. /// # Arguments @@ -20,7 +20,7 @@ use structopt::StructOpt; async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let shared_config = make_config(Opt::from_args()).await?; + let shared_config = make_config(Opt::parse()).await?; let client = Client::new(&shared_config); list_tables_are_more(&client).await diff --git a/rust_dev_preview/dynamodb/src/bin/create-table.rs b/rust_dev_preview/dynamodb/src/bin/create-table.rs index 2dc39f1ee5c..436102f4423 100644 --- a/rust_dev_preview/dynamodb/src/bin/create-table.rs +++ b/rust_dev_preview/dynamodb/src/bin/create-table.rs @@ -6,13 +6,13 @@ #![allow(clippy::result_large_err)] use aws_sdk_dynamodb::{error::DisplayErrorContext, Client}; +use clap::Parser; use dynamodb_code_examples::{ make_config, scenario::create::create_table, scenario::error::Error, Opt as BaseOpt, }; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The table name #[structopt(short, long)] @@ -39,7 +39,7 @@ struct Opt { async fn main() { tracing_subscriber::fmt::init(); - if let Err(err) = run_example(Opt::from_args()).await { + if let Err(err) = run_example(Opt::parse()).await { eprintln!("Error: {}", DisplayErrorContext(err)); process::exit(1); } diff --git a/rust_dev_preview/dynamodb/src/bin/crud.rs b/rust_dev_preview/dynamodb/src/bin/crud.rs index b9ca2c818e7..076fad36e66 100644 --- a/rust_dev_preview/dynamodb/src/bin/crud.rs +++ b/rust_dev_preview/dynamodb/src/bin/crud.rs @@ -15,14 +15,14 @@ use aws_smithy_http::result::SdkError; use aws_sdk_dynamodb::operation::create_table::CreateTableError; use aws_sdk_dynamodb::operation::put_item::PutItemError; +use clap::Parser; use rand::distributions::Alphanumeric; use rand::{thread_rng, Rng}; use std::io::{stdin, Read}; use std::time::Duration; use std::{iter, process}; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// Whether to run in interactive mode (you have to press return between operations) #[structopt(short, long)] @@ -210,7 +210,7 @@ async fn main() -> Result<(), Error> { interactive, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/dynamodb/src/bin/delete-item.rs b/rust_dev_preview/dynamodb/src/bin/delete-item.rs index 38af2766388..a10bb087dce 100644 --- a/rust_dev_preview/dynamodb/src/bin/delete-item.rs +++ b/rust_dev_preview/dynamodb/src/bin/delete-item.rs @@ -6,13 +6,13 @@ #![allow(clippy::result_large_err)] use aws_sdk_dynamodb::{error::DisplayErrorContext, Client}; +use clap::Parser; use dynamodb_code_examples::{ make_config, scenario::delete::delete_item, scenario::error::Error, Opt as BaseOpt, }; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The name of the table. #[structopt(short, long)] @@ -45,7 +45,7 @@ struct Opt { async fn main() { tracing_subscriber::fmt::init(); - if let Err(err) = run_example(Opt::from_args()).await { + if let Err(err) = run_example(Opt::parse()).await { eprintln!("Error: {}", DisplayErrorContext(err)); process::exit(1); } diff --git a/rust_dev_preview/dynamodb/src/bin/delete-table.rs b/rust_dev_preview/dynamodb/src/bin/delete-table.rs index 2f089216b21..5e34dff656c 100644 --- a/rust_dev_preview/dynamodb/src/bin/delete-table.rs +++ b/rust_dev_preview/dynamodb/src/bin/delete-table.rs @@ -6,13 +6,13 @@ #![allow(clippy::result_large_err)] use aws_sdk_dynamodb::{error::DisplayErrorContext, Client}; +use clap::Parser; use dynamodb_code_examples::{ make_config, scenario::delete::delete_table, scenario::error::Error, Opt as BaseOpt, }; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The name of the table. #[structopt(short, long)] @@ -32,7 +32,7 @@ struct Opt { /// * `[-v]` - Whether to display additional information. #[tokio::main] async fn main() { - if let Err(err) = run_example(Opt::from_args()).await { + if let Err(err) = run_example(Opt::parse()).await { eprintln!("Error: {}", DisplayErrorContext(err)); process::exit(1); } diff --git a/rust_dev_preview/dynamodb/src/bin/dynamodb-helloworld.rs b/rust_dev_preview/dynamodb/src/bin/dynamodb-helloworld.rs index 758cf9a9440..47320231f77 100644 --- a/rust_dev_preview/dynamodb/src/bin/dynamodb-helloworld.rs +++ b/rust_dev_preview/dynamodb/src/bin/dynamodb-helloworld.rs @@ -10,9 +10,9 @@ use aws_sdk_dynamodb::types::{ AttributeDefinition, KeySchemaElement, KeyType, ProvisionedThroughput, ScalarAttributeType, }; use aws_sdk_dynamodb::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -79,7 +79,7 @@ async fn create_table(client: &Client) -> Result<(), Error> { #[tokio::main] async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/dynamodb/src/bin/list-items.rs b/rust_dev_preview/dynamodb/src/bin/list-items.rs index 1a0a429a4f7..b843df864ac 100644 --- a/rust_dev_preview/dynamodb/src/bin/list-items.rs +++ b/rust_dev_preview/dynamodb/src/bin/list-items.rs @@ -6,10 +6,10 @@ #![allow(clippy::result_large_err)] use aws_sdk_dynamodb::{Client, Error}; +use clap::Parser; use dynamodb_code_examples::{make_config, scenario::list::list_items, Opt as BaseOpt}; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The name of the table. #[structopt(short, long)] @@ -31,7 +31,7 @@ struct Opt { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { table, base } = Opt::from_args(); + let Opt { table, base } = Opt::parse(); let shared_config = make_config(base).await?; let client = Client::new(&shared_config); diff --git a/rust_dev_preview/dynamodb/src/bin/list-more-tables.rs b/rust_dev_preview/dynamodb/src/bin/list-more-tables.rs index b11b0cabbd0..523d5f7e0a4 100644 --- a/rust_dev_preview/dynamodb/src/bin/list-more-tables.rs +++ b/rust_dev_preview/dynamodb/src/bin/list-more-tables.rs @@ -6,8 +6,8 @@ #![allow(clippy::result_large_err)] use aws_sdk_dynamodb::{Client, Error}; +use clap::Parser; use dynamodb_code_examples::{make_config, scenario::list::list_tables_iterative, Opt}; -use structopt::StructOpt; /// Lists your DynamoDB tables. /// # Arguments @@ -20,7 +20,7 @@ use structopt::StructOpt; async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let config = make_config(Opt::from_args()).await?; + let config = make_config(Opt::parse()).await?; let client = Client::new(&config); list_tables_iterative(&client).await?; diff --git a/rust_dev_preview/dynamodb/src/bin/list-tables-local.rs b/rust_dev_preview/dynamodb/src/bin/list-tables-local.rs index f8ab7538c18..a202e61b88d 100644 --- a/rust_dev_preview/dynamodb/src/bin/list-tables-local.rs +++ b/rust_dev_preview/dynamodb/src/bin/list-tables-local.rs @@ -7,13 +7,13 @@ // snippet-start:[dynamodb.rust.list-tables-local] use aws_sdk_dynamodb::{Client, Error}; +use clap::Parser; use dynamodb_code_examples::{make_config, scenario::list::list_tables, Opt}; -use structopt::StructOpt; /// Lists your tables in DynamoDB local. #[tokio::main] async fn main() -> Result<(), Error> { - let config = make_config(Opt::from_args()).await?; + let config = make_config(Opt::parse()).await?; let dynamodb_local_config = aws_sdk_dynamodb::config::Builder::from(&config) .endpoint_url( // 8000 is the default dynamodb port diff --git a/rust_dev_preview/dynamodb/src/bin/list-tables.rs b/rust_dev_preview/dynamodb/src/bin/list-tables.rs index b69f4ddfa76..6a07ae7c98c 100644 --- a/rust_dev_preview/dynamodb/src/bin/list-tables.rs +++ b/rust_dev_preview/dynamodb/src/bin/list-tables.rs @@ -6,8 +6,8 @@ #![allow(clippy::result_large_err)] use aws_sdk_dynamodb::{Client, Error}; +use clap::Parser; use dynamodb_code_examples::{make_config, scenario::list::list_tables, Opt}; -use structopt::StructOpt; /// Lists your DynamoDB tables. /// # Arguments @@ -20,7 +20,7 @@ use structopt::StructOpt; async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let shared_config = make_config(Opt::from_args()).await?; + let shared_config = make_config(Opt::parse()).await?; let client = Client::new(&shared_config); list_tables(&client).await?; Ok(()) diff --git a/rust_dev_preview/dynamodb/src/bin/list10-tables.rs b/rust_dev_preview/dynamodb/src/bin/list10-tables.rs index ee6c0b31e79..7c1d0d1b2ea 100644 --- a/rust_dev_preview/dynamodb/src/bin/list10-tables.rs +++ b/rust_dev_preview/dynamodb/src/bin/list10-tables.rs @@ -6,8 +6,8 @@ #![allow(clippy::result_large_err)] use aws_sdk_dynamodb::{Client, Error}; +use clap::Parser; use dynamodb_code_examples::{make_config, scenario::list::list_tables_limit_10, Opt}; -use structopt::StructOpt; /// Lists your DynamoDB tables. /// # Arguments @@ -20,7 +20,7 @@ use structopt::StructOpt; async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let shared_config = make_config(Opt::from_args()).await?; + let shared_config = make_config(Opt::parse()).await?; let client = Client::new(&shared_config); list_tables_limit_10(&client).await diff --git a/rust_dev_preview/dynamodb/src/bin/partiql.rs b/rust_dev_preview/dynamodb/src/bin/partiql.rs index 9de80b816dc..61add8fac18 100644 --- a/rust_dev_preview/dynamodb/src/bin/partiql.rs +++ b/rust_dev_preview/dynamodb/src/bin/partiql.rs @@ -15,14 +15,14 @@ use aws_smithy_http::result::SdkError; use aws_sdk_dynamodb::operation::create_table::CreateTableError; use aws_sdk_dynamodb::operation::execute_statement::ExecuteStatementError; +use clap::Parser; use rand::distributions::Alphanumeric; use rand::{thread_rng, Rng}; use std::io::{stdin, Read}; use std::time::Duration; use std::{iter, process}; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// Whether to run in interactive mode (you have to press return between operations) #[structopt(short, long)] @@ -208,7 +208,7 @@ async fn main() -> Result<(), Error> { interactive, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/dynamodb/src/lib.rs b/rust_dev_preview/dynamodb/src/lib.rs index 899d5020943..54fa319ee16 100644 --- a/rust_dev_preview/dynamodb/src/lib.rs +++ b/rust_dev_preview/dynamodb/src/lib.rs @@ -7,9 +7,9 @@ pub mod scenario; use aws_config::{meta::region::RegionProviderChain, SdkConfig}; use aws_sdk_dynamodb::{config::Region, meta::PKG_VERSION, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] pub struct Opt { /// The AWS Region. #[structopt(short, long)] diff --git a/rust_dev_preview/ebs/Cargo.toml b/rust_dev_preview/ebs/Cargo.toml index 17b9d558049..8c189f7f99c 100644 --- a/rust_dev_preview/ebs/Cargo.toml +++ b/rust_dev_preview/ebs/Cargo.toml @@ -10,11 +10,11 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-ebs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-ec2 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-ebs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-ec2 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } base64 = "0.13.0" sha2 = "0.9.5" -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/ebs/src/bin/create-snapshot.rs b/rust_dev_preview/ebs/src/bin/create-snapshot.rs index b1191d115b1..2af75311ba2 100644 --- a/rust_dev_preview/ebs/src/bin/create-snapshot.rs +++ b/rust_dev_preview/ebs/src/bin/create-snapshot.rs @@ -9,13 +9,13 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ebs::primitives::ByteStream; use aws_sdk_ebs::types::ChecksumAlgorithm; use aws_sdk_ebs::{config::Region, meta::PKG_VERSION, Client, Error}; +use clap::Parser; use sha2::Digest; -use structopt::StructOpt; /// Amazon EBS only supports one fixed size of block const EBS_BLOCK_SIZE: usize = 524288; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -103,7 +103,7 @@ async fn main() -> Result<(), Error> { description, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ebs/src/bin/delete-snapshot.rs b/rust_dev_preview/ebs/src/bin/delete-snapshot.rs index a237c448892..3cb798c5b05 100644 --- a/rust_dev_preview/ebs/src/bin/delete-snapshot.rs +++ b/rust_dev_preview/ebs/src/bin/delete-snapshot.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -52,7 +52,7 @@ async fn main() -> Result<(), Error> { region, snapshot_id, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ebs/src/bin/get-snapshot-state.rs b/rust_dev_preview/ebs/src/bin/get-snapshot-state.rs index 37f30e5ed96..12ba9b90f76 100644 --- a/rust_dev_preview/ebs/src/bin/get-snapshot-state.rs +++ b/rust_dev_preview/ebs/src/bin/get-snapshot-state.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::types::Filter; use aws_sdk_ec2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -66,7 +66,7 @@ async fn main() -> Result<(), Error> { region, snapshot_id, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ebs/src/bin/list-snapshots.rs b/rust_dev_preview/ebs/src/bin/list-snapshots.rs index 46b115cdaa6..eccdef02d6a 100644 --- a/rust_dev_preview/ebs/src/bin/list-snapshots.rs +++ b/rust_dev_preview/ebs/src/bin/list-snapshots.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -62,7 +62,7 @@ async fn show_snapshots(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ec2/Cargo.toml b/rust_dev_preview/ec2/Cargo.toml index 617233025a7..4214dda6b10 100644 --- a/rust_dev_preview/ec2/Cargo.toml +++ b/rust_dev_preview/ec2/Cargo.toml @@ -10,9 +10,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-ec2 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-ec2 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/ec2/src/bin/describe-instances.rs b/rust_dev_preview/ec2/src/bin/describe-instances.rs index 8a5c26472d2..5a9f98b92fd 100644 --- a/rust_dev_preview/ec2/src/bin/describe-instances.rs +++ b/rust_dev_preview/ec2/src/bin/describe-instances.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -63,7 +63,7 @@ async fn main() -> Result<(), Error> { region, instance_id, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ec2/src/bin/ec2-helloworld.rs b/rust_dev_preview/ec2/src/bin/ec2-helloworld.rs index 9a0fb396bd9..eef6ee0afea 100644 --- a/rust_dev_preview/ec2/src/bin/ec2-helloworld.rs +++ b/rust_dev_preview/ec2/src/bin/ec2-helloworld.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -44,7 +44,7 @@ async fn show_regions(client: &Client) -> Result<(), Error> { #[tokio::main] async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ec2/src/bin/list-all-instance-events.rs b/rust_dev_preview/ec2/src/bin/list-all-instance-events.rs index e29018f8dc7..56bf8ebd328 100644 --- a/rust_dev_preview/ec2/src/bin/list-all-instance-events.rs +++ b/rust_dev_preview/ec2/src/bin/list-all-instance-events.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -64,7 +64,7 @@ async fn show_all_events(client: &Client) -> Result<(), Error> { #[tokio::main] async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ec2/src/bin/monitor-instance.rs b/rust_dev_preview/ec2/src/bin/monitor-instance.rs index 6292cd5a220..ea6a16f22de 100644 --- a/rust_dev_preview/ec2/src/bin/monitor-instance.rs +++ b/rust_dev_preview/ec2/src/bin/monitor-instance.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -50,7 +50,7 @@ async fn main() -> Result<(), Error> { region, instance_id, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ec2/src/bin/reboot-instance.rs b/rust_dev_preview/ec2/src/bin/reboot-instance.rs index a0c3b384dde..040876ff469 100644 --- a/rust_dev_preview/ec2/src/bin/reboot-instance.rs +++ b/rust_dev_preview/ec2/src/bin/reboot-instance.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -49,7 +49,7 @@ async fn main() -> Result<(), Error> { region, instance_id, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ec2/src/bin/start-instance.rs b/rust_dev_preview/ec2/src/bin/start-instance.rs index 59e0bf8ff32..c0b13bc9ffd 100644 --- a/rust_dev_preview/ec2/src/bin/start-instance.rs +++ b/rust_dev_preview/ec2/src/bin/start-instance.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -50,7 +50,7 @@ async fn main() -> Result<(), Error> { region, instance_id, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ec2/src/bin/stop-instance.rs b/rust_dev_preview/ec2/src/bin/stop-instance.rs index fdcd317ec24..0710ffae295 100644 --- a/rust_dev_preview/ec2/src/bin/stop-instance.rs +++ b/rust_dev_preview/ec2/src/bin/stop-instance.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ec2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -50,7 +50,7 @@ async fn main() -> Result<(), Error> { region, instance_id, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ecr/Cargo.toml b/rust_dev_preview/ecr/Cargo.toml index aa31af86074..851edf156b8 100644 --- a/rust_dev_preview/ecr/Cargo.toml +++ b/rust_dev_preview/ecr/Cargo.toml @@ -8,9 +8,9 @@ authors = [ edition = "2021" [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-ecr = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-ecr = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/ecr/src/bin/describe-repos.rs b/rust_dev_preview/ecr/src/bin/describe-repos.rs index d6bd653e88c..eef7756c1c0 100644 --- a/rust_dev_preview/ecr/src/bin/describe-repos.rs +++ b/rust_dev_preview/ecr/src/bin/describe-repos.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ecr::{config::Region, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -48,7 +48,7 @@ async fn show_repos(client: &aws_sdk_ecr::Client) -> Result<(), aws_sdk_ecr::Err #[tokio::main] async fn main() -> Result<(), Error> { - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); if verbose { tracing_subscriber::fmt::init(); diff --git a/rust_dev_preview/ecr/src/bin/list-images.rs b/rust_dev_preview/ecr/src/bin/list-images.rs index 68e83f84e69..f7e46b60d64 100644 --- a/rust_dev_preview/ecr/src/bin/list-images.rs +++ b/rust_dev_preview/ecr/src/bin/list-images.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ecr::{config::Region, meta::PKG_VERSION, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -67,7 +67,7 @@ async fn main() -> Result<(), Error> { region, repository, verbose, - } = Opt::from_args(); + } = Opt::parse(); if verbose { tracing_subscriber::fmt::init(); diff --git a/rust_dev_preview/ecs/Cargo.toml b/rust_dev_preview/ecs/Cargo.toml index 2c20fa6f708..da9d6812b47 100644 --- a/rust_dev_preview/ecs/Cargo.toml +++ b/rust_dev_preview/ecs/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-ecs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-ecs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/ecs/src/bin/cluster.rs b/rust_dev_preview/ecs/src/bin/cluster.rs index c23d9fca378..f374c48a00e 100644 --- a/rust_dev_preview/ecs/src/bin/cluster.rs +++ b/rust_dev_preview/ecs/src/bin/cluster.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ecs::{config::Region, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -61,7 +61,7 @@ async fn main() -> Result<(), Error> { name, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); if verbose { tracing_subscriber::fmt::init(); diff --git a/rust_dev_preview/ecs/src/bin/describe-clusters.rs b/rust_dev_preview/ecs/src/bin/describe-clusters.rs index 58967646232..9b98c59f393 100644 --- a/rust_dev_preview/ecs/src/bin/describe-clusters.rs +++ b/rust_dev_preview/ecs/src/bin/describe-clusters.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ecs::{config::Region, meta::PKG_VERSION, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -52,7 +52,7 @@ async fn show_clusters(client: &aws_sdk_ecs::Client) -> Result<(), aws_sdk_ecs:: /// * `[-v]` - Whether to display additional information. #[tokio::main] async fn main() -> Result<(), Error> { - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); if verbose { tracing_subscriber::fmt::init(); diff --git a/rust_dev_preview/eks/Cargo.toml b/rust_dev_preview/eks/Cargo.toml index a739c78af43..6f95be6a24e 100644 --- a/rust_dev_preview/eks/Cargo.toml +++ b/rust_dev_preview/eks/Cargo.toml @@ -8,9 +8,9 @@ authors = [ edition = "2021" [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-eks = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-eks = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/eks/src/bin/create-cluster.rs b/rust_dev_preview/eks/src/bin/create-cluster.rs index 8d9b5abd971..a4f1d009a38 100644 --- a/rust_dev_preview/eks/src/bin/create-cluster.rs +++ b/rust_dev_preview/eks/src/bin/create-cluster.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_eks::config::Region; use aws_sdk_eks::types::VpcConfigRequest; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The region #[structopt(short, long)] @@ -44,7 +44,7 @@ async fn main() -> Result<(), aws_sdk_eks::Error> { cluster_name, role_arn, subnet_id, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() .or_else(Region::new("us-west-2")); diff --git a/rust_dev_preview/eks/src/bin/create-delete-cluster.rs b/rust_dev_preview/eks/src/bin/create-delete-cluster.rs index 39b35d0fc67..528aa82cd58 100644 --- a/rust_dev_preview/eks/src/bin/create-delete-cluster.rs +++ b/rust_dev_preview/eks/src/bin/create-delete-cluster.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_eks::types::VpcConfigRequest; use aws_sdk_eks::{config::Region, meta::PKG_VERSION, Client}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -91,7 +91,7 @@ async fn main() -> Result<(), Box> { region, subnet_ids, verbose, - } = Opt::from_args(); + } = Opt::parse(); if verbose { tracing_subscriber::fmt::init(); diff --git a/rust_dev_preview/eks/src/bin/list-clusters.rs b/rust_dev_preview/eks/src/bin/list-clusters.rs index 4c386de3838..61f02f993b7 100644 --- a/rust_dev_preview/eks/src/bin/list-clusters.rs +++ b/rust_dev_preview/eks/src/bin/list-clusters.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_eks::{config::Region, meta::PKG_VERSION, Client}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -46,7 +46,7 @@ async fn show_clusters(client: &aws_sdk_eks::Client) -> Result<(), aws_sdk_eks:: /// * `[-v]` - Whether to display additional information. #[tokio::main] async fn main() -> Result<(), Box> { - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); if verbose { tracing_subscriber::fmt::init(); diff --git a/rust_dev_preview/firehose/Cargo.toml b/rust_dev_preview/firehose/Cargo.toml index d1d5e8ff1c0..e61fae4ed65 100644 --- a/rust_dev_preview/firehose/Cargo.toml +++ b/rust_dev_preview/firehose/Cargo.toml @@ -9,10 +9,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-firehose = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = {git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-firehose = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = {git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/firehose/src/bin/put-records-batch.rs b/rust_dev_preview/firehose/src/bin/put-records-batch.rs index fc24ca86d33..0a4194a7497 100644 --- a/rust_dev_preview/firehose/src/bin/put-records-batch.rs +++ b/rust_dev_preview/firehose/src/bin/put-records-batch.rs @@ -12,9 +12,9 @@ use aws_sdk_firehose::primitives::Blob; use aws_sdk_firehose::types::Record; use aws_sdk_firehose::{meta::PKG_VERSION, Client, Error}; use aws_types::region::Region; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(long)] @@ -61,7 +61,7 @@ async fn main() -> Result<(), Error> { region, verbose, firehose_stream, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/globalaccelerator/Cargo.toml b/rust_dev_preview/globalaccelerator/Cargo.toml index ffd0e1a10b3..dc306ba7440 100644 --- a/rust_dev_preview/globalaccelerator/Cargo.toml +++ b/rust_dev_preview/globalaccelerator/Cargo.toml @@ -7,9 +7,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-globalaccelerator = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-globalaccelerator = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } tokio-stream = "0.1.8" -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/globalaccelerator/src/bin/globalaccelerator-helloworld.rs b/rust_dev_preview/globalaccelerator/src/bin/globalaccelerator-helloworld.rs index 858fa5ce123..dbb5482e829 100644 --- a/rust_dev_preview/globalaccelerator/src/bin/globalaccelerator-helloworld.rs +++ b/rust_dev_preview/globalaccelerator/src/bin/globalaccelerator-helloworld.rs @@ -7,10 +7,10 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_globalaccelerator::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; use tokio_stream::StreamExt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// Whether to display additional information. #[structopt(short, long)] @@ -46,7 +46,7 @@ async fn show_accelerators(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { verbose } = Opt::from_args(); + let Opt { verbose } = Opt::parse(); // Global Accelerator is a global service with its API in us-west-2 let region_provider = RegionProviderChain::first_try(Region::new("us-west-2")); diff --git a/rust_dev_preview/glue/Cargo.toml b/rust_dev_preview/glue/Cargo.toml index 4a552a0b11e..e9aae5e5b4c 100644 --- a/rust_dev_preview/glue/Cargo.toml +++ b/rust_dev_preview/glue/Cargo.toml @@ -13,27 +13,26 @@ name = "scenario" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-glue = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-glue = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "client-hyper", "rustls", "rt-tokio", ] } -aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "rt-tokio", ] } -aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } tracing = "0.1.37" async_once = "0.2.6" lazy_static = "1.4.0" -clap = { version = "~4.0.18", features = ["derive"] } -clap_lex = "=0.3.0" +clap = { version = "4.2.1", features = ["derive"] } thiserror = "1.0.37" secrecy = "0.8.0" uuid = { version = "1.2.1", features = ["v4"] } diff --git a/rust_dev_preview/greengrassv2/Cargo.toml b/rust_dev_preview/greengrassv2/Cargo.toml index 3dcc00cbe0e..f6f3a98c767 100644 --- a/rust_dev_preview/greengrassv2/Cargo.toml +++ b/rust_dev_preview/greengrassv2/Cargo.toml @@ -5,9 +5,9 @@ authors = ["Aaron Tsui "] edition = "2021" [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-greengrassv2 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-greengrassv2 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.5", features = ["env-filter"] } diff --git a/rust_dev_preview/greengrassv2/src/bin/list-core-devices.rs b/rust_dev_preview/greengrassv2/src/bin/list-core-devices.rs index d8858b960d1..e61eb68254b 100644 --- a/rust_dev_preview/greengrassv2/src/bin/list-core-devices.rs +++ b/rust_dev_preview/greengrassv2/src/bin/list-core-devices.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_greengrassv2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -57,7 +57,7 @@ async fn show_cores(client: &Client) -> Result<(), Error> { #[tokio::main] async fn main() -> Result<(), Box> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/iam/Cargo.toml b/rust_dev_preview/iam/Cargo.toml index 42871e47dde..12ea1cf78d6 100644 --- a/rust_dev_preview/iam/Cargo.toml +++ b/rust_dev_preview/iam/Cargo.toml @@ -17,18 +17,18 @@ name = "iam_getting_started" path = "src/bin/iam-getting-started.rs" [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-credential-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["hardcoded-credentials"] } -aws-hyper = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-iam = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-sts = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["test-util"] } -aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-credential-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = ["hardcoded-credentials"] } +aws-hyper = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-iam = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-sts = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = ["test-util"] } +aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } sdk-examples-test-utils = { path = "../test-utils" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } uuid = { version = "0.8", features = ["serde", "v4"] } tower-service = "0.3.2" diff --git a/rust_dev_preview/iam/src/bin/create-role.rs b/rust_dev_preview/iam/src/bin/create-role.rs index 907015d5b62..3427015f333 100644 --- a/rust_dev_preview/iam/src/bin/create-role.rs +++ b/rust_dev_preview/iam/src/bin/create-role.rs @@ -7,10 +7,10 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_iam::{config::Region, meta::PKG_VERSION, Client, Error}; +use clap::Parser; use std::fs; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -71,7 +71,7 @@ async fn main() -> Result<(), Error> { policy_file, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/iot/Cargo.toml b/rust_dev_preview/iot/Cargo.toml index 2a80697db60..3b0f8651a5d 100644 --- a/rust_dev_preview/iot/Cargo.toml +++ b/rust_dev_preview/iot/Cargo.toml @@ -7,9 +7,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-iot = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-iot = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/iot/src/bin/describe-endpoint.rs b/rust_dev_preview/iot/src/bin/describe-endpoint.rs index 625036ccf16..5a89b3e76b4 100644 --- a/rust_dev_preview/iot/src/bin/describe-endpoint.rs +++ b/rust_dev_preview/iot/src/bin/describe-endpoint.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_iot::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -62,7 +62,7 @@ async fn main() -> Result<(), Error> { region, endpoint_type, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/iot/src/bin/list-things.rs b/rust_dev_preview/iot/src/bin/list-things.rs index cc423fa57a5..97d76f781e8 100644 --- a/rust_dev_preview/iot/src/bin/list-things.rs +++ b/rust_dev_preview/iot/src/bin/list-things.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_iot::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -60,7 +60,7 @@ async fn show_things(client: &Client) -> Result<(), Error> { #[tokio::main] async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/kinesis/Cargo.toml b/rust_dev_preview/kinesis/Cargo.toml index 01f8f809475..1d86df1b4f6 100644 --- a/rust_dev_preview/kinesis/Cargo.toml +++ b/rust_dev_preview/kinesis/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-kinesis = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-kinesis = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/kinesis/src/bin/create-stream.rs b/rust_dev_preview/kinesis/src/bin/create-stream.rs index 96973d21286..e086015b9fc 100644 --- a/rust_dev_preview/kinesis/src/bin/create-stream.rs +++ b/rust_dev_preview/kinesis/src/bin/create-stream.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kinesis::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -55,7 +55,7 @@ async fn main() -> Result<(), Error> { stream_name, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/kinesis/src/bin/delete-stream.rs b/rust_dev_preview/kinesis/src/bin/delete-stream.rs index 784c21d468a..4f40f2b9e6a 100644 --- a/rust_dev_preview/kinesis/src/bin/delete-stream.rs +++ b/rust_dev_preview/kinesis/src/bin/delete-stream.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kinesis::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -50,7 +50,7 @@ async fn main() -> Result<(), Error> { stream_name, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/kinesis/src/bin/describe-stream.rs b/rust_dev_preview/kinesis/src/bin/describe-stream.rs index 8c110a00580..696a7726b16 100644 --- a/rust_dev_preview/kinesis/src/bin/describe-stream.rs +++ b/rust_dev_preview/kinesis/src/bin/describe-stream.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kinesis::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -60,7 +60,7 @@ async fn main() -> Result<(), Error> { stream_name, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/kinesis/src/bin/list-streams.rs b/rust_dev_preview/kinesis/src/bin/list-streams.rs index 3ec418fcbcf..a65ad4ecf52 100644 --- a/rust_dev_preview/kinesis/src/bin/list-streams.rs +++ b/rust_dev_preview/kinesis/src/bin/list-streams.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kinesis::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -42,7 +42,7 @@ async fn show_streams(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/kinesis/src/bin/put-record.rs b/rust_dev_preview/kinesis/src/bin/put-record.rs index ad4753a9524..95e07728e58 100644 --- a/rust_dev_preview/kinesis/src/bin/put-record.rs +++ b/rust_dev_preview/kinesis/src/bin/put-record.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kinesis::primitives::Blob; use aws_sdk_kinesis::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -72,7 +72,7 @@ async fn main() -> Result<(), Error> { stream_name, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/kms/Cargo.toml b/rust_dev_preview/kms/Cargo.toml index fdad49058e7..b6f0ea99f0b 100644 --- a/rust_dev_preview/kms/Cargo.toml +++ b/rust_dev_preview/kms/Cargo.toml @@ -9,14 +9,14 @@ edition = "2021" description = "Example usage of the KMS service" [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-kms = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-kms = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "client-hyper", "rustls", "rt-tokio", ] } tokio = { version = "1.20.1", features = ["full"] } base64 = "0.13.0" -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/kms/src/bin/create-key.rs b/rust_dev_preview/kms/src/bin/create-key.rs index a9e5404c13e..aeedb65b38b 100644 --- a/rust_dev_preview/kms/src/bin/create-key.rs +++ b/rust_dev_preview/kms/src/bin/create-key.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kms::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -48,7 +48,7 @@ async fn make_key(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/kms/src/bin/decrypt.rs b/rust_dev_preview/kms/src/bin/decrypt.rs index 4631dab0845..2d4b132c9f7 100644 --- a/rust_dev_preview/kms/src/bin/decrypt.rs +++ b/rust_dev_preview/kms/src/bin/decrypt.rs @@ -8,10 +8,10 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kms::primitives::Blob; use aws_sdk_kms::{config::Region, meta::PKG_VERSION, Client, Error}; +use clap::Parser; use std::fs; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -79,7 +79,7 @@ async fn main() -> Result<(), Error> { input_file, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/kms/src/bin/encrypt.rs b/rust_dev_preview/kms/src/bin/encrypt.rs index fba1f032a8a..772113225ac 100644 --- a/rust_dev_preview/kms/src/bin/encrypt.rs +++ b/rust_dev_preview/kms/src/bin/encrypt.rs @@ -8,11 +8,11 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kms::primitives::Blob; use aws_sdk_kms::{config::Region, meta::PKG_VERSION, Client, Error}; +use clap::Parser; use std::fs::File; use std::io::Write; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -86,7 +86,7 @@ async fn main() -> Result<(), Error> { region, text, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/kms/src/bin/generate-data-key-without-plaintext.rs b/rust_dev_preview/kms/src/bin/generate-data-key-without-plaintext.rs index 64d2b8022ef..54ac37fbef6 100644 --- a/rust_dev_preview/kms/src/bin/generate-data-key-without-plaintext.rs +++ b/rust_dev_preview/kms/src/bin/generate-data-key-without-plaintext.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kms::types::DataKeySpec; use aws_sdk_kms::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -65,7 +65,7 @@ async fn main() -> Result<(), Error> { key, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/kms/src/bin/generate-data-key.rs b/rust_dev_preview/kms/src/bin/generate-data-key.rs index 3c17510d3fd..71a83450998 100644 --- a/rust_dev_preview/kms/src/bin/generate-data-key.rs +++ b/rust_dev_preview/kms/src/bin/generate-data-key.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kms::types::DataKeySpec; use aws_sdk_kms::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -65,7 +65,7 @@ async fn main() -> Result<(), Error> { key, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/kms/src/bin/generate-random.rs b/rust_dev_preview/kms/src/bin/generate-random.rs index 14e19abb712..091638592a3 100644 --- a/rust_dev_preview/kms/src/bin/generate-random.rs +++ b/rust_dev_preview/kms/src/bin/generate-random.rs @@ -7,10 +7,10 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kms::{config::Region, meta::PKG_VERSION, Client, Error}; +use clap::Parser; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -64,7 +64,7 @@ async fn main() -> Result<(), Error> { length, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/kms/src/bin/list-keys.rs b/rust_dev_preview/kms/src/bin/list-keys.rs index 120741ed287..cb8bc4c74ad 100644 --- a/rust_dev_preview/kms/src/bin/list-keys.rs +++ b/rust_dev_preview/kms/src/bin/list-keys.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kms::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -51,7 +51,7 @@ async fn show_keys(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/kms/src/bin/reencrypt-data.rs b/rust_dev_preview/kms/src/bin/reencrypt-data.rs index 42f27aad60b..6886680f2f3 100644 --- a/rust_dev_preview/kms/src/bin/reencrypt-data.rs +++ b/rust_dev_preview/kms/src/bin/reencrypt-data.rs @@ -8,12 +8,12 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_kms::primitives::Blob; use aws_sdk_kms::{config::Region, meta::PKG_VERSION, Client, Error}; +use clap::Parser; use std::fs; use std::fs::File; use std::io::Write; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -108,7 +108,7 @@ async fn main() -> Result<(), Error> { output_file, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/lambda/Cargo.toml b/rust_dev_preview/lambda/Cargo.toml index cfede4b18a1..472d994d79b 100644 --- a/rust_dev_preview/lambda/Cargo.toml +++ b/rust_dev_preview/lambda/Cargo.toml @@ -10,14 +10,14 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-ec2 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-lambda = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-ec2 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-lambda = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } lambda_runtime = "0.4" log = "0.4" serde = { version = "1", features = ["derive"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tokio = { version = "1.20.1", features = ["full"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } time = "0.3" diff --git a/rust_dev_preview/lambda/src/bin/change-java-runtime.rs b/rust_dev_preview/lambda/src/bin/change-java-runtime.rs index 15f0649f501..5e01fe11c8b 100644 --- a/rust_dev_preview/lambda/src/bin/change-java-runtime.rs +++ b/rust_dev_preview/lambda/src/bin/change-java-runtime.rs @@ -7,8 +7,8 @@ use aws_sdk_lambda::types::Runtime; use aws_sdk_lambda::{Client, Error}; +use clap::Parser; use lambda_code_examples::{make_client, ArnOpt}; -use structopt::StructOpt; // Change Java runtime in Lambda function. // snippet-start:[lambda.rust.change-java-runtime] @@ -53,7 +53,7 @@ async fn set_runtimes(client: &Client, arn: &str) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let ArnOpt { arn, base } = ArnOpt::from_args(); + let ArnOpt { arn, base } = ArnOpt::parse(); let client = make_client(base).await; diff --git a/rust_dev_preview/lambda/src/bin/invoke-function.rs b/rust_dev_preview/lambda/src/bin/invoke-function.rs index a08e5a143a3..22628ec1507 100644 --- a/rust_dev_preview/lambda/src/bin/invoke-function.rs +++ b/rust_dev_preview/lambda/src/bin/invoke-function.rs @@ -6,8 +6,8 @@ #![allow(clippy::result_large_err)] use aws_sdk_lambda::{Client, Error}; +use clap::Parser; use lambda_code_examples::{make_client, ArnOpt}; -use structopt::StructOpt; // Runs a Lambda function. // snippet-start:[lambda.rust.invoke-function] @@ -32,7 +32,7 @@ async fn run_function(client: &Client, arn: &str) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let ArnOpt { arn, base } = ArnOpt::from_args(); + let ArnOpt { arn, base } = ArnOpt::parse(); let client = make_client(base).await; diff --git a/rust_dev_preview/lambda/src/bin/list-all-function-runtimes.rs b/rust_dev_preview/lambda/src/bin/list-all-function-runtimes.rs index bce667ad46c..e894b44c0f6 100644 --- a/rust_dev_preview/lambda/src/bin/list-all-function-runtimes.rs +++ b/rust_dev_preview/lambda/src/bin/list-all-function-runtimes.rs @@ -6,10 +6,10 @@ #![allow(clippy::result_large_err)] use aws_sdk_lambda::Error; +use clap::Parser; use lambda_code_examples::{make_client, make_config, Opt as BaseOpt}; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { #[structopt(flatten)] base: BaseOpt, @@ -77,7 +77,7 @@ async fn show_lambdas(language: &str, region: &str, verbose: bool) -> Result<(), async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { language, base } = Opt::from_args(); + let Opt { language, base } = Opt::parse(); let language = language.as_deref().unwrap_or_default(); let verbose = base.verbose; diff --git a/rust_dev_preview/lambda/src/bin/list-functions.rs b/rust_dev_preview/lambda/src/bin/list-functions.rs index 453d099fe9f..fc8fc3d5b0a 100644 --- a/rust_dev_preview/lambda/src/bin/list-functions.rs +++ b/rust_dev_preview/lambda/src/bin/list-functions.rs @@ -6,8 +6,8 @@ #![allow(clippy::result_large_err)] use aws_sdk_lambda::{Client, Error}; +use clap::Parser; use lambda_code_examples::{make_client, Opt}; -use structopt::StructOpt; // Lists the ARNs of your Lambda functions. // snippet-start:[lambda.rust.list-functions] @@ -41,7 +41,7 @@ async fn show_arns(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let client = make_client(Opt::from_args()).await; + let client = make_client(Opt::parse()).await; show_arns(&client).await } diff --git a/rust_dev_preview/lambda/src/lib.rs b/rust_dev_preview/lambda/src/lib.rs index f40a4b330b1..14ca1e9ba07 100644 --- a/rust_dev_preview/lambda/src/lib.rs +++ b/rust_dev_preview/lambda/src/lib.rs @@ -5,9 +5,9 @@ use aws_config::{meta::region::RegionProviderChain, SdkConfig}; use aws_sdk_lambda::{config::Region, meta::PKG_VERSION, Client}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] pub struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -18,7 +18,7 @@ pub struct Opt { pub verbose: bool, } -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] pub struct ArnOpt { #[structopt(flatten)] pub base: Opt, diff --git a/rust_dev_preview/localstack/Cargo.toml b/rust_dev_preview/localstack/Cargo.toml index 89d6895933e..3bbe80da8bd 100644 --- a/rust_dev_preview/localstack/Cargo.toml +++ b/rust_dev_preview/localstack/Cargo.toml @@ -6,9 +6,9 @@ authors = ["Doug Schwartz "] edition = "2021" [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-sqs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-sqs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } http = "0.2" tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/logging/logger/Cargo.toml b/rust_dev_preview/logging/logger/Cargo.toml index a43b6576dc4..62d8da4b1f6 100644 --- a/rust_dev_preview/logging/logger/Cargo.toml +++ b/rust_dev_preview/logging/logger/Cargo.toml @@ -11,11 +11,11 @@ version = "0.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } # snippet-start:[logging.rust.logger-cargo.toml-env_logger] env_logger = "0.9.0" # snippet-end:[logging.rust.logger-cargo.toml-env_logger] -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tokio = { version = "1.20.1", features = ["full"] } # snippet-end:[logging.rust.logger-cargo.toml] diff --git a/rust_dev_preview/logging/logger/src/main.rs b/rust_dev_preview/logging/logger/src/main.rs index ed479d05db9..44745f5e7cc 100644 --- a/rust_dev_preview/logging/logger/src/main.rs +++ b/rust_dev_preview/logging/logger/src/main.rs @@ -8,9 +8,9 @@ // snippet-start:[logging.rust.main] use aws_config::meta::region::RegionProviderChain; use aws_sdk_dynamodb::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -27,7 +27,7 @@ async fn main() -> Result<(), Error> { env_logger::init(); // snippet-end:[logging.rust.main-logger-init] - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/logging/tracing/Cargo.toml b/rust_dev_preview/logging/tracing/Cargo.toml index 0b5b1701201..0a7c0a6c972 100644 --- a/rust_dev_preview/logging/tracing/Cargo.toml +++ b/rust_dev_preview/logging/tracing/Cargo.toml @@ -11,9 +11,9 @@ version = "0.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -structopt = { version = "0.3", default-features = false } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-dynamodb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +clap = { version = "4.2.1", features = ["derive"] } tokio = { version = "1.20.1", features = ["full"] } # snippet-start:[logging.rust.tracing-cargo.toml-tracing_subscriber] tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/rust_dev_preview/logging/tracing/src/main.rs b/rust_dev_preview/logging/tracing/src/main.rs index 666f667e326..f8a39dac1bc 100644 --- a/rust_dev_preview/logging/tracing/src/main.rs +++ b/rust_dev_preview/logging/tracing/src/main.rs @@ -8,9 +8,9 @@ // snippet-start:[tracing.rust.main] use aws_config::meta::region::RegionProviderChain; use aws_sdk_dynamodb::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -27,7 +27,7 @@ async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); // snippet-end:[tracing.rust.main-tracing-init] - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/medialive/Cargo.toml b/rust_dev_preview/medialive/Cargo.toml index df2171b7b3a..a71b355ce95 100644 --- a/rust_dev_preview/medialive/Cargo.toml +++ b/rust_dev_preview/medialive/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-medialive = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-medialive = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/medialive/src/bin/medialive-helloworld.rs b/rust_dev_preview/medialive/src/bin/medialive-helloworld.rs index b322dc4e2fd..54fb2420de3 100644 --- a/rust_dev_preview/medialive/src/bin/medialive-helloworld.rs +++ b/rust_dev_preview/medialive/src/bin/medialive-helloworld.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_medialive::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -49,7 +49,7 @@ async fn show_inputs(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/mediapackage/Cargo.toml b/rust_dev_preview/mediapackage/Cargo.toml index 151c993b5c2..294ae22a5d3 100644 --- a/rust_dev_preview/mediapackage/Cargo.toml +++ b/rust_dev_preview/mediapackage/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-mediapackage = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-mediapackage = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/mediapackage/src/bin/list-endpoints.rs b/rust_dev_preview/mediapackage/src/bin/list-endpoints.rs index ca89570f076..79376947b6f 100644 --- a/rust_dev_preview/mediapackage/src/bin/list-endpoints.rs +++ b/rust_dev_preview/mediapackage/src/bin/list-endpoints.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_mediapackage::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -50,7 +50,7 @@ async fn show_endpoints(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/mediapackage/src/bin/mediapackage-helloworld.rs b/rust_dev_preview/mediapackage/src/bin/mediapackage-helloworld.rs index e0d41411ad7..5260d9cddf7 100644 --- a/rust_dev_preview/mediapackage/src/bin/mediapackage-helloworld.rs +++ b/rust_dev_preview/mediapackage/src/bin/mediapackage-helloworld.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_mediapackage::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -51,7 +51,7 @@ async fn show_channels(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/polly/Cargo.toml b/rust_dev_preview/polly/Cargo.toml index 619f1c830de..a1a2551229d 100644 --- a/rust_dev_preview/polly/Cargo.toml +++ b/rust_dev_preview/polly/Cargo.toml @@ -10,9 +10,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-polly = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-polly = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } bytes = "1" -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/polly/src/bin/describe-voices.rs b/rust_dev_preview/polly/src/bin/describe-voices.rs index bd2d0e90c83..172520d1fc2 100644 --- a/rust_dev_preview/polly/src/bin/describe-voices.rs +++ b/rust_dev_preview/polly/src/bin/describe-voices.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_polly::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -55,7 +55,7 @@ async fn list_voices(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/polly/src/bin/list-lexicons.rs b/rust_dev_preview/polly/src/bin/list-lexicons.rs index e1a59c45baf..3e771fb5c05 100644 --- a/rust_dev_preview/polly/src/bin/list-lexicons.rs +++ b/rust_dev_preview/polly/src/bin/list-lexicons.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_polly::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -63,7 +63,7 @@ async fn show_lexicons(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/polly/src/bin/polly-helloworld.rs b/rust_dev_preview/polly/src/bin/polly-helloworld.rs index 6ad151661bd..745e60a323e 100644 --- a/rust_dev_preview/polly/src/bin/polly-helloworld.rs +++ b/rust_dev_preview/polly/src/bin/polly-helloworld.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_polly::types::{Engine, Voice}; use aws_sdk_polly::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -82,7 +82,7 @@ async fn show_voices(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/polly/src/bin/put-lexicon.rs b/rust_dev_preview/polly/src/bin/put-lexicon.rs index 7b67f1128d3..d5097e7c984 100644 --- a/rust_dev_preview/polly/src/bin/put-lexicon.rs +++ b/rust_dev_preview/polly/src/bin/put-lexicon.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_polly::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -75,7 +75,7 @@ async fn main() -> Result<(), Error> { region, to, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/polly/src/bin/synthesize-speech-presigned.rs b/rust_dev_preview/polly/src/bin/synthesize-speech-presigned.rs index 8e4bad1d439..a8f1439f70b 100644 --- a/rust_dev_preview/polly/src/bin/synthesize-speech-presigned.rs +++ b/rust_dev_preview/polly/src/bin/synthesize-speech-presigned.rs @@ -9,12 +9,12 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_polly::presigning::PresigningConfig; use aws_sdk_polly::types::{OutputFormat, VoiceId}; use aws_sdk_polly::{config::Region, meta::PKG_VERSION, Client}; +use clap::Parser; use std::error::Error; use std::fs; use std::time::Duration; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The default AWS Region. #[structopt(short, long)] @@ -75,7 +75,7 @@ async fn main() -> Result<(), Box> { region, expires_in, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/polly/src/bin/synthesize-speech.rs b/rust_dev_preview/polly/src/bin/synthesize-speech.rs index 31543b311a5..6256208e4c5 100644 --- a/rust_dev_preview/polly/src/bin/synthesize-speech.rs +++ b/rust_dev_preview/polly/src/bin/synthesize-speech.rs @@ -8,11 +8,11 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_polly::types::{OutputFormat, VoiceId}; use aws_sdk_polly::{config::Region, meta::PKG_VERSION, Client, Error}; +use clap::Parser; use std::fs; -use structopt::StructOpt; use tokio::io::AsyncWriteExt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -79,7 +79,7 @@ async fn main() -> Result<(), Error> { filename, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/qldb/Cargo.toml b/rust_dev_preview/qldb/Cargo.toml index c857af035eb..3182a734dde 100644 --- a/rust_dev_preview/qldb/Cargo.toml +++ b/rust_dev_preview/qldb/Cargo.toml @@ -10,10 +10,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-qldb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-qldbsession = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-qldb = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-qldbsession = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } tokio-stream = { version = "0.1.9", features = ["default"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/qldb/src/bin/create-ledger.rs b/rust_dev_preview/qldb/src/bin/create-ledger.rs index 03610bef7a0..c8ee61597a2 100644 --- a/rust_dev_preview/qldb/src/bin/create-ledger.rs +++ b/rust_dev_preview/qldb/src/bin/create-ledger.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_qldb::types::PermissionsMode; use aws_sdk_qldb::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -57,7 +57,7 @@ async fn main() -> Result<(), Error> { ledger, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/qldb/src/bin/list-ledgers.rs b/rust_dev_preview/qldb/src/bin/list-ledgers.rs index 299910db405..634ad639194 100644 --- a/rust_dev_preview/qldb/src/bin/list-ledgers.rs +++ b/rust_dev_preview/qldb/src/bin/list-ledgers.rs @@ -7,10 +7,10 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_qldb::{config::Region, meta::PKG_VERSION, Client as QLDBClient, Error}; -use structopt::StructOpt; +use clap::Parser; use tokio_stream::StreamExt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -48,7 +48,7 @@ async fn show_ledgers(client: &QLDBClient) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/qldb/src/bin/qldb-helloworld.rs b/rust_dev_preview/qldb/src/bin/qldb-helloworld.rs index 9a4d27db997..b3e2ab9f7b9 100644 --- a/rust_dev_preview/qldb/src/bin/qldb-helloworld.rs +++ b/rust_dev_preview/qldb/src/bin/qldb-helloworld.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_qldbsession::types::StartSessionRequest; use aws_sdk_qldbsession::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -59,7 +59,7 @@ async fn main() -> Result<(), Error> { ledger, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/rds/Cargo.toml b/rust_dev_preview/rds/Cargo.toml index dfb1dd4ee73..0ad952caf65 100644 --- a/rust_dev_preview/rds/Cargo.toml +++ b/rust_dev_preview/rds/Cargo.toml @@ -10,8 +10,8 @@ version = "0.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-rds = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-rds = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/rds/src/bin/rds-helloworld.rs b/rust_dev_preview/rds/src/bin/rds-helloworld.rs index 2e069e59125..79c61880838 100644 --- a/rust_dev_preview/rds/src/bin/rds-helloworld.rs +++ b/rust_dev_preview/rds/src/bin/rds-helloworld.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_rds::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -72,7 +72,7 @@ async fn show_instances(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/rdsdata/Cargo.toml b/rust_dev_preview/rdsdata/Cargo.toml index 49f53af637e..b08d5884259 100644 --- a/rust_dev_preview/rdsdata/Cargo.toml +++ b/rust_dev_preview/rdsdata/Cargo.toml @@ -10,8 +10,8 @@ version = "0.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-rdsdata = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-rdsdata = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/rdsdata/src/bin/rdsdata-helloworld.rs b/rust_dev_preview/rdsdata/src/bin/rdsdata-helloworld.rs index dc16981a629..0385f81616f 100644 --- a/rust_dev_preview/rdsdata/src/bin/rdsdata-helloworld.rs +++ b/rust_dev_preview/rdsdata/src/bin/rdsdata-helloworld.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_rdsdata::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -80,7 +80,7 @@ async fn main() -> Result<(), Error> { region, secret_arn, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/route53/Cargo.toml b/rust_dev_preview/route53/Cargo.toml index a299980336e..26cf9a92f28 100644 --- a/rust_dev_preview/route53/Cargo.toml +++ b/rust_dev_preview/route53/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-route53 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-route53 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/route53/src/bin/route53-helloworld.rs b/rust_dev_preview/route53/src/bin/route53-helloworld.rs index 2ac01d2d5ca..7f1c10e24f9 100644 --- a/rust_dev_preview/route53/src/bin/route53-helloworld.rs +++ b/rust_dev_preview/route53/src/bin/route53-helloworld.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_route53::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -58,7 +58,7 @@ async fn show_host_info(client: &aws_sdk_route53::Client) -> Result<(), aws_sdk_ async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/s3/Cargo.toml b/rust_dev_preview/s3/Cargo.toml index 77e2cd1a331..a912861c1ec 100644 --- a/rust_dev_preview/s3/Cargo.toml +++ b/rust_dev_preview/s3/Cargo.toml @@ -21,16 +21,16 @@ assert_cmd = "2.0" predicates = "2.1" [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } # snippet-start:[s3.rust.s3-object-lambda-cargo.toml] -aws-endpoint = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-endpoint = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } # snippet-end:[s3.rust.s3-object-lambda-cargo.toml] -aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "test-util", ] } -aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["rt-tokio"] } -aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = ["rt-tokio"] } +aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } sdk-examples-test-utils = { path = "../test-utils" } bytes = "0.4.12" futures-util = { version = "0.3.21", features = ["alloc"] } @@ -38,7 +38,7 @@ http = "0.2.8" http-body = "0.4.5" md-5 = "0.10.1" rand = "0.5.0" -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } thiserror = "1.0" tokio = { version = "1.20.1", features = ["full"] } tokio-stream = "0.1.8" diff --git a/rust_dev_preview/s3/src/bin/copy-object.rs b/rust_dev_preview/s3/src/bin/copy-object.rs index a6439f27b46..b055af46962 100644 --- a/rust_dev_preview/s3/src/bin/copy-object.rs +++ b/rust_dev_preview/s3/src/bin/copy-object.rs @@ -13,9 +13,9 @@ use aws_sdk_s3::{ operation::copy_object::{CopyObjectError, CopyObjectOutput}, Client, Error, }; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -118,7 +118,7 @@ async fn main() -> Result<(), Error> { key, name, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/s3/src/bin/create-bucket.rs b/rust_dev_preview/s3/src/bin/create-bucket.rs index bbbf10ce196..fdde5485586 100644 --- a/rust_dev_preview/s3/src/bin/create-bucket.rs +++ b/rust_dev_preview/s3/src/bin/create-bucket.rs @@ -10,9 +10,9 @@ use aws_sdk_s3::error::SdkError; use aws_sdk_s3::operation::create_bucket::{CreateBucketError, CreateBucketOutput}; use aws_sdk_s3::types::{BucketLocationConstraint, CreateBucketConfiguration}; use aws_sdk_s3::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -87,7 +87,7 @@ async fn main() -> Result<(), Error> { region, bucket, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/s3/src/bin/delete-object.rs b/rust_dev_preview/s3/src/bin/delete-object.rs index c1410e4a95b..4bdcf048084 100644 --- a/rust_dev_preview/s3/src/bin/delete-object.rs +++ b/rust_dev_preview/s3/src/bin/delete-object.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -62,7 +62,7 @@ async fn main() -> Result<(), Error> { bucket, key, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/s3/src/bin/delete-objects.rs b/rust_dev_preview/s3/src/bin/delete-objects.rs index 642457bc34a..dca9cc4249d 100644 --- a/rust_dev_preview/s3/src/bin/delete-objects.rs +++ b/rust_dev_preview/s3/src/bin/delete-objects.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::types::{Delete, ObjectIdentifier}; use aws_sdk_s3::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -72,7 +72,7 @@ async fn main() -> Result<(), Error> { bucket, objects, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/s3/src/bin/get-object-presigned.rs b/rust_dev_preview/s3/src/bin/get-object-presigned.rs index b87a8843001..cf4f254e0c6 100644 --- a/rust_dev_preview/s3/src/bin/get-object-presigned.rs +++ b/rust_dev_preview/s3/src/bin/get-object-presigned.rs @@ -8,11 +8,11 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::presigning::PresigningConfig; use aws_sdk_s3::{config::Region, meta::PKG_VERSION, Client}; +use clap::Parser; use std::error::Error; use std::time::Duration; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -78,7 +78,7 @@ async fn main() -> Result<(), Box> { object, expires_in, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/s3/src/bin/list-buckets.rs b/rust_dev_preview/s3/src/bin/list-buckets.rs index a89256bafe5..932180ac1d6 100644 --- a/rust_dev_preview/s3/src/bin/list-buckets.rs +++ b/rust_dev_preview/s3/src/bin/list-buckets.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -80,7 +80,7 @@ async fn main() -> Result<(), Error> { region, strict, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/s3/src/bin/list-object-versions.rs b/rust_dev_preview/s3/src/bin/list-object-versions.rs index 011cbc64aa2..de7b175b900 100644 --- a/rust_dev_preview/s3/src/bin/list-object-versions.rs +++ b/rust_dev_preview/s3/src/bin/list-object-versions.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -55,7 +55,7 @@ async fn main() -> Result<(), Error> { region, bucket, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/s3/src/bin/list-objects.rs b/rust_dev_preview/s3/src/bin/list-objects.rs index 0e0c11f476d..d733745a736 100644 --- a/rust_dev_preview/s3/src/bin/list-objects.rs +++ b/rust_dev_preview/s3/src/bin/list-objects.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -55,7 +55,7 @@ async fn main() -> Result<(), Error> { region, bucket, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/s3/src/bin/put-object-presigned.rs b/rust_dev_preview/s3/src/bin/put-object-presigned.rs index 67f04c84db2..2d967bba277 100644 --- a/rust_dev_preview/s3/src/bin/put-object-presigned.rs +++ b/rust_dev_preview/s3/src/bin/put-object-presigned.rs @@ -8,11 +8,11 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::presigning::PresigningConfig; use aws_sdk_s3::{config::Region, meta::PKG_VERSION, Client}; +use clap::Parser; use std::error::Error; use std::time::Duration; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -79,7 +79,7 @@ async fn main() -> Result<(), Box> { object, expires_in, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/s3/src/bin/s3-helloworld.rs b/rust_dev_preview/s3/src/bin/s3-helloworld.rs index 8c6e3d3a741..5b74357eef1 100644 --- a/rust_dev_preview/s3/src/bin/s3-helloworld.rs +++ b/rust_dev_preview/s3/src/bin/s3-helloworld.rs @@ -8,11 +8,11 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::primitives::ByteStream; use aws_sdk_s3::{config::Region, meta::PKG_VERSION, Client, Error}; +use clap::Parser; use std::path::Path; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -99,7 +99,7 @@ async fn main() -> Result<(), Error> { key, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/s3/src/bin/select-object-content.rs b/rust_dev_preview/s3/src/bin/select-object-content.rs index bf6c105f2ee..c2654ffce9f 100644 --- a/rust_dev_preview/s3/src/bin/select-object-content.rs +++ b/rust_dev_preview/s3/src/bin/select-object-content.rs @@ -11,9 +11,9 @@ use aws_sdk_s3::types::{ OutputSerialization, SelectObjectContentEventStream, }; use aws_sdk_s3::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -121,7 +121,7 @@ async fn main() -> Result<(), Error> { object, name, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/sagemaker/Cargo.toml b/rust_dev_preview/sagemaker/Cargo.toml index 2be03c212cd..7d62e1b6384 100644 --- a/rust_dev_preview/sagemaker/Cargo.toml +++ b/rust_dev_preview/sagemaker/Cargo.toml @@ -10,12 +10,12 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-sagemaker = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-types-convert = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-sagemaker = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-types-convert = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "convert-chrono", ] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } thiserror = "1.0" tokio = { version = "1.20.1", features = ["full"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/sagemaker/src/bin/list-training-jobs.rs b/rust_dev_preview/sagemaker/src/bin/list-training-jobs.rs index 4c7d43dcedc..7bd2386d83e 100644 --- a/rust_dev_preview/sagemaker/src/bin/list-training-jobs.rs +++ b/rust_dev_preview/sagemaker/src/bin/list-training-jobs.rs @@ -8,10 +8,10 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sagemaker::{config::Region, meta::PKG_VERSION, Client}; use aws_smithy_types_convert::date_time::DateTimeExt; +use clap::Parser; use sagemaker_code_examples::Error; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -63,7 +63,7 @@ async fn show_jobs(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/sagemaker/src/bin/sagemaker-helloworld.rs b/rust_dev_preview/sagemaker/src/bin/sagemaker-helloworld.rs index 9817e29a733..3caa5f020ed 100644 --- a/rust_dev_preview/sagemaker/src/bin/sagemaker-helloworld.rs +++ b/rust_dev_preview/sagemaker/src/bin/sagemaker-helloworld.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sagemaker::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -53,7 +53,7 @@ async fn show_instances(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/sdk-config/Cargo.toml b/rust_dev_preview/sdk-config/Cargo.toml index 4cd1d0e0a74..fd8ea798464 100644 --- a/rust_dev_preview/sdk-config/Cargo.toml +++ b/rust_dev_preview/sdk-config/Cargo.toml @@ -10,10 +10,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } lazy_static = "1.4.0" async_once = "0.2.6" diff --git a/rust_dev_preview/sdk-config/src/bin/disable_retries.rs b/rust_dev_preview/sdk-config/src/bin/disable_retries.rs index 2a5c02f243e..d2892807b0d 100644 --- a/rust_dev_preview/sdk-config/src/bin/disable_retries.rs +++ b/rust_dev_preview/sdk-config/src/bin/disable_retries.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::config::retry::RetryConfig; use aws_sdk_s3::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -41,7 +41,7 @@ async fn show_num_buckets(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/sdk-config/src/bin/set_retries.rs b/rust_dev_preview/sdk-config/src/bin/set_retries.rs index 3886758ccf9..d6b5c144777 100644 --- a/rust_dev_preview/sdk-config/src/bin/set_retries.rs +++ b/rust_dev_preview/sdk-config/src/bin/set_retries.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::config::retry::RetryConfig; use aws_sdk_s3::{config, config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -51,7 +51,7 @@ async fn main() -> Result<(), Error> { region, tries, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/secretsmanager/Cargo.toml b/rust_dev_preview/secretsmanager/Cargo.toml index 1ecc6c514af..313274aab77 100644 --- a/rust_dev_preview/secretsmanager/Cargo.toml +++ b/rust_dev_preview/secretsmanager/Cargo.toml @@ -9,8 +9,8 @@ edition = "2021" description = "Example usage of the SecretManager service" [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-secretsmanager = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-secretsmanager = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/secretsmanager/src/bin/create-secret.rs b/rust_dev_preview/secretsmanager/src/bin/create-secret.rs index dca61ecc94d..ab81356aa0a 100644 --- a/rust_dev_preview/secretsmanager/src/bin/create-secret.rs +++ b/rust_dev_preview/secretsmanager/src/bin/create-secret.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_secretsmanager::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -61,7 +61,7 @@ async fn main() -> Result<(), Error> { region, secret_value, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/secretsmanager/src/bin/get-secret-value.rs b/rust_dev_preview/secretsmanager/src/bin/get-secret-value.rs index 8a3cae98779..3f63eda0837 100644 --- a/rust_dev_preview/secretsmanager/src/bin/get-secret-value.rs +++ b/rust_dev_preview/secretsmanager/src/bin/get-secret-value.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_secretsmanager::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -50,7 +50,7 @@ async fn main() -> Result<(), Error> { name, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/secretsmanager/src/bin/list-secrets.rs b/rust_dev_preview/secretsmanager/src/bin/list-secrets.rs index 4ddd9ae061a..181b269387d 100644 --- a/rust_dev_preview/secretsmanager/src/bin/list-secrets.rs +++ b/rust_dev_preview/secretsmanager/src/bin/list-secrets.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_secretsmanager::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -49,7 +49,7 @@ async fn show_secrets(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/sending-presigned-requests/Cargo.toml b/rust_dev_preview/sending-presigned-requests/Cargo.toml index 91f8d134df5..db2a9ba6de1 100644 --- a/rust_dev_preview/sending-presigned-requests/Cargo.toml +++ b/rust_dev_preview/sending-presigned-requests/Cargo.toml @@ -7,12 +7,12 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } http = "0.2.6" hyper = "0.14" reqwest = "0.11" -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tokio = { version = "1.20.1", features = ["full"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/sending-presigned-requests/src/main.rs b/rust_dev_preview/sending-presigned-requests/src/main.rs index 6ad860f2c3e..1f8cc963c9e 100644 --- a/rust_dev_preview/sending-presigned-requests/src/main.rs +++ b/rust_dev_preview/sending-presigned-requests/src/main.rs @@ -8,11 +8,11 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_s3::presigning::{PresignedRequest, PresigningConfig}; use aws_sdk_s3::{config::Region, meta::PKG_VERSION, Client}; +use clap::Parser; use std::error::Error; use std::time::Duration; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -61,7 +61,7 @@ async fn main() -> Result<(), Box> { object, expires_in, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ses/Cargo.toml b/rust_dev_preview/ses/Cargo.toml index 8b3c09701fc..03e91ca8d59 100644 --- a/rust_dev_preview/ses/Cargo.toml +++ b/rust_dev_preview/ses/Cargo.toml @@ -8,8 +8,8 @@ authors = [ edition = "2021" [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-sesv2 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-sesv2 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/ses/src/bin/create-contact-list.rs b/rust_dev_preview/ses/src/bin/create-contact-list.rs index 9948bed75f9..ec7f7defb9f 100644 --- a/rust_dev_preview/ses/src/bin/create-contact-list.rs +++ b/rust_dev_preview/ses/src/bin/create-contact-list.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sesv2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The name of the contact list. #[structopt(short, long)] @@ -55,7 +55,7 @@ async fn main() -> Result<(), Error> { contact_list, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ses/src/bin/create-contact.rs b/rust_dev_preview/ses/src/bin/create-contact.rs index 77042668a74..1ffa8c20f5f 100644 --- a/rust_dev_preview/ses/src/bin/create-contact.rs +++ b/rust_dev_preview/ses/src/bin/create-contact.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sesv2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The name of the contact list. #[structopt(short, long)] @@ -62,7 +62,7 @@ async fn main() -> Result<(), Error> { region, email_address, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ses/src/bin/is-email-verified.rs b/rust_dev_preview/ses/src/bin/is-email-verified.rs index 6d47ff0d9b5..380d30083b1 100644 --- a/rust_dev_preview/ses/src/bin/is-email-verified.rs +++ b/rust_dev_preview/ses/src/bin/is-email-verified.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sesv2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The email address. #[structopt(short, long)] @@ -59,7 +59,7 @@ async fn main() -> Result<(), Error> { email_address, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ses/src/bin/list-contact-lists.rs b/rust_dev_preview/ses/src/bin/list-contact-lists.rs index fdab5f8cf84..5faa18b3e7f 100644 --- a/rust_dev_preview/ses/src/bin/list-contact-lists.rs +++ b/rust_dev_preview/ses/src/bin/list-contact-lists.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sesv2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -46,7 +46,7 @@ async fn show_lists(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ses/src/bin/list-contacts.rs b/rust_dev_preview/ses/src/bin/list-contacts.rs index 0931f06a681..d8204047cb6 100644 --- a/rust_dev_preview/ses/src/bin/list-contacts.rs +++ b/rust_dev_preview/ses/src/bin/list-contacts.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sesv2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The name of the contact list. #[structopt(short, long)] @@ -59,7 +59,7 @@ async fn main() -> Result<(), Error> { contact_list, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ses/src/bin/send-email.rs b/rust_dev_preview/ses/src/bin/send-email.rs index 5393922edae..1bbba7d7721 100644 --- a/rust_dev_preview/ses/src/bin/send-email.rs +++ b/rust_dev_preview/ses/src/bin/send-email.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sesv2::types::{Body, Content, Destination, EmailContent, Message}; use aws_sdk_sesv2::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The contact list containing email addresses to send the message to. #[structopt(short, long)] @@ -108,7 +108,7 @@ async fn main() -> Result<(), Error> { message, subject, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/sitewise/Cargo.toml b/rust_dev_preview/sitewise/Cargo.toml index 03eff9d7b60..5782ca05e98 100644 --- a/rust_dev_preview/sitewise/Cargo.toml +++ b/rust_dev_preview/sitewise/Cargo.toml @@ -7,12 +7,12 @@ edition = "2021" # For more keys and their definitions, see https://doc.rust-lang.org/cargo/reference/manifest.html. [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-iotsitewise = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-types-convert = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-iotsitewise = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-types-convert = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "convert-chrono", ] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } thiserror = "1.0" tokio = { version = "1.20.1", features = ["full"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } \ No newline at end of file diff --git a/rust_dev_preview/sitewise/src/bin/describe-asset.rs b/rust_dev_preview/sitewise/src/bin/describe-asset.rs index d052369237b..d8af96c35aa 100644 --- a/rust_dev_preview/sitewise/src/bin/describe-asset.rs +++ b/rust_dev_preview/sitewise/src/bin/describe-asset.rs @@ -9,11 +9,11 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_iotsitewise::error::DisplayErrorContext; use aws_sdk_iotsitewise::{config::Region, meta::PKG_VERSION, Client}; use aws_smithy_types_convert::date_time::DateTimeExt; +use clap::Parser; use sitewise_code_examples::Error; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -183,7 +183,7 @@ async fn list_assets(client: &Client, asset_id: Option) -> Result<(), Er async fn main() { tracing_subscriber::fmt::init(); - if let Err(err) = run_example(Opt::from_args()).await { + if let Err(err) = run_example(Opt::parse()).await { eprintln!("Error: {}", DisplayErrorContext(err)); process::exit(1); } diff --git a/rust_dev_preview/sitewise/src/bin/list-asset-models.rs b/rust_dev_preview/sitewise/src/bin/list-asset-models.rs index 98dee0ee99a..bae5a04f2d4 100644 --- a/rust_dev_preview/sitewise/src/bin/list-asset-models.rs +++ b/rust_dev_preview/sitewise/src/bin/list-asset-models.rs @@ -9,11 +9,11 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_iotsitewise::error::DisplayErrorContext; use aws_sdk_iotsitewise::{config::Region, meta::PKG_VERSION, Client}; use aws_smithy_types_convert::date_time::DateTimeExt; +use clap::Parser; use sitewise_code_examples::Error; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -74,7 +74,7 @@ async fn list_asset_models(client: &Client) -> Result<(), Error> { async fn main() { tracing_subscriber::fmt::init(); - if let Err(err) = run_example(Opt::from_args()).await { + if let Err(err) = run_example(Opt::parse()).await { eprintln!("Error: {}", DisplayErrorContext(err)); process::exit(1); } diff --git a/rust_dev_preview/sitewise/src/bin/list-assets.rs b/rust_dev_preview/sitewise/src/bin/list-assets.rs index ba1c0966fbe..8793d882845 100644 --- a/rust_dev_preview/sitewise/src/bin/list-assets.rs +++ b/rust_dev_preview/sitewise/src/bin/list-assets.rs @@ -9,11 +9,11 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_iotsitewise::error::DisplayErrorContext; use aws_sdk_iotsitewise::{config::Region, meta::PKG_VERSION, types::ListAssetsFilter, Client}; use aws_smithy_types_convert::date_time::DateTimeExt; +use clap::Parser; use sitewise_code_examples::Error; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -111,7 +111,7 @@ async fn list_assets( async fn main() { tracing_subscriber::fmt::init(); - if let Err(err) = run_example(Opt::from_args()).await { + if let Err(err) = run_example(Opt::parse()).await { eprintln!("Error: {}", DisplayErrorContext(err)); process::exit(1); } diff --git a/rust_dev_preview/sitewise/src/bin/list-portals.rs b/rust_dev_preview/sitewise/src/bin/list-portals.rs index ca163b4a069..ba07a307187 100644 --- a/rust_dev_preview/sitewise/src/bin/list-portals.rs +++ b/rust_dev_preview/sitewise/src/bin/list-portals.rs @@ -9,11 +9,11 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_iotsitewise::error::DisplayErrorContext; use aws_sdk_iotsitewise::{config::Region, meta::PKG_VERSION, Client}; use aws_smithy_types_convert::date_time::DateTimeExt; +use clap::Parser; use sitewise_code_examples::Error; use std::process; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -76,7 +76,7 @@ async fn list_portals(client: &Client) -> Result<(), Error> { async fn main() { tracing_subscriber::fmt::init(); - if let Err(err) = run_example(Opt::from_args()).await { + if let Err(err) = run_example(Opt::parse()).await { eprintln!("Error: {}", DisplayErrorContext(err)); process::exit(1); } diff --git a/rust_dev_preview/snowball/Cargo.toml b/rust_dev_preview/snowball/Cargo.toml index 1cc534d2334..187dd6d9614 100644 --- a/rust_dev_preview/snowball/Cargo.toml +++ b/rust_dev_preview/snowball/Cargo.toml @@ -7,8 +7,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-snowball = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-snowball = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/snowball/src/bin/create-address.rs b/rust_dev_preview/snowball/src/bin/create-address.rs index be0701fc915..60291d183cc 100644 --- a/rust_dev_preview/snowball/src/bin/create-address.rs +++ b/rust_dev_preview/snowball/src/bin/create-address.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_snowball::types::Address; use aws_sdk_snowball::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -108,7 +108,7 @@ async fn main() -> Result<(), Error> { street2, street3, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/snowball/src/bin/describe-addresses.rs b/rust_dev_preview/snowball/src/bin/describe-addresses.rs index d1259c6bcb0..83558ab3598 100644 --- a/rust_dev_preview/snowball/src/bin/describe-addresses.rs +++ b/rust_dev_preview/snowball/src/bin/describe-addresses.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_snowball::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -43,7 +43,7 @@ async fn show_addresses(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/snowball/src/bin/list-jobs.rs b/rust_dev_preview/snowball/src/bin/list-jobs.rs index fd042e5f81d..077e3b73285 100644 --- a/rust_dev_preview/snowball/src/bin/list-jobs.rs +++ b/rust_dev_preview/snowball/src/bin/list-jobs.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_snowball::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -43,7 +43,7 @@ async fn show_jobs(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/sns/Cargo.toml b/rust_dev_preview/sns/Cargo.toml index b6919c3da59..53bb3d79c32 100644 --- a/rust_dev_preview/sns/Cargo.toml +++ b/rust_dev_preview/sns/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-sns = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-sns = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/sns/src/bin/create-topic.rs b/rust_dev_preview/sns/src/bin/create-topic.rs index c131233dfd3..cc51abcbae8 100644 --- a/rust_dev_preview/sns/src/bin/create-topic.rs +++ b/rust_dev_preview/sns/src/bin/create-topic.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sns::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -54,7 +54,7 @@ async fn main() -> Result<(), Error> { region, topic, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/sns/src/bin/list-topics.rs b/rust_dev_preview/sns/src/bin/list-topics.rs index b4c813d0a90..975f223a408 100644 --- a/rust_dev_preview/sns/src/bin/list-topics.rs +++ b/rust_dev_preview/sns/src/bin/list-topics.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sns::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -46,7 +46,7 @@ async fn show_topics(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/sns/src/bin/sns-hello-world.rs b/rust_dev_preview/sns/src/bin/sns-hello-world.rs index 2eb3c74615e..ce8f96f2352 100644 --- a/rust_dev_preview/sns/src/bin/sns-hello-world.rs +++ b/rust_dev_preview/sns/src/bin/sns-hello-world.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sns::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -80,7 +80,7 @@ async fn main() -> Result<(), Error> { email_address, topic_arn, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/sqs/Cargo.toml b/rust_dev_preview/sqs/Cargo.toml index be980f85050..fa8dda7d119 100644 --- a/rust_dev_preview/sqs/Cargo.toml +++ b/rust_dev_preview/sqs/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-sqs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-sqs = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/sqs/src/bin/sqs-hello-world.rs b/rust_dev_preview/sqs/src/bin/sqs-hello-world.rs index f0e7a251441..280abae35d3 100644 --- a/rust_dev_preview/sqs/src/bin/sqs-hello-world.rs +++ b/rust_dev_preview/sqs/src/bin/sqs-hello-world.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sqs::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -92,7 +92,7 @@ async fn main() -> Result<(), Error> { region, queue, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ssm/Cargo.toml b/rust_dev_preview/ssm/Cargo.toml index 9028e7e7427..36f0b5294e4 100644 --- a/rust_dev_preview/ssm/Cargo.toml +++ b/rust_dev_preview/ssm/Cargo.toml @@ -10,8 +10,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-ssm = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-ssm = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/ssm/src/bin/create-parameter.rs b/rust_dev_preview/ssm/src/bin/create-parameter.rs index 411f7b9ec79..db83ef6cfce 100644 --- a/rust_dev_preview/ssm/src/bin/create-parameter.rs +++ b/rust_dev_preview/ssm/src/bin/create-parameter.rs @@ -8,9 +8,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ssm::types::ParameterType; use aws_sdk_ssm::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -76,7 +76,7 @@ async fn main() -> Result<(), Error> { title, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/ssm/src/bin/describe-parameters.rs b/rust_dev_preview/ssm/src/bin/describe-parameters.rs index 35115504d45..343129d16f3 100644 --- a/rust_dev_preview/ssm/src/bin/describe-parameters.rs +++ b/rust_dev_preview/ssm/src/bin/describe-parameters.rs @@ -7,9 +7,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_ssm::{config::Region, meta::PKG_VERSION, Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -44,7 +44,7 @@ async fn show_parameters(client: &Client) -> Result<(), Error> { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/stepfunction/Cargo.toml b/rust_dev_preview/stepfunction/Cargo.toml index ad863b6fcbf..bae0d35f886 100644 --- a/rust_dev_preview/stepfunction/Cargo.toml +++ b/rust_dev_preview/stepfunction/Cargo.toml @@ -5,8 +5,8 @@ authors = ["Daniele Frasca "] edition = "2021" [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-sfn = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-sfn = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/stepfunction/src/bin/start-execution.rs b/rust_dev_preview/stepfunction/src/bin/start-execution.rs index 93db7b22542..b95340a791c 100644 --- a/rust_dev_preview/stepfunction/src/bin/start-execution.rs +++ b/rust_dev_preview/stepfunction/src/bin/start-execution.rs @@ -6,9 +6,9 @@ #![allow(clippy::result_large_err)] use aws_sdk_sfn::{Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The Amazon Resource Name (ARN) of the state machine to execute. #[structopt(short, long)] @@ -32,7 +32,7 @@ async fn main() -> Result<(), Error> { arn, input, verbose, - } = Opt::from_args(); + } = Opt::parse(); let shared_config = aws_config::load_from_env().await; let client = Client::new(&shared_config); diff --git a/rust_dev_preview/stepfunction/src/bin/stop-execution.rs b/rust_dev_preview/stepfunction/src/bin/stop-execution.rs index 6e973899979..baa5234db93 100644 --- a/rust_dev_preview/stepfunction/src/bin/stop-execution.rs +++ b/rust_dev_preview/stepfunction/src/bin/stop-execution.rs @@ -6,9 +6,9 @@ #![allow(clippy::result_large_err)] use aws_sdk_sfn::{Client, Error}; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The Amazon Resource Name (ARN) of the state machine to execute. #[structopt(short, long)] @@ -24,7 +24,7 @@ struct Opt { async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { arn, verbose } = Opt::from_args(); + let Opt { arn, verbose } = Opt::parse(); let shared_config = aws_config::load_from_env().await; let client = Client::new(&shared_config); diff --git a/rust_dev_preview/sts/Cargo.toml b/rust_dev_preview/sts/Cargo.toml index ef1f779d377..f477cc0cdea 100644 --- a/rust_dev_preview/sts/Cargo.toml +++ b/rust_dev_preview/sts/Cargo.toml @@ -9,10 +9,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-sts = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = {git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-sts = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = {git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } tokio = { version = "1.20.1", features = ["full"] } -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/sts/src/bin/assume-role.rs b/rust_dev_preview/sts/src/bin/assume-role.rs index ff60c8b6c6c..c94e9ecb55d 100644 --- a/rust_dev_preview/sts/src/bin/assume-role.rs +++ b/rust_dev_preview/sts/src/bin/assume-role.rs @@ -9,9 +9,9 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sts::{meta::PKG_VERSION, Client, Error}; use aws_types::region::Region; use aws_types::sdk_config::SdkConfig; -use structopt::StructOpt; +use clap::Parser; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(long)] @@ -86,7 +86,7 @@ async fn main() -> Result<(), Error> { verbose, role_arn, role_session_name, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/sts/src/bin/get-caller-identity.rs b/rust_dev_preview/sts/src/bin/get-caller-identity.rs index f04b4c09b23..c7042b533b8 100644 --- a/rust_dev_preview/sts/src/bin/get-caller-identity.rs +++ b/rust_dev_preview/sts/src/bin/get-caller-identity.rs @@ -7,10 +7,10 @@ use aws_config::meta::region::RegionProviderChain; use aws_sdk_sts::{config::Region, meta::PKG_VERSION, Client, Error}; +use clap::Parser; use std::fmt::Debug; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(long)] @@ -54,7 +54,7 @@ async fn get_caller_identity(client: &Client) -> Result<(), Error> { #[tokio::main] async fn main() -> Result<(), Error> { tracing_subscriber::fmt::init(); - let Opt { region, verbose } = Opt::from_args(); + let Opt { region, verbose } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/test-utils/Cargo.toml b/rust_dev_preview/test-utils/Cargo.toml index 31888d7d87e..4311bbc453a 100644 --- a/rust_dev_preview/test-utils/Cargo.toml +++ b/rust_dev_preview/test-utils/Cargo.toml @@ -7,12 +7,12 @@ authors = [ edition = "2021" [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "test-util", ] } -aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next"} +aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main"} http = "0.2" [lib] diff --git a/rust_dev_preview/testing/Cargo.toml b/rust_dev_preview/testing/Cargo.toml index 148311e7581..44b9f1df164 100644 --- a/rust_dev_preview/testing/Cargo.toml +++ b/rust_dev_preview/testing/Cargo.toml @@ -11,19 +11,19 @@ edition = "2021" [dependencies] async-trait = "0.1.51" # snippet-end:[testing.rust.Cargo.toml] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-s3 = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "test-util", ] } -aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-credential-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = [ +aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-credential-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = [ "hardcoded-credentials", ] } tokio = { version = "1.20.1", features = ["full"] } serde_json = "1" -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } [[bin]] diff --git a/rust_dev_preview/testing/src/intro.rs b/rust_dev_preview/testing/src/intro.rs index 5324932ce05..71cd8d59546 100644 --- a/rust_dev_preview/testing/src/intro.rs +++ b/rust_dev_preview/testing/src/intro.rs @@ -8,10 +8,10 @@ use aws_config::meta::region::RegionProviderChain; // So we can refer to the S3 package as s3 for the rest of the example. use aws_sdk_s3 as s3; // snippet-end:[testing.rust.intro-import] +use clap::Parser; use std::error::Error; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -78,7 +78,7 @@ async fn main() -> Result<(), Box> { prefix, region, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(s3::config::Region::new)) .or_default_provider() diff --git a/rust_dev_preview/tls/Cargo.toml b/rust_dev_preview/tls/Cargo.toml index 1600814f87c..4e310fbc883 100644 --- a/rust_dev_preview/tls/Cargo.toml +++ b/rust_dev_preview/tls/Cargo.toml @@ -12,9 +12,9 @@ name = "tls" path = "src/lib.rs" [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-kms = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-kms = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", default-features = false } webpki-roots = "0.22.4" tokio = { version = "1.20.1", features = ["full"] } rustls = "0.20.6" diff --git a/rust_dev_preview/transcribestreaming/Cargo.toml b/rust_dev_preview/transcribestreaming/Cargo.toml index 20ba9ace728..133e0e85abb 100644 --- a/rust_dev_preview/transcribestreaming/Cargo.toml +++ b/rust_dev_preview/transcribestreaming/Cargo.toml @@ -10,11 +10,11 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-sdk-transcribestreaming = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-sdk-transcribestreaming = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } async-stream = "0.3" bytes = "1" hound = "3.4" -structopt = { version = "0.3", default-features = false } +clap = { version = "4.2.1", features = ["derive"] } tokio = { version = "1.20.1", features = ["full"] } tracing-subscriber = { version = "0.3.15", features = ["env-filter"] } diff --git a/rust_dev_preview/transcribestreaming/src/main.rs b/rust_dev_preview/transcribestreaming/src/main.rs index e6331352aaf..de172bf95f6 100644 --- a/rust_dev_preview/transcribestreaming/src/main.rs +++ b/rust_dev_preview/transcribestreaming/src/main.rs @@ -13,10 +13,10 @@ use aws_sdk_transcribestreaming::types::{ }; use aws_sdk_transcribestreaming::{config::Region, meta::PKG_VERSION, Client, Error}; use bytes::BufMut; +use clap::Parser; use std::time::Duration; -use structopt::StructOpt; -#[derive(Debug, StructOpt)] +#[derive(Debug, Parser)] struct Opt { /// The AWS Region. #[structopt(short, long)] @@ -51,7 +51,7 @@ async fn main() -> Result<(), Error> { region, audio_file, verbose, - } = Opt::from_args(); + } = Opt::parse(); let region_provider = RegionProviderChain::first_try(region.map(Region::new)) .or_default_provider() diff --git a/rust_dev_preview/webassembly/Cargo.toml b/rust_dev_preview/webassembly/Cargo.toml index 7970ab0687b..6b1b6018c76 100644 --- a/rust_dev_preview/webassembly/Cargo.toml +++ b/rust_dev_preview/webassembly/Cargo.toml @@ -10,13 +10,13 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false } -aws-credential-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["hardcoded-credentials"] } -aws-sdk-lambda = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false } -aws-smithy-async = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } -aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", default-features = false } -aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next", features = ["event-stream"] } -aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "next" } +aws-config = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", default-features = false } +aws-credential-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = ["hardcoded-credentials"] } +aws-sdk-lambda = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", default-features = false } +aws-smithy-async = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } +aws-smithy-client = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", default-features = false } +aws-smithy-http = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main", features = ["event-stream"] } +aws-smithy-types = { git = "https://github.com/awslabs/aws-sdk-rust", branch = "main" } async-trait = "0.1.63" console_error_panic_hook = "0.1.7" http = "0.2.8" From 1e84253f12318ddef6b0ceec401f49e3206de839 Mon Sep 17 00:00:00 2001 From: David Souther Date: Sun, 19 Mar 2023 16:09:44 -0700 Subject: [PATCH 9/9] Add weathertop instructions. Closes #4160, #4170, #4179 --- rust_dev_preview/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rust_dev_preview/README.md b/rust_dev_preview/README.md index 2de84e64c9e..595ded233df 100644 --- a/rust_dev_preview/README.md +++ b/rust_dev_preview/README.md @@ -54,8 +54,15 @@ The following environment variables are specific to the AWS SDK for Rust. You must have an AWS account, and have configured your default credentials and AWS Region as described in [Getting started with the AWS SDK for Rust](https://docs.aws.amazon.com/sdk-for-rust/latest/dg/getting-started.html). +You must have the [Cargo](https://doc.rust-lang.org/cargo/) build tool, which is typically installed via [rustup](https://rustup.rs/). + +Each example has one or more examples that can be executed with `cargo run --bin [program name]`. See the individual readme files in each service directory for information about specific code examples for that service. +Unit tests for each example can be run with `cargo test`, and these will not cause any changes or charges to your AWS account. +Integration tests may cause changes or charges to your AWS account, and are described individually for each example. +However, they can be run with `cargo test -- --ignored`. + ## Resources - [AWS SDK for Rust repo](https://github.com/awslabs/aws-sdk-rust) @@ -63,6 +70,7 @@ See the individual readme files in each service directory for information about - [AWS SDK for Rust Developer Guide](https://docs.aws.amazon.com/sdk-for-rust/latest/dg) ## Docker image (Beta) + This example code will soon be available in a container image hosted on [Amazon Elastic Container Registry (ECR)](https://docs.aws.amazon.com/AmazonECR/latest/userguide/what-is-ecr.html). This image will be pre-loaded with all Rust examples with dependencies pre-resolved, allowing you to explore