-
-
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
21 changed files
with
202 additions
and
6 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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# Compiled files | ||
*.tfstate | ||
*.tfstate.backup | ||
*.tfstate* | ||
|
||
# Module directory | ||
.terraform/ | ||
|
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
File renamed without changes.
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 - Runner - Private subnets | ||
|
||
Example how create a gitlab runner, running in a private subnet. | ||
|
||
## 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. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.7 |
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 - Runner - Public subnets | ||
|
||
Example how create a gitlab runner, running in a public subnet. | ||
|
||
## 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
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,40 @@ | ||
module "vpc" { | ||
source = "terraform-aws-modules/vpc/aws" | ||
version = "1.37.0" | ||
|
||
name = "vpc-${var.environment}" | ||
cidr = "10.1.0.0/16" | ||
|
||
azs = ["eu-west-1a"] | ||
public_subnets = ["10.1.101.0/24"] | ||
|
||
tags = { | ||
Environment = "${var.environment}" | ||
} | ||
} | ||
|
||
module "runner" { | ||
source = "../../" | ||
|
||
aws_region = "${var.aws_region}" | ||
environment = "${var.environment}" | ||
|
||
ssh_public_key = "${local_file.public_ssh_key.content}" | ||
|
||
runners_use_private_address = false | ||
|
||
vpc_id = "${module.vpc.vpc_id}" | ||
subnet_id_gitlab_runner = "${element(module.vpc.public_subnets, 0)}" | ||
subnet_id_runners = "${element(module.vpc.public_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 = "1.23" | ||
} | ||
|
||
provider "template" { | ||
version = "1.0" | ||
} | ||
|
||
provider "local" { | ||
version = "1.1" | ||
} | ||
|
||
provider "null" { | ||
version = "1.0" | ||
} | ||
|
||
provider "tls" { | ||
version = "1.1" | ||
} |
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 @@ | ||
key_name = "gitlab-runner" | ||
|
||
environment = "runner-public" | ||
|
||
aws_region = "eu-west-1" | ||
|
||
# Add the following variables: | ||
runner_name = "docker.m3" | ||
|
||
gitlab_url = "https://gitlab.com" | ||
|
||
runner_token = "3939146918cced54ecf1dd08e6b87e" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": "iam:CreateServiceLinkedRole", | ||
"Resource": "arn:aws:iam::*:role/aws-service-role/*" | ||
} | ||
] | ||
} |
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