diff --git a/bin/cml-cloud-runner-entrypoint.js b/bin/cml-cloud-runner-entrypoint.js index 9640f9540..a07d305b0 100755 --- a/bin/cml-cloud-runner-entrypoint.js +++ b/bin/cml-cloud-runner-entrypoint.js @@ -15,6 +15,7 @@ const { RUNNER_EXECUTOR = 'shell', RUNNER_RUNTIME = '', RUNNER_IMAGE = 'dvcorg/cml:latest', + RUNNER_TF_NAME, RUNNER_DRIVER, RUNNER_REPO, @@ -49,8 +50,11 @@ const shutdown_host = async () => { try { console.log('Terraform destroy...'); try { + const tf_resource = RUNNER_TF_NAME ? `-target=${RUNNER_TF_NAME}` : ''; console.log( - await exec('cd / && terraform init && terraform destroy -auto-approve') + await exec( + `cd / && terraform init && terraform destroy -auto-approve ${tf_resource}` + ) ); } catch (err) { console.log(`Failed destroying terraform: ${err.message}`); diff --git a/bin/cml-cloud-runner.js b/bin/cml-cloud-runner.js index 73a3819b3..85bb76a41 100644 --- a/bin/cml-cloud-runner.js +++ b/bin/cml-cloud-runner.js @@ -108,6 +108,7 @@ const setup_runners = async (opts) => { -e AWS_ACCESS_KEY_ID=${process.env.AWS_ACCESS_KEY_ID} \ -v $(pwd)/terraform.tfstate:/terraform.tfstate \ -v $(pwd)/main.tf:/main.tf \ + -e "RUNNER_TF_NAME=iterative_machine.${resource.name}" \ -e "repo_token=${repo_token}" \ -e "RUNNER_REPO=${runner_repo}" \ -e "RUNNER_DRIVER=${driver}" \