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_application_gateway - add trusted_root_certificate_names property #4821

Closed
Closed
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
44 changes: 44 additions & 0 deletions azurerm/resource_arm_application_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ func resourceArmApplicationGateway() *schema.Resource {
},
},

"trusted_root_certificate_names": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validate.NoEmptyStrings,
},
},

"connection_draining": {
Type: schema.TypeList,
MaxItems: 1,
Expand Down Expand Up @@ -2011,6 +2020,23 @@ func expandApplicationGatewayBackendHTTPSettings(d *schema.ResourceData, gateway
setting.ApplicationGatewayBackendHTTPSettingsPropertiesFormat.AuthenticationCertificates = &authCertSubResources
}

if v["trusted_root_certificate_names"] != nil {
trustedRootCertNames := v["trusted_root_certificate_names"].([]interface{})
trustedRootCertSubResources := make([]network.SubResource, 0)

for _, rawTrustedRootCertName := range trustedRootCertNames {
trustedRootCertName := rawTrustedRootCertName.(string)
trustedRootCertID := fmt.Sprintf("%s/trustedRootCertificates/%s", gatewayID, trustedRootCertName)
trustedRootCertSubResource := network.SubResource{
ID: utils.String(trustedRootCertID),
}

trustedRootCertSubResources = append(trustedRootCertSubResources, trustedRootCertSubResource)
}

setting.ApplicationGatewayBackendHTTPSettingsPropertiesFormat.TrustedRootCertificates = &trustedRootCertSubResources
}

probeName := v["probe_name"].(string)
if probeName != "" {
probeID := fmt.Sprintf("%s/probes/%s", gatewayID, probeName)
Expand Down Expand Up @@ -2094,6 +2120,24 @@ func flattenApplicationGatewayBackendHTTPSettings(input *[]network.ApplicationGa
}
output["authentication_certificate"] = authenticationCertificates

trustedRootCertificateNames := make([]interface{}, 0)
if certs := props.TrustedRootCertificates; certs != nil {
for _, cert := range *certs {
if cert.ID == nil {
continue
}

certId, err := azure.ParseAzureResourceID(*cert.ID)
if err != nil {
return nil, err
}

certName := certId.Path["trustedRootCertificates"]
trustedRootCertificateNames = append(trustedRootCertificateNames, certName)
}
}
output["trusted_root_certificate_names"] = trustedRootCertificateNames

if probe := props.Probe; probe != nil {
if probe.ID != nil {
id, err := azure.ParseAzureResourceID(*probe.ID)
Expand Down
6 changes: 4 additions & 2 deletions website/docs/r/application_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ A `authentication_certificate` block supports the following:

A `trusted_root_certificate` block supports the following:

* `name` - (Required) The Name of the Authentication Certificate to use.
* `name` - (Required) The Name of the Trusted Root Certificate to use.

* `data` - (Required) The contents of the Authentication Certificate which should be used.
* `data` - (Required) The contents of the Trusted Root Certificate which should be used.

---

Expand Down Expand Up @@ -238,6 +238,8 @@ A `backend_http_settings` block supports the following:

* `authentication_certificate` - (Optional) One or more `authentication_certificate` blocks.

* `trusted_root_certificate_names` - (Optional) A list of `trusted_root_certificate` names.

* `connection_draining` - (Optional) A `connection_draining` block as defined below.

---
Expand Down