-
Notifications
You must be signed in to change notification settings - Fork 23
/
atlassian_cidr_ip4.tf
48 lines (41 loc) · 1.43 KB
/
atlassian_cidr_ip4.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# vim:ts=2:sts=2:sw=2:et
#
# Author: Hari Sekhon
# Date: [% DATE # 2020-07-27 18:33:49 +0100 (Mon, 27 Jul 2020) %]
#
# https://github.com/HariSekhon/Terraform
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/HariSekhon
#
# tested on Terraform 0.12
# XXX: uncomment if not in provider.tf
#provider "http" {}
# doesn't verify SSL except chain of trust according to Important notice for 0.12 at:
#
# https://registry.terraform.io/providers/hashicorp/http/latest/docs/data-sources/data_source
#
data "http" "atlassian_ips" {
url = "https://ip-ranges.atlassian.com/"
request_headers = {
Accept = "application/json"
}
}
# verifies SSL - gets a casting type error though - Error: command "curl" produced invalid JSON: json: cannot unmarshal number into Go value of type string
#data "external" "atlassian_ips" {
# program = ["curl", "-sSL", "https://ip-ranges.atlassian.com/"]
#}
locals {
atlassian_ips_data = jsondecode("${data.http.atlassian_ips.body}")
#atlassian_ips_data = jsondecode("${data.external.atlassian_ips.result}")
atlassian_cidr_ipv4 = [
for item in "${local.atlassian_ips_data.items}" :
item.cidr if length(regexall(":|[[:alpha:]]", item.cidr)) < 1
]
}
output "atlassian_cidr_ip4" {
value = local.atlassian_cidr_ipv4
}