Unverified Commit d25be58a authored by John DiSanti's avatar John DiSanti Committed by GitHub
Browse files

Add Auto Scaling Plans and Application Auto Scaling to Tier-1 (#582)

* Add Auto Scaling Plans and Application Auto Scaling to Tier-1

* Apply suggestions from code review
parent ba7ec2b6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -50,7 +50,9 @@ dependencies {
// Tier 1 Services have examples and tests
val tier1Services = setOf(
    "apigateway",
    "applicationautoscaling",
    "autoscaling",
    "autoscalingplans",
    "batch",
    "cloudformation",
    "cloudwatch",
+14 −0
Original line number Diff line number Diff line
[package]
name = "applicationautoscaling"
version = "0.1.0"
authors = ["John DiSanti <jdisanti@amazon.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
applicationautoscaling = { package = "aws-sdk-applicationautoscaling", path = "../../build/aws-sdk/applicationautoscaling" }
aws-types = { path = "../../build/aws-sdk/aws-types" }
tokio = { version = "1", features = ["full"] }
structopt = { version = "0.3", default-features = false }
tracing-subscriber = { version = "0.2.16", features = ["fmt"] }
+68 −0
Original line number Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

use applicationautoscaling::model::ServiceNamespace;
use applicationautoscaling::{Client, Config, Error, Region};
use aws_types::region::{self, ProvideRegion};
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
struct Opt {
    /// The region
    #[structopt(short, long)]
    region: Option<String>,

    /// Whether to display additional information
    #[structopt(short, long)]
    verbose: bool,
}

/// Lists your Amazon Cognito identities
/// # Arguments
///
/// * `[-r REGION]` - The region containing the buckets.
///   If not supplied, uses the value of the **AWS_DEFAULT_REGION** environment variable.
///   If the environment variable is not set, defaults to **us-west-2**.
/// * `[-v]` - Whether to display additional information.
#[tokio::main]
async fn main() -> Result<(), Error> {
    tracing_subscriber::fmt::init();

    let Opt { region, verbose } = Opt::from_args();

    let region_provider = region::ChainProvider::first_try(region.map(Region::new))
        .or_default_provider()
        .or_else(Region::new("us-west-2"));

    if verbose {
        println!(
            "Application Auto Scaling client version: {}",
            applicationautoscaling::PKG_VERSION
        );
        println!(
            "Region:                                  {:?}",
            region_provider.region()
        );
        println!();
    }

    let config = Config::builder().region(region_provider).build();
    let client = Client::from_conf(config);

    let response = client
        .describe_scaling_policies()
        .service_namespace(ServiceNamespace::Ec2)
        .send()
        .await?;
    if let Some(policies) = response.scaling_policies {
        println!("Auto Scaling Policies:");
        for policy in policies {
            println!("{:?}\n", policy);
        }
    }
    println!("Next token: {:?}", response.next_token);

    Ok(())
}
+14 −0
Original line number Diff line number Diff line
[package]
name = "autoscalingplans"
version = "0.1.0"
authors = ["John DiSanti <jdisanti@amazon.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
autoscalingplans = { package = "aws-sdk-autoscalingplans", path = "../../build/aws-sdk/autoscalingplans" }
aws-types = { path = "../../build/aws-sdk/aws-types" }
tokio = { version = "1", features = ["full"] }
structopt = { version = "0.3", default-features = false }
tracing-subscriber = "0.2.18"
+63 −0
Original line number Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

use autoscalingplans::{Client, Config, Error, Region};
use aws_types::region::{self, ProvideRegion};
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
struct Opt {
    /// The region
    #[structopt(short, long)]
    region: Option<String>,

    /// Whether to display additional information
    #[structopt(short, long)]
    verbose: bool,
}

/// Lists your Amazon Cognito identities
/// # Arguments
///
/// * `[-r REGION]` - The region containing the buckets.
///   If not supplied, uses the value of the **AWS_DEFAULT_REGION** environment variable.
///   If the environment variable is not set, defaults to **us-west-2**.
/// * `[-v]` - Whether to display additional information.
#[tokio::main]
async fn main() -> Result<(), Error> {
    tracing_subscriber::fmt::init();

    let Opt { region, verbose } = Opt::from_args();

    let region_provider = region::ChainProvider::first_try(region.map(Region::new))
        .or_default_provider()
        .or_else(Region::new("us-west-2"));

    if verbose {
        println!(
            "Auto Scaling Plans client version: {}",
            autoscalingplans::PKG_VERSION
        );
        println!(
            "Region:                            {:?}",
            region_provider.region()
        );
        println!();
    }

    let config = Config::builder().region(region_provider).build();
    let client = Client::from_conf(config);

    let response = client.describe_scaling_plans().send().await?;
    if let Some(plans) = response.scaling_plans {
        println!("Auto Scaling Plans:");
        for plan in plans {
            println!("{:?}\n", plan);
        }
    }
    println!("Next token: {:?}", response.next_token);

    Ok(())
}