You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add ASG lifecycle management Lambda function (#392)
This introduces an Auto Scaling Group instance termination lifecycle
hook using Lambda and related resources. The Lambda function is a Python
script that is triggered when the persistent runner instance in the ASG
is terminated. The function receives the instance ID of the "parent"
runner and queries for spawned instances that it launched to terminate.
Additionally, it will check for other "orphaned" instances that have a
`gitlab-runner-parent-id` tag that doesn't match an existing instance. This
resolves the issue where spawned instances could be orphaned when their
parent runner is terminated.
This feature is disabled by default.
The user data script is updated to provide the 'parent' instance ID as a
tag named 'gitlab-runner-parent-id' on spawned instances.
A new sub-module is provided called "terminate-workers". It is optional
to use this feature, and the input variable
`asg_terminate_lifecycle_hook_create` can be toggled `true` or `false`
for this behavior.
Copy file name to clipboardExpand all lines: README.md
+32
Original file line number
Diff line number
Diff line change
@@ -143,6 +143,19 @@ Once you have created the parameter, you must remove the variable `runners_token
143
143
144
144
Finally, the runner still supports the manual runner creation. No changes are required. Please keep in mind that this setup will be removed in future releases.
|[archive_file.terminate_runner_instances_lambda](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file)| data source |
|[aws_iam_policy_document.assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
315
+
|[aws_iam_policy_document.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
| <aname="input_arn_format"></a> [arn\_format](#input\_arn\_format)| ARN format to be used. May be changed to support deployment in GovCloud/China regions. |`string`|`"arn:aws"`| no |
323
350
| <aname="input_asg_delete_timeout"></a> [asg\_delete\_timeout](#input\_asg\_delete\_timeout)| Timeout when trying to delete the Runner ASG. |`string`|`"10m"`| no |
324
351
| <aname="input_asg_max_instance_lifetime"></a> [asg\_max\_instance\_lifetime](#input\_asg\_max\_instance\_lifetime)| The seconds before an instance is refreshed in the ASG. |`number`|`null`| no |
352
+
| <aname="input_asg_terminate_lifecycle_hook_create"></a> [asg\_terminate\_lifecycle\_hook\_create](#input\_asg\_terminate\_lifecycle\_hook\_create)| Boolean toggling the creation of the ASG instance terminate lifecycle hook. |`bool`|`true`| no |
353
+
| <aname="input_asg_terminate_lifecycle_hook_heartbeat_timeout"></a> [asg\_terminate\_lifecycle\_hook\_heartbeat\_timeout](#input\_asg\_terminate\_lifecycle\_hook\_heartbeat\_timeout)| The amount of time, in seconds, for the instances to remain in wait state. |`number`|`90`| no |
354
+
| <aname="input_asg_terminate_lifecycle_hook_name"></a> [asg\_terminate\_lifecycle\_hook\_name](#input\_asg\_terminate\_lifecycle\_hook\_name)| Specifies a custom name for the ASG terminate lifecycle hook and related resources. |`string`|`null`| no |
355
+
| <aname="input_asg_terminate_lifecycle_lambda_memory_size"></a> [asg\_terminate\_lifecycle\_lambda\_memory\_size](#input\_asg\_terminate\_lifecycle\_lambda\_memory\_size)| The memory size in MB to allocate to the terminate-instances Lambda function. |`number`|`128`| no |
356
+
| <aname="input_asg_terminate_lifecycle_lambda_timeout"></a> [asg\_terminate\_lifecycle\_lambda\_timeout](#input\_asg\_terminate\_lifecycle\_lambda\_timeout)| Amount of time the terminate-instances Lambda Function has to run in seconds. |`number`|`30`| no |
| <aname="input_cache_bucket"></a> [cache\_bucket](#input\_cache\_bucket)| Configuration to control the creation of the cache bucket. By default the bucket will be created and used as shared cache. To use the same cache across multiple runners disable the creation of the cache and provide a policy and bucket name. See the public runner example for more details. |`map(any)`| <pre>{<br> "bucket": "",<br> "create": true,<br> "policy": ""<br>}</pre> | no |
327
359
| <aname="input_cache_bucket_name_include_account_id"></a> [cache\_bucket\_name\_include\_account\_id](#input\_cache\_bucket\_name\_include\_account\_id)| Boolean to add current account ID to cache bucket name. |`bool`|`true`| no |
0 commit comments