Skip to content

Commit 59e2d6e

Browse files
authored
fix: always add policy to maintain SSM parameters (#510)
* always add `ssm:GetParameter` and `ssm:PutParameter` policy * update docs * update docs * remove space from docs * add ignore to variable * ENABLE-MANAGE-GITLAB-TOKEN * ENABLE-MANAGE-GITLAB-TOKEN * fix count resource
1 parent 6c1180e commit 59e2d6e

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ Made with [contributors-img](https://contrib.rocks).
478478
| <a name="input_enable_docker_machine_ssm_access"></a> [enable\_docker\_machine\_ssm\_access](#input\_enable\_docker\_machine\_ssm\_access) | Add IAM policies to the docker-machine instances to connect via the Session Manager. | `bool` | `false` | no |
479479
| <a name="input_enable_eip"></a> [enable\_eip](#input\_enable\_eip) | Enable the assignment of an EIP to the gitlab runner instance | `bool` | `false` | no |
480480
| <a name="input_enable_kms"></a> [enable\_kms](#input\_enable\_kms) | Let the module manage a KMS key, logs will be encrypted via KMS. Be-aware of the costs of an custom key. | `bool` | `false` | no |
481-
| <a name="input_enable_manage_gitlab_token"></a> [enable\_manage\_gitlab\_token](#input\_enable\_manage\_gitlab\_token) | Boolean to enable the management of the GitLab token in SSM. If `true` the token will be stored in SSM, which means the SSM property is a terraform managed resource. If `false` the Gitlab token will be stored in the SSM by the user-data script during creation of the the instance. However the SSM parameter is not managed by terraform and will remain in SSM after a `terraform destroy`. | `bool` | `true` | no |
481+
| <a name="input_enable_manage_gitlab_token"></a> [enable\_manage\_gitlab\_token](#input\_enable\_manage\_gitlab\_token) | (Deprecated and ignored) Boolean to enable the management of the GitLab token in SSM. If `true` the token will be stored in SSM, which means the SSM property is a terraform managed resource. If `false` the Gitlab token will be stored in the SSM by the user-data script during creation of the the instance. However the SSM parameter is not managed by terraform and will remain in SSM after a `terraform destroy`. | `bool` | `true` | no |
482482
| <a name="input_enable_ping"></a> [enable\_ping](#input\_enable\_ping) | Allow ICMP Ping to the ec2 instances. | `bool` | `false` | no |
483483
| <a name="input_enable_runner_ssm_access"></a> [enable\_runner\_ssm\_access](#input\_enable\_runner\_ssm\_access) | Add IAM policies to the runner agent instance to connect via the Session Manager. | `bool` | `false` | no |
484484
| <a name="input_enable_runner_user_data_trace_log"></a> [enable\_runner\_user\_data\_trace\_log](#input\_enable\_runner\_user\_data\_trace\_log) | Enable bash xtrace for the user data script that creates the EC2 instance for the runner agent. Be aware this could log sensitive data such as you GitLab runner token. | `bool` | `true` | no |

main.tf

+1-3
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,6 @@ resource "aws_eip" "gitlab_runner" {
500500
### AWS Systems Manager access to store runner token once registered
501501
################################################################################
502502
resource "aws_iam_policy" "ssm" {
503-
count = var.enable_manage_gitlab_token ? 1 : 0
504-
505503
name = "${local.name_iam_objects}-ssm"
506504
path = "/"
507505
description = "Policy for runner token param access via SSM"
@@ -513,7 +511,7 @@ resource "aws_iam_role_policy_attachment" "ssm" {
513511
count = var.enable_manage_gitlab_token ? 1 : 0
514512

515513
role = var.create_runner_iam_role ? aws_iam_role.instance[0].name : local.aws_iam_role_instance_name
516-
policy_arn = aws_iam_policy.ssm[0].arn
514+
policy_arn = aws_iam_policy.ssm.arn
517515
}
518516

519517
################################################################################

variables.tf

+7-2
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,14 @@ variable "secure_parameter_store_runner_sentry_dsn" {
609609
}
610610

611611
variable "enable_manage_gitlab_token" {
612-
description = "Boolean to enable the management of the GitLab token in SSM. If `true` the token will be stored in SSM, which means the SSM property is a terraform managed resource. If `false` the Gitlab token will be stored in the SSM by the user-data script during creation of the the instance. However the SSM parameter is not managed by terraform and will remain in SSM after a `terraform destroy`."
612+
description = "(Deprecated) Boolean to enable the management of the GitLab token in SSM. If `true` the token will be stored in SSM, which means the SSM property is a terraform managed resource. If `false` the Gitlab token will be stored in the SSM by the user-data script during creation of the the instance. However the SSM parameter is not managed by terraform and will remain in SSM after a `terraform destroy`."
613613
type = bool
614-
default = true
614+
default = null
615+
616+
validation {
617+
condition = anytrue([var.enable_manage_gitlab_token == null])
618+
error_message = "Deprecated, this variable is no longer in use and can be removed."
619+
}
615620
}
616621

617622
variable "overrides" {

0 commit comments

Comments
 (0)