From 3037c54592c0ab3692b6f7eafda485c104267354 Mon Sep 17 00:00:00 2001 From: Matthias Kay Date: Sun, 27 Feb 2022 16:03:48 +0100 Subject: [PATCH] fix: remove the null resource (#441) * remove the null resource * amend the docs to not forget to remove the runner manually --- README.md | 14 +++++++------- main.tf | 23 ----------------------- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 6259bf0f9..868857474 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,9 @@ module "runner" { } ``` +### Removing the module + +Remove the module from your Terraform code and deregister the runner manually from your Gitlab instance. ### Scenario: Multi-region deployment Name clashes due to multi-region deployments for global AWS ressources create by this module (IAM, S3) can be avoided by including a distinguishing region specific prefix via the _cache_bucket_prefix_ string respectively via _name_iam_objects_ in the _overrides_ map. A simple example for this would be to set _region-specific-prefix_ to the AWS region the module is deployed to. @@ -252,18 +255,18 @@ module "runner" { run_untagged = "false" maximum_timeout = "3600" } - + overrides = { name_iam_objects = "-gitlab-runner-iam" } - + cache_bucket_prefix = "" } ``` ## Examples -A few [examples](https://github.com/npalm/terraform-aws-gitlab-runner/tree/develop/examples/) are provided. Use the following steps to deploy. Ensure your AWS and Terraform environment is set up correctly. All commands below should be run from the `terraform-aws-gitlab-runner/examples/` directory. +A few [examples](https://github.com/npalm/terraform-aws-gitlab-runner/tree/develop/examples/) are provided. Use the following steps to deploy. Ensure your AWS and Terraform environment is set up correctly. All commands below should be run from the `terraform-aws-gitlab-runner/examples/` directory. Don't forget to remove the runners manually from your Gitlab instance as soon as your are done. ### SSH keys @@ -307,8 +310,7 @@ terraform destroy | Name | Version | |------|---------| -| [aws](#provider\_aws) | ~> 3.35 | -| [null](#provider\_null) | n/a | +| [aws](#provider\_aws) | 3.71.0 | ## Modules @@ -360,12 +362,10 @@ terraform destroy | [aws_security_group_rule.runner_ping_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource | | [aws_ssm_parameter.runner_registration_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource | | [aws_ssm_parameter.runner_sentry_dsn](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource | -| [null_resource.remove_runner](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | | [aws_ami.docker-machine](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | | [aws_ami.runner](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source | | [aws_availability_zone.runners](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zone) | data source | | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | -| [aws_ssm_parameter.current_runner_registration_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source | | [aws_subnet.runners](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet) | data source | ## Inputs diff --git a/main.tf b/main.tf index 59eb6bde1..de9133a70 100644 --- a/main.tf +++ b/main.tf @@ -21,29 +21,6 @@ resource "aws_ssm_parameter" "runner_registration_token" { } } -# to read the current token for the null_resource. aws_ssm_parameter.runner_registration_token.value is never updated! -data "aws_ssm_parameter" "current_runner_registration_token" { - depends_on = [aws_ssm_parameter.runner_registration_token] - - name = local.secure_parameter_store_runner_token_key -} - -resource "null_resource" "remove_runner" { - depends_on = [aws_ssm_parameter.runner_registration_token] - - triggers = { - aws_region = var.aws_region - runners_gitlab_url = var.runners_gitlab_url - runner_registration_token = data.aws_ssm_parameter.current_runner_registration_token.value - } - - provisioner "local-exec" { - when = destroy - on_failure = continue - command = "curl -sS --request DELETE \"${self.triggers.runners_gitlab_url}/api/v4/runners\" --form \"token=${self.triggers.runner_registration_token}\"" - } -} - resource "aws_ssm_parameter" "runner_sentry_dsn" { name = local.secure_parameter_store_runner_sentry_dsn type = "SecureString"