[英]Pull private module within Terraform docker container
要運行我的 Terraform,我有一個 docker-compose 設置,它可以提取hashcorp/terraform:light
圖像,然后構建我的基礎架構。
我最近介紹了一個私有模塊,它位於我的私有 Github 存儲庫中。 當我在我的機器上運行terraform get
時它工作正常,但在 Docker 組合設置中我收到以下錯誤:
Could not download module "privateModule" (privateModule.tf:1) source code from
"git@github.com:sum/private.go.deploy.git": error downloading
'ssh://git@github.com/sum/private.go.deploy.git': /usr/bin/git exited with
128: Cloning into '.terraform/modules/privateModule'...
Warning: Permanently added 'github.com,140.82.121.3' (RSA) to the list of
known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我正在嘗試將我的 SSH 密鑰傳遞給容器,以便它可以拉動私有 Github 存儲庫,但它似乎沒有做任何事情。
version: '3.4'
services:
terraform:
image: hashicorp/terraform:light
volumes:
- .:/terraform
- ~/.ssh:/.ssh
working_dir: /terraform
environment:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}
我的 Makefile 中的命令是:
tf-init:
docker-compose run --rm terraform init
有沒有辦法讓我的容器從 Git 中提取私有依賴項以與 Terraform 一起使用?
ssh 文件夾未安裝到正確的位置。
通過將其安裝到root/.ssh
它解決了我的問題,我可以成功下載私有 Terraform 模塊!
version: '3.4'
services:
terraform:
image: hashicorp/terraform:light
volumes:
- .:/terraform
- ~/.ssh:/root/.ssh
working_dir: /terraform
environment:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.