blob: 8f1ae88ee4bc919ac24c50cf5186373de3145d6c (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
use aws_config::{BehaviorVersion, SdkConfig};
use aws_sdk_autoscaling as asg;
use aws_sdk_ec2 as ec2;
use aws_sdk_route53 as route53;
use crate::autoscaling::AutoScaling;
use crate::ec2::Ec2;
use crate::route53::Route53;
pub struct AwsContext {
asg: asg::Client,
ec2: ec2::Client,
route53: route53::Client,
}
impl AwsContext {
pub async fn from_env() -> Self {
let config = aws_config::defaults(BehaviorVersion::v2024_03_28())
.load()
.await;
Self::new(&config)
}
fn new(config: &SdkConfig) -> Self {
Self {
asg: asg::Client::new(config),
ec2: ec2::Client::new(config),
route53: route53::Client::new(config),
}
}
}
impl AutoScaling for AwsContext {
fn autoscaling(&self) -> &asg::Client {
&self.asg
}
}
impl Ec2 for AwsContext {
fn ec2(&self) -> &ec2::Client {
&self.ec2
}
}
impl Route53 for AwsContext {
fn route53(&self) -> &route53::Client {
&self.route53
}
}
|