Skip to content

Latest commit

 

History

History
154 lines (99 loc) · 5.22 KB

windows-bitbucket-terraform-jenkins.md

File metadata and controls

154 lines (99 loc) · 5.22 KB

Windows Client Setup Guide

This guide covers setting up Bitbucket, Git, Terraform, and VS Code on Windows for infrastructure as code using SSH keys for authentication.

Generate SSH Keys

From the VS Code terminal, generate an ed25519 SSH key pair:

ssh-keygen -t ed25519 -C "[email protected]"

Add Public Key to Bitbucket

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 Bitbucket Repos

Clone your Bitbucket repos in the terminal using the SSH URL:

git clone git@bitbucket.org:user/repo.git

Configure Git in VS Code

Set your Git username and email:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Install Terraform Extension

Install the Terraform extension for VS Code. In the extension settings, configure the terraform.cli path to point to your Terraform binary.

Configure Terraform Backend

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" 
  }
}

Connect to Jenkins Pipeline

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.

Manage Repos in VS Code

Use VS Code to commit changes and push to Bitbucket to trigger deployments.

More Resources

  1. Azure CLI Installation and Configuration:

  2. Azure Provider Configuration in Terraform:

  3. Azure VM Management with Terraform:

  4. Azure Extensions in Visual Studio Code:

  5. Azure DevOps Integration:

  6. Jenkins on Azure:

  7. Azure VM Monitoring and Management:

  8. Security Best Practices:

  9. Collaboration and Version Control:

  10. Automated Testing and Deployment:

Here is a markdown section on security best practices for SSH keys:

SSH Security Best Practices

When working with SSH keys, follow these security best practices:

Use SSH agent forwarding

  • 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 keys

  • Avoid copying private keys between machines.

  • Copy public key instead and generate keys on each host.

Use passphrase for keys

  • Secure keys with a passphrase.

  • Prevents use of keys if compromised.

Revoke compromised keys

  • 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.