Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 9007844

Browse files
committed
init: add terraform code and actions
1 parent 3bc53ba commit 9007844

9 files changed

+206
-1
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @presentium/developers/infrastructure

.github/workflows/drift.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Check for infrastructure drift
2+
3+
on:
4+
schedule:
5+
- cron: "0 8 * * *"
6+
7+
permissions:
8+
id-token: write
9+
contents: read
10+
11+
jobs:
12+
check_drift:
13+
runs-on: ubuntu-latest
14+
name: Check for drift of terraform configuration
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Configure AWS credentials
20+
uses: aws-actions/configure-aws-credentials@v4
21+
with:
22+
aws-region: ${{ vars.AWS_REGION }}
23+
role-to-assume: ${{ vars.AWS_ARN }}
24+
role-session-name: terraform-check
25+
26+
- name: Check for drift
27+
uses: dflook/terraform-check@v1
28+
with:
29+
path: terraform

.github/workflows/terraform-apply.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Apply terraform plan
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
pull-requests: write
12+
13+
jobs:
14+
apply:
15+
runs-on: ubuntu-latest
16+
name: Apply the terraform plan
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Configure AWS credentials
22+
uses: aws-actions/configure-aws-credentials@v4
23+
with:
24+
aws-region: ${{ vars.AWS_REGION }}
25+
role-to-assume: ${{ vars.AWS_ARN }}
26+
role-session-name: terraform-apply
27+
28+
- name: terraform apply
29+
uses: dflook/terraform-apply@v1
30+
with:
31+
path: terraform

.github/workflows/terraform-plan.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Create terraform plan
2+
3+
on: [pull_request]
4+
5+
permissions:
6+
contents: read
7+
id-token: write
8+
pull-requests: write
9+
10+
jobs:
11+
plan:
12+
runs-on: ubuntu-latest
13+
name: Create a plan for the terraform configuration
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Configure AWS credentials
19+
uses: aws-actions/configure-aws-credentials@v4
20+
with:
21+
aws-region: ${{ vars.AWS_REGION }}
22+
role-to-assume: ${{ vars.AWS_ARN }}
23+
role-session-name: terraform-plan
24+
25+
- name: terraform plan
26+
uses: dflook/terraform-plan@v1
27+
with:
28+
path: terraform

.github/workflows/validate.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Validate changes
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'main'
7+
8+
permissions:
9+
id-token: write
10+
contents: read
11+
12+
jobs:
13+
fmt-check:
14+
runs-on: ubuntu-latest
15+
name: Check formatting of terraform files
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Configure AWS credentials
21+
uses: aws-actions/configure-aws-credentials@v4
22+
with:
23+
aws-region: ${{ vars.AWS_REGION }}
24+
role-to-assume: ${{ vars.AWS_ARN }}
25+
role-session-name: terraform-fmt-check
26+
27+
- name: terraform fmt
28+
uses: dflook/terraform-fmt-check@v1
29+
with:
30+
path: terraform
31+
32+
validate:
33+
runs-on: ubuntu-latest
34+
name: Validate terraform configuration
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Configure AWS credentials
40+
uses: aws-actions/configure-aws-credentials@v4
41+
with:
42+
aws-region: ${{ vars.AWS_REGION }}
43+
role-to-assume: ${{ vars.AWS_ARN }}
44+
role-session-name: terraform-validate
45+
46+
- name: terraform validate
47+
uses: dflook/terraform-validate@v1
48+
with:
49+
path: terraform

LICENSE.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The MIT License (MIT)
2+
3+
Copyright © `2024` `The Presentium Project and its contributors`
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6+
documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8+
persons to whom the Software is furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11+
Software.
12+
13+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1-
# infra
1+
# Infrastructure for Presentium
2+
23
Infrastructure for deploying the Presentium API and dashboard on the cloud.
4+
5+
## Continus Delivery
6+
7+
The infrastructure is deployed using GitHub Actions. The workflow is defined in `.github/workflows/terraform-apply.yml`.
8+
9+
The default branch therefore is `dev`, and the `main` branch is protected.
10+
When an infrastructure change is ready to be deployed, a pull request should be made from `dev` to `main`.
11+
12+
## Contributing
13+
14+
Please refer to the [Contributing Guide][contributing] before making a pull request.
15+
16+
[contributing]: https://github.com/presentium/meta/blob/main/CONTRIBUTING.md

terraform/.terraform.lock.hcl

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

terraform/main.tf

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = "~> 5.0"
6+
}
7+
}
8+
}
9+
10+
provider "aws" {
11+
region = "eu-central-2"
12+
}

0 commit comments

Comments
 (0)