gpt4 book ai didi

指定模块时 terraform init 不起作用

转载 作者:行者123 更新时间:2023-12-04 12:41:46 25 4
gpt4 key购买 nike

我是 terraform 的新手,并试图解决我在测试模块时面临的一个小问题。

以下是我在本地计算机中的文件夹结构。

enter image description here

我在存储文件夹级别有以下代码

#-------storage/main.tf

provider "aws" {
region = "us-east-1"
}

resource "aws_s3_bucket" "my-first-terraform-bucket" {
bucket = "first-terraform-bucket"
acl = "private"
force_destroy = true
}

下面来自 main_code 级别引用存储模块的片段
#-------main_code/main.tf

module "storage" {
source = "../storage"
}

当我从存储文件夹发出 terraform init/plan/apply 时,它工作得很好,并且 terraform 创建了 s3 存储桶。

但是,当我从 main_code 文件夹尝试相同的操作时,出现以下错误 -
main_code@DFW11-8041WL3: terraform init
Initializing modules...
- module.storage
Error downloading modules: Error loading modules: module storage: No Terraform configuration files found in directory: .terraform/modules/0d1a7f4efdea90caaf99886fa2f65e95

我在堆栈溢出和其他 github 问题论坛上阅读了许多问题板,但没有帮助解决这个问题。不知道我错过了什么!

最佳答案

只需通过运行 terraform get --update 更新现有模块.如果这不起作用,请删除 .terraform 文件夹。

关于指定模块时 terraform init 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54637346/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com