-
Notifications
You must be signed in to change notification settings - Fork 421
/
Copy pathupdate_layer_arn_v3.sh
executable file
·38 lines (33 loc) · 1.55 KB
/
update_layer_arn_v3.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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."