Skip to content

Commit 3037c54

Browse files
authored
fix: remove the null resource (#441)
* remove the null resource * amend the docs to not forget to remove the runner manually
1 parent a596aa8 commit 3037c54

File tree

2 files changed

+7
-30
lines changed

2 files changed

+7
-30
lines changed

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ module "runner" {
221221
}
222222
```
223223

224+
### Removing the module
225+
226+
Remove the module from your Terraform code and deregister the runner manually from your Gitlab instance.
224227
### Scenario: Multi-region deployment
225228

226229
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" {
252255
run_untagged = "false"
253256
maximum_timeout = "3600"
254257
}
255-
258+
256259
overrides = {
257260
name_iam_objects = "<region-specific-prefix>-gitlab-runner-iam"
258261
}
259-
262+
260263
cache_bucket_prefix = "<region-specific-prefix>"
261264
}
262265
```
263266

264267
## Examples
265268

266-
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/<example-dir>` directory.
269+
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/<example-dir>` directory. Don't forget to remove the runners manually from your Gitlab instance as soon as your are done.
267270

268271
### SSH keys
269272

@@ -307,8 +310,7 @@ terraform destroy
307310

308311
| Name | Version |
309312
|------|---------|
310-
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 3.35 |
311-
| <a name="provider_null"></a> [null](#provider\_null) | n/a |
313+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.71.0 |
312314

313315
## Modules
314316

@@ -360,12 +362,10 @@ terraform destroy
360362
| [aws_security_group_rule.runner_ping_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
361363
| [aws_ssm_parameter.runner_registration_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
362364
| [aws_ssm_parameter.runner_sentry_dsn](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ssm_parameter) | resource |
363-
| [null_resource.remove_runner](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
364365
| [aws_ami.docker-machine](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
365366
| [aws_ami.runner](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
366367
| [aws_availability_zone.runners](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zone) | data source |
367368
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
368-
| [aws_ssm_parameter.current_runner_registration_token](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
369369
| [aws_subnet.runners](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet) | data source |
370370

371371
## Inputs

main.tf

-23
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,6 @@ resource "aws_ssm_parameter" "runner_registration_token" {
2121
}
2222
}
2323

24-
# to read the current token for the null_resource. aws_ssm_parameter.runner_registration_token.value is never updated!
25-
data "aws_ssm_parameter" "current_runner_registration_token" {
26-
depends_on = [aws_ssm_parameter.runner_registration_token]
27-
28-
name = local.secure_parameter_store_runner_token_key
29-
}
30-
31-
resource "null_resource" "remove_runner" {
32-
depends_on = [aws_ssm_parameter.runner_registration_token]
33-
34-
triggers = {
35-
aws_region = var.aws_region
36-
runners_gitlab_url = var.runners_gitlab_url
37-
runner_registration_token = data.aws_ssm_parameter.current_runner_registration_token.value
38-
}
39-
40-
provisioner "local-exec" {
41-
when = destroy
42-
on_failure = continue
43-
command = "curl -sS --request DELETE \"${self.triggers.runners_gitlab_url}/api/v4/runners\" --form \"token=${self.triggers.runner_registration_token}\""
44-
}
45-
}
46-
4724
resource "aws_ssm_parameter" "runner_sentry_dsn" {
4825
name = local.secure_parameter_store_runner_sentry_dsn
4926
type = "SecureString"

0 commit comments

Comments
 (0)