Terraform模块无法正常工作
我们正在为我们的项目使用私人github和Terraform云。一切都可以互相交谈,因此没有问题。但是,我正在尝试为我启动的项目创建模块。我能够使其作为常规Terraform文件工作,但是当我尝试将其转换为模块系统时,我在导入州时遇到问题。
我们有一个单独的存储库,称为TF-MODULES。在此存储库中,我的目录设置:
> root
>> mymodule
>>> lambda.tf
>>> eventbridge.tf
>>> bucket.tf
这些文件管理要在我们的AWS环境中部署的软件。它们在多个环境中用于我们的每个客户(每个客户都被环境[QA,DEV,PORD]分开)。
在我的Terraform文件中,我有:
> root
>> CUSTNAME
>>> mymodule
>>>> main.tf
内部Main.tf我有:
module "mymodule" {
source = "git::https://github.com/myprivaterepo/tf-modules.git"
}
在我的开发环境中,一切都设置了,因此我需要导入状态。但是,它根本没有检测到资源。在.trraform目录中,它正在下载整个存储库(带有readme.md和所有内容的根)
我是Terraform的新手。我是在处理这个错误还是误解?
我正在使用最新版本的Terraform。
We are using a private Github and Terraform Cloud for our projects. Everything is able to talk to each other so there is no issue there. However, I'm trying to create modules for a project I started. I was able to make it work as regular terraform files, but when I try to convert to the module system I am having issues with getting the state imported.
We have a separate repository called tf-modules. In this repository, my directory setup:
> root
>> mymodule
>>> lambda.tf
>>> eventbridge.tf
>>> bucket.tf
These files manage the software being deployed in our AWS environment. They are being used across multiple environments for each of our customers (each separated out by environment [qa, dev, prod]).
In my terraform files, I have:
> root
>> CUSTNAME
>>> mymodule
>>>> main.tf
Inside main.tf I have:
module "mymodule" {
source = "git::https://github.com/myprivaterepo/tf-modules.git"
}
In my dev environment, everything is set up so I need to import the state. However, it's not detecting the resources at all. In the .terraform directory, it is downloading the entire repository (the root with the readme.md and all)
I'm fairly new to Terraform. Am I approaching this wrong or misunderstanding?
I am using the latest version of Terraform.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于有一个子目录“ myModule”,因此应指定整个路径。
请参阅模块源 - sub Directory -sub Directory
示例:
git :: https :: https :: https ://example.com/network.git//modules/vpc
Since there is a sub-directory "mymodule", you should specify the whole path.
Refer to module sources - sub directory
Example:
git::https://example.com/network.git//modules/vpc