diff --git a/.doc_gen/metadata/auto-scaling_metadata.yaml b/.doc_gen/metadata/auto-scaling_metadata.yaml index dc253f068e0..4836972a29f 100644 --- a/.doc_gen/metadata/auto-scaling_metadata.yaml +++ b/.doc_gen/metadata/auto-scaling_metadata.yaml @@ -33,7 +33,7 @@ auto-scaling_Hello: Rust: versions: - sdk_version: 1 - github: rust_dev_preview/examples/autoscaling + github: rust_dev_preview/examples/auto-scaling excerpts: - description: snippet_tags: @@ -101,7 +101,7 @@ auto-scaling_CreateAutoScalingGroup: Rust: versions: - sdk_version: 1 - github: rust_dev_preview/examples/autoscaling + github: rust_dev_preview/examples/auto-scaling excerpts: - description: snippet_tags: @@ -171,7 +171,7 @@ auto-scaling_DeleteAutoScalingGroup: Rust: versions: - sdk_version: 1 - github: rust_dev_preview/examples/autoscaling + github: rust_dev_preview/examples/auto-scaling excerpts: - description: snippet_tags: @@ -238,7 +238,7 @@ auto-scaling_DescribeAutoScalingGroups: Rust: versions: - sdk_version: 1 - github: rust_dev_preview/examples/autoscaling + github: rust_dev_preview/examples/auto-scaling excerpts: - description: snippet_tags: @@ -305,7 +305,7 @@ auto-scaling_UpdateAutoScalingGroup: Rust: versions: - sdk_version: 1 - github: rust_dev_preview/examples/autoscaling + github: rust_dev_preview/examples/auto-scaling excerpts: - description: snippet_tags: @@ -386,12 +386,12 @@ auto-scaling_TerminateInstanceInAutoScalingGroup: Rust: versions: - sdk_version: 1 - github: rust_dev_preview/examples/autoscaling + github: rust_dev_preview/examples/auto-scaling excerpts: - description: snippet_tags: - - rust.autoscaling.scenario.terminate_some_instance - - rust.autoscaling.scenario.get_group + - rust.auto-scaling.scenario.terminate_some_instance + - rust.auto-scaling.scenario.get_group services: auto-scaling: {TerminateInstanceInAutoScalingGroup} auto-scaling_SetDesiredCapacity: @@ -457,11 +457,11 @@ auto-scaling_SetDesiredCapacity: Rust: versions: - sdk_version: 1 - github: rust_dev_preview/examples/autoscaling + github: rust_dev_preview/examples/auto-scaling excerpts: - description: snippet_tags: - - rust.autoscaling.scenario.scale_desired_capacity + - rust.auto-scaling.scenario.scale_desired_capacity services: auto-scaling: {SetDesiredCapacity} auto-scaling_DescribeAutoScalingInstances: @@ -527,11 +527,11 @@ auto-scaling_DescribeAutoScalingInstances: Rust: versions: - sdk_version: 1 - github: rust_dev_preview/examples/autoscaling + github: rust_dev_preview/examples/auto-scaling excerpts: - description: snippet_tags: - - rust.autoscaling.scenario.list_instances + - rust.auto-scaling.scenario.list_instances services: auto-scaling: {DescribeAutoScalingInstances} auto-scaling_DescribeScalingActivities: @@ -597,11 +597,11 @@ auto-scaling_DescribeScalingActivities: Rust: versions: - sdk_version: 1 - github: rust_dev_preview/examples/autoscaling + github: rust_dev_preview/examples/auto-scaling excerpts: - description: snippet_tags: - - rust.autoscaling.scenario.describe_scenario + - rust.auto-scaling.scenario.describe_scenario services: auto-scaling: {DescribeScalingActivities} auto-scaling_EnableMetricsCollection: @@ -667,11 +667,11 @@ auto-scaling_EnableMetricsCollection: Rust: versions: - sdk_version: 1 - github: rust_dev_preview/examples/autoscaling + github: rust_dev_preview/examples/auto-scaling excerpts: - description: snippet_tags: - - rust.autoscaling.scenario.enable_metrics_collection + - rust.auto-scaling.scenario.enable_metrics_collection services: auto-scaling: {EnableMetricsCollection} auto-scaling_DisableMetricsCollection: @@ -737,11 +737,11 @@ auto-scaling_DisableMetricsCollection: Rust: versions: - sdk_version: 1 - github: rust_dev_preview/examples/autoscaling + github: rust_dev_preview/examples/auto-scaling excerpts: - description: snippet_tags: - - rust.autoscaling.scenario.disable_metrics_collection + - rust.auto-scaling.scenario.disable_metrics_collection services: auto-scaling: {DisableMetricsCollection} auto-scaling_AttachLoadBalancerTargetGroups: @@ -845,7 +845,7 @@ auto-scaling_Scenario_GroupsAndInstances: Rust: versions: - sdk_version: 1 - github: rust_dev_preview/examples/autoscaling + github: rust_dev_preview/examples/auto-scaling excerpts: - description: snippet_files: diff --git a/rust_dev_preview/examples/auto-scaling/README.md b/rust_dev_preview/examples/auto-scaling/README.md index d9aaa92298e..62c2cecd015 100644 --- a/rust_dev_preview/examples/auto-scaling/README.md +++ b/rust_dev_preview/examples/auto-scaling/README.md @@ -1,4 +1,4 @@ - + # Auto Scaling code examples for the SDK for Rust ## Overview @@ -12,7 +12,7 @@ Shows how to use the AWS SDK for Rust to work with Amazon EC2 Auto Scaling. ## ⚠ Important -* Running this code might result in charges to your AWS account. +* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/?aws-products-pricing.sort-by=item.additionalFields.productNameLowercase&aws-products-pricing.sort-order=asc&awsf.Free%20Tier%20Type=*all&awsf.tech-category=*all) and [Free Tier](https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all). * 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). @@ -33,29 +33,29 @@ For prerequisites, see the [README](../../README.md#Prerequisites) in the `rust_ ### Get started -* [Hello Auto Scaling](None) (`DescribeAutoScalingGroups`) +* [Hello Auto Scaling](src/bin/list-autoscaling-groups.rs#L24) (`DescribeAutoScalingGroups`) ### Single actions Code excerpts that show you how to call individual service functions. -* [Create a group](None) (`CreateAutoScalingGroup`) -* [Delete a group](None) (`DeleteAutoScalingGroup`) -* [Disable metrics collection for a group](None) (`DisableMetricsCollection`) -* [Enable metrics collection for a group](None) (`EnableMetricsCollection`) -* [Get information about groups](None) (`DescribeAutoScalingGroups`) -* [Get information about instances](None) (`DescribeAutoScalingInstances`) -* [Get information about scaling activities](None) (`DescribeScalingActivities`) -* [Set the desired capacity of a group](None) (`SetDesiredCapacity`) -* [Terminate an instance in a group](None) (`TerminateInstanceInAutoScalingGroup`) -* [Update a group](None) (`UpdateAutoScalingGroup`) +* [Create a group](src/bin/create-autoscaling-group.rs#L32) (`CreateAutoScalingGroup`) +* [Delete a group](src/bin/delete-autoscaling-group.rs#L32) (`DeleteAutoScalingGroup`) +* [Disable metrics collection for a group](src/scenario.rs#L608) (`DisableMetricsCollection`) +* [Enable metrics collection for a group](src/scenario.rs#L288) (`EnableMetricsCollection`) +* [Get information about groups](src/bin/list-autoscaling-groups.rs#L24) (`DescribeAutoScalingGroups`) +* [Get information about instances](src/scenario.rs#L529) (`DescribeAutoScalingInstances`) +* [Get information about scaling activities](src/scenario.rs#L393) (`DescribeScalingActivities`) +* [Set the desired capacity of a group](src/scenario.rs#L586) (`SetDesiredCapacity`) +* [Terminate an instance in a group](src/scenario.rs#L645) (`TerminateInstanceInAutoScalingGroup`) +* [Update a group](src/bin/update-autoscaling-group.rs#L32) (`UpdateAutoScalingGroup`) ### Scenarios Code examples that show you how to accomplish a specific task by calling multiple functions within the same service. -* [Manage groups and instances](rust_dev_preview/examples/auto-scaling/Cargo.toml) +* [Manage groups and instances](README.md) ## Run the examples diff --git a/rust_dev_preview/examples/auto-scaling/src/scenario.rs b/rust_dev_preview/examples/auto-scaling/src/scenario.rs index 76d394595db..5146dd96365 100644 --- a/rust_dev_preview/examples/auto-scaling/src/scenario.rs +++ b/rust_dev_preview/examples/auto-scaling/src/scenario.rs @@ -285,7 +285,7 @@ impl AutoScalingScenario { launch_template_arn, }; - // snippet-start:[rust.autoscaling.scenario.enable_metrics_collection] + // snippet-start:[rust.auto-scaling.scenario.enable_metrics_collection] let enable_metrics_collection = autoscaling .enable_metrics_collection() .auto_scaling_group_name(auto_scaling_group_name.as_str()) @@ -299,7 +299,7 @@ impl AutoScalingScenario { ])) .send() .await; - // snippet-end:[rust.autoscaling.scenario.enable_metrics_collection] + // snippet-end:[rust.auto-scaling.scenario.enable_metrics_collection] match enable_metrics_collection { Ok(_) => Ok(scenario), @@ -390,7 +390,7 @@ impl AutoScalingScenario { } } - // snippet-start:[rust.autoscaling.scenario.describe_scenario] + // snippet-start:[rust.auto-scaling.scenario.describe_scenario] pub async fn describe_scenario(&self) -> AutoScalingScenarioDescription { let group = self .autoscaling @@ -446,9 +446,9 @@ impl AutoScalingScenario { activities, } } - // snippet-end:[rust.autoscaling.scenario.describe_scenario] + // snippet-end:[rust.auto-scaling.scenario.describe_scenario] - // snippet-start:[rust.autoscaling.scenario.get_group] + // snippet-start:[rust.auto-scaling.scenario.get_group] async fn get_group(&self) -> Result { let describe_auto_scaling_groups = self .autoscaling @@ -483,7 +483,7 @@ impl AutoScalingScenario { Ok(auto_scaling_group.unwrap().clone()) } - // snippet-end:[rust.autoscaling.scenario.get_group] + // snippet-end:[rust.auto-scaling.scenario.get_group] pub async fn wait_for_no_scaling(&self) -> Result<(), ScenarioError> { let waiter = Waiter::new(); @@ -526,7 +526,7 @@ impl AutoScalingScenario { Ok(()) } - // snippet-start:[rust.autoscaling.scenario.list_instances] + // snippet-start:[rust.auto-scaling.scenario.list_instances] pub async fn list_instances(&self) -> Result, ScenarioError> { // The direct way to list instances is by using DescribeAutoScalingGroup's instances property. However, this returns a Vec, as opposed to a Vec. // Ok(self.get_group().await?.instances.unwrap_or_default().map(|i| i.instance_id.clone().unwrap_or_default()).filter(|id| !id.is_empty()).collect()) @@ -546,7 +546,7 @@ impl AutoScalingScenario { .collect::>() .await) } - // snippet-end:[rust.autoscaling.scenario.list_instances] + // snippet-end:[rust.auto-scaling.scenario.list_instances] pub async fn scale_min_size(&self, size: i32) -> Result<(), ScenarioError> { let update_group = self @@ -583,7 +583,7 @@ impl AutoScalingScenario { Ok(()) } - // snippet-start:[rust.autoscaling.scenario.scale_desired_capacity] + // snippet-start:[rust.auto-scaling.scenario.scale_desired_capacity] pub async fn scale_desired_capacity(&self, capacity: i32) -> Result<(), ScenarioError> { // 7. SetDesiredCapacity: set desired capacity to 2. // Wait for a second instance to launch. @@ -602,10 +602,10 @@ impl AutoScalingScenario { } Ok(()) } - // snippet-end:[rust.autoscaling.scenario.scale_desired_capacity] + // snippet-end:[rust.auto-scaling.scenario.scale_desired_capacity] pub async fn scale_group_to_zero(&self) -> Result<(), ScenarioError> { - // snippet-start:[rust.autoscaling.scenario.disable_metrics_collection] + // snippet-start:[rust.auto-scaling.scenario.disable_metrics_collection] // If this fails it's fine, just means there are extra cloudwatch metrics events for the scale-down. let _ = self .autoscaling @@ -613,7 +613,7 @@ impl AutoScalingScenario { .auto_scaling_group_name(self.auto_scaling_group_name.clone()) .send() .await; - // snippet-end:[rust.autoscaling.scenario.disable_metrics_collection] + // snippet-end:[rust.auto-scaling.scenario.disable_metrics_collection] // 12. DeleteAutoScalingGroup (to delete the group you must stop all instances): // UpdateAutoScalingGroup with MinSize=0 @@ -642,7 +642,7 @@ impl AutoScalingScenario { Ok(()) } - // snippet-start:[rust.autoscaling.scenario.terminate_some_instance] + // snippet-start:[rust.auto-scaling.scenario.terminate_some_instance] pub async fn terminate_some_instance(&self) -> Result<(), ScenarioError> { // Retrieve a list of instances in the auto scaling group. let instances = self.get_group().await?.instances.unwrap_or_default(); @@ -667,7 +667,7 @@ impl AutoScalingScenario { Err(ScenarioError::with("There was no instance to terminate")) } } - // snippet-end:[rust.autoscaling.scenario.terminate_some_instance] + // snippet-end:[rust.auto-scaling.scenario.terminate_some_instance] } fn count_group_instances(group: &AutoScalingGroup) -> usize {