Home > OS >  How to execute a bash script from null resource terraform azure
How to execute a bash script from null resource terraform azure

Time:08-12

I want to run a .sh script

  resource "null_resource" "Add_pipeline_Stages2" {
    provisioner "local-exec" {
      command= "chmod  x ${path.cwd}/../Terraform-Scripts/addpipelinestage.sh"
      interpreter = ["bash", "-command"] 

    }
    depends_on = [null_resource.iac_Configuration]
  }

but I got this error:

bash: line 0: bash: chmod  x /home/vsts/work/1/s/Terraform/templates/../Terraform- 
Scripts/addpipelinestage.sh: invalid option name

CodePudding user response:

Since the script needs to be invoked after changing it to be executable, here is what needs to change:

resource "null_resource" "Add_pipeline_Stages2" {
  provisioner "local-exec" {
    command     = "chmod  x ${path.cwd}/../Terraform-Scripts/addpipelinestage.sh; ${path.cwd}/../Terraform-Scripts/addpipelinestage.sh"
    interpreter = ["bash", "-c"]
  }
  depends_on = [null_resource.iac_Configuration]
}
  • Related