diff --git a/aws/logs_monitoring/tools/publish_layers.sh b/aws/logs_monitoring/tools/publish_layers.sh index 94693982..823d288c 100755 --- a/aws/logs_monitoring/tools/publish_layers.sh +++ b/aws/logs_monitoring/tools/publish_layers.sh @@ -149,10 +149,10 @@ index_of_layer() { } publish_layer() { - region=$1 - layer_name=$2 - aws_version_key=$3 - layer_path=$4 + region="${1}" + layer_name="${2}" + aws_version_key="${3}" + layer_path="${4}" version_nbr=$(aws lambda publish-layer-version --layer-name "${layer_name}" \ --description "Datadog Forwarder Layer Package" \ @@ -162,11 +162,15 @@ publish_layer() { --cli-read-timeout 60 | jq -r '.Version') - permission=$(aws lambda add-layer-version-permission --layer-name "${layer_name}" \ + if [[ -z ${version_nbr:-} ]]; then + return 1 + fi + + aws lambda add-layer-version-permission --layer-name "${layer_name}" \ --version-number "${version_nbr}" \ --statement-id "release-$version_nbr" \ - --action lambda:GetLayerVersion --principal "*" \ - --region "${region}") + --action "lambda:GetLayerVersion" --principal "*" \ + --region "${region}" echo "${version_nbr}" }