-
-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
462 additions
and
170 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ | |
config-terraform.sh | ||
|
||
*.out | ||
example/*.secrets*.tfvars | ||
*.secrets*.tfvars |
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 @@ | ||
terraform.tfvars |
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 @@ | ||
# Examples | ||
|
||
Please see the readme in per example for more details: | ||
|
||
- [runner-default] The default setup, private subnet, auto register, runner on spot instances. | ||
- [runner-public] Runner in a public subnet, auto register, runner on spot instances. | ||
- [runner-docker] Runners run on the same instance as the agent. | ||
- [runner-pre-registered] Runner needs to be preregistered, old setup DEPRECATED. |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Example - Runner - Private subnets | ||
# Example - Spot Runner - Private subnets | ||
|
||
Example how create a gitlab runner, running in a private subnet. | ||
Example how to run builds on spot instnaces in a private subent. | ||
|
||
## Prerequisite | ||
The terraform version is managed using [tfenv](https://github.com/Zordrak/tfenv). If you are not using tfenv please check `.terraform-version` for the tested version. |
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 @@ | ||
0.11.13 |
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,6 @@ | ||
# Example - Spot Runner - Private subnets | ||
|
||
This is the previous default example. For this example you need to register the runner before running terraform and provide the runner token. Since version 3+ the runner can register itself by providing the registration token. This examples is to show case backwards compatibility. | ||
|
||
## Prerequisite | ||
The terraform version is managed using [tfenv](https://github.com/Zordrak/tfenv). If you are not using tfenv please check `.terraform-version` for the tested version. |
Empty file.
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,25 @@ | ||
resource "tls_private_key" "ssh" { | ||
algorithm = "RSA" | ||
} | ||
|
||
resource "local_file" "public_ssh_key" { | ||
depends_on = ["tls_private_key.ssh"] | ||
|
||
content = "${tls_private_key.ssh.public_key_openssh}" | ||
filename = "${var.public_ssh_key_filename}" | ||
} | ||
|
||
resource "local_file" "private_ssh_key" { | ||
depends_on = ["tls_private_key.ssh"] | ||
|
||
content = "${tls_private_key.ssh.private_key_pem}" | ||
filename = "${var.private_ssh_key_filename}" | ||
} | ||
|
||
resource "null_resource" "file_permission" { | ||
depends_on = ["local_file.private_ssh_key"] | ||
|
||
provisioner "local-exec" { | ||
command = "${format("chmod 600 %s", var.private_ssh_key_filename)}" | ||
} | ||
} |
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,44 @@ | ||
module "vpc" { | ||
source = "terraform-aws-modules/vpc/aws" | ||
version = "1.60.0" | ||
|
||
name = "vpc-${var.environment}" | ||
cidr = "10.0.0.0/16" | ||
|
||
azs = ["eu-west-1a"] | ||
private_subnets = ["10.0.1.0/24"] | ||
public_subnets = ["10.0.101.0/24"] | ||
|
||
enable_nat_gateway = true | ||
single_nat_gateway = true | ||
|
||
enable_s3_endpoint = true | ||
|
||
tags = { | ||
Environment = "${var.environment}" | ||
} | ||
} | ||
|
||
module "runner" { | ||
source = "../../" | ||
|
||
aws_region = "${var.aws_region}" | ||
environment = "${var.environment}" | ||
|
||
ssh_public_key = "${local_file.public_ssh_key.content}" | ||
|
||
vpc_id = "${module.vpc.vpc_id}" | ||
subnet_ids_gitlab_runner = "${module.vpc.private_subnets}" | ||
subnet_id_runners = "${element(module.vpc.private_subnets, 0)}" | ||
|
||
runners_name = "${var.runner_name}" | ||
runners_gitlab_url = "${var.gitlab_url}" | ||
runners_token = "${var.runner_token}" | ||
|
||
runners_off_peak_timezone = "Europe/Amsterdam" | ||
runners_off_peak_idle_count = 0 | ||
runners_off_peak_idle_time = 60 | ||
|
||
# working 9 to 5 :) | ||
runners_off_peak_periods = "[\"* * 0-9,17-23 * * mon-fri *\", \"* * * * * sat,sun *\"]" | ||
} |
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,20 @@ | ||
provider "aws" { | ||
region = "${var.aws_region}" | ||
version = "2.4" | ||
} | ||
|
||
provider "template" { | ||
version = "2.1" | ||
} | ||
|
||
provider "local" { | ||
version = "1.2" | ||
} | ||
|
||
provider "null" { | ||
version = "2.1" | ||
} | ||
|
||
provider "tls" { | ||
version = "1.2" | ||
} |
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,34 @@ | ||
variable "aws_region" { | ||
description = "AWS region." | ||
type = "string" | ||
default = "eu-west-1" | ||
} | ||
|
||
variable "environment" { | ||
description = "A name that indentifies the environment, will used as prefix and for taggin." | ||
default = "ci-runners" | ||
type = "string" | ||
} | ||
|
||
variable "public_ssh_key_filename" { | ||
default = "generated/id_rsa.pub" | ||
} | ||
|
||
variable "private_ssh_key_filename" { | ||
default = "generated/id_rsa" | ||
} | ||
|
||
variable "runner_name" { | ||
description = "Name of the runner, will be used in the runner config.toml" | ||
type = "string" | ||
} | ||
|
||
variable "gitlab_url" { | ||
description = "URL of the gitlab instance to connect to." | ||
type = "string" | ||
} | ||
|
||
variable "runner_token" { | ||
description = "Token for the runner, will be used in the runner config.toml" | ||
type = "string" | ||
} |
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.