-
Notifications
You must be signed in to change notification settings - Fork 637
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/v0.7.0' into master
- Loading branch information
Showing
37 changed files
with
1,650 additions
and
1,118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Action runners deployment ubuntu example | ||
|
||
This modules shows how to create GitHub action runners using an Ubuntu AMI. Lambda release will be downloaded from GitHub. | ||
|
||
## Usages | ||
|
||
Steps for the full setup, such as creating a GitHub app can be found in the root module's [README](../../README.md). First download the Lambda releases from GitHub. Alternatively you can build the lambdas locally with Node or Docker, there is a simple build script in `<root>/.ci/build.sh`. In the `main.tf` you can simple remove the location of the lambda zip files, the default location will work in this case. | ||
|
||
```bash | ||
cd lambdas-download | ||
terraform init | ||
terraform apply | ||
cd .. | ||
``` | ||
|
||
Before running Terraform, ensure the GitHub app is configured. | ||
|
||
```bash | ||
terraform init | ||
terraform apply | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module "lambdas" { | ||
source = "../../../modules/download-lambda" | ||
lambdas = [ | ||
{ | ||
name = "webhook" | ||
tag = "v0.5.0" | ||
}, | ||
{ | ||
name = "runners" | ||
tag = "v0.5.0" | ||
}, | ||
{ | ||
name = "runner-binaries-syncer" | ||
tag = "v0.5.0" | ||
} | ||
] | ||
} | ||
|
||
output "files" { | ||
value = module.lambdas.files | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
locals { | ||
environment = "ubuntu" | ||
aws_region = "eu-west-1" | ||
} | ||
|
||
resource "random_password" "random" { | ||
length = 28 | ||
} | ||
|
||
module "runners" { | ||
source = "../../" | ||
|
||
aws_region = local.aws_region | ||
vpc_id = module.vpc.vpc_id | ||
subnet_ids = module.vpc.private_subnets | ||
|
||
environment = local.environment | ||
tags = { | ||
Project = "ProjectX" | ||
} | ||
|
||
github_app = { | ||
key_base64 = var.github_app_key_base64 | ||
id = var.github_app_id | ||
client_id = var.github_app_client_id | ||
client_secret = var.github_app_client_secret | ||
webhook_secret = random_password.random.result | ||
} | ||
|
||
webhook_lambda_zip = "lambdas-download/webhook.zip" | ||
runner_binaries_syncer_lambda_zip = "lambdas-download/runner-binaries-syncer.zip" | ||
runners_lambda_zip = "lambdas-download/runners.zip" | ||
|
||
enable_organization_runners = false | ||
runner_extra_labels = "ubuntu,example" | ||
|
||
# enable access to the runners via SSM | ||
enable_ssm_on_runners = true | ||
|
||
userdata_template = "./templates/user-data.sh" | ||
ami_owners = ["099720109477"] # Canonical's Amazon account ID | ||
|
||
ami_filter = { | ||
name = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"] | ||
} | ||
|
||
block_device_mappings = { | ||
# Set the block device name for Ubuntu root device | ||
device_name = "/dev/sda1" | ||
} | ||
|
||
# Uncommet idle config to have idle runners from 9 to 5 in time zone Amsterdam | ||
# idle_config = [{ | ||
# cron = "* * 9-17 * * *" | ||
# timeZone = "Europe/Amsterdam" | ||
# idleCount = 1 | ||
# }] | ||
|
||
# disable KMS and encryption | ||
# encrypt_secrets = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
output "runners" { | ||
value = { | ||
lambda_syncer_name = module.runners.binaries_syncer.lambda.function_name | ||
} | ||
} | ||
|
||
output "webhook" { | ||
value = { | ||
secret = random_password.random.result | ||
endpoint = module.runners.webhook.endpoint | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
provider "aws" { | ||
region = local.aws_region | ||
version = "3.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash -e | ||
exec > >(tee /var/log/user-data.log | logger -t user-data -s 2>/dev/console) 2>&1 | ||
|
||
# Install AWS CLI | ||
apt-get update | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y awscli jq | ||
|
||
# Install runner | ||
cd /home/ubuntu | ||
mkdir actions-runner && cd actions-runner | ||
|
||
aws s3 cp ${s3_location_runner_distribution} actions-runner.tar.gz | ||
tar xzf ./actions-runner.tar.gz | ||
rm -rf actions-runner.tar.gz | ||
|
||
INSTANCE_ID=$(wget -q -O - http://169.254.169.254/latest/meta-data/instance-id) | ||
REGION=$(curl -s 169.254.169.254/latest/dynamic/instance-identity/document | jq -r .region) | ||
|
||
echo wait for configuration | ||
while [[ $(aws ssm get-parameters --names ${environment}-$INSTANCE_ID --with-decryption --region $REGION | jq -r ".Parameters | .[0] | .Value") == null ]]; do | ||
echo Waiting for configuration ... | ||
sleep 1 | ||
done | ||
CONFIG=$(aws ssm get-parameters --names ${environment}-$INSTANCE_ID --with-decryption --region $REGION | jq -r ".Parameters | .[0] | .Value") | ||
aws ssm delete-parameter --name ${environment}-$INSTANCE_ID --region $REGION | ||
|
||
export RUNNER_ALLOW_RUNASROOT=1 | ||
|
||
sudo -u ubuntu mkdir /home/ubuntu/work | ||
|
||
./bin/installdependencies.sh | ||
./config.sh --unattended --name $INSTANCE_ID --work "/home/ubuntu/work" $CONFIG | ||
|
||
chown -R ubuntu:ubuntu . | ||
./svc.sh install ubuntu | ||
|
||
./svc.sh start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
variable "github_app_key_base64" {} | ||
|
||
variable "github_app_id" {} | ||
|
||
variable "github_app_client_id" {} | ||
|
||
variable "github_app_client_secret" {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module "vpc" { | ||
source = "git::https://github.com/philips-software/terraform-aws-vpc.git?ref=2.1.0" | ||
|
||
environment = local.environment | ||
aws_region = local.aws_region | ||
create_private_hosted_zone = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.