我正在尝试为当前项目中包含的所有子文件夹创建backend.tf。我已经在本地系统上安装了terragrunt
$ which terragrunt
/usr/local/bin/terragrunt
$ terragrunt -version
terragrunt version v0.28.18这是我父文件夹中的terragrunt.hcl
$ cat /user_folder/user-x/terragrunt.hcl
remote_state {
backend = "gcs"
generate = {
path = "backend.tf"
if_exists = "overwrite_terragrunt"
}
config = {
bucket = "terraform-bucket"
prefix = "${path_relative_to_include()}/user_folder/user-x/terraform.tfstate"
}
}在我的子文件夹/user_folder/user-x/permissions/中,我有terragrunt.hcl
$ cat /user_folder/user-x/permissions/terragrunt.hcl
include {
path = find_in_parent_folders()
}此外,我还使用适当的JSON导出了GOOGLE_APPLICATION_CREDENTIALS。
现在当我执行
$ terragrunt plan --terragrunt-log-level debug --terragrunt-debug
DEBU[0000] Did not find any locals block: skipping evaluation.
DEBU[0000] Running command: terraform --version prefix=[/mylocalpc/git_test_repo/user-x]
DEBU[0000] Terraform version: 0.13.5
DEBU[0000] Reading Terragrunt config file at /mylocalpc/git_test_repo/user-x/terragrunt.hcl
DEBU[0000] Did not find any locals block: skipping evaluation.
DEBU[0000] The file path /mylocalpc/git_test_repo/user-x/backend.tf already exists, but was a previously generated file by terragrunt. Since if_exists for code generation is set to "overwrite_terragrunt", regenerating file.
DEBU[0000] Generated file /mylocalpc/git_test_repo/user-x/backend.tf.
INFO[0000] Debug mode requested: generating debug file terragrunt-debug.tfvars.json in working dir /mylocalpc/git_test_repo/user-x
DEBU[0000] The following variables were detected in the terraform module:
DEBU[0000] [project_name project_owner contact_group project_expiration organization_id location billing_account_id vpc_project_id folder_id gcs_location sa_role shared_vpcs]
DEBU[0000] Variables passed to terraform are located in "/mylocalpc/git_test_repo/user-x/terragrunt-debug.tfvars.json"
DEBU[0000] Run this command to replicate how terraform was invoked:
DEBU[0000] terraform plan -var-file="/mylocalpc/git_test_repo/user-x/terragrunt-debug.tfvars.json" "/mylocalpc/git_test_repo/user-x/"
DEBU[0002] Initializing remote state for the gcs backend prefix=[/mylocalpc/git_test_repo/user-x/]
DEBU[0003] Remote state GCS bucket terraform-bucket does not exist. Attempting to create it prefix=[/mylocalpc/git_test_repo/user-x/]
ERRO[0003] Missing required GCS remote state configuration project
ERRO[0003] Unable to determine underlying exit code, so Terragrunt will exit with error code 1并且GCS bucket terraform-bucket确实存在。不知道我错过了什么..。寻找善意的帮助
发布于 2021-04-22 03:58:38
因此:
ERRO[0003] Missing required GCS remote state configuration project我想你需要在运行terragrunt之前运行这些程序?
gcloud config set project <your project>
gcloud auth application-default loginhttps://stackoverflow.com/questions/66976591
复制相似问题