feat(cloudfront-origins): add mutual TLS (mTLS) authentication support for custom origins#37316
feat(cloudfront-origins): add mutual TLS (mTLS) authentication support for custom origins#37316
Conversation
…t for custom origins
…ttpOrigin, RestApiOrigin, and FunctionUrlOrigin
…Y protocol policy
There was a problem hiding this comment.
The pull request linter fails with the following errors:
❌ Features must contain a change to an integration test file and the resulting snapshot.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.
✅ A exemption request has been requested. Please wait for a maintainer's review.
|
Exemption Request Integration test files ( As noted in the contributing guide, I am unable to run the |
Issue # (if applicable)
N/A
Reason for this change
CloudFront now supports mutual TLS (mTLS) authentication between CloudFront and custom origins via the
OriginMtlsConfigproperty onCustomOriginConfig. This allows CloudFront to present a client certificate from ACM when connecting to the origin, enabling two-way TLS authentication.Currently, the CDK L1 construct (
CfnDistribution) already supportsOriginMtlsConfigthrough the latest CloudFormation resource spec update, but there is no L2 support for configuring mTLS on origin classes.Description of changes
The L1 construct (
CfnDistribution) already supportsOriginMtlsConfigwithClientCertificateArninsideCustomOriginConfigthrough the CloudFormation resource spec. This PR adds L2 support for it.OriginMtlsConfiginterface toaws-cloudfront(origin.ts) with aclientCertificateproperty acceptingICertificateRef.originMtlsConfigproperty to the following origin classes that useCustomOriginConfig:HttpOriginRestApiOriginFunctionUrlOrigin(both standard and OAC variant viaFunctionUrlOriginWithOAC)These origins each independently render
originMtlsConfigin their_renderCustomOriginConfig()method. While this introduces some duplication, it follows the same pattern used byipAddressTypeand other origin-specific properties, preserving backward compatibility and keeping each origin class self-contained.Note on
clientCertificate.certificateRef.certificateIdThe implementation uses
clientCertificate.certificateRef.certificateIdto obtain the certificate ARN. This works becauseCertificateBase(which backsICertificateRef) returns the full ARN fromcertificateId. This is consistent with how other CDK constructs resolve certificate references.Origins NOT covered (by design):
S3BucketOrigin/S3Origin— usesS3OriginConfig, notCustomOriginConfigVpcOrigin— usesVpcOriginConfig, notCustomOriginConfigS3StaticWebsiteOrigin— inheritsHttpOriginPropsviaHttpOrigin, sooriginMtlsConfigis exposed at the type level. However, S3 website endpoints only support HTTP, soHTTP_ONLYis forced and the validation added in this PR will reject the combination at construction time.Describe any new or updated permissions being added
None
Description of how you validated changes
Unit tests:
HttpOrigin: verifiesoriginMtlsConfigis rendered with the correctclientCertificateArnRestApiOrigin: verifiesoriginMtlsConfigis rendered with the correctclientCertificateArnFunctionUrlOrigin: verifies both standard and OAC variants renderoriginMtlsConfigcorrectlyIntegration tests:
integ.http-origin-mtls.ts,integ.rest-api-origin-mtls.ts, andinteg.function-url-origin-mtls.tsTLS Web Client Authentication(OID 1.3.6.1.5.5.7.3.2). Standard ACM-issued certificates will be rejected by CloudFront.CDK_INTEG_ACM_CERT_ARNorACM_CERT_ARNenvironment variable.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license