@@ -15,7 +15,7 @@ use crate::Args;
1515use aws_config:: SdkConfig ;
1616use aws_sdk_ec2:: { types:: ArchitectureValues , Client as Ec2Client } ;
1717use aws_sdk_ssm:: { config:: Region , Client as SsmClient } ;
18- use clap:: Parser ;
18+ use clap:: { ArgGroup , Parser } ;
1919use futures:: stream:: { StreamExt , TryStreamExt } ;
2020use governor:: { prelude:: * , Quota , RateLimiter } ;
2121use log:: { error, info, trace} ;
@@ -32,6 +32,11 @@ use std::{
3232
3333/// Sets SSM parameters based on current build information
3434#[ derive( Debug , Parser ) ]
35+ #[ command( group(
36+ ArgGroup :: new( "dry_run_requirements" )
37+ . arg( "dry_run" )
38+ . requires( "ssm_parameter_output" )
39+ ) ) ]
3540pub ( crate ) struct SsmArgs {
3641 // This is JSON output from `pubsys ami` like `{"us-west-2": "ami-123"}`
3742 /// Path to the JSON file containing regional AMI IDs to modify
@@ -69,6 +74,10 @@ pub(crate) struct SsmArgs {
6974 /// If set, writes the generated SSM parameters to this path
7075 #[ arg( long) ]
7176 ssm_parameter_output : Option < PathBuf > ,
77+
78+ /// Enables dry-run mode (only generates parameter manifest, does not update SSM)
79+ #[ arg( long) ]
80+ dry_run : bool ,
7281}
7382
7483/// Wrapper struct over parameter update and AWS clients needed to execute on it.
@@ -143,6 +152,12 @@ pub(crate) async fn run(args: &Args, ssm_args: &SsmArgs) -> Result<()> {
143152 ) ?;
144153 }
145154
155+ // Exit early if `--dry-run` is enabled
156+ if ssm_args. dry_run {
157+ info ! ( "Dry-run mode enabled: Exiting after writing parameter manifest." ) ;
158+ return Ok ( ( ) ) ;
159+ }
160+
146161 // Generate AWS Clients to use for the updates.
147162 let mut param_update_ops: Vec < SsmParamUpdateOp > = Vec :: with_capacity ( new_parameters. len ( ) ) ;
148163 let mut aws_sdk_configs: HashMap < Region , SdkConfig > = HashMap :: with_capacity ( regions. len ( ) ) ;
0 commit comments