-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
144 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
export AWS_FOLDER=${AWS_FOLDER:-.aws} | ||
export SUFFIX_ARN_FILE=${SUFFIX_ARN_FILE:-arn-file.md} | ||
|
||
GOOS=${GOOS:?Pleas provide GOOS environment variable.} | ||
GOARCH=${GOARCH:?Please provide GOARCH environment variable.} | ||
ELASTIC_LAYER_NAME=${ELASTIC_LAYER_NAME:?Please provide ELASTIC_LAYER_NAME environment variable.} | ||
ARCHITECTURE=${ARCHITECTURE:?Please provide ARCHITECTURE environment variable.} | ||
VERSION=${VERSION:?Please provide VERSION environment variable. e.g. current git tag} | ||
|
||
FULL_LAYER_NAME="${ELASTIC_LAYER_NAME}-${ARCHITECTURE}" | ||
|
||
ALL_AWS_REGIONS=$(aws ec2 describe-regions --output json --no-cli-pager | jq -r '.Regions[].RegionName') | ||
|
||
rm -rf ${AWS_FOLDER} | ||
|
||
# Delete previous layers | ||
for region in $ALL_AWS_REGIONS; do | ||
layer_versions=$(aws lambda list-layer-versions --region="${region}" --layer-name="${FULL_LAYER_NAME}" | jq '.LayerVersions[].Version') | ||
echo "Found layer versions for ${FULL_LAYER_NAME} in ${region}: ${layer_versions:-none}" | ||
for version_number in $layer_versions; do | ||
echo "- Deleting ${FULL_LAYER_NAME}:${version_number} in ${region}" | ||
aws lambda delete-layer-version \ | ||
--region="${region}" \ | ||
--layer-name="${FULL_LAYER_NAME}" \ | ||
--version-number="${version_number}" | ||
done | ||
done | ||
|
||
mkdir -p "${AWS_FOLDER}" | ||
|
||
for region in $ALL_AWS_REGIONS; do | ||
echo "Publish ${FULL_LAYER_NAME} in ${region}" | ||
publish_output=$(aws lambda \ | ||
--output json \ | ||
publish-layer-version \ | ||
--region="${region}" \ | ||
--layer-name="${FULL_LAYER_NAME}" \ | ||
--description="AWS Lambda Extension Layer for Elastic APM ${ARCHITECTURE}" \ | ||
--license="Apache-2.0" \ | ||
--zip-file="fileb://./dist/${VERSION}-${GOOS}-${GOARCH}.zip") | ||
echo "${publish_output}" > "${AWS_FOLDER}/${region}" | ||
layer_version=$(echo "${publish_output}" | jq '.Version') | ||
echo "Grant public layer access ${FULL_LAYER_NAME}:${layer_version} in ${region}" | ||
grant_access_output=$(aws lambda \ | ||
--output json \ | ||
add-layer-version-permission \ | ||
--region="${region}" \ | ||
--layer-name="${FULL_LAYER_NAME}" \ | ||
--action="lambda:GetLayerVersion" \ | ||
--principal='*' \ | ||
--statement-id="${FULL_LAYER_NAME}" \ | ||
--version-number="${layer_version}") | ||
echo "${grant_access_output}" > "${AWS_FOLDER}/.${region}-public" | ||
done | ||
|
||
sh -c "./.ci/create-arn-table.sh" |
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,18 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
export SUFFIX_ARN_FILE=${SUFFIX_ARN_FILE:-arn-file.md} | ||
VERSION=${VERSION:?Please provide VERSION environment variable. e.g. current git tag} | ||
|
||
rm -rf "${SUFFIX_ARN_FILE}" | ||
|
||
cat ./*"-${SUFFIX_ARN_FILE}" >> "$SUFFIX_ARN_FILE" | ||
|
||
gh release \ | ||
create "${VERSION}" \ | ||
--draft \ | ||
--title="${VERSION}" \ | ||
--generate-notes \ | ||
--notes-file="${SUFFIX_ARN_FILE}" \ | ||
./dist/${VERSION}*.zip | ||
|
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,60 @@ | ||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- v*.*.* | ||
|
||
env: | ||
DOCKER_BUILDKIT: 1 | ||
DOCKER_REGISTRY: docker.elastic.co | ||
DOCKER_IMAGE_NAME: observability/apm-lambda-extension | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
os: ${{ steps.artifacts.outputs.os }} | ||
arch: ${{ steps.artifacts.outputs.arch }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version-file: 'go.mod' | ||
- uses: docker/setup-qemu-action@v2 | ||
with: | ||
platforms: linux/arm64, linux/amd64 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- uses: elastic/apm-pipeline-library/.github/actions/docker-login@current | ||
with: | ||
registry: docker.elastic.co | ||
secret: secret/observability-team/ci/docker-registry/prod | ||
url: ${{ secrets.VAULT_ADDR }} | ||
roleId: ${{ secrets.VAULT_ROLE_ID }} | ||
secretId: ${{ secrets.VAULT_SECRET_ID }} | ||
- uses: hashicorp/vault-action@v2 | ||
with: | ||
url: ${{ secrets.VAULT_ADDR }} | ||
method: approle | ||
roleId: ${{ secrets.VAULT_ROLE_ID }} | ||
secretId: ${{ secrets.VAULT_SECRET_ID }} | ||
secrets: | | ||
secret/observability-team/ci/service-account/apm-aws-lambda access_key_id | AWS_ACCESS_KEY_ID ; | ||
secret/observability-team/ci/service-account/apm-aws-lambda secret_access_key | AWS_SECRET_ACCESS_KEY | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v4 | ||
with: | ||
args: release --rm-dist | ||
- name: GitHub Release | ||
run: make release-notes | ||
env: | ||
VERSION: ${{ github.ref_name }} | ||
|
||
|
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 |
---|---|---|
|
@@ -22,9 +22,11 @@ | |
|
||
# AWS regions file | ||
.regions | ||
.aws/ | ||
.aws-*/ | ||
*arn-file.md | ||
|
||
bin/ | ||
|
||
# local docs | ||
html_docs | ||
html_docs | ||
dist/ |
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