Skip to content

Commit

Permalink
azurerm_app_service_environment - support for internal_ip_address, …
Browse files Browse the repository at this point in the history
…`service_ip_address`, `outbound_ip_addresses` (#12026)

#8179

Return the VipInfo for the ASE on create. This is required for configuration of external Azure resources (e.g. App Gateway WAF). Using the data provider will cause failures if the resource doesn't exist. This is the preferred solution.
  • Loading branch information
bduzik authored Jun 3, 2021
1 parent 87bf1be commit c3d39df
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
33 changes: 33 additions & 0 deletions azurerm/internal/services/web/app_service_environment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,26 @@ func resourceAppServiceEnvironment() *pluginsdk.Resource {
"tags": tags.ForceNewSchema(),

// Computed

// VipInfo
"internal_ip_address": {
Type: pluginsdk.TypeString,
Computed: true,
},

"service_ip_address": {
Type: pluginsdk.TypeString,
Computed: true,
},

"outbound_ip_addresses": {
Type: pluginsdk.TypeList,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
Computed: true,
},

"location": {
Type: pluginsdk.TypeString,
Computed: true,
Expand Down Expand Up @@ -386,6 +406,19 @@ func resourceAppServiceEnvironmentRead(d *pluginsdk.ResourceData, meta interface
d.Set("cluster_setting", flattenClusterSettings(props.ClusterSettings))
}

// Get IP attributes for ASE.
vipInfo, err := client.GetVipInfo(ctx, id.ResourceGroup, id.HostingEnvironmentName)
if err != nil {
if utils.ResponseWasNotFound(vipInfo.Response) {
return fmt.Errorf("Error retrieving VIP info: App Service Environment %q (Resource Group %q) was not found", id.HostingEnvironmentName, id.ResourceGroup)
}
return fmt.Errorf("Error retrieving VIP info App Service Environment %q (Resource Group %q): %+v", id.HostingEnvironmentName, id.ResourceGroup, err)
}

d.Set("internal_ip_address", vipInfo.InternalIPAddress)
d.Set("service_ip_address", vipInfo.ServiceIPAddress)
d.Set("outbound_ip_addresses", vipInfo.OutboundIPAddresses)

return tags.FlattenAndSet(d, existing.Tags)
}

Expand Down
6 changes: 6 additions & 0 deletions website/docs/r/app_service_environment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ A `cluster_setting` block supports the following:

* `id` - The ID of the App Service Environment.

* `internal_ip_address` - IP address of internal load balancer of the App Service Environment.

* `location` - The location where the App Service Environment exists.

* `outbound_ip_addresses` - List of outbound IP addresses of the App Service Environment.

* `service_ip_address` - IP address of service endpoint of the App Service Environment.

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions:
Expand Down

0 comments on commit c3d39df

Please sign in to comment.