terraform-aws-gitlab-runner icon indicating copy to clipboard operation
terraform-aws-gitlab-runner copied to clipboard

cancel-spot-instances.sh fails in Terraform container

Open Leonidimus opened this issue 3 years ago • 2 comments
trafficstars

This module "npalm/gitlab-runner/aws" is meant to be run in a Terraform container, however script bin/cancel-spot-instances.sh doesn't work because it requires bash which doesn't exist in Terraform images. Terraform images only have sh. Besides, the script also requires jq and awscli which don't exist either in Terraform alpine based images.

I get this error:

│ Error: local-exec provisioner error
│ 
│   with null_resource.cancel_spot_requests,
│   on main.tf line 142, in resource "null_resource" "cancel_spot_requests":
│  142:   provisioner "local-exec" {
│ 
│ Error running command
│ './.terraform/modules/gitlab-runner/bin/cancel-spot-instances.sh
│ voice-runners': exit status 127. Output: env: can't execute 'bash': No such
│ file or directory

Leonidimus avatar May 20 '22 20:05 Leonidimus

Thanks for reporting. I see not another way to cancel spot instances when destroy than using a local executor. We could explore the following options:

  • Run in /bin/sh
  • Add an op-out flag for the script

npalm avatar May 20 '22 20:05 npalm

As far as I remember this null_resource has been removed some time ago. Could you please check the module version you are using? Any chance to update to 5.0.2?

EDIT: Ah, I see. This null_resource is introduced in the examples.

kayman-mk avatar Jun 19 '22 11:06 kayman-mk

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days.

github-actions[bot] avatar Jan 01 '23 03:01 github-actions[bot]

To be tackled in #623 as we need an option to remove resources created during runtime.

kayman-mk avatar Jan 01 '23 15:01 kayman-mk

The script will be removed. A Lambda function will handle the cancellation of spot instances when the agent is shutdown.

kayman-mk avatar Jan 10 '23 22:01 kayman-mk

The script was created to support the examples (for testing purpose).

npalm avatar Jan 13 '23 10:01 npalm