Introduction
This Knowledge Base (KB) article addresses an issue encountered after upgrading Bitbucket version to 8.18.0. Specifically, Terraform is unable to download a module, resulting in the following error:
fatal: could not read Username for 'http://bitbucket_server_url': No such device or address
Problem
Post-upgrade, Terraform fails to download modules from Bitbucket, leading to authentication issues. The error message indicates that Terraform is attempting to read a username for HTTP authentication, which is failing.
Prerequisites (if applicable)
- Access to the Terraform Enterprise (TFE) environment.
- Administrative access to the Bitbucket server for configuration changes.
- Bitbucket Server 8.18.0
Cause
- Module hosted bitbucket version prior to 8.18.0 was publicly accessible but with bitbucket version 8.18.0 "anonymous public access" was disabled by default
- Terraform module source is configured to used http
Overview of possible solutions (if applicable)
- Configure SSH for module source URLs in Terraform.
- Ensure port 22 is open for SSH communication between TFE and the Bitbucket server.
- Add ssh key with appropriate access to module repository.
Solution:
- Check SSH Connectivity: Check and open the network communication between bitbucket(VCS) and TFE.
-
Update the Terraform Configuration: Edit the Terraform configuration file to update the module source URL to use SSH.
Module source should look like below :
git::ssh://git@code.xxx.com/scm/tfe/terraform-aws-xxx-xxx-vpc.git?ref=v0.4.2.1
- Add the ssh-key with required access of module repository into TFE.
Outcome
After implementing the above solutions, Terraform should be able to download the modules using SSH, thereby resolving the authentication issue.
Additional Information
-
For more details on configuring SSH keys in Terraform, refer to the official documentation: Terraform SSH Key Configuration.
- https://confluence.atlassian.com/bitbucketserver/bitbucket-data-center-8-18-release-notes-1333992708.html
- https://developer.hashicorp.com/terraform/language/modules/sources#github