|
14 | 14 |
|
15 | 15 | echo "Creating an binary executable using the go build command for Linux Systems."
|
16 | 16 | binary_name="sumologic-extension"
|
17 |
| -extension_bin_dir="${TARGET_DIR}/extensions" |
18 |
| -extension_zip_dir="${TARGET_DIR}/zip" |
19 | 17 |
|
20 |
| -mkdir -p ${extension_bin_dir} |
21 |
| -mkdir -p ${extension_zip_dir} |
22 | 18 |
|
23 |
| -env GOOS=linux go build -o "${extension_bin_dir}/${binary_name}" "lambda-extensions/${binary_name}.go" |
| 19 | +ARCHITECTURES=( |
| 20 | + amd64 |
| 21 | + arm64 |
| 22 | +) |
24 | 23 |
|
25 |
| -status=$? |
26 |
| -if [ $status -ne 0 ]; then |
27 |
| - echo "Binary Generation Failed" |
28 |
| - exit 1 |
29 |
| -fi |
30 |
| -chmod +x "${extension_bin_dir}/${binary_name}" |
31 |
| - |
32 |
| -echo "Creating the Zip file binary in extension folder." |
33 |
| -cd ${TARGET_DIR} |
34 |
| -zip -r "zip/${binary_name}.zip" extensions/ |
35 |
| -status=$? |
36 |
| -if [ $status -ne 0 ]; then |
37 |
| - echo "Zip Generation Failed" |
38 |
| - exit 1 |
39 |
| -fi |
40 |
| -cd .. |
| 24 | +for arch in "${ARCHITECTURES[@]}"; do |
41 | 25 |
|
42 |
| -echo "Create lambda Layer from the new ZIP file in the provided AWS_PROFILE aws account." |
43 |
| -if [[ -z "${AWS_PROFILE}" ]]; then |
44 |
| - export AWS_PROFILE="personal" |
45 |
| -fi |
| 26 | + echo "Creating an binary executable for $arch" |
| 27 | + extension_bin_dir="${TARGET_DIR}/${arch}/extensions" |
| 28 | + extension_zip_dir="${TARGET_DIR}/${arch}/zip" |
| 29 | + mkdir -p "${extension_bin_dir}" |
| 30 | + mkdir -p "${extension_zip_dir}" |
46 | 31 |
|
47 |
| -AWS_REGIONS=( |
48 |
| - us-east-1 |
49 |
| - us-east-2 |
50 |
| - eu-north-1 |
51 |
| - ap-south-1 |
52 |
| - eu-west-3 |
53 |
| - eu-west-2 |
54 |
| - eu-south-1 |
55 |
| - eu-west-1 |
56 |
| - ap-northeast-2 |
57 |
| - me-south-1 |
58 |
| - ap-northeast-1 |
59 |
| - sa-east-1 |
60 |
| - ca-central-1 |
61 |
| - ap-east-1 |
62 |
| - ap-southeast-1 |
63 |
| - ap-southeast-2 |
64 |
| - eu-central-1 |
65 |
| - us-west-1 |
66 |
| - us-west-2 |
67 |
| -) |
| 32 | + env GOOS="linux" GOARCH="$arch" go build -o "${extension_bin_dir}/${binary_name}" "lambda-extensions/${binary_name}.go" |
| 33 | + |
| 34 | + status=$? |
| 35 | + if [ $status -ne 0 ]; then |
| 36 | + echo "Binary Generation Failed" |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | + chmod +x "${extension_bin_dir}/${binary_name}" |
| 40 | + |
| 41 | + echo "Creating the Zip file binary in extension folder." |
| 42 | + cd "${TARGET_DIR}/${arch}" |
| 43 | + zip -r "zip/${binary_name}.zip" extensions/ |
| 44 | + tar -czvf "zip/${binary_name}-${arch}.tar.gz" extensions/ |
| 45 | + status=$? |
| 46 | + if [ $status -ne 0 ]; then |
| 47 | + echo "Zip Generation Failed" |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | + cd - |
| 51 | + |
| 52 | + echo "Create lambda Layer from the new ZIP file in the provided AWS_PROFILE aws account." |
| 53 | + if [[ -z "${AWS_PROFILE}" ]]; then |
| 54 | + export AWS_PROFILE="personal" |
| 55 | + fi |
| 56 | + |
| 57 | + AWS_REGIONS=( |
| 58 | + us-east-1 |
| 59 | + us-east-2 |
| 60 | + eu-north-1 |
| 61 | + ap-south-1 |
| 62 | + eu-west-3 |
| 63 | + eu-west-2 |
| 64 | + eu-south-1 |
| 65 | + eu-west-1 |
| 66 | + ap-northeast-2 |
| 67 | + me-south-1 |
| 68 | + ap-northeast-1 |
| 69 | + sa-east-1 |
| 70 | + ca-central-1 |
| 71 | + ap-east-1 |
| 72 | + ap-southeast-1 |
| 73 | + ap-southeast-2 |
| 74 | + eu-central-1 |
| 75 | + us-west-1 |
| 76 | + us-west-2 |
| 77 | + ) |
| 78 | + |
| 79 | + echo "Using AWS_PROFILE: ${AWS_PROFILE}" |
68 | 80 |
|
69 |
| -echo "Using AWS_PROFILE: ${AWS_PROFILE}" |
| 81 | + # We have layer name as sumologic-extension. Please change name for local testing. |
| 82 | + layer_name="${binary_name}-${arch}" |
70 | 83 |
|
71 |
| -# We have layer name as sumologic-extension. Please change name for local testing. |
72 |
| -layer_name=${binary_name} |
| 84 | + for region in "${AWS_REGIONS[@]}"; do |
| 85 | + layer_version=$(aws lambda publish-layer-version --layer-name ${layer_name} \ |
| 86 | + --description "The SumoLogic Extension collects lambda logs and send it to Sumo Logic." \ |
| 87 | + --license-info "Apache-2.0" --zip-file fileb://$(pwd)/${extension_zip_dir}/${binary_name}.zip \ |
| 88 | + --profile ${AWS_PROFILE} --region ${region} --output text --query Version ) |
| 89 | + echo "Layer Arn: arn:aws:lambda:${region}:<accountId>:layer:${layer_name}:${layer_version} deployed to Region ${region}" |
73 | 90 |
|
74 |
| -for region in "${AWS_REGIONS[@]}"; do |
75 |
| - layer_version=$(aws lambda publish-layer-version --layer-name ${layer_name} \ |
76 |
| - --description "The SumoLogic Extension collects lambda logs and send it to Sumo Logic." \ |
77 |
| - --license-info "Apache-2.0" --zip-file fileb://$(pwd)/${TARGET_DIR}/zip/${layer_name}.zip \ |
78 |
| - --profile ${AWS_PROFILE} --region ${region} --output text --query Version ) |
79 |
| - echo "Layer Arn: arn:aws:lambda:${region}:<accountId>:layer:${layer_name}:${layer_version} deployed to Region ${region}" |
| 91 | + echo "Setting public permissions for layer version: ${layer_version}" |
| 92 | + aws lambda add-layer-version-permission --layer-name ${layer_name} --statement-id ${layer_name}-prod --version-number $layer_version --principal '*' --action lambda:GetLayerVersion --region ${region} |
| 93 | + # aws lambda add-layer-version-permission --layer-name ${layer_name} --statement-id ${layer_name}-dev --version-number ${layer_version} --principal '956882708938' --action lambda:GetLayerVersion --region ${region} |
| 94 | + done |
80 | 95 |
|
81 |
| - echo "Setting public permissions for layer version: ${layer_version}" |
82 |
| - aws lambda add-layer-version-permission --layer-name ${layer_name} --statement-id ${layer_name}-prod --version-number $layer_version --principal '*' --action lambda:GetLayerVersion --region ${region} |
83 |
| - # aws lambda add-layer-version-permission --layer-name ${layer_name} --statement-id ${layer_name}-dev --version-number ${layer_version} --principal '956882708938' --action lambda:GetLayerVersion --region ${region} |
84 | 96 | done
|
0 commit comments