Skip to content

Commit

Permalink
fix: check arg count
Browse files Browse the repository at this point in the history
  • Loading branch information
pgollucci committed Nov 21, 2024
1 parent b0f9300 commit 2d30205
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions bin/p6lzctl
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ p6_lz_cmd_stacks() {
p6_msg
done

local management_account_id=$(p6_aws_svc_organization_management_account_id_get)
local account_name=$(p6_aws_svc_organizations_account_name_from_account_id $management_account_id)
local management_account_name=$(p6_aws_svc_organization_management_account_name_get)
p6_h3 "$account_name"
p6_lz_util_stacks_list

Expand Down Expand Up @@ -572,7 +571,7 @@ p6_lz_run_phase_3_logarchive_account() {
p6_lz_util_cdk_execute $action p6-lz-logarchive-1

p6_h3 "Phase 3: Logarchive Add Logarchive Bucket Name to Context"
p6_aws_svc_organizations_sts_run_as p6m7g8-logarchive p6_lz_util_cdk_context_add_logarchive_bucket
p6_aws_svc_organizations_sts_run_as p6m7g8-logarchive p6_lz_util_cdk_context_add_logarchive_bucket "$action"

p6_lz_util_cdk_execute $action p6-lz-logarchive-2

Expand Down Expand Up @@ -780,12 +779,14 @@ p6_lz_run_phase_4_prod_account() {
#>
######################################################################
p6_lz_util_cdk_context_add_logarchive_bucket() {
local action="$1"

local logarchive_bucket_name=$(p6_aws_svc_s3_bucket_find_prefix "p6-lz-logarchive-1-p6lzsracentralbucket")
jq --arg k "logarchive-bucket-name" --arg v "$logarchive_bucket_name" '. + {($k): $v}' cdk.context.json >temp.json
p6_file_move temp.json cdk.context.json
p6_file_rmf temp.json

if ! p6_string_eq "$action" "destroy"; then
local logarchive_bucket_name=$(p6_aws_svc_s3_bucket_find_prefix "p6-lz-logarchive-1-p6lzsracentralbucket")
jq --arg k "logarchive-bucket-name" --arg v "$logarchive_bucket_name" '. + {($k): $v}' cdk.context.json >temp.json
p6_file_move temp.json cdk.context.json
p6_file_rmf temp.json
fi
p6_return_void
}

Expand Down Expand Up @@ -904,7 +905,11 @@ p6_lz_util_cdk_execute() {
local stack="$2"
local account_id="$3"
local region="$4"
shift 4
if [ $# -gt 3 ]; then
shift 4
else
shift 2
fi

local args="--require-approval never --no-rollback"
if ! p6_string_blank "$stack"; then
Expand Down

0 comments on commit 2d30205

Please sign in to comment.