@@ -54,6 +54,11 @@ for arch in "${ARCHITECTURES[@]}"; do
5454 export AWS_PROFILE=" personal"
5555 fi
5656
57+ # Set AWS_PROFILE_EUSC for European Sovereign Cloud regions (can be overridden via environment)
58+ if [[ -z " ${AWS_PROFILE_EUSC} " ]]; then
59+ export AWS_PROFILE_EUSC=" esc_personal"
60+ fi
61+
5762 AWS_REGIONS=(
5863 us-east-1
5964 us-east-2
@@ -76,27 +81,38 @@ for arch in "${ARCHITECTURES[@]}"; do
7681 us-west-1
7782 us-west-2
7883 ca-west-1
84+ eusc-de-east-1
7985 )
8086
8187 echo " Using AWS_PROFILE: ${AWS_PROFILE} "
88+ echo " Using AWS_PROFILE_EUSC: ${AWS_PROFILE_EUSC} "
8289
8390 # We have layer name as sumologic-extension. Please change name for local testing.
8491 layer_name=" ${binary_name} -${arch} "
8592
8693 for region in " ${AWS_REGIONS[@]} " ; do
94+ # Auto-detect profile based on region prefix
95+ if [[ " ${region} " =~ ^eusc- ]]; then
96+ profile=" ${AWS_PROFILE_EUSC} "
97+ else
98+ profile=" ${AWS_PROFILE} "
99+ fi
100+
101+ echo " Deploying to region ${region} using profile ${profile} "
102+
87103 layer_version=$( aws lambda publish-layer-version --layer-name ${layer_name} \
88104 --description " The SumoLogic Extension collects lambda logs and send it to Sumo Logic." \
89105 --license-info " Apache-2.0" --zip-file fileb://$( pwd) /${extension_zip_dir} /${binary_name} .zip \
90- --profile ${AWS_PROFILE } --region ${region} --output text --query Version )
106+ --profile ${profile } --region ${region} --output text --query Version )
91107
92108 # Dynamically get the partition for the region from AWS
93- caller_arn=$( aws sts get-caller-identity --region ${region} --profile ${AWS_PROFILE } --query ' Arn' --output text)
109+ caller_arn=$( aws sts get-caller-identity --region ${region} --profile ${profile } --query ' Arn' --output text)
94110 partition=$( echo ${caller_arn} | cut -d' :' -f2)
95111
96112 echo " Layer Arn: arn:${partition} :lambda:${region} :<accountId>:layer:${layer_name} :${layer_version} deployed to Region ${region} "
97113
98114 echo " Setting public permissions for layer version: ${layer_version} "
99- 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} --profile ${AWS_PROFILE }
115+ 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} --profile ${profile }
100116 # 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}
101117 done
102118
0 commit comments