-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
67 lines (54 loc) · 1.23 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
## terraform.tfvars, or environment.tf
variable "username" {
description = "basic-auth user"
default = "default-user"
type = string
}
variable "password" {
description = "basic-auth pass"
default = "default-pass"
type = string
}
variable "api_uri" {
description = "restapi-uri"
default = "https://some-fake-host.local"
type = string
}
variable "insecure" {
description = "insecure-tls"
default = "true"
type = bool
}
variable "existing_records" {
description = "previous existing-records"
default = ["NA"]
type = list(string)
}
# versions.tf
terraform {
required_providers {
restapi = {
source = "Mastercard/restapi"
version = ">= 1.18.0"
}
}
}
## providers.tf
provider "restapi" {
uri = var.api_uri
username = var.username
password = var.password
insecure = var.insecure
}
# main.tf
data "restapi_object" "ip-dns-static-records" {
for_each = toset(var.existing_records)
path = "/rest/ip/dns/static"
search_key = "name"
search_value = each.key
id_attribute = "name"
}
output "static_records" {
description = "IP DNS Static Record Data"
value = data.restapi_object.ip-dns-static-records[*]
}