Hello guys, we have an issue using terraform commands in a Dagger pipeline, we have a git repository that contains terraform modules written in house, the issue is when terraform init command is executed from a Dagger container we receive an error like:
Cloning into 'gitrepository-terraform-modules'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
We try the following things to solve it, without success:
- Setup ssh agent socket, snippet code:
Collect value of SSH_AUTH_SOCK env var, to retrieve auth socket path
ssh_auth_path = os.environ.get("SSH_AUTH_SOCK", "")
Retrieve authentication socket from host
ssh_agent_socket = client.host().unix_socket(ssh_auth_path)
out = (
c
.container()
.from_("ubuntu:latest")
.with_directory("/infrastructure", src)
.with_directory("/root/.ssh", ssh_keys, exclude=["config", "known_hosts"])
.with_workdir("/infrastructure")
.with_exec([
"wget", "https://releases.hashicorp.com/terraform/1.2.9/terraform_1.2.9_linux_amd64.zip"
])
.with_exec(["unzip", "terraform_1.2.9_linux_amd64.zip", "-d", "/usr/local/bin"])
.with_unix_socket("/tmp/ssh-agent/", ssh_agent_socket )
)
- Point 2 in the first comment.