This guide covers setting up Bitbucket, Git, Terraform, and VS Code on Windows for infrastructure as code using SSH keys for authentication.
From the VS Code terminal, generate an ed25519 SSH key pair:
ssh-keygen -t ed25519 -C "[email protected]"
Copy your public key and add it to your Bitbucket account:
Get-Content -Path ~/.ssh/id_ed25519.pub
# Copy output and add to Bitbucket SSH keys
Clone your Bitbucket repos in the terminal using the SSH URL:
git clone git@bitbucket.org:user/repo.git
Set your Git username and email:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Install the Terraform extension for VS Code. In the extension settings, configure the terraform.cli
path to point to your Terraform binary.
- HashiCorp Terraform VSCode extension - GitHub
- Enabling VS Code Terraform extension code completion on Windows and ...
In your Terraform files, set the backend
config to point to your remote state storage in Bitbucket:
terraform {
backend "s3" {
endpoint = "https://bitbucket.org/account/repo"
bucket = "terraform-state"
key = "env/myterraform.tfstate"
region = "us-east-1"
}
}
- Using SSH Keys for Cloning Modules - HashiCorp Developer
- How to use Project wide ssh keys with terraform - StackOverflow
- Terraform GitHub Actions
Install the Jenkins and Pipeline extensions. Add your private key to Jenkins credentials for SSH access. Configure a webhook in your Bitbucket repo to trigger the Jenkins pipeline on changes.
- Using Jenkins agents
- Step-By-Step Guide to Setting Up SSH Keys for Jenkins | Jhooq
- Jenkins and GIT Integration using SSH Key - GeeksforGeeks
Use VS Code to commit changes and push to Bitbucket to trigger deployments.
-
Azure CLI Installation and Configuration:
-
Azure Provider Configuration in Terraform:
-
Azure VM Management with Terraform:
-
Azure Extensions in Visual Studio Code:
-
Azure DevOps Integration:
-
Jenkins on Azure:
-
Azure VM Monitoring and Management:
-
Security Best Practices:
-
Collaboration and Version Control:
-
Automated Testing and Deployment:
Here is a markdown section on security best practices for SSH keys:
When working with SSH keys, follow these security best practices:
- Start the SSH agent in the background:
# Start SSH agent
ssh-agent -s
# Add key
ssh-add ~\.ssh\id_ed25519
- Enable agent forwarding when connecting:
ssh -A user@host
- This allows you to access remote hosts without copying keys.
-
Avoid copying private keys between machines.
-
Copy public key instead and generate keys on each host.
-
Secure keys with a passphrase.
-
Prevents use of keys if compromised.
-
If a key is compromised, revoke it immediately.
-
Remove from remote hosts and regenerate.
Following these best practices prevents your SSH keys from being misused if compromised.