diff --git a/CHANGELOG.md b/CHANGELOG.md index 953be0b0a..a572d6da9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [2.2.1] - 2019-03-19 +- Bugfix: Add tags to spot instances #39 +- Changed: Updated terraform providers in examples and default terraform version + ## [2.2.0] - 2019-03-08 - Changed: Upgrade default runner agent to 11.8.0 and docker machine to 0.16.1 - Bugfix: Correct example for docker_machine_options #36 (@declension) @@ -94,7 +98,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Update default AMI's to The latest Amazon Linux AMI 2017.09.1 - released on 2018-01-17. - Minor updates in the example -[Unreleased]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/2.2.0...HEAD +[Unreleased]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/2.2.1...HEAD +[2.2.1]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/2.2.0...2.2.1 [2.2.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/2.1.0...2.2.0 [2.1.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/2.0.0...2.1.0 [2.0.0]: https://github.com/npalm/terraform-aws-gitlab-runner/compare/1.8.0...2.0.0 diff --git a/README.md b/README.md index b5a9d6998..660487ff8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Build Status](https://travis-ci.com/npalm/terraform-aws-gitlab-runner.svg?branch=master)](https://travis-ci.com/npalm/terraform-aws-gitlab-runner) +[![Gitter](https://badges.gitter.im/terraform-aws-gitlab-runner/Lobby.svg)](https://gitter.im/terraform-aws-gitlab-runner/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) # Terraform module for GitLab auto scaling runners on Spot instances @@ -157,7 +158,7 @@ module "gitlab-runner" { | ssh_public_key | Public SSH key used for the gitlab-runner ec2 instance. | string | - | yes | | subnet_id_runners | Subnet used to hosts the docker-machine runners. | string | - | yes | | subnet_ids_gitlab_runner | Subnet used for hosting the gitlab-runner. | list | - | yes | -| tags | Map of tags that will be added to created resources. By default resources will be taggen with name and environemnt. | map | `` | no | +| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environnemnt. | map | `` | no | | userdata_post_install | User-data script snippet to insert after gitlab-runner install | string | `` | no | | userdata_pre_install | User-data script snippet to insert before gitlab-runner install | string | `` | no | | vpc_id | The VPC that is used for the instances. | string | - | yes | diff --git a/ci/bin/run-local.sh b/ci/bin/run-local.sh index f7488f4a1..c0b00cde4 100755 --- a/ci/bin/run-local.sh +++ b/ci/bin/run-local.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash -docker run --entrypoint="/bin/sh" -it --rm -w /build -v $(pwd):/build hashicorp/terraform:0.11.7 ./ci/bin/verify.sh -docker run --entrypoint="/bin/sh" -it --rm -w /build -v $(pwd):/build hashicorp/terraform:0.11.7 ./ci/bin/verify-examples.sh +docker run --entrypoint="/bin/sh" -it --rm -w /build -v $(pwd):/build hashicorp/terraform:0.11.13 ./ci/bin/verify.sh +docker run --entrypoint="/bin/sh" -it --rm -w /build -v $(pwd):/build hashicorp/terraform:0.11.13 ./ci/bin/verify-examples.sh diff --git a/ci/bin/terraform.sh b/ci/bin/terraform.sh index 1ed7237a3..0ef4d469e 100755 --- a/ci/bin/terraform.sh +++ b/ci/bin/terraform.sh @@ -3,7 +3,7 @@ TARGET_DIR=/opt PATH=${PATH}:${TARGET_DIR} -TERRAFORM_VERSION=${1:-"0.11.7"} +TERRAFORM_VERSION=${1:-"0.11.13"} OS=${2:-"linux"} TERRAFORM_URL="https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_${OS}_amd64.zip" diff --git a/examples/runner-default/.terraform-version b/examples/runner-default/.terraform-version index b80f98e66..44ab23e43 100644 --- a/examples/runner-default/.terraform-version +++ b/examples/runner-default/.terraform-version @@ -1 +1 @@ -0.11.7 +0.11.13 diff --git a/examples/runner-default/main.tf b/examples/runner-default/main.tf index f1da0bbbe..0cb2fdba7 100644 --- a/examples/runner-default/main.tf +++ b/examples/runner-default/main.tf @@ -1,6 +1,6 @@ module "vpc" { source = "terraform-aws-modules/vpc/aws" - version = "1.37.0" + version = "1.59.0" name = "vpc-${var.environment}" cidr = "10.0.0.0/16" diff --git a/examples/runner-default/providers.tf b/examples/runner-default/providers.tf index 448ccd70f..21363a663 100644 --- a/examples/runner-default/providers.tf +++ b/examples/runner-default/providers.tf @@ -1,10 +1,10 @@ provider "aws" { region = "${var.aws_region}" - version = "1.23" + version = "2.2" } provider "template" { - version = "1.0" + version = "2.1" } provider "local" { @@ -12,9 +12,9 @@ provider "local" { } provider "null" { - version = "1.0" + version = "2.1" } provider "tls" { - version = "1.1" + version = "1.2" } diff --git a/examples/runner-docker/.terraform-version b/examples/runner-docker/.terraform-version index b80f98e66..44ab23e43 100644 --- a/examples/runner-docker/.terraform-version +++ b/examples/runner-docker/.terraform-version @@ -1 +1 @@ -0.11.7 +0.11.13 diff --git a/examples/runner-docker/main.tf b/examples/runner-docker/main.tf index a6360d07d..e9ae9cf84 100644 --- a/examples/runner-docker/main.tf +++ b/examples/runner-docker/main.tf @@ -1,6 +1,6 @@ module "vpc" { source = "terraform-aws-modules/vpc/aws" - version = "1.37.0" + version = "1.59.0" name = "vpc-${var.environment}" cidr = "10.1.0.0/16" diff --git a/examples/runner-docker/providers.tf b/examples/runner-docker/providers.tf index 448ccd70f..21363a663 100644 --- a/examples/runner-docker/providers.tf +++ b/examples/runner-docker/providers.tf @@ -1,10 +1,10 @@ provider "aws" { region = "${var.aws_region}" - version = "1.23" + version = "2.2" } provider "template" { - version = "1.0" + version = "2.1" } provider "local" { @@ -12,9 +12,9 @@ provider "local" { } provider "null" { - version = "1.0" + version = "2.1" } provider "tls" { - version = "1.1" + version = "1.2" } diff --git a/examples/runner-public/.terraform-version b/examples/runner-public/.terraform-version index b80f98e66..44ab23e43 100644 --- a/examples/runner-public/.terraform-version +++ b/examples/runner-public/.terraform-version @@ -1 +1 @@ -0.11.7 +0.11.13 diff --git a/examples/runner-public/main.tf b/examples/runner-public/main.tf index 4ec067058..f44d33f25 100644 --- a/examples/runner-public/main.tf +++ b/examples/runner-public/main.tf @@ -1,6 +1,6 @@ module "vpc" { source = "terraform-aws-modules/vpc/aws" - version = "1.37.0" + version = "1.59.0" name = "vpc-${var.environment}" cidr = "10.1.0.0/16" diff --git a/examples/runner-public/providers.tf b/examples/runner-public/providers.tf index 448ccd70f..21363a663 100644 --- a/examples/runner-public/providers.tf +++ b/examples/runner-public/providers.tf @@ -1,10 +1,10 @@ provider "aws" { region = "${var.aws_region}" - version = "1.23" + version = "2.2" } provider "template" { - version = "1.0" + version = "2.1" } provider "local" { @@ -12,9 +12,9 @@ provider "local" { } provider "null" { - version = "1.0" + version = "2.1" } provider "tls" { - version = "1.1" + version = "1.2" } diff --git a/main.tf b/main.tf index b51aa9972..8675d74a0 100644 --- a/main.tf +++ b/main.tf @@ -101,21 +101,19 @@ data "template_file" "runners" { template = "${file("${path.module}/template/runner-config.tpl")}" vars { - aws_region = "${var.aws_region}" - gitlab_url = "${var.runners_gitlab_url}" - environment = "${var.environment}" - - runners_vpc_id = "${var.vpc_id}" - runners_subnet_id = "${var.subnet_id_runners}" - runners_aws_zone = "${var.aws_zone}" - runners_instance_type = "${var.docker_machine_instance_type}" - runners_spot_price_bid = "${var.docker_machine_spot_price_bid}" - runners_security_group_name = "${aws_security_group.docker_machine.name}" - runners_monitoring = "${var.runners_monitoring}" - - docker_machine_options = "${length(var.docker_machine_options) == 0 ? "" : local.docker_machine_options_string}" - + aws_region = "${var.aws_region}" + gitlab_url = "${var.runners_gitlab_url}" + + runners_vpc_id = "${var.vpc_id}" + runners_subnet_id = "${var.subnet_id_runners}" + runners_aws_zone = "${var.aws_zone}" + runners_instance_type = "${var.docker_machine_instance_type}" + runners_spot_price_bid = "${var.docker_machine_spot_price_bid}" + runners_security_group_name = "${aws_security_group.docker_machine.name}" + runners_monitoring = "${var.runners_monitoring}" + docker_machine_options = "${length(var.docker_machine_options) == 0 ? "" : local.docker_machine_options_string}" runners_name = "${var.runners_name}" + runners_tags = "${local.tags_string}" runners_token = "${var.runners_token}" runners_executor = "${var.runners_executor}" runners_limit = "${var.runners_limit}" diff --git a/tags.tf b/tags.tf index 61166b089..d2fee7c4b 100644 --- a/tags.tf +++ b/tags.tf @@ -2,6 +2,8 @@ locals { tags = "${merge(map("Name", format("%s", var.environment)), map("Environment", format("%s", var.environment)), var.tags)}" + + tags_string = "${replace(replace(jsonencode(local.tags), "/[\\{\\}\"\\s]/", ""), ":", ",")}" } data "null_data_source" "tags" { diff --git a/template/runner-config.tpl b/template/runner-config.tpl index 4537aff7e..7ac0fdc3c 100644 --- a/template/runner-config.tpl +++ b/template/runner-config.tpl @@ -42,7 +42,7 @@ check_interval = 0 "amazonec2-request-spot-instance=true", "amazonec2-spot-price=${runners_spot_price_bid}", "amazonec2-security-group=${runners_security_group_name}", - "amazonec2-tags=environment,${environment}", + "amazonec2-tags=${runners_tags}", "amazonec2-monitoring=${runners_monitoring}", "amazonec2-root-size=${runners_root_size}" ${docker_machine_options}