Skip to content

Commit a1e213e

Browse files
committed
0.8.3: tag with SSO signing email/user-id
Signed-off-by: Gyuho Lee <[email protected]>
1 parent 33c509d commit a1e213e

File tree

14 files changed

+96
-58
lines changed

14 files changed

+96
-58
lines changed

avalanche-kms/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "avalanche-kms"
3-
version = "0.8.2" # https://github.com/ava-labs/avalanche-ops/releases
3+
version = "0.8.3" # https://github.com/ava-labs/avalanche-ops/releases
44
edition = "2021"
55
rust-version = "1.69"
66

77
[dependencies]
88
avalanche-types = { version = "0.0.393", features = ["jsonrpc_client", "wallet", "wallet_evm", "kms_aws"] } # https://crates.io/crates/avalanche-types
9-
aws-manager = { version = "0.28.11", features = ["kms", "sts"] } # https://github.com/gyuho/aws-manager/tags
9+
aws-manager = { version = "0.28.13", features = ["kms", "sts"] } # https://github.com/gyuho/aws-manager/tags
1010
clap = { version = "4.3.0", features = ["cargo", "derive"] } # https://github.com/clap-rs/clap/releases
1111
crossterm = "0.26.1"
1212
dialoguer = "0.10.4"

avalanche-ops/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "avalanche-ops"
3-
version = "0.8.2" # https://crates.io/crates/avalanche-ops
3+
version = "0.8.3" # https://crates.io/crates/avalanche-ops
44
edition = "2021"
55
rust-version = "1.69"
66
publish = true
@@ -11,7 +11,7 @@ license = "Apache-2.0"
1111

1212
[dependencies]
1313
avalanche-types = { version = "0.0.393", features = ["avalanchego"] } # https://crates.io/crates/avalanche-types
14-
aws-manager = { version = "0.28.11", features = ["ec2", "sts"] } # https://github.com/gyuho/aws-manager/tags
14+
aws-manager = { version = "0.28.13", features = ["ec2", "sts"] } # https://github.com/gyuho/aws-manager/tags
1515
compress-manager = "0.0.10"
1616
dir-manager = "0.0.1"
1717
env_logger = "0.10.0"

avalanche-ops/src/aws/cfn-templates/asg_ubuntu.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Parameters:
1111
Type: String
1212
Description: Unique identifier, prefix for all resources created below.
1313

14+
UserId:
15+
Type: String
16+
Description: For tagging resources.
17+
1418
NetworkId:
1519
Type: Number
1620
Description: Avalanche network ID, used for resource tagging.
@@ -453,6 +457,7 @@ Resources:
453457
# load balancer name '...' cannot be longer than '32' characters
454458
Tags:
455459
- { Key: Name, Value: !Sub "${Id}-nlb" }
460+
- { Key: UserId, Value: !Sub "${UserId}" }
456461

457462
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticloadbalancingv2-targetgroup.html
458463
NLBTargetGroup:
@@ -549,6 +554,7 @@ Resources:
549554
- ResourceType: instance
550555
Tags:
551556
- { Key: Name, Value: !Sub "${Id}-${ArchType}" }
557+
- { Key: UserId, Value: !Sub "${UserId}" }
552558

553559
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-launchtemplatedata.html#cfn-ec2-launchtemplate-launchtemplatedata-userdata
554560
# https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/QuickStartEC2Instance.html
@@ -794,6 +800,9 @@ Resources:
794800
- Key: ID
795801
Value: !Ref Id
796802
PropagateAtLaunch: true
803+
- Key: USER_ID
804+
Value: !Ref UserId
805+
PropagateAtLaunch: true
797806
- Key: NETWORK_ID
798807
Value: !Ref NetworkId
799808
PropagateAtLaunch: true

avalanche-ops/src/aws/cfn-templates/vpc.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Parameters:
1010
Type: String
1111
Description: Unique identifier, prefix for all resources created below.
1212

13+
UserId:
14+
Type: String
15+
Description: For tagging resources.
16+
1317
VpcCidr:
1418
Type: String
1519
Default: 10.0.0.0/16
@@ -97,6 +101,8 @@ Resources:
97101
Tags:
98102
- Key: Name
99103
Value: !Join ["-", [!Ref Id, "igw"]]
104+
- Key: UserId
105+
Value: !Ref UserId
100106

101107
VPC:
102108
Type: AWS::EC2::VPC
@@ -107,6 +113,8 @@ Resources:
107113
Tags:
108114
- Key: Name
109115
Value: !Join ["-", [!Ref Id, "vpc"]]
116+
- Key: UserId
117+
Value: !Ref UserId
110118

111119
VPCGatewayAttachment:
112120
Type: AWS::EC2::VPCGatewayAttachment
@@ -137,6 +145,8 @@ Resources:
137145
Value: !Join ["-", [!Ref Id, "public-subnet-1"]]
138146
- Key: Network
139147
Value: Public
148+
- Key: UserId
149+
Value: !Ref UserId
140150

141151
PublicSubnet2:
142152
Type: AWS::EC2::Subnet
@@ -155,6 +165,8 @@ Resources:
155165
Value: !Join ["-", [!Ref Id, "public-subnet-2"]]
156166
- Key: Network
157167
Value: Public
168+
- Key: UserId
169+
Value: !Ref UserId
158170

159171
PublicSubnet3:
160172
Condition: HasMoreThan2Azs
@@ -174,6 +186,8 @@ Resources:
174186
Value: !Join ["-", [!Ref Id, "public-subnet-3"]]
175187
- Key: Network
176188
Value: Public
189+
- Key: UserId
190+
Value: !Ref UserId
177191

178192
PublicRouteTable:
179193
Type: AWS::EC2::RouteTable
@@ -186,6 +200,8 @@ Resources:
186200
Value: !Join ["-", [!Ref Id, "public-round-table"]]
187201
- Key: Network
188202
Value: Public
203+
- Key: UserId
204+
Value: !Ref UserId
189205

190206
PublicRoute:
191207
Type: AWS::EC2::Route

avalanche-ops/src/aws/spec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ pub struct KmsKey {
121121
pub struct Resource {
122122
/// AWS STS caller loaded from its local environment.
123123
/// READ ONLY.
124-
#[serde(skip_serializing_if = "Option::is_none")]
125-
pub identity: Option<sts::Identity>,
124+
#[serde(default)]
125+
pub identity: sts::Identity,
126126

127127
/// AWS region to create resources.
128128
/// MUST BE NON-EMPTY.
@@ -161,7 +161,7 @@ impl Default for Resource {
161161
impl Resource {
162162
pub fn default() -> Self {
163163
Self {
164-
identity: None,
164+
identity: sts::Identity::default(),
165165

166166
regions: vec![String::from("us-west-2")],
167167
s3_bucket: String::new(),

avalanched-aws/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "avalanched-aws"
3-
version = "0.8.2" # https://github.com/ava-labs/avalanche-ops/releases
3+
version = "0.8.3" # https://github.com/ava-labs/avalanche-ops/releases
44
edition = "2021"
55
rust-version = "1.69"
66

@@ -14,7 +14,7 @@ avalanche-ops = { path = "../avalanche-ops" }
1414
avalanche-telemetry-cloudwatch-installer = "0.0.107" # https://crates.io/crates/avalanche-telemetry-cloudwatch-installer
1515
avalanche-types = { version = "0.0.393", features = ["avalanchego", "jsonrpc_client", "subnet_evm"] } # https://crates.io/crates/avalanche-types
1616
aws-ip-provisioner-installer = "0.0.94" # https://crates.io/crates/aws-ip-provisioner-installer
17-
aws-manager = { version = "0.28.11", features = ["autoscaling", "cloudwatch", "ec2", "s3"] } # https://github.com/gyuho/aws-manager/tags
17+
aws-manager = { version = "0.28.13", features = ["autoscaling", "cloudwatch", "ec2", "s3"] } # https://github.com/gyuho/aws-manager/tags
1818
aws-sdk-cloudwatch = "0.28.0" # https://github.com/awslabs/aws-sdk-rust/releases
1919
aws-sdk-ec2 = "0.28.0" # https://github.com/awslabs/aws-sdk-rust/releases
2020
aws-sdk-s3 = "0.28.0" # https://github.com/awslabs/aws-sdk-rust/releases

avalancheup-aws/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "avalancheup-aws"
3-
version = "0.8.2" # https://github.com/ava-labs/avalanche-ops/releases
3+
version = "0.8.3" # https://github.com/ava-labs/avalanche-ops/releases
44
edition = "2021"
55
rust-version = "1.69"
66

@@ -11,8 +11,8 @@ path = "src/main.rs"
1111
[dependencies]
1212
avalanche-ops = { path = "../avalanche-ops" }
1313
avalanche-types = { version = "0.0.393", features = ["avalanchego", "jsonrpc_client", "wallet", "subnet", "subnet_evm", "kms_aws"] } # https://crates.io/crates/avalanche-types
14-
aws-dev-machine = "0.0.16"
15-
aws-manager = { version = "0.28.11", features = ["cloudformation", "cloudwatch", "ec2", "s3", "ssm", "sts"] } # https://github.com/gyuho/aws-manager/tags
14+
aws-dev-machine = "0.0.17"
15+
aws-manager = { version = "0.28.13", features = ["cloudformation", "cloudwatch", "ec2", "s3", "ssm", "sts"] } # https://github.com/gyuho/aws-manager/tags
1616
aws-sdk-cloudformation = "0.28.0" # https://github.com/awslabs/aws-sdk-rust/releases
1717
aws-sdk-ec2 = "0.28.0" # https://github.com/awslabs/aws-sdk-rust/releases
1818
aws-sdk-s3 = "0.28.0" # https://github.com/awslabs/aws-sdk-rust/releases

avalancheup-aws/src/apply/mod.rs

+40-26
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,17 @@ pub async fn execute(log_level: &str, spec_file_path: &str, skip_prompt: bool) -
8787
let current_identity = sts_manager.get_identity().await.unwrap();
8888

8989
// validate identity
90-
if let Some(identity) = &spec.resource.identity {
90+
if !spec.resource.identity.user_id.is_empty() {
9191
// AWS calls must be made from the same caller
92-
if !identity.eq(&current_identity) {
93-
return Err(Error::new(
94-
ErrorKind::Other,
95-
format!(
96-
"config identity {:?} != currently loaded identity {:?}",
97-
identity, current_identity
98-
),
99-
));
92+
if spec.resource.identity.user_id != current_identity.user_id {
93+
log::warn!(
94+
"config identity {:?} != currently loaded identity {:?}",
95+
spec.resource.identity,
96+
current_identity
97+
);
10098
}
10199
} else {
102-
spec.resource.identity = Some(current_identity);
100+
spec.resource.identity = current_identity;
103101
}
104102

105103
// set defaults based on ID
@@ -639,6 +637,7 @@ pub async fn execute(log_level: &str, spec_file_path: &str, skip_prompt: bool) -
639637
let vpc_stack_name = regional_resource.cloudformation_vpc.clone().unwrap();
640638
let vpc_params = Vec::from([
641639
build_param("Id", &spec.id),
640+
build_param("UserId", &spec.resource.identity.user_id),
642641
build_param("VpcCidr", "10.0.0.0/16"),
643642
build_param("PublicSubnetCidr1", "10.0.64.0/19"),
644643
build_param("PublicSubnetCidr2", "10.0.128.0/19"),
@@ -767,6 +766,7 @@ pub async fn execute(log_level: &str, spec_file_path: &str, skip_prompt: bool) -
767766

768767
let mut common_asg_params = vec![
769768
build_param("Id", &spec.id),
769+
build_param("UserId", &spec.resource.identity.user_id),
770770
build_param(
771771
"NetworkId",
772772
format!("{}", &spec.avalanchego_config.network_id).as_str(),
@@ -834,6 +834,8 @@ pub async fn execute(log_level: &str, spec_file_path: &str, skip_prompt: bool) -
834834
// just copy the regional machine params, and later overwrite if 'create-dev-machine' is true
835835
let mut common_dev_machine_params = BTreeMap::new();
836836
common_dev_machine_params.insert("Id".to_string(), format!("{}-dev-machine", spec.id));
837+
common_dev_machine_params
838+
.insert("UserId".to_string(), spec.resource.identity.user_id.clone());
837839
common_dev_machine_params.insert("AsgName".to_string(), format!("{}-dev-machine", spec.id));
838840
common_dev_machine_params.insert(
839841
"KmsKeyArn".to_string(),
@@ -1039,10 +1041,13 @@ pub async fn execute(log_level: &str, spec_file_path: &str, skip_prompt: bool) -
10391041
None,
10401042
OnFailure::Delete,
10411043
&cloudformation_asg_anchor_nodes_tmpl,
1042-
Some(Vec::from([Tag::builder()
1043-
.key("KIND")
1044-
.value("avalanche-ops")
1045-
.build()])),
1044+
Some(Vec::from([
1045+
Tag::builder().key("KIND").value("avalanche-ops").build(),
1046+
Tag::builder()
1047+
.key("UserId")
1048+
.value(spec.resource.identity.user_id.clone())
1049+
.build(),
1050+
])),
10461051
Some(anchor_asg_params),
10471052
)
10481053
.await
@@ -1515,10 +1520,13 @@ pub async fn execute(log_level: &str, spec_file_path: &str, skip_prompt: bool) -
15151520
None,
15161521
OnFailure::Delete,
15171522
&cloudformation_asg_non_anchor_nodes_tmpl,
1518-
Some(Vec::from([Tag::builder()
1519-
.key("KIND")
1520-
.value("avalanche-ops")
1521-
.build()])),
1523+
Some(Vec::from([
1524+
Tag::builder().key("KIND").value("avalanche-ops").build(),
1525+
Tag::builder()
1526+
.key("UserId")
1527+
.value(spec.resource.identity.user_id.clone())
1528+
.build(),
1529+
])),
15221530
Some(non_anchor_asg_params),
15231531
)
15241532
.await
@@ -2194,10 +2202,13 @@ cat /tmp/{node_id}.crt
21942202
Some(vec![Capability::CapabilityNamedIam]),
21952203
OnFailure::Delete,
21962204
&ssm_doc_tmpl,
2197-
Some(Vec::from([Tag::builder()
2198-
.key("KIND")
2199-
.value("avalanche-ops")
2200-
.build()])),
2205+
Some(Vec::from([
2206+
Tag::builder().key("KIND").value("avalanche-ops").build(),
2207+
Tag::builder()
2208+
.key("UserId")
2209+
.value(spec.resource.identity.user_id.clone())
2210+
.build(),
2211+
])),
22012212
Some(cfn_params),
22022213
)
22032214
.await
@@ -2665,10 +2676,13 @@ default-spec --log-level=info --funded-keys={funded_keys} --region={region} --up
26652676
None,
26662677
OnFailure::Delete,
26672678
&asg_tmpl,
2668-
Some(Vec::from([Tag::builder()
2669-
.key("KIND")
2670-
.value("avalanche-ops")
2671-
.build()])),
2679+
Some(Vec::from([
2680+
Tag::builder().key("KIND").value("avalanche-ops").build(),
2681+
Tag::builder()
2682+
.key("UserId")
2683+
.value(spec.resource.identity.user_id.clone())
2684+
.build(),
2685+
])),
26722686
Some(cfn_params),
26732687
)
26742688
.await

avalancheup-aws/src/delete/mod.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{
22
collections::HashMap,
33
fs,
4-
io::{self, stdout, Error, ErrorKind},
4+
io::{self, stdout},
55
path::Path,
66
};
77

@@ -119,19 +119,18 @@ pub async fn execute(
119119
let sts_manager = sts::Manager::new(&shared_config);
120120
let current_identity = sts_manager.get_identity().await.unwrap();
121121

122-
if let Some(identity) = &spec.resource.identity {
122+
// validate identity
123+
if !spec.resource.identity.user_id.is_empty() {
123124
// AWS calls must be made from the same caller
124-
if !identity.eq(&current_identity) {
125-
return Err(Error::new(
126-
ErrorKind::Other,
127-
format!(
128-
"config identity {:?} != currently loaded identity {:?}",
129-
identity, current_identity
130-
),
131-
));
125+
if spec.resource.identity.user_id != current_identity.user_id {
126+
log::warn!(
127+
"config identity {:?} != currently loaded identity {:?}",
128+
spec.resource.identity,
129+
current_identity
130+
);
132131
}
133132
} else {
134-
return Err(Error::new(ErrorKind::Other, "unknown identity"));
133+
spec.resource.identity = current_identity;
135134
}
136135

137136
execute!(

blizzard-aws/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "blizzard-aws"
3-
version = "0.8.2" # https://github.com/ava-labs/avalanche-ops/releases
3+
version = "0.8.3" # https://github.com/ava-labs/avalanche-ops/releases
44
edition = "2021"
55
rust-version = "1.69"
66

@@ -10,7 +10,7 @@ path = "src/main.rs"
1010

1111
[dependencies]
1212
avalanche-types = { version = "0.0.393", features = ["jsonrpc_client", "wallet", "wallet_evm"] } # https://crates.io/crates/avalanche-types
13-
aws-manager = { version = "0.28.11", features = ["cloudwatch", "ec2", "s3"] } # https://github.com/gyuho/aws-manager/tags
13+
aws-manager = { version = "0.28.13", features = ["cloudwatch", "ec2", "s3"] } # https://github.com/gyuho/aws-manager/tags
1414
aws-sdk-cloudwatch = "0.28.0" # https://github.com/awslabs/aws-sdk-rust/releases
1515
aws-sdk-ec2 = "0.28.0" # https://github.com/awslabs/aws-sdk-rust/releases
1616
aws-sdk-s3 = "0.28.0" # https://github.com/awslabs/aws-sdk-rust/releases

blizzardup-aws/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "blizzardup-aws"
3-
version = "0.8.2" # https://github.com/ava-labs/avalanche-ops/releases
3+
version = "0.8.3" # https://github.com/ava-labs/avalanche-ops/releases
44
edition = "2021"
55
rust-version = "1.69"
66

@@ -10,7 +10,7 @@ path = "src/main.rs"
1010

1111
[dependencies]
1212
avalanche-types = { version = "0.0.393", features = ["avalanchego", "jsonrpc_client", "subnet_evm"] } # https://crates.io/crates/avalanche-types
13-
aws-manager = { version = "0.28.11", features = ["cloudformation", "cloudwatch", "ec2", "s3", "sts"] } # https://github.com/gyuho/aws-manager/tags
13+
aws-manager = { version = "0.28.13", features = ["cloudformation", "cloudwatch", "ec2", "s3", "sts"] } # https://github.com/gyuho/aws-manager/tags
1414
aws-sdk-cloudformation = "0.28.0" # https://github.com/awslabs/aws-sdk-rust/releases
1515
aws-sdk-ec2 = "0.28.0" # https://github.com/awslabs/aws-sdk-rust/releases
1616
aws-sdk-s3 = "0.28.0" # https://github.com/awslabs/aws-sdk-rust/releases

devnet-faucet/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "devnet-faucet"
3-
version = "0.8.2" # https://github.com/ava-labs/avalanche-ops/releases
3+
version = "0.8.3" # https://github.com/ava-labs/avalanche-ops/releases
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66

0 commit comments

Comments
 (0)