Skip to content

Commit

Permalink
Resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcturusZhang committed Nov 1, 2019
1 parent 7a492a7 commit 1092e85
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 25 deletions.
2 changes: 2 additions & 0 deletions azurerm/data_source_nat_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func dataSourceArmNatGateway() *schema.Resource {
"public_ip_address_ids": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Expand All @@ -41,6 +42,7 @@ func dataSourceArmNatGateway() *schema.Resource {
"public_ip_prefix_ids": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Expand Down
30 changes: 17 additions & 13 deletions azurerm/resource_arm_nat_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"strconv"
"time"

"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-06-01/network"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
Expand Down Expand Up @@ -46,9 +48,10 @@ func resourceArmNatGateway() *schema.Resource {
"resource_group_name": azure.SchemaResourceGroupName(),

"idle_timeout_in_minutes": {
Type: schema.TypeInt,
Optional: true,
Default: 4,
Type: schema.TypeInt,
Optional: true,
Default: 4,
ValidateFunc: validate.IntBetweenAndDivisibleBy(4, 120, 1),
},

"public_ip_address_ids": {
Expand All @@ -70,9 +73,10 @@ func resourceArmNatGateway() *schema.Resource {
},

"resource_guid": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validate.UUID,
},

"sku_name": {
Expand Down Expand Up @@ -121,8 +125,8 @@ func resourceArmNatGatewayCreateUpdate(d *schema.ResourceData, meta interface{})

location := azure.NormalizeLocation(d.Get("location").(string))
idleTimeoutInMinutes := d.Get("idle_timeout_in_minutes").(int)
publicIpAddressIds := d.Get("public_ip_address_ids").([]interface{})
publicIpPrefixIds := d.Get("public_ip_prefix_ids").([]interface{})
publicIpAddressIds := d.Get("public_ip_address_ids").(*schema.Set).List()
publicIpPrefixIds := d.Get("public_ip_prefix_ids").(*schema.Set).List()
skuName := d.Get("sku_name").(string)
zones := d.Get("zones").([]interface{})
t := d.Get("tags").(map[string]interface{})
Expand Down Expand Up @@ -271,11 +275,9 @@ func expandArmNatGatewaySubResourceID(input []interface{}) *[]network.SubResourc
for _, item := range input {
id := item.(string)

result := network.SubResource{
results = append(results, network.SubResource{
ID: utils.String(id),
}

results = append(results, result)
})
}
return &results
}
Expand All @@ -287,7 +289,9 @@ func flattenArmNatGatewaySubResourceID(input *[]network.SubResource) []interface
}

for _, item := range *input {
results = append(results, *item.ID)
if item.ID != nil {
results = append(results, *item.ID)
}
}

return results
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_nat_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ resource "azurerm_nat_gateway" "test" {
public_ip_prefix_ids = ["${azurerm_public_ip_prefix.test.id}"]
sku_name = "Standard"
idle_timeout_in_minutes = 10
zones = ["1"]
zones = ["1"]
}
`, rInt, location, rInt, rInt, rInt)
}
2 changes: 2 additions & 0 deletions azurerm/resource_arm_subnet_nat_gateway_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func resourceArmSubnetNatGatewayAssociation() *schema.Resource {
func resourceArmSubnetNatGatewayAssociationCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient).Network.SubnetsClient
ctx := meta.(*ArmClient).StopContext

log.Printf("[INFO] preparing arguments for Subnet <-> NAT Gateway Association creation.")
subnetId := d.Get("subnet_id").(string)
natGatewayId := d.Get("nat_gateway_id").(string)
Expand Down Expand Up @@ -181,6 +182,7 @@ func resourceArmSubnetNatGatewayAssociationDelete(d *schema.ResourceData, meta i
if err != nil {
return err
}

gatewayName := parsedGatewayId.Path["natGateways"]
locks.ByName(gatewayName, natGatewayResourceName)
defer locks.UnlockByName(gatewayName, natGatewayResourceName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestAccAzureRMSubnetNatGatewayAssociation_requiresImport(t *testing.T) {
t.Skip("Skipping since resources aren't required to be imported")
return
}

resourceName := "azurerm_subnet_nat_gateway_association.test"
ri := tf.AccRandTimeInt()
location := testLocation()
Expand Down
8 changes: 8 additions & 0 deletions website/azurerm.erb
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@
<a href="/docs/providers/azurerm/d/mssql_elasticpool.html">azurerm_mssql_elasticpool</a>
</li>

<li>
<a href="/docs/providers/azurerm/d/nat_gateway.html">azurerm_nat_gateway</a>
</li>

<li>
<a href="/docs/providers/azurerm/d/network_ddos_protection_plan.html">azurerm_network_ddos_protection_plan</a>
</li>
Expand Down Expand Up @@ -1516,6 +1520,10 @@
<a href="/docs/providers/azurerm/r/local_network_gateway.html">azurerm_local_network_gateway</a>
</li>

<li>
<a href="/docs/providers/azurerm/r/nat_gateway.html">azurerm_nat_gateway</a>
</li>

<li>
<a href="/docs/providers/azurerm/r/network_interface.html">azurerm_network_interface</a>
</li>
Expand Down
16 changes: 8 additions & 8 deletions website/docs/d/nat_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ Use this data source to access information about an existing Nat Gateway.

The following arguments are supported:

* `name` - (Required) Specifies the name of the Nat Gateway.
* `name` - (Required) The Name of the Resource Group where the Nat Gateway exists.

* `resource_group_name` - (Required) Specifies the name of the Resource Group where the Nat Gateway exists.

## Attributes Reference

The following attributes are exported:

* `location` - The location of the specified NAT Gateway.
* `location` - The location where the NAT Gateway exists.

* `idle_timeout_in_minutes` - The idle timeout of the specified Nat Gateway.
* `idle_timeout_in_minutes` - The idle timeout of the Nat Gateway.

* `public_ip_address_ids` - A list of existing Public IP Address resource IDs which the specified NAT Gateway is using.
* `public_ip_address_ids` - A list of existing Public IP Address resource IDs which the NAT Gateway is using.

* `public_ip_prefix_ids` - A list of existing Public IP Prefix resource IDs which the specified NAT Gateway is using.
* `public_ip_prefix_ids` - A list of existing Public IP Prefix resource IDs which the NAT Gateway is using.

* `resource_guid` - The resource GUID property of the Nat Gateway.

* `sku_name` - The SKU used by the NAT Gateway.

* `subnet_ids` - A list of existing Subnet resource IDs.
* `subnet_ids` - A list of existing Subnet resource IDs which the NAT Gateway is using.

* `zones` - A list of Availability Zones which the NAT Gateway should be created in .
* `zones` - A list of Availability Zones which the NAT Gateway gets created in.

* `tags` - A mapping of tags to assign to the resource.
* `tags` - A mapping of tags assigned to the resource.
6 changes: 3 additions & 3 deletions website/docs/r/nat_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The following arguments are supported:

* `name` - (Required) Specifies the name of the Nat Gateway. Changing this forces a new resource to be created.

* `resource_group_name` - (Required) The name of the resource group where this resource exists. Changing this forces a new resource to be created.
* `resource_group_name` - (Required) The name of the Resource Group in which the NAT Gateway exists.

* `location` - (Optional) Specifies the supported Azure location where the resource should exist. Changing this forces a new resource to be created.

Expand All @@ -26,8 +26,6 @@ The following arguments are supported:

* `public_ip_prefix_ids` - (Optional) An array of the IDs of Public IP Prefixes associated with the NAT Gateway resource.

* `resource_guid` - (Optional) The resource GUID property of the Nat Gateway.

* `sku_name` - (Optional) The nat gateway SKU, supported value, `Standard`. Defaults to `Standard`.

* `zones` - (Optional) A list of availability zones where the Nat Gateway should be provisioned. Supported values are `1`, `2`, and `3`. For more information on `zones` please refer to the [product documentation](https://docs.microsoft.com/en-us/azure/availability-zones/az-overview). Changing this forces a new resource to be created.
Expand All @@ -38,6 +36,8 @@ The following arguments are supported:

The following attributes are exported:

* `resource_guid` - The resource GUID property of the Nat Gateway.

* `subnet_ids` - An array of IDs of the Subnets using this NAT Gateway resource.

## Import
Expand Down

0 comments on commit 1092e85

Please sign in to comment.