Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ module "runner" {
|------|-------------|------|---------|:--------:|
| <a name="input_ami"></a> [ami](#input\_ami) | AMI information for the EC2 instance | <pre>object({<br> id = string<br> owner_id = string<br> })</pre> | <pre>{<br> "id": "ami-04505e74c0741db8d",<br> "owner_id": "099720109477"<br>}</pre> | no |
| <a name="input_associate_public_ip_address"></a> [associate\_public\_ip\_address](#input\_associate\_public\_ip\_address) | Associate a public IP address with the instance | `bool` | `false` | no |
| <a name="input_docker_compose_yaml_override"></a> [docker\_compose\_yaml\_override](#input\_docker\_compose\_yaml\_override) | This var allows the downstream module to override the docker-compose.yaml template used by this module.<br>When you set this variable, you own the docker compose stack for the runner."<br>Validate your docker-compose.yaml and pass it as a string. This module will bas64encode it. | `string` | `null` | no |
| <a name="input_ec2_runner_iam_role_policy_arns"></a> [ec2\_runner\_iam\_role\_policy\_arns](#input\_ec2\_runner\_iam\_role\_policy\_arns) | IAM role policies to attach to the Runner instance | `list(string)` | <pre>[<br> "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore",<br> "arn:aws:iam::aws:policy/service-role/AmazonEC2RoleforSSM"<br>]</pre> | no |
| <a name="input_environment"></a> [environment](#input\_environment) | Name of the environment, i.e. dev, stage, prod | `string` | n/a | yes |
| <a name="input_github_owner"></a> [github\_owner](#input\_github\_owner) | GitHub Owner the runner belongs to. If you are adding a repo, the format will be `owner/repo` | `string` | `"sourcefuse"` | no |
Expand Down
10 changes: 10 additions & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@ locals {

runner_name = var.runner_name != null ? var.runner_name : "${var.namespace}-${var.environment}-github-runner-${random_string.runner.result}"
aws_friendly_runner_labels = replace(var.runner_labels, ",", " + ")
docker_compose_default_template = base64encode(templatefile("${path.module}/templates/docker-compose.yml.tftpl", {
runner_token = data.aws_ssm_parameter.runner_token.value
runner_owner = var.github_owner
runner_name = local.runner_name
runner_user = var.runner_user
runner_image = var.runner_image
runner_labels = var.runner_labels
repos_or_orgs = var.repos_or_orgs
}))
docker_compose_config = var.docker_compose_yaml_override == null ? local.docker_compose_default_template : base64encode(var.docker_compose_yaml_override)
}
10 changes: 1 addition & 9 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,7 @@ resource "aws_s3_object" "docker_compose" {
bucket = aws_s3_bucket.runner.id
key = "docker-compose.yml"

content_base64 = base64encode(templatefile("${path.module}/templates/docker-compose.yml.tftpl", {
runner_token = data.aws_ssm_parameter.runner_token.value
runner_owner = var.github_owner
runner_name = local.runner_name
runner_user = var.runner_user
runner_image = var.runner_image
runner_labels = var.runner_labels
repos_or_orgs = var.repos_or_orgs
}))
content_base64 = local.docker_compose_config

depends_on = [
module.runner,
Expand Down
10 changes: 10 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ variable "runner_labels" {
default = ""
}

variable "docker_compose_yaml_override" {
description = <<-EOT
This var allows the downstream module to override the docker-compose.yaml template used by this module.
When you set this variable, you own the docker compose stack for the runner."
Validate your docker-compose.yaml and pass it as a string. This module will bas64encode it.
EOT
type = string
default = null
}

################################################################################
## security
################################################################################
Expand Down