diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2023-10-17 21:17:55 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2023-10-17 22:32:21 -0400 |
| commit | 288205e302d9f6afa06b8602184e983d2080a5b6 (patch) | |
| tree | dfb307e8f3cb82d280e5a0392f11318194e09ef1 /src/aws_context.rs | |
CLI tool for updating Route53 DNS for an ASG.
Diffstat (limited to 'src/aws_context.rs')
| -rw-r--r-- | src/aws_context.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/aws_context.rs b/src/aws_context.rs new file mode 100644 index 0000000..2eff941 --- /dev/null +++ b/src/aws_context.rs @@ -0,0 +1,48 @@ +use aws_sdk_autoscaling as asg; +use aws_sdk_ec2 as ec2; +use aws_sdk_route53 as route53; +use aws_types::SdkConfig; + +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::from_env().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 + } +} |
