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_container_app: add support for client_certificate_mode #28523

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,7 @@ resource "azurerm_container_app" "test" {
external_enabled = true
target_port = 5000
transport = "http"
client_certificate_mode = "accept"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we include an update to this property in the tests too?

traffic_weight {
latest_revision = true
percentage = 100
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 @@ -158,6 +158,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 @@ -214,6 +215,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 @@ -289,6 +301,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 @@ -314,6 +330,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 @@ -398,6 +398,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
Loading