How to fork step process and make new process running within the same enviroment?


I’m running terraform from my Github Actions workflow. One of my Terraform resources uses a ‘post-create’ step to run a bash command.

resource "google\_endpoints\_service" "openapi\_service" {
service\_name = replace(var.espService.url, "https://", "")
project = var.project\_id  
 openapi\_config = var.config  
 provisioner "local-exec" {  
 command = "gcloud beta run services update ${} --set-env-vars ENDPOINTS\_SERVICE\_NAME=${self.service\_name} --project ${var.project\_id} --platform=managed --region=${var.region}"  
 interpreter = ["/bin/bash", "-c"]  

So this invokes the following bash command 

cloud beta run services update ${} --set-env-vars ENDPOINTS_SERVICE_NAME=${self.service_name} --project ${var.project_id} --platform=managed --region=${var.region}

Please note that the command is initiated by Terraform process (job step) and not by the Github Action runner  (from workflow yaml).

It turns out that my command gets started within a completely different enviroment, perfectly ‘clean’. I don’t have access to previously installed Google SDK (gcloud). Though if run same command from my workflow yaml it works just fine.

- name Run command
 run: gcloud beta run services update $ESP_NAME --set-env-vars ENDPOINTS_SERVICE_NAME=$ENDPOINT --project $PROJECT --platform=managed

Is there a way to run bash command from inside the Job Step process so that it runs within the same enviroment and have access to the same ‘resources’ as command started with run: … from workflow yaml ?

Do you use this Terraform GitHub Actions? As this is a Docker Container action, if you run post-create bash command inside this step, it is executed on docker container not on the github actions runner machine. So when you run scripts in next steps, the environment will change, it will use runner machine environment , not the Terraform docker container.  
If this doesn’t match your scenario, could you pleaseenable step debug logging and share your workflow yaml and workflow run logs here? 


Yes I use Terraform GitHub Actions.

Hm … do you know if there is any alternative to Terraform GitHub Actions which is not a docker based? this is quite an annoying limitattion as having access to local-exec would be userful.

Thank you for the reply!

Sorry to tell you that I don’t know an alternative to that docker container Terraform action. What’s the insufficient of

running  gcloud  command from your workflow yaml ? 

yeah that’s what I finally went for! 

Thank you.