Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_public_ip: renamed public_ip_address_allocation to allocation_method & added missing properties to datasource #2576

Merged
merged 8 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions azurerm/data_source_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ resource "azurerm_subnet" "test" {
}

resource "azurerm_public_ip" "test" {
name = "acctestpip%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "Dynamic"
domain_name_label = "acctestpip%d"
name = "acctestpip%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Dynamic"
domain_name_label = "acctestpip%d"
}

resource "azurerm_network_interface" "testsource" {
Expand All @@ -102,7 +102,7 @@ resource "azurerm_network_interface" "testsource" {
ip_configuration {
name = "testconfigurationsource"
subnet_id = "${azurerm_subnet.test.id}"
private_ip_address_allocation = "dynamic"
private_ip_address_allocation = "Dynamic"
public_ip_address_id = "${azurerm_public_ip.test.id}"
}
}
Expand Down Expand Up @@ -216,11 +216,11 @@ resource "azurerm_subnet" "test" {
}

resource "azurerm_public_ip" "test" {
name = "acctestpip%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "Dynamic"
domain_name_label = "acctestpip%d"
name = "acctestpip%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Dynamic"
domain_name_label = "acctestpip%d"
}

resource "azurerm_network_interface" "testsource" {
Expand All @@ -231,7 +231,7 @@ resource "azurerm_network_interface" "testsource" {
ip_configuration {
name = "testconfigurationsource"
subnet_id = "${azurerm_subnet.test.id}"
private_ip_address_allocation = "dynamic"
private_ip_address_allocation = "Dynamic"
public_ip_address_id = "${azurerm_public_ip.test.id}"
}
}
Expand Down
4 changes: 2 additions & 2 deletions azurerm/data_source_network_interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ resource "azurerm_network_interface" "test" {
ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.test.id}"
private_ip_address_allocation = "dynamic"
private_ip_address_allocation = "Dynamic"
}

tags {
Expand Down Expand Up @@ -116,7 +116,7 @@ resource "azurerm_network_interface" "test" {
ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.test.id}"
private_ip_address_allocation = "dynamic"
private_ip_address_allocation = "Dynamic"
}

tags {
Expand Down
36 changes: 36 additions & 0 deletions azurerm/data_source_public_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,20 @@ func dataSourceArmPublicIP() *schema.Resource {
ValidateFunc: validate.NoEmptyStrings,
},

"location": locationForDataSourceSchema(),

"resource_group_name": resourceGroupNameForDataSourceSchema(),

"sku": {
Type: schema.TypeString,
Computed: true,
},

"allocation_method": {
Type: schema.TypeString,
Computed: true,
},

"ip_version": {
Type: schema.TypeString,
Computed: true,
Expand All @@ -40,11 +52,18 @@ func dataSourceArmPublicIP() *schema.Resource {
Computed: true,
},

"reverse_fqdn": {
Type: schema.TypeString,
Computed: true,
},

"ip_address": {
Type: schema.TypeString,
Computed: true,
},

"zones": zonesSchemaComputed(),

"tags": tagsSchema(),
},
}
Expand All @@ -67,19 +86,36 @@ func dataSourceArmPublicIPRead(d *schema.ResourceData, meta interface{}) error {

d.SetId(*resp.ID)

d.Set("zones", resp.Zones)

//ensure values are at least set to "", d.Set() is a noop on a nil
//there must be a better way...
d.Set("location", "")
d.Set("sku", "")
d.Set("fqdn", "")
d.Set("reverse_fqdn", "")
d.Set("domain_name_label", "")
d.Set("allocation_method", "")
d.Set("ip_address", "")
d.Set("ip_version", "")
d.Set("idle_timeout_in_minutes", 0)

if location := resp.Location; location != nil {
d.Set("location", azureRMNormalizeLocation(*location))
}

if sku := resp.Sku; sku != nil {
d.Set("sku", string(sku.Name))
}

if props := resp.PublicIPAddressPropertiesFormat; props != nil {
if dnsSettings := props.DNSSettings; dnsSettings != nil {
d.Set("fqdn", dnsSettings.Fqdn)
d.Set("reverse_fqdn", dnsSettings.ReverseFqdn)
d.Set("domain_name_label", dnsSettings.DomainNameLabel)
}

d.Set("allocation_method", string(props.PublicIPAllocationMethod))
d.Set("ip_address", props.IPAddress)
d.Set("ip_version", string(props.PublicIPAddressVersion))
d.Set("idle_timeout_in_minutes", props.IdleTimeoutInMinutes)
Expand Down
20 changes: 10 additions & 10 deletions azurerm/data_source_public_ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ resource "azurerm_resource_group" "test" {
}

resource "azurerm_public_ip" "test" {
name = "%s"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
domain_name_label = "acctest-%d"
idle_timeout_in_minutes = 30
name = "%s"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Static"
domain_name_label = "acctest-%d"
idle_timeout_in_minutes = 30

tags {
environment = "test"
Expand All @@ -102,10 +102,10 @@ resource "azurerm_resource_group" "test" {
}

resource "azurerm_public_ip" "test" {
name = "acctestpublicip-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "dynamic"
name = "acctestpublicip-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Dynamic"

ip_version = "%s"

Expand Down
60 changes: 30 additions & 30 deletions azurerm/data_source_public_ips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ resource "azurerm_resource_group" "test" {
}

resource "azurerm_public_ip" "test" {
count = 7
name = "acctestpip%s-${count.index}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
idle_timeout_in_minutes = 30
count = 7
name = "acctestpip%s-${count.index}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Static"
idle_timeout_in_minutes = 30

tags {
environment = "test"
Expand Down Expand Up @@ -160,25 +160,25 @@ resource "azurerm_resource_group" "test" {
}

resource "azurerm_public_ip" "test" {
count = 2
name = "acctestpipb%s-${count.index}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
idle_timeout_in_minutes = 30
count = 2
name = "acctestpipb%s-${count.index}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Static"
idle_timeout_in_minutes = 30

tags {
environment = "test"
}
}

resource "azurerm_public_ip" "test2" {
count = 2
name = "acctestpipa%s-${count.index}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
idle_timeout_in_minutes = 30
count = 2
name = "acctestpipa%s-${count.index}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Static"
idle_timeout_in_minutes = 30

tags {
environment = "test"
Expand Down Expand Up @@ -207,25 +207,25 @@ resource "azurerm_resource_group" "test" {
}

resource "azurerm_public_ip" "dynamic" {
count = 4
name = "acctestpipd%s-${count.index}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "dynamic"
idle_timeout_in_minutes = 30
count = 4
name = "acctestpipd%s-${count.index}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Dynamic"
idle_timeout_in_minutes = 30

tags {
environment = "test"
}
}

resource "azurerm_public_ip" "static" {
count = 3
name = "acctestpips%s-${count.index}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
idle_timeout_in_minutes = 30
count = 3
name = "acctestpips%s-${count.index}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Static"
idle_timeout_in_minutes = 30

tags {
environment = "test"
Expand Down
8 changes: 4 additions & 4 deletions azurerm/data_source_virtual_network_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ resource "azurerm_subnet" "test" {
}

resource "azurerm_public_ip" "test" {
name = "acctestpip-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "Dynamic"
name = "acctestpip-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Dynamic"
}

resource "azurerm_virtual_network_gateway" "test" {
Expand Down
8 changes: 4 additions & 4 deletions azurerm/resource_arm_application_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1098,10 +1098,10 @@ resource "azurerm_subnet" "test" {
}

resource "azurerm_public_ip" "test" {
name = "acctest-pubip-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "dynamic"
name = "acctest-pubip-%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Dynamic"
}
`, rInt, location, rInt, rInt, rInt)
}
40 changes: 20 additions & 20 deletions azurerm/resource_arm_firewall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,11 @@ resource "azurerm_subnet" "test" {
}

resource "azurerm_public_ip" "test" {
name = "acctestpip%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "Static"
sku = "Standard"
name = "acctestpip%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Static"
sku = "Standard"
}

resource "azurerm_firewall" "test" {
Expand Down Expand Up @@ -346,11 +346,11 @@ resource "azurerm_subnet" "test" {
}

resource "azurerm_public_ip" "test" {
name = "acctestpip%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "Static"
sku = "Standard"
name = "acctestpip%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Static"
sku = "Standard"
}

resource "azurerm_firewall" "test" {
Expand Down Expand Up @@ -408,11 +408,11 @@ resource "azurerm_subnet" "test" {
}

resource "azurerm_public_ip" "test" {
name = "acctestpip%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "Static"
sku = "Standard"
name = "acctestpip%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Static"
sku = "Standard"
}

resource "azurerm_firewall" "test" {
Expand Down Expand Up @@ -456,11 +456,11 @@ resource "azurerm_subnet" "test" {
}

resource "azurerm_public_ip" "test" {
name = "acctestpip%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "Static"
sku = "Standard"
name = "acctestpip%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
allocation_method = "Static"
sku = "Standard"
}

resource "azurerm_firewall" "test" {
Expand Down
Loading