Fix set -u empty array expansion in 9 scripts#80
Merged
Conversation
set -u fix: ${ARRAY[@]} on empty array triggers 'unbound variable'.
Use ${ARRAY[@]+"${ARRAY[@]}"} which expands to nothing when empty.
Scripts: 001, 015, 046, 049, 055, 062, 070, 077, 079.
015-vpc-peering: Replace broken VPC reuse logic with:
- Check VPC quota upfront, fail fast if insufficient
- Use prereq stack VPC if available (saves 1 VPC slot)
- Create fresh VPCs with non-overlapping CIDRs otherwise
- Use .100.0/24 subnets to avoid prereq subnet overlap
Tested both scenarios locally.
47959a2 to
7388f94
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Under
set -u,${ARRAY[@]}on an empty array triggersunbound variableand exits the script. This causes spurious failures in cleanup functions when no resources were tracked.Fix:
${ARRAY[@]+"${ARRAY[@]}"}— expands to nothing when the array is empty.Scripts fixed: 001, 015, 046, 049, 055, 062, 070, 077, 079
Tested locally: 070-dynamodb, 062-support, 077-account-management, 079-iot-device-defender — all pass clean.
Also adds
.gitignorefor test artifacts (log files, temp keys, JSON outputs).