Open jlomba09 opened 5 hours ago
Hi, based on the log message, it looks like it is a message from terrafrom executable, can you confirm that are set env variables to flag that terraform is executed in automation:
TF_INPUT = "0"
TF_IN_AUTOMATION = "1"
# somewhere in Jenkins file
environment {
TF_INPUT = "0"
TF_IN_AUTOMATION = "1"
}
Hi @denis256 - thanks for the quick reply. Those environment variables are not set in the pipeline. I was able to work around this by using:
sh "echo 'yes' | terragrunt --terragrunt-non-interactive init"
It proceeds with the S3/DynamoDB creation but would be nice if the flag answers yes to all prompts as it's supposed to do.
Describe the bug
When running terragrunt init --terragrunt-non-interactive in a Jenkins pipeline, Terragrunt still asks for a yes/no confirmation:
"Do you want to copy existing state to the new backend?" Pre-existing state was found while migrating the previous local backend to newly configured "s3" backend. No existing state was found in the newly configured "s3" backend. Do you want to copy this state to the new "s3" backend? Enter "yes" to copy and "no" to start with an empty state.
Steps To Reproduce
Create a Jenkins pipeline with the following stage: stage("Initialize terraform") { steps { script { dir("terraform") { sh "terragrunt init --terragrunt-non-interactive" } } }
remote_state { backend = "s3" generate = { path = "backend.tf" if_exists = "overwrite" } config = { bucket = "jenkins-ansible-demo-tf-state" key = "ansible/terraform.tfstate" region = "us-east-1" encrypt = true dynamodb_table = "jenkins-ansible-demo-lock-table" } }
Expected behavior
The terragrunt init --terragrunt-non-interactive command should answer yes to all prompts.
Nice to haves
Versions
Additional context
Add any other context about the problem here.