Skip to content

Commit 8388aa8

Browse files
committed
added cfn deployment process
1 parent a23577b commit 8388aa8

27 files changed

+663
-27
lines changed

.github/release-drafter.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# For the https://github.com/marketplace/actions/release-drafter Action
2+
name-template: v$RESOLVED_VERSION Release
3+
tag-template: v$RESOLVED_VERSION
4+
categories:
5+
- title: 🚀 Features
6+
labels:
7+
- feature
8+
- enhancement
9+
- title: 🐛 Bug Fixes
10+
labels:
11+
- fix
12+
- bugfix
13+
- bug
14+
- title: 🧰 Maintenance
15+
label: chore
16+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
17+
# You can add # and @ to disable mentions, and add ` to disable code blocks.
18+
change-title-escapes: '\<*_&'
19+
version-resolver:
20+
major:
21+
labels:
22+
- major
23+
minor:
24+
labels:
25+
- minor
26+
patch:
27+
labels:
28+
- patch
29+
default: patch
30+
template: |
31+
## Changes
32+
$CHANGES
33+
include-pre-releases: true
34+
prerelease: true

.github/workflows/codecov.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/deploy-prod-eu.yaml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Deploy To Prod EU
2+
3+
on:
4+
release:
5+
types:
6+
- released
7+
8+
permissions:
9+
id-token: write
10+
contents: write
11+
pull-requests: write
12+
env:
13+
GOLANG_VERSION: 1.23
14+
REGION_NAME: eu-west-1
15+
ACCOUNT_ID: 247286868737
16+
ROLE_TO_ASSUME: arn:aws:iam::247286868737:role/firetail-prod-github-serverless-lambda-deployment
17+
LAMBDA_SERVERLESS_REPO: firetail-prod-eu-west-1-serverless-applications
18+
APP_NAME: firetail-appsync-logger
19+
CFN_TEMPLATES_BUCKET: firetail-prod-us-east-1-cf-templates
20+
CFN_TEMPLATES_BUCKET_REGION: us-east-1
21+
jobs:
22+
setup:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
mymatrix: ${{ steps.matrixStep.outputs.matrixItems }}
26+
steps:
27+
- name: Checkout Code
28+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
29+
with:
30+
fetch-depth: 2
31+
- name: Configure AWS Credentials
32+
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0
33+
with:
34+
aws-region: ${{ env.REGION_NAME }}
35+
role-to-assume: ${{env.ROLE_TO_ASSUME }}
36+
role-session-name: github
37+
- id: matrixStep
38+
run: |
39+
python3 -m pip install boto3
40+
matrix=$(python3 build_setup/get_regions.py)
41+
echo $matrix
42+
echo "matrixItems=$(echo $matrix)" >> $GITHUB_ENV
43+
download-artifact:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout Code
47+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
48+
with:
49+
fetch-depth: 2
50+
- name: Get Release
51+
id: get_release
52+
uses: bruceadams/get-release@74c3d60f5a28f358ccf241a00c9021ea16f0569f
53+
env:
54+
GITHUB_TOKEN: ${{ github.token }}
55+
- name: Download zip from release
56+
uses: robinraju/release-downloader@efa4cd07bd0195e6cc65e9e30c251b49ce4d3e51
57+
with:
58+
releaseId: ${{ steps.get_release.outputs.id }}
59+
fileName: lambda.zip
60+
out-file-path: "build"
61+
- name: Configure AWS Credentials
62+
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0
63+
with:
64+
aws-region: ${{ env.REGION_NAME }}
65+
role-to-assume: ${{env.ROLE_TO_ASSUME }}
66+
role-session-name: github
67+
- run:
68+
sam package --template-file template.yaml --output-template-file packaged.yaml --s3-bucket ${{
69+
env.LAMBDA_SERVERLESS_REPO }} --region ${{env.REGION_NAME}}
70+
- uses: actions/upload-artifact@v3
71+
with:
72+
name: packaged.yaml
73+
path: packaged.yaml
74+
release-application:
75+
needs: download-artifact
76+
runs-on: ubuntu-latest
77+
strategy:
78+
# matrix: ${{ fromJson(needs.setup.outputs.mymatrix) }}
79+
fail-fast: false
80+
matrix:
81+
region:
82+
[
83+
"us-east-2",
84+
"us-east-1",
85+
"us-west-1",
86+
"us-west-2",
87+
"af-south-1",
88+
"ap-east-1",
89+
"ap-south-2",
90+
"ap-southeast-3",
91+
"ap-southeast-4",
92+
"ap-south-1",
93+
"ap-northeast-3",
94+
"ap-northeast-2",
95+
"ap-southeast-1",
96+
"ap-southeast-2",
97+
"ap-northeast-1",
98+
"ca-central-1",
99+
"eu-central-1",
100+
"eu-west-1",
101+
"eu-west-2",
102+
"eu-south-1",
103+
"eu-west-3",
104+
"eu-south-2",
105+
"eu-north-1",
106+
"eu-central-2",
107+
"il-central-1",
108+
"me-south-1",
109+
"me-central-1",
110+
"sa-east-1",
111+
]
112+
steps:
113+
- name: Configure AWS Credentials
114+
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0
115+
with:
116+
aws-region: ${{ env.REGION_NAME }}
117+
role-to-assume: ${{env.ROLE_TO_ASSUME }}
118+
role-session-name: github
119+
- name: Get Release
120+
id: get_release
121+
uses: bruceadams/get-release@74c3d60f5a28f358ccf241a00c9021ea16f0569f
122+
env:
123+
GITHUB_TOKEN: ${{ github.token }}
124+
- uses: actions/download-artifact@v4
125+
with:
126+
name: packaged.yaml
127+
- run: |
128+
version=$(echo "${{ steps.get_release.outputs.tag_name }}" | cut -c 2-)
129+
sam publish --template packaged.yaml --region ${{ matrix.region }} --semantic-version $version
130+
aws serverlessrepo put-application-policy --region ${{ matrix.region }} --application-id arn:aws:serverlessrepo:${{ matrix.region }}:${{env.ACCOUNT_ID}}:applications/${{env.APP_NAME}} --statements Principals=*,Actions=Deploy
131+
continue-on-error: true
132+
release-cloudformation:
133+
needs: release-application
134+
runs-on: ubuntu-latest
135+
timeout-minutes: 15
136+
steps:
137+
- name: Checkout Code
138+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
139+
with:
140+
fetch-depth: 2
141+
- name: Get Release
142+
id: get_release
143+
uses: bruceadams/get-release@74c3d60f5a28f358ccf241a00c9021ea16f0569f
144+
env:
145+
GITHUB_TOKEN: ${{ github.token }}
146+
- run: |
147+
version=$(echo "${{ steps.get_release.outputs.tag_name }}" | cut -c 2-)
148+
sed -i -e "s/0.0.1/${version}/g" cfn_templates/appsync_logging_template.yaml
149+
- name: Configure AWS Credentials
150+
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0
151+
with:
152+
aws-region: ${{ env.REGION_NAME }}
153+
role-to-assume: ${{env.ROLE_TO_ASSUME }}
154+
role-session-name: github
155+
- name: copy new cfn to s3
156+
run: |
157+
aws s3 cp ./cfn_templates/ s3://${{env.CFN_TEMPLATES_BUCKET}}/applications/cfn/ --acl public-read --region ${{env.CFN_TEMPLATES_BUCKET_REGION}} --recursive

.github/workflows/deploy-sandbox.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
env:
2+
SANDBOX_AWS_ACCT_ID: 453671210445
3+
SANDBOX_AWS_ACCT_NAME: firetail-sandbox
4+
AWS_REGION: eu-west-1
5+
ROLE_TO_ASSUME: arn:aws:iam::453671210445:role/firetail-sandbox-github-serverless-lambda-deployment
6+
LAMBDA_SERVERLESS_REPO: firetail-sandbox-eu-west-1-serverless-applications
7+
CFN_TEMPLATES_BUCKET: firetail-sandbox-us-east-1-cf-templates
8+
CFN_TEMPLATES_BUCKET_REGION: us-east-1
9+
APP_NAME: aws-appsync-logging-lambda
10+
SEMANTIC_VERSION: 1.1.39
11+
name: Deploy to Sandbox
12+
run-name: "@${{ github.triggering_actor }}: ${{ github.ref_name }}: ${{ github.event_name }}"
13+
on:
14+
push:
15+
branches:
16+
- dev
17+
- dev-preview
18+
defaults:
19+
run:
20+
shell: bash
21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref_name }}
23+
cancel-in-progress: true
24+
permissions:
25+
id-token: write
26+
contents: read
27+
pull-requests: read
28+
jobs:
29+
deploy-sandbox:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout Code
33+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
34+
with:
35+
fetch-depth: 2
36+
- name: Set Environment
37+
run: |
38+
git_hash="$(git rev-parse --short "${{ github.sha }}")"
39+
RELEASE_VERSION="sandbox-${git_hash}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
40+
IMAGE_TAG="${{ env.SANDBOX_ECR_HOSTNAME }}/${{ env.ECR_REPO }}:${RELEASE_VERSION}"
41+
42+
cat <<EOF >>"${GITHUB_ENV}"
43+
RELEASE_VERSION=${RELEASE_VERSION}
44+
IMAGE_TAG=${IMAGE_TAG}
45+
EOF
46+
- name: Configure AWS Credentials
47+
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0
48+
with:
49+
aws-region: ${{ env.AWS_REGION }}
50+
role-to-assume: ${{env.ROLE_TO_ASSUME }}
51+
role-session-name: github
52+
- name: Run build docker image
53+
run: docker build -t lambda-image:latest --target runtime-image -f build_setup/Dockerfile .
54+
- name: create build dir
55+
run: mkdir build -p
56+
- name: extract docker build zip
57+
run: docker run --rm --entrypoint cat lambda-image:latest /src/lambda.zip > build/lambda.zip
58+
- name: sam
59+
run: |
60+
sam package --template-file template.yaml --output-template-file packaged.yaml --s3-bucket ${{ env.LAMBDA_SERVERLESS_REPO }}
61+
sam publish --template packaged.yaml --region ${{env.AWS_REGION}} --semantic-version ${{env.SEMANTIC_VERSION}}
62+
- name: copy new cfn to s3
63+
run: |
64+
sed -i -e "s/0.0.1/${{env.SEMANTIC_VERSION}}/g" cfn_templates/appsync_logging_template.yaml
65+
aws s3 cp ./cfn_templates/ s3://${{env.CFN_TEMPLATES_BUCKET}}/applications/cfn/ --acl public-read --region ${{env.CFN_TEMPLATES_BUCKET_REGION}} --recursive

0 commit comments

Comments
 (0)