https://github.com/bzon/azureip2tfvars
Create Terraform list variables from Azure data centre IPs.
https://github.com/bzon/azureip2tfvars
azure devops golang terraform
Last synced: about 1 month ago
JSON representation
Create Terraform list variables from Azure data centre IPs.
- Host: GitHub
- URL: https://github.com/bzon/azureip2tfvars
- Owner: bzon
- Created: 2018-11-07T22:33:09.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-10T00:33:25.000Z (over 7 years ago)
- Last Synced: 2025-01-22T08:28:30.451Z (over 1 year ago)
- Topics: azure, devops, golang, terraform
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://travis-ci.org/bzon/azureip2tfvars)
[](https://goreportcard.com/report/github.com/bzon/azureip2tfvars)
## Synopsis
If your team is using Azure services like Bots that calls some APIs from your server,
you probably want to whitelist specific Azure IP addressess for security purposes.
In order to do that, you can go to https://www.microsoft.com/en-gb/download/details.aspx?id=41653
and download the XML file from there. The problem is, the IP ranges may change on a regular basis
and if you are using infra as code tools such as Terraform, you need to find an easy way to automate
this task and update your Terraform variables.
**azureip2tfvars** is created to easily extract the latest Azure Data Centre IPs and create a
Terraform variables file out of it. We use Terraform to create AWS security groups with ingress rules that whitelist these Azure data centre IP's.
**azureip2tfvars** lets our team update our `tf` files on a regular basis easily to keep our ingress rules up to date.
## Quickstart
Download the latest binary for your Operating System from the [releases page](https://github.com/bzon/azureip2tfvars/releases/) and place it to your preferred directory or folder.
**From the command line terminal**
```bash
# for linux or macos
export PATH=$PATH:/directory/of/the/binary
azureip2tfvars -writeto /tmp/vars.tf
```
```bash
# for windows
SET PATH=%PATH%;C:\directory\of\the\binary
azureip2tfvars.exe -writeto /tmp/vars.tf
```
**Command example output**
```bash
⡿ Download url is: https://download.microsoft.com/download/0/1/8/018E208D-54F8-44CD-AA26-CD7BC9524A8C/PublicIPs_20181107.xml
Terraform file "/tmp/vars.tf" successfully created!
```
**Terraform file**
```go
...
variable "azure_indiawest_subnets" {
type = "list"
default = [
"20.40.8.0/21",
"20.190.146.128/25",
"40.79.219.0/24",
"40.81.80.0/20",
"40.87.220.0/22",
"40.90.138.224/27",
"40.126.18.128/25",
"52.109.64.0/22",
"52.114.28.0/22",
"52.136.16.0/24",
"52.136.32.0/19",
"52.140.128.0/18",
"52.183.128.0/18",
"52.239.135.192/26",
"52.239.187.128/25",
"52.245.76.0/22",
"52.249.64.0/19",
"104.44.93.224/27",
"104.44.95.112/28",
"104.47.212.0/23",
"104.211.128.0/18",
]
}
variable "azure_uswest2_subnets" {
...
}
```