Skip to content

[NR-343531] Workflows for lambda code and templates deployment #11

[NR-343531] Workflows for lambda code and templates deployment

[NR-343531] Workflows for lambda code and templates deployment #11

Workflow file for this run

name: Build and Deploy Lambda
on:
pull_request:
branches:
- main
env:
log_forwarder_zip_file_name: new-relic-log-forwarder.zip
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Build and Package Go executable
run: |
cd src
go mod tidy
GOOS=linux GOARCH=amd64 go build -o bootstrap main.go
zip -r ../$log_forwarder_zip_file_name .
cd ..
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: log-forwarder-zip
path: $log_forwarder_zip_file_name
deploy-lambda-code:
needs: build
permissions:
id-token: write
contents: write
runs-on: ubuntu-latest
strategy:
matrix:
region:
- us-east-1
- us-east-2
# - eu-west-1
# - eu-west-2
# - us-west-1
# - us-west-2
# - af-south-1
# - ap-east-1
# - ap-south-2
# - ap-southeast-3
# - ap-southeast-5
# - ap-southeast-4
# - ap-south-1
# - ap-northeast-3
# - ap-northeast-2
# - ap-southeast-1
# - ap-southeast-2
# - ap-northeast-1
# - ca-central-1
# - ca-west-1
# - eu-central-1
# - eu-south-1
# - eu-west-3
# - eu-south-2
# - eu-north-1
# - eu-central-2
# - me-south-1
# - me-central-1
# - il-central-1
# - sa-east-1
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: ${{ secrets.AWS_S3_PUBLISH_ROLE_TEMP }}
aws-region: us-east-2
- name: Upload lambda code to S3 buckets in all AWS region
env:
bucket_prefix: new-relic-log-forwarder-folder
region: ${{ matrix.region }}
run: |
bucket_name="unified-logging-lambda-code-test-${region}"
aws s3 cp "$log_forwarder_zip_file_name" "s3://$bucket_name/$bucket_prefix/" --region "$region"
echo "Deploying $log_forwarder_zip_file_name to region $REGION"
deploy-temaplate-files:
needs: deploy-lambda-code
runs-on: ubuntu-latest
steps:
- name: Install AWS SAM CLI
run: |
pip install aws-sam-cli
- name: Build and Package SAM Application and Upload to S3
env:
bucket_name: anusha-test-ansuha
region: us-east-1
run: |
TEMPLATES=(
"logging-lambda-metric-polling.yaml"
"logging-lambda-metric-stream.yaml"
"logging-firehose-metric-polling.yaml"
"logging-firehose-metric-stream.yaml"
"logging-lambda-firehose-metric-polling.yaml"
"logging-lambda-firehose-metric-stream.yaml"
"lambda-template.yaml"
"logging-lambda-firehose-template.yaml"
)
for TEMPLATE_FILE in "${TEMPLATES[@]}"; do
sam build --template-file "$TEMPLATE_FILE"
sam package --s3-bucket "$bucket_name" --template-file "template.yaml" --output-template-file "$TEMPLATE_FILE" --region $region
aws s3 cp "$TEMPLATE_FILE" "s3://$bucket_name/$TEMPLATE_FILE"
done