Skip to content

Commit 6ae8d81

Browse files
authored
Merge pull request #469 from qianxjcraig/qianxj-ssm-canary-fix
pubsys: add --dry-run mode
2 parents 2519e56 + 0e0b6b5 commit 6ae8d81

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
labels: bottlerocket_ubuntu-latest_16-core
1616
steps:
1717
- uses: actions/checkout@v3
18-
- run: cargo install cargo-deny --locked
18+
- run: cargo install cargo-deny@0.17.0 --locked
1919
- run: cargo install cargo-make --locked
2020
- uses: actions/setup-go@v5
2121
with:

tools/pubsys/src/aws/ssm/mod.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::Args;
1515
use aws_config::SdkConfig;
1616
use aws_sdk_ec2::{types::ArchitectureValues, Client as Ec2Client};
1717
use aws_sdk_ssm::{config::Region, Client as SsmClient};
18-
use clap::Parser;
18+
use clap::{ArgGroup, Parser};
1919
use futures::stream::{StreamExt, TryStreamExt};
2020
use governor::{prelude::*, Quota, RateLimiter};
2121
use 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+
))]
3540
pub(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());

twoliter/embedded/Makefile.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,8 @@ pubsys \
14731473
--ssm-parameter-output "${ssm_parameter_output}" \
14741474
\
14751475
${PUBLISH_REGIONS:+--regions "${PUBLISH_REGIONS}"} \
1476-
${ALLOW_CLOBBER:+--allow-clobber}
1476+
${ALLOW_CLOBBER:+--allow-clobber} \
1477+
${PUBLISH_SSM_DRY_RUN:+--dry-run}
14771478
'''
14781479
]
14791480

0 commit comments

Comments
 (0)