Skip to content

Commit b6c0f89

Browse files
authored
add a CI workflow to test Terraform deployments (#47)
* add a CI workflow to test Terraform deployments * fix yaml * attempt to fix * another attempt to fix
1 parent b52da46 commit b6c0f89

File tree

2 files changed

+77
-16
lines changed

2 files changed

+77
-16
lines changed

.github/workflows/integration-test.yml

+76-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,82 @@ on:
2626

2727

2828
jobs:
29-
run-it-tests-job:
29+
run-terraform-deployment:
30+
name: Run Terraform Deployment
31+
runs-on: ${{ inputs.runner-os || 'ubuntu-latest' }}
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Set up Python 3.11
37+
id: setup-python
38+
uses: actions/setup-python@v2
39+
with:
40+
python-version: 3.11
41+
42+
- name: Install Terraform
43+
uses: hashicorp/setup-terraform@v3
44+
45+
- name: Install Terraform Local
46+
run: |
47+
pip install --upgrade terraform-local
48+
49+
- name: Set up Project
50+
run: |
51+
pip install -r requirements-dev.txt
52+
53+
- name: Start LocalStack
54+
uses: LocalStack/[email protected]
55+
with:
56+
image-tag: 'latest'
57+
use-pro: 'true'
58+
configuration: LS_LOG=trace
59+
install-awslocal: 'true'
60+
env:
61+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
62+
63+
- name: Build lambdas
64+
run: |
65+
bin/build_lambdas.sh
66+
67+
- name: Deploy infrastructure
68+
run: |
69+
cd deployment/terraform
70+
tflocal init
71+
tflocal apply --auto-approve
72+
73+
- name: Show localstack logs
74+
if: always()
75+
run: |
76+
localstack logs
77+
78+
- name: Send a Slack notification
79+
if: failure() || github.event_name != 'pull_request'
80+
uses: ravsamhq/notify-slack-action@v2
81+
with:
82+
status: ${{ job.status }}
83+
token: ${{ secrets.GITHUB_TOKEN }}
84+
notification_title: "{workflow} has {status_message}"
85+
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
86+
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>"
87+
notify_when: "failure"
88+
env:
89+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
90+
91+
- name: Generate a Diagnostic Report
92+
if: failure()
93+
run: |
94+
curl -s localhost:4566/_localstack/diagnose | gzip -cf > diagnose.json.gz
95+
96+
- name: Upload the Diagnostic Report
97+
if: failure()
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: diagnose.json.gz
101+
path: ./diagnose.json.gz
102+
103+
run-integration-tests-job:
104+
name: Run Integration Tests
30105
runs-on: ${{ inputs.runner-os || 'ubuntu-latest' }}
31106
steps:
32107
- name: Checkout

deployment/terraform/main.tf

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
terraform {
2-
required_providers {
3-
aws = {
4-
source = "hashicorp/aws"
5-
version = "<= 5.72.1"
6-
}
7-
}
8-
}
9-
10-
provider "aws" {
11-
region = "us-east-1"
12-
skip_requesting_account_id = true
13-
}
14-
151
locals {
162
# TO-DO: The environment variable STAGE is required for Lambdas to connect to LocalStack endpoints.
173
# The environment variable can be removed once Lambdas are adapted to support transparent endpoint injection.
@@ -335,4 +321,4 @@ output "list_lambda_function_url" {
335321

336322
output "cloudfront_url" {
337323
value = "Now open the Web app under: http://${aws_cloudfront_distribution.cdn.domain_name}"
338-
}
324+
}

0 commit comments

Comments
 (0)