Skip to content

Commit

Permalink
azurerm_container_app: add support for client_certificate_mode (h…
Browse files Browse the repository at this point in the history
…ashicorp#28523)

* add client certificate mode

* add tests

* add update test
  • Loading branch information
jiaweitao001 authored and hqhqhqhqhqhqhqhqhqhqhq committed Feb 26, 2025
1 parent fb005c2 commit f419ea8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,7 @@ resource "azurerm_container_app" "test" {
external_enabled = true
target_port = 5000
transport = "http"
client_certificate_mode = "accept"
traffic_weight {
latest_revision = true
percentage = 100
Expand Down Expand Up @@ -2182,6 +2183,7 @@ resource "azurerm_container_app" "test" {
external_enabled = true
target_port = 5000
transport = "auto"
client_certificate_mode = "ignore"
traffic_weight {
latest_revision = true
Expand Down
20 changes: 20 additions & 0 deletions internal/services/containerapps/helpers/container_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ type Ingress struct {
TrafficWeights []TrafficWeight `tfschema:"traffic_weight"`
Transport string `tfschema:"transport"`
IpSecurityRestrictions []IpSecurityRestriction `tfschema:"ip_security_restriction"`
ClientCertificateMode string `tfschema:"client_certificate_mode"`
}

func ContainerAppIngressSchema() *pluginsdk.Schema {
Expand Down Expand Up @@ -215,6 +216,17 @@ func ContainerAppIngressSchema() *pluginsdk.Schema {
ValidateFunc: validation.StringInSlice(containerapps.PossibleValuesForIngressTransportMethod(), false),
Description: "The transport method for the Ingress. Possible values include `auto`, `http`, and `http2`, `tcp`. Defaults to `auto`",
},

"client_certificate_mode": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
string(containerapps.IngressClientCertificateModeAccept),
string(containerapps.IngressClientCertificateModeRequire),
string(containerapps.IngressClientCertificateModeIgnore),
}, false),
Description: "Client certificate mode for mTLS authentication. Ignore indicates server drops client certificate on forwarding. Accept indicates server forwards client certificate but does not require a client certificate. Require indicates server requires a client certificate.",
},
},
},
}
Expand Down Expand Up @@ -290,6 +302,10 @@ func ExpandContainerAppIngress(input []Ingress, appName string) *containerapps.I
}
transport := containerapps.IngressTransportMethod(ingress.Transport)
result.Transport = &transport
if ingress.ClientCertificateMode != "" {
clientCertificateMode := containerapps.IngressClientCertificateMode(ingress.ClientCertificateMode)
result.ClientCertificateMode = &clientCertificateMode
}

return result
}
Expand All @@ -315,6 +331,10 @@ func FlattenContainerAppIngress(input *containerapps.Ingress, appName string) []
result.Transport = strings.ToLower(string(*ingress.Transport))
}

if ingress.ClientCertificateMode != nil {
result.ClientCertificateMode = string(*ingress.ClientCertificateMode)
}

return []Ingress{result}
}

Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/container_app.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ An `ingress` block supports the following:

~> **Note:** if `transport` is set to `tcp`, `exposed_port` and `target_port` should be set at the same time.

* `client_certificate_mode` - (Optional) The client certificate mode for the Ingress. Possible values are `require`, `accept`, and `ignore`.

---

A `ip_security_restriction` block supports the following:
Expand Down

0 comments on commit f419ea8

Please sign in to comment.