blob: 327a4f7d86b3f20baf99cc1a33158c084103fc9c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
use anyhow::{anyhow, Result};
use aws_sdk_autoscaling as autoscaling;
use aws_sdk_autoscaling::types::AutoScalingGroup;
use crate::single::Single;
pub trait AutoScaling {
fn autoscaling(&self) -> &autoscaling::Client;
}
pub async fn asg_by_name<C>(aws_context: &C, name: &str) -> Result<AutoScalingGroup>
where
C: AutoScaling,
{
let asg_resp = aws_context
.autoscaling()
.describe_auto_scaling_groups()
.auto_scaling_group_names(name)
.send()
.await?;
let auto_scaling_groups = asg_resp.auto_scaling_groups();
let auto_scaling_group = auto_scaling_groups
.iter()
.map(ToOwned::to_owned)
.single()
.ok_or(anyhow!(
"No unique autoscaling group found with name: {}",
name
))?;
Ok(auto_scaling_group)
}
|