Skip to content

Commit

Permalink
Replace vpc in example, update README.
Browse files Browse the repository at this point in the history
  • Loading branch information
npalm committed Dec 6, 2017
1 parent 2351f3a commit dd365ba
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 27 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ On mac simple install tfenv using brew.
```
brew install tfenv
```
Next intall a terraform version.
Next install a terraform version.
```
tfenv install <version>
```
Expand All @@ -34,24 +34,24 @@ Currently register a new runner is a manual process. See the GitLab Runner [docu
```
docker run -it --rm gitlab/gitlab-runner register
```
Provide the details in the interactive terminal. Once done the token cen found in the GitLab runners section, choose edit to get the token or see the config.toml file.
Provide the details in the interactive terminal. Once done the token can be found in the GitLab runners section, choose edit to get the token or see the config.toml file.


## Usage

### Configuration
Update the variables in `terraform.tfvars` to your needs and add the folling variables, see prevous step for how to obtain the token.
Update the variables in `terraform.tfvars` to your needs and add the following variables, see previous step for how to obtain the token.
```
runner_name = "NAME_OF_YOUR_RUNNER"
gitlab_url = "GIT_LAB_URL"
runner_token = "RUNNER_TOKEN"
runner_name = "NAME_OF_YOUR_RUNNER"
gitlab_url = "GIT_LAB_URL"
runner_token = "RUNNER_TOKEN"
```


### Usage module.
```
module "runner" {
source = "https://github.com/npalm/terraform-aws-gitlab-runner.git"
source = "npalm/gitlab-runner/aws"
aws_region = "${var.aws_region}"
environment = "${var.environment}"
Expand All @@ -78,8 +78,8 @@ All variables and defaults:
| docker_machine_instance_type | Instance type used for the instances hosting docker-machine. | string | `m4.large` | no |
| docker_machine_spot_price_bid | Spot price bid. | string | `0.03` | no |
| docker_machine_user | User name for the user to create spot instances to host docker-machine. | string | `docker-machine` | no |
| enable_cloudwatch_logging | Enable or disable the cloudwatch logging. | string | `0` | no |
| environment | A name that indentifies the environment, will used as prefix and for taggin. | string | - | yes |
| enable_cloudwatch_logging | Enable or disable the CloudWatch logging. | string | `1` | no |
| environment | A name that identifies the environment, will used as prefix and for tagging. | string | - | yes |
| gitlab_runner_version | Version for the gitlab runner. | string | `10.2.0` | no |
| instance_type | Instance type used for the gitlab-runner. | string | `t2.micro` | no |
| runners_concurrent | Concurrent value for the runners, will be used in the runner config.toml | string | `10` | no |
Expand Down Expand Up @@ -110,11 +110,11 @@ docker run -it --rm gitlab/gitlab-runner register
Once done, lookup the token in GitLab and update the `terraform.tfvars` file.

## Create runner
Run `terraform init` to initialize terraform. Next you can run `terraform plan` to inspect the resources that will be created.
Run `terraform init` to initialise terraform. Next you can run `terraform plan` to inspect the resources that will be created.

To create the runner run:
```
terrafrom apply
terraform apply
```
To destroy runner:
```
Expand Down
File renamed without changes.
33 changes: 19 additions & 14 deletions example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,35 @@ provider "template" {
}

module "vpc" {
source = "git::https://github.com/npalm/tf-aws-vpc.git?ref=1.0.0"
source = "terraform-aws-modules/vpc/aws"
version = "1.5.1"

aws_region = "${var.aws_region}"
environment = "${var.environment}"
name = "vpc-${var.environment}"
cidr = "10.0.0.0/16"

create_private_hosted_zone = "true"
create_private_subnets = "true"
azs = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"]

availability_zones = {
us-east-1 = ["us-east-1a"]
eu-west-1 = ["eu-west-1a"]
enable_nat_gateway = true

tags = {
Environment = "${var.environment}"
}
}

module "runner" {
source = "../"

aws_region = "${var.aws_region}"
environment = "${var.environment}"
ssh_public_key = "${file("${var.ssh_key_file}")}"
aws_region = "${var.aws_region}"
environment = "${var.environment}"
ssh_public_key = "${file("${var.ssh_key_file}")}"

vpc_id = "${module.vpc.vpc_id}"
subnet_id_gitlab_runner = "${element(module.vpc.private_subnets, 0)}"
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_name = "${var.runner_name}"
runners_gitlab_url = "${var.gitlab_url}"
runners_token = "${var.runner_token}"
}
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ resource "aws_launch_configuration" "gitlab_runner_instance" {
instance_type = "${var.instance_type}"
iam_instance_profile = "${aws_iam_instance_profile.instance.name}"

associate_public_ip_address = false

lifecycle {
create_before_destroy = true
}
Expand Down
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ variable "aws_region" {
}

variable "environment" {
description = "A name that indentifies the environment, will used as prefix and for taggin."
description = "A name that identifies the environment, will used as prefix and for tagging."
type = "string"
}

Expand Down Expand Up @@ -132,6 +132,6 @@ variable "gitlab_runner_version" {
}

variable "enable_cloudwatch_logging" {
description = "Enable or disable the cloudwatch logging."
description = "Enable or disable the CloudWatch logging."
default = 1
}

0 comments on commit dd365ba

Please sign in to comment.