You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This guide provides two solutions for securely accessing your Azure resources when your local computer has a dynamic (changing) IP address.
4
+
5
+
---
6
+
7
+
## 🏆 Solution 1: Azure Bastion (Recommended for All Environments)
8
+
9
+
Azure Bastion is the most secure and convenient method. It allows you to connect to your VMs from anywhere, without needing to whitelist your IP address.
10
+
11
+
**How It Works**: Bastion provides a secure connection to your VMs directly from the Azure Portal over an encrypted SSL channel. Your VMs no longer need public IP addresses for SSH or RDP access, drastically reducing their exposure to the internet.
12
+
13
+
**Cost**: ~$144/month
14
+
15
+
### How to Use It:
16
+
1.**Enable in Terraform**: Set `enable_bastion = true` in your `terraform.tfvars` file. This is the default.
17
+
2.**Deploy**: Run `terraform apply`.
18
+
3.**Connect**:
19
+
* Go to your Virtual Machine in the Azure Portal.
20
+
* Click **Connect** > **Bastion**.
21
+
* Enter your VM credentials to start a secure session in your browser.
22
+
23
+
**When Bastion is enabled, the security rules for direct SSH and RDP access are automatically removed, enforcing a secure-by-default architecture.**
24
+
25
+
---
26
+
27
+
## 💻 Solution 2: IP Update Script (For Development Only)
28
+
29
+
If you choose not to use Azure Bastion (e.g., to save costs in a temporary development environment), you can use the `update-my-ip.sh` script.
30
+
31
+
**How It Works**: This script automatically detects your current public IP and updates the necessary Terraform configuration files to grant you access.
32
+
33
+
### How to Use It:
34
+
1.**Disable Bastion**: Set `enable_bastion = false` in your `terraform.tfvars` file.
35
+
2.**Run the Script**: Execute the script from the project root whenever your IP changes.
36
+
```bash
37
+
./scripts/update-my-ip.sh
38
+
```
39
+
3. The script will find your new IP, update the files, and run `terraform apply` to update the firewall rules in Azure.
40
+
41
+
**Security Note**: This method is less secure than Bastion because it requires opening administrative ports to your IP address over the internet. It should only be used for temporary development work.
0 commit comments