Skip to content

Commit 5139b61

Browse files
committed
Add a Terraform configuration to deploy lnt.llvm.org
This patch adds a Terraform configuration file that should allow deploying to an EC2 instance. It requires a few secrets to be made available to Github Actions.
1 parent f89e20a commit 5139b61

File tree

4 files changed

+100
-0
lines changed

4 files changed

+100
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy lnt.llvm.org
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-24.04
14+
15+
steps:
16+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
17+
18+
- name: Setup Terraform
19+
uses: hashicorp/setup-terraform@v3
20+
21+
- name: Configure AWS Credentials
22+
uses: aws-actions/configure-aws-credentials@v4
23+
with:
24+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
25+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
26+
27+
- name: Initialize Terraform
28+
run: terraform init
29+
30+
- name: Apply Terraform changes
31+
run: terraform apply -auto-approve
32+
env:
33+
TF_VAR_lnt_db_password: ${{ secrets.LNT_DB_PASSWORD }}
34+
TF_VAR_lnt_auth_token: ${{ secrets.LNT_AUTH_TOKEN }}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
#
4+
# This is a template for the startup script that gets run on the EC2
5+
# instance running lnt.llvm.org. This template gets filled in by the
6+
# Terraform configuration file.
7+
#
8+
9+
sudo yum update -y
10+
sudo amazon-linux-extras install docker git -y
11+
sudo service docker start
12+
sudo usermod -a -G docker ec2-user
13+
sudo chkconfig docker on
14+
15+
LNT_DB_PASSWORD=${__db_password__}
16+
LNT_AUTH_TOKEN=${__auth_token__}
17+
docker compose --file compose.yaml up

docker/lnt.llvm.org/main.tf

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# Terraform file for deploying lnt.llvm.org.
3+
#
4+
5+
provider "aws" {
6+
region = "us-west-2"
7+
}
8+
9+
variable "lnt_db_password" {
10+
type = string
11+
description = "The database password for the lnt.llvm.org database."
12+
sensitive = true
13+
}
14+
15+
variable "lnt_auth_token" {
16+
type = string
17+
description = "The authentication token to perform destructive operations on lnt.llvm.org."
18+
sensitive = true
19+
}
20+
21+
resource "local_file" "docker-compose-file" {
22+
source = "../compose.yaml"
23+
filename = "${path.module}/compose.yaml"
24+
}
25+
26+
resource "aws_instance" "docker_server" {
27+
ami = "ami-0c97bd51d598d45e4" # Amazon Linux 2023 kernel-6.12 AMI in us-west-2
28+
instance_type = "t2.micro"
29+
key_name = "test-key-name" # TODO
30+
tags = {
31+
Name = "lnt.llvm.org"
32+
}
33+
34+
user_data = templatefile("${path.module}/ec2-startup.sh.tpl", {
35+
__db_password__ = var.lnt_db_password,
36+
__auth_token__ = var.lnt_auth_token,
37+
})
38+
}

docs/developer_guide.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,14 @@ install the development dependencies, and then run the following commands from t
8484
This requires setting up the right API token, see `the official documentation <https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives>`_
8585
for details. You can replace ``--repository testpypi`` with ``--repository pypi`` once you are actually ready
8686
to publish the package.
87+
88+
Deploying lnt.llvm.org
89+
----------------------
90+
91+
The `lnt.llvm.org <https://lnt.llvm.org>`_ instance gets re-deployed automatically on every tag
92+
that gets pushed to main via a Github Action. Manually deploying the instance is also possible
93+
by directly using Terraform::
94+
95+
cd docker/lnt.llvm.org
96+
terraform init
97+
terraform apply -var <foo> # see docker/lnt.llvm.org/main.tf for required variables

0 commit comments

Comments
 (0)