-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): add new script to bump Lambda layer version (#6001)
* Adding new script to bump layer version * Adding new script to bump layer version * Making changes to work with GNU sed
- Loading branch information
1 parent
196529b
commit d355fde
Showing
3 changed files
with
62 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# This script is run during the publish_v3_layer.yml CI job, | ||
# and it is responsible for replacing the layer ARN in our documentation. | ||
# Our pipeline must generate the same layer number for all commercial regions + gov cloud | ||
# If this doesn't happens, we have an error and we must fix it in the deployment. | ||
# | ||
# see .github/workflows/reusable_deploy_v3_layer_stack.yml | ||
|
||
|
||
# Get the new version number from the first command-line argument | ||
new_version=$1 | ||
if [ -z "$new_version" ]; then | ||
echo "Usage: $0 <new_version>" | ||
exit 1 | ||
fi | ||
|
||
# Find all files with specified extensions in ./docs and ./examples directories | ||
# -type f: only find files (not directories) | ||
# \( ... \): group conditions | ||
# -o: logical OR | ||
# -print0: use null character as separator (handles filenames with spaces) | ||
find ./docs ./examples -type f \( -name "*.md" -o -name "*.py" -o -name "*.yaml" -o -name "*.txt" -o -name "*.tf" -o -name "*.yml" \) -print0 | while IFS= read -r -d '' file; do | ||
echo "Processing file: $file" | ||
|
||
# Use sed to replace the version number in the Lambda layer ARN | ||
# -i: edit files in-place without creating a backup | ||
# -E: use extended regular expressions | ||
# The regex matches the layer name and replaces only the version number at the end | ||
sed -i -E "s/(AWSLambdaPowertoolsPythonV3-python[0-9]+-((arm64)|(x86_64)):)[0-9]+/\1$new_version/g" "$file" | ||
if [ $? -eq 0 ]; then | ||
echo "Updated $file successfully" | ||
grep "arn:aws:lambda:" "$file" | ||
else | ||
echo "Error processing $file" | ||
fi | ||
done | ||
echo "Layer version update attempt completed." |