A distribution could name a certificate in ACMCertificateArn and in IAMCertificateId at once, and could name one in either of them without the MinimumProtocolVersion and SSLSupportMethod that go with it. It could also carry a security policy or a viewer support method outside the values those members admit, carry SSLv3 alongside sni-only, and claim CloudFrontDefaultCertificate while naming a certificate of its own. The ViewerCertificate entry states every one of those rules, and nothing here read any of them, so a configuration AWS refuses was taken and the distribution went on to serve it. They are read now on the distribution create and the distribution update, and the shape of the protocol members before any of it, so a request that breaks a rule is refused for the rule and not for a certificate nothing matches. A member carried blank counts as no value, the way a blank location member already names no certificate, and a distribution on the CloudFront domain name needs neither location member. Two of the refusals are published. A MinimumProtocolVersion outside its enumeration is InvalidMinimumProtocolVersion, whose own sentence is that the minimum protocol version specified is not valid. SSLv3 alongside sni-only is InvalidProtocolSettings, whose sentence names that pair and nothing else and which is the same rule as the floor the member states for SNI, "you must specify TLSv1 or higher", SSLv3 being the only value below TLSv1. That code is declared on CreateDistribution, CreateDistributionWithTags and CopyDistribution and has never been declared on UpdateDistribution, which has declared InvalidMinimumProtocolVersion since 2015, so the update answers the pair with the code it declares and keeps the pair's published sentence. The declared code is the one a caller's SDK can map, an undeclared one reaching it as a generic error, and the sentence keeps the two causes the update answers under that one code apart. The others are readings. An SSLSupportMethod outside its enumeration has no code of its own and answers InvalidArgument, what this service already answers a member outside its shape with. The three rules about the certificate itself answer InvalidViewerCertificate 400: InvalidArgument and InvalidMinimumProtocolVersion are modelled on both writes as well and no sentence says which one a caller gets, and the Developer Guide page that enumerates what InvalidViewerCertificate answers reaches none of those cases, naming the certificate's own trust, its chain, its format and the names it covers. That code's own documentation is that a viewer certificate specified is not valid, which is what each of the three carries. One rule in the group replaces a value instead of refusing the request. MinimumProtocolVersion's entry says that when CloudFrontDefaultCertificate is true CloudFront "automatically sets the security policy to TLSv1 regardless of the value that you set here", so the policy such a request asks for is overwritten and the config reads back TLSv1. A distribution created with no ViewerCertificate at all already read as the default certificate and reads TLSv1 with it now, where it had been answering TLSv1.2_2021. Two more readings go with the group. The claim itself is a member declared boolean, so it is held to the four forms XML gives a boolean, true, false, 1 and 0, rather than read for the word true alone: taken for false, a request saying yes would dodge every rule the member governs, the refusal beside a named certificate and the replaced policy alike. Anything else answers the InvalidArgument this service answers a member outside its shape with, CloudFront modelling no error for a malformed document. And the SSLv3 pair is read for a distribution on a certificate of its own alone, since on the CloudFront certificate the policy is replaced and the value that would make the pair is discarded, so refusing the request for it would contradict the override. Both enumerations are read either way. The us-east-1 restriction AWS states for ACM certificates is left unenforced, as is the /cloudfront upload path before it: refusing either here could meet a distribution somebody already built. All of the above, that included, is set out in docs/services/cloudfront.md.
36 KiB
CloudFront
CloudFront management-plane and local content-delivery emulation. Supports distribution lifecycle, cache policies, origin request policies, response headers policies, origin access controls, origin access identities, public keys, trusted key groups, CloudFront Functions, invalidations, tagging, and viewer delivery from S3 or custom origins for every CloudFront viewer method (GET, HEAD, OPTIONS, POST, PUT, PATCH and DELETE).
Protocol: REST XML
API version: 2020-05-31
Endpoint prefix: cloudfront
Namespace: http://cloudfront.amazonaws.com/doc/2020-05-31/
Global service — ARNs contain no region segment.
Supported Operations
Distributions
| Operation | Method | Path |
|---|---|---|
CreateDistribution |
POST | /2020-05-31/distribution |
CreateDistributionWithTags |
POST | /2020-05-31/distribution?WithTags |
GetDistribution |
GET | /2020-05-31/distribution/{Id} |
GetDistributionConfig |
GET | /2020-05-31/distribution/{Id}/config |
UpdateDistribution |
PUT | /2020-05-31/distribution/{Id}/config |
DeleteDistribution |
DELETE | /2020-05-31/distribution/{Id} |
ListDistributions |
GET | /2020-05-31/distribution |
AssociateAlias |
PUT | /2020-05-31/distribution/{TargetDistributionId}/associate-alias |
Invalidations
| Operation | Method | Path |
|---|---|---|
CreateInvalidation |
POST | /2020-05-31/distribution/{Id}/invalidation |
GetInvalidation |
GET | /2020-05-31/distribution/{Id}/invalidation/{InvId} |
ListInvalidations |
GET | /2020-05-31/distribution/{Id}/invalidation |
Cache Policies
| Operation | Method | Path |
|---|---|---|
CreateCachePolicy |
POST | /2020-05-31/cache-policy |
GetCachePolicy |
GET | /2020-05-31/cache-policy/{Id} |
GetCachePolicyConfig |
GET | /2020-05-31/cache-policy/{Id}/config |
UpdateCachePolicy |
PUT | /2020-05-31/cache-policy/{Id} |
DeleteCachePolicy |
DELETE | /2020-05-31/cache-policy/{Id} |
ListCachePolicies |
GET | /2020-05-31/cache-policy |
Origin Request Policies
| Operation | Method | Path |
|---|---|---|
CreateOriginRequestPolicy |
POST | /2020-05-31/origin-request-policy |
GetOriginRequestPolicy |
GET | /2020-05-31/origin-request-policy/{Id} |
GetOriginRequestPolicyConfig |
GET | /2020-05-31/origin-request-policy/{Id}/config |
UpdateOriginRequestPolicy |
PUT | /2020-05-31/origin-request-policy/{Id} |
DeleteOriginRequestPolicy |
DELETE | /2020-05-31/origin-request-policy/{Id} |
ListOriginRequestPolicies |
GET | /2020-05-31/origin-request-policy |
Response Headers Policies
| Operation | Method | Path |
|---|---|---|
CreateResponseHeadersPolicy |
POST | /2020-05-31/response-headers-policy |
GetResponseHeadersPolicy |
GET | /2020-05-31/response-headers-policy/{Id} |
GetResponseHeadersPolicyConfig |
GET | /2020-05-31/response-headers-policy/{Id}/config |
UpdateResponseHeadersPolicy |
PUT | /2020-05-31/response-headers-policy/{Id} |
DeleteResponseHeadersPolicy |
DELETE | /2020-05-31/response-headers-policy/{Id} |
ListResponseHeadersPolicies |
GET | /2020-05-31/response-headers-policy |
Origin Access Control (OAC)
| Operation | Method | Path |
|---|---|---|
CreateOriginAccessControl |
POST | /2020-05-31/origin-access-control |
GetOriginAccessControl |
GET | /2020-05-31/origin-access-control/{Id} |
GetOriginAccessControlConfig |
GET | /2020-05-31/origin-access-control/{Id}/config |
UpdateOriginAccessControl |
PUT | /2020-05-31/origin-access-control/{Id} |
DeleteOriginAccessControl |
DELETE | /2020-05-31/origin-access-control/{Id} |
ListOriginAccessControls |
GET | /2020-05-31/origin-access-control |
Origin Access Identity (OAI — legacy)
| Operation | Method | Path |
|---|---|---|
CreateCloudFrontOriginAccessIdentity |
POST | /2020-05-31/origin-access-identity/cloudfront |
GetCloudFrontOriginAccessIdentity |
GET | /2020-05-31/origin-access-identity/cloudfront/{Id} |
GetCloudFrontOriginAccessIdentityConfig |
GET | /2020-05-31/origin-access-identity/cloudfront/{Id}/config |
UpdateCloudFrontOriginAccessIdentity |
PUT | /2020-05-31/origin-access-identity/cloudfront/{Id}/config |
DeleteCloudFrontOriginAccessIdentity |
DELETE | /2020-05-31/origin-access-identity/cloudfront/{Id} |
ListCloudFrontOriginAccessIdentities |
GET | /2020-05-31/origin-access-identity/cloudfront |
CloudFront Functions
| Operation | Method | Path |
|---|---|---|
CreateFunction |
POST | /2020-05-31/function |
GetFunction |
GET | /2020-05-31/function/{Name} |
DescribeFunction |
GET | /2020-05-31/function/{Name}/describe |
UpdateFunction |
PUT | /2020-05-31/function/{Name} |
PublishFunction |
POST | /2020-05-31/function/{Name}/publish |
DeleteFunction |
DELETE | /2020-05-31/function/{Name} |
ListFunctions |
GET | /2020-05-31/function |
Public Keys and Key Groups
| Operation | Method | Path |
|---|---|---|
CreatePublicKey |
POST | /2020-05-31/public-key |
GetPublicKey |
GET | /2020-05-31/public-key/{Id} |
GetPublicKeyConfig |
GET | /2020-05-31/public-key/{Id}/config |
UpdatePublicKey |
PUT | /2020-05-31/public-key/{Id}/config |
DeletePublicKey |
DELETE | /2020-05-31/public-key/{Id} |
ListPublicKeys |
GET | /2020-05-31/public-key |
CreateKeyGroup |
POST | /2020-05-31/key-group |
GetKeyGroup |
GET | /2020-05-31/key-group/{Id} |
GetKeyGroupConfig |
GET | /2020-05-31/key-group/{Id}/config |
UpdateKeyGroup |
PUT | /2020-05-31/key-group/{Id} |
DeleteKeyGroup |
DELETE | /2020-05-31/key-group/{Id} |
ListKeyGroups |
GET | /2020-05-31/key-group |
Tagging
| Operation | Method | Path |
|---|---|---|
ListTagsForResource |
GET | /2020-05-31/tagging?Resource={arn} |
TagResource |
POST | /2020-05-31/tagging?Operation=Tag&Resource={arn} |
UntagResource |
POST | /2020-05-31/tagging?Operation=Untag&Resource={arn} |
Behavior
- All distributions are immediately set to
Deployedstate (no asyncInProgressdelay). - Distribution IDs are 14 uppercase alphanumeric characters starting with
E(e.g.E1Z2X3C4V5B6N7). - Distribution domain names follow the pattern
{id}.cloudfront.net, with the id lower-cased as AWS writes it in a host name. - Public key IDs are
Kfollowed by 13 uppercase alphanumeric characters (e.g.K2JCJMDEHXQW5F), the value a signed URL carries asKey-Pair-Id. Key group, cache policy, origin request policy and response headers policy IDs are UUIDs, as they are on AWS. - ARNs are global — no region segment:
arn:aws:cloudfront::{accountId}:distribution/{id}. - Invalidations are immediately marked
Completed. DeleteDistributionreturnsDistributionNotDisabled(409) ifEnabledistruein the config.- All mutating operations (
PUT,DELETE) require anIf-Matchheader containing the currentETag. Response headers policies, public keys, and key groups distinguish a missing header (InvalidIfMatchVersion, 400) from a staleETag(PreconditionFailed, 412). Other CloudFront resources currently returnInvalidIfMatchVersion(400) for either case. - All
GETandPOST(create) responses include anETagresponse header. - List operations emit the payload root declared by the CloudFront REST XML model (for example,
ListDistributionsreturns<DistributionList>), with list contents represented by<Quantity>N</Quantity><Items>...</Items>. - OAI
CallerReferenceuniqueness is enforced — duplicateCallerReferencevalues returnCloudFrontOriginAccessIdentityAlreadyExists(409). - CNAME aliases are globally unique.
AssociateAliasatomically transfers an alias from its current owner to the target distribution. Exact aliases take precedence over the most-specific matching wildcard alias. - Viewer requests addressed to an enabled distribution's generated domain or alias are routed to the
matching S3 or custom origin when the matched cache behavior's
AllowedMethodsincludes the method; any other method returns 403Invalid method.. A behavior withoutAllowedMethodsallows GET and HEAD. Origin forwarding preserves the raw path, including%25for a literal percent sign, on generated domains and aliases. Custom-origin redirects are not followed. - POST, PUT, PATCH and DELETE are forwarded to custom origins with the viewer request body and its
Content-Type. The body is streamed to the origin with the viewer'sContent-Length, or chunked when the viewer sent it chunked or, as HTTP/2 allows, with no length, so it is never held in memory. Their responses are never cached, as on AWS. Signed URL and signed cookie enforcement applies to them like any other method. Request bodies are bounded by the emulator-widefloci.protocols.max-request-sizelimit (FLOCI_PROTOCOLS_MAX_REQUEST_SIZE, 2048 MB by default); CloudFront accepts up to 64 GB, so raise it for larger uploads. - Every distribution is also served as
{id}.cloudfront.{host}for each endpoint host Floci resolves:localhost,localhost.floci.io,localhost.localstack.cloud,FLOCI_HOSTNAMEand everyFLOCI_DNS_EXTRA_SUFFIXESentry.{id}.cloudfront.localhost.floci.ioand{id}.cloudfront.localhostreach loopback with no host-file edit and are covered by the generated HTTPS certificate, so a signed URL for either can be downloaded overhttps://. See Downloading over HTTPS. - Origin custom headers are persisted through the CloudFront API and CloudFormation. They replace
every same-named forwarded viewer header on custom-origin requests. For in-process S3 origins, a
configured
Originheader is used for S3 CORS evaluation. AWS-prohibited names, malformed values, inconsistent quantities, duplicates, and quota violations are rejected with modeled CloudFront errors when the distribution is created or updated. - Cache behaviors with enabled
TrustedKeyGroupsrequire a valid CloudFront signed URL or signed cookie before the origin is contacted. Signed URL parameters take precedence over signed cookies. Canned and custom policies support SHA-1 or SHA-256 signatures with RSA-2048 or ECDSA P-256 public keys. Custom policies enforce resource wildcards, expiration, optional activation time, and IPv4 CIDR restrictions. Canned resources compare literally, including query strings. Exact custom resources can include one raw query delimiter. As a conservative limitation, other custom resources containing a raw?fail closed because the character is ambiguous with CloudFront's one-character wildcard; custom query-string wildcards are therefore not supported. Invalid or expired signatures return 403. - A key group must contain one to five existing public keys. Public keys that belong to a key group and key groups referenced by a cache behavior cannot be deleted until those references are removed.
- Application query parameters are retained when constructing the resource covered by a signature. CloudFront signing parameters are excluded from that resource and are never sent to the origin.
- S3-origin reads honor anonymous access, OAI bucket-policy or object-ACL grants, and OAC
service-principal bucket-policy grants (including the distribution
AWS:SourceArn) when strict S3 authentication is enabled. OACalways,never, and unsignedno-overriderequests follow their documented signing behavior; signedno-overrideviewer requests retain their authorization. - Requests to custom origins carry what the matched cache behavior forwards. With a cache policy,
the viewer headers, cookies and query strings selected by the cache policy's
ParametersInCacheKeyAndForwardedToOriginand by the origin request policy are forwarded (the union of both).HeaderBehaviornone,whitelist,allViewer,allViewerAndWhitelistCloudFrontandallExcept,CookieBehaviorandQueryStringBehaviornone,whitelist,allExceptandallare evaluated. A cache policy that selects nothing and no origin request policy forwards no viewer headers, cookies or query strings, as on AWS, apart from the headers below that CloudFront forwards whatever the policies. - A cache behavior without a cache policy uses its legacy
ForwardedValues:QueryString=trueforwards every query string (QueryStringCacheKeysonly narrows the cache key), cookies followForwardnone,whitelist(with*and?wildcards) orall, and viewer headers are forwarded by default exceptAccept,Accept-Charset,Accept-Language,Authorization,Host,Referer,User-AgentandX-HTTP-Method-Override, whichHeaderscan add back (*forwards all of them). An origin request policy needs a cache policy on AWS, so a behavior without one ignores it. - Whatever the policies, CloudFront sets
Hostto the origin's domain name unless the viewer'sHostis forwarded, sendsUser-Agent: Amazon CloudFrontunless the viewer'sUser-Agentis forwarded, appends the viewer address toX-Forwarded-For, adds aVia: <viewer HTTP version> <distribution domain> (CloudFront)hop and anX-Amz-Cf-Id.Authorizationis always forwarded on POST, PUT, PATCH and DELETE, and on OPTIONS unless OPTIONS is a cached method;Content-Typetravels with a request body; a GET or HEAD with aRangecarries the viewer'sRangeandIf-Range, since CloudFront forwards a range GET to the origin, and a HEAD can then report the range's length. Cache policy compression settings normalizeAccept-Encodingtobr,gzip,gzip,broridentity. Forwarded cookies are sorted by name, and cookies that are notname=valueor whose name starts with$are dropped. Hop-by-hop headers,Expect,X-Edge-*,X-Real-IP,X-Forwarded-Protoand viewer-suppliedCloudFront-*headers are never forwarded. - Of the CloudFront request headers,
CloudFront-Forwarded-Proto,CloudFront-Viewer-AddressandCloudFront-Viewer-Http-Versionare generated when a policy names them, or when anallExceptheader behavior does not exclude them (AWS documents Managed-AllViewerExceptHostHeader as adding them). Device-type, geolocation, TLS, JA3/JA4 and header-order headers are not generated. - The eight AWS managed origin request policies are available by their AWS IDs through
GetOriginRequestPolicyandListOriginRequestPolicies(Typeismanagedorcustom), and cannot be updated or deleted. The seven AWS managed cache policies with published settings (Managed-Amplify,Managed-CachingDisabled,Managed-CachingOptimized,Managed-CachingOptimizedForUncompressedObjects,Managed-Elemental-MediaPackage,Managed-UseOriginCacheControlHeadersandManaged-UseOriginCacheControlHeaders-QueryStrings) are available by their AWS IDs throughGetCachePolicy,GetCachePolicyConfigandListCachePolicies(Typeismanagedorcustom), and cannot be updated or deleted. A behavior that references one forwards what its settings select. The four Amplify-only managed cache policies (Amplify-Default,Amplify-DefaultNoCookies,Amplify-ImageOptimizationandAmplify-StaticContent) are not modeled: a behavior that references one forwards nothing. - In-process S3 origins do not apply forwarding settings: viewer query strings, cookies and headers
do not change the S3 read, apart from the viewer's
RangeandIf-Rangeon a GET or HEAD. - Origin responses are streamed to the viewer, from in-process S3 origins and custom origins alike,
so a large object is never held in memory. A custom origin's
Content-Lengthis passed on, and a response it sends chunked stays chunked. Floci does not cache, so it serves objects larger than 50 GB the way CloudFront does with caching disabled; with caching enabled, CloudFront refuses them. - WebSocket connections to custom origins are tunneled on every distribution, with no setting, as on
AWS. An HTTP/1.1 GET with
Upgrade: websocketandConnection: Upgradegoes to the origin the matched behavior selects with itsUpgradeandConnectionfields, and once the origin answers101 Switching Protocolsthe viewer and origin connections are joined. Any other origin answer is relayed as an ordinary response, without custom error responses or a response headers policy, within the origin's response and response completion timeouts. TheSec-WebSocket-*fields follow the behavior's forwarding settings as any other header does, so the behavior must forward all viewer headers (theAllViewerorigin request policy, or legacy cache settings) or at leastSec-WebSocket-KeyandSec-WebSocket-Version. A WebSocket handshake to an S3 origin is served as an ordinary GET. - Range GETs: an S3 origin serves the one byte range a viewer's
Rangeasks for as 206 with itsContent-Range, and answers 416 when the range starts past the end of the object. Any otherRangegets the whole object: one CloudFront does not accept (ranges out of order or overlapping, or a negative value), several ranges, which S3 does not serve in one request, or a last byte before the first, as does aRangewhoseIf-Rangeno longer describes the object, which S3 answers with the whole object. A HEAD is answered as S3's HeadObject answers aRange: a satisfiable range changes only itsContent-Length, and one past the end gets 416. A custom origin gets the viewer'sRangeandIf-Rangeon every GET or HEAD with aRange, whatever the forwarding settings, and its answer (206, the whole object, or 416) is passed on. Floci does not cache, so unlike CloudFront it cannot serve a later range request from an object the origin sent whole. A custom error page is served whole, whatever theRangeof the request it replaces. - Origin
Set-Cookieheaders always reach the viewer. With legacyForward=none, AWS strips them from the response; Floci does not. - Custom-origin requests honor the origin's connection settings.
Origin.ConnectionAttempts(1 to 3, default 3) is how many times CloudFront tries to reach the origin, andOrigin.ConnectionTimeout(1 to 10 seconds, default 10) how long it waits for the connection.CustomOriginConfig.OriginReadTimeout(1 to 120 seconds, default 30) bounds the wait for the origin's response, and a read timeout on a GET or HEAD is retried up to the connection attempts, as CloudFront does, while a POST, PUT, PATCH or DELETE is not retried.Origin.ResponseCompletionTimeoutbounds the time the origin takes, connecting, answering and streaming the body included, over every attempt, and ends the connection when it expires; unset, or 0, leaves the origin as long as it wants to take, and a set value must be at least the read timeout. The time a slow viewer takes to read what the origin already sent is not part of it: the origin answered in time, so the response is not expired.CustomOriginConfig.OriginKeepaliveTimeout(1 to 300 seconds, default 5) is how long CloudFront keeps a connection to the origin after the last packet of a response. An origin that does not answer in time is answered 504, "The origin didn't respond before the request expired", as on AWS. - Custom origins that resolve to loopback, private, link-local, carrier-grade NAT, or other non-routable addresses are rejected by default. Development-only private origins must be explicitly allowlisted by exact hostname. A refused origin is logged with the host and the setting that allows it.
- A custom origin that names this Floci itself, as
localhost,127.0.0.1,::1or the configuredfloci.hostname, on a port Floci listens on (its own port, orfloci.tls.aws-https-portwith TLS on) for the protocol the request uses, is served by Floci itself, so neither DNS nor the private address check applies. This is the usual local setup for a single-page app: a path-style S3 bucket as the origin path, fronted by the distribution's custom error responses. The request reaches Floci with the origin's domain as itsHost, and dot segments cannot leave the origin path. A forwarded viewerHostis a 502, since it would route the request back to the distribution. The same hosts on any other port are still refused unless allowlisted. - A custom origin whose domain is an execute-api endpoint (
{apiId}.execute-api.{region}.amazonaws.com) of an HTTP or REST API that exists in this Floci is served by Floci itself, at the address the viewer reached, through the same host routing as a direct call. The origin path names the stage, as on AWS. Neither DNS nor the private address check applies. A forwarded viewerHostis a 502, so use an origin request policy such asManaged-AllViewerExceptHostHeader. An execute-api domain of an API that does not exist in this Floci is fetched like any other custom origin. A request that the host routing would not send to the API (a WebSocket API, a disabled endpoint, a missing stage, or a region other than the API's) is answered 404{"message":"Not Found"}and never reaches Floci's other endpoints. - A custom origin whose domain is a Lambda Web Function endpoint of this Floci is
served by Floci itself, at the address the viewer reached. The origin names the endpoint's
domainNamewith or without its port, and its protocol and ports do not matter, so neither DNS nor the private address check applies. A forwarded viewerHostis a 502, as on AWS, where the endpoint's certificate does not name it. Under analways-amz-authorigin access control, Floci signs these requests for the distribution. AnIamAuthendpoint then lets them through, or with IAM enforcement on evaluates the function's resource policy forcloudfront.amazonaws.com, with the distribution asaws:SourceArnand its account asaws:SourceAccount. Without one, anIamAuthendpoint answers with its 403 page. CloudFront forwards the viewer'sAuthorizationon GET and HEAD only when the cache policy includes it. A forwardedAuthorizationreaches the function unless it is an AWS signature. - Origin access controls and distributions follow the AWS checks for Lambda origins. CloudFront tells
them apart by a hostname under
on.awswith its fixed labels in lowercase, and Floci also by one under its own host. A Web Function endpoint needs alambdaorigin access control withalways-amz-auth, signed withsigv4afor aglobalendpoint andsigv4otherwise, andalways-amz-authis for Web Function origins only. A Lambda@Edge origin trigger is refused in front of an origin signed withalways-amz-authorsigv4a. Theexecute-apiorigin type is refused withAccessDenied, as AWS refuses it. A distribution has to name an origin access control that exists, and a control in use keeps its origin type, its signing protocol and whether it isalways-amz-auth. - Response headers policies validate the AWS configuration shape and are applied after the origin
response, including CORS preflight fields, origin override behavior, custom headers, security
headers, allowed header removals, and sampled
Server-Timingmetrics.Pragma: server-timingforces those metrics for enabled policies. Distribution writes reject unknown policy IDs, and policies attached to a cache behavior cannot be deleted. ViewerCertificate.IAMCertificateIdmust be theServerCertificateIdof an uploaded IAM server certificate: distribution create and update reject an unknown one withInvalidViewerCertificate, andDeleteServerCertificatereturnsDeleteConflictwhile a distribution references it. A blank value names no certificate, which is what a distribution on the CloudFront domain name sends. The/cloudfrontupload path AWS documents for a certificate meant for CloudFront is not enforced, so a certificate uploaded anywhere serves a distribution: a deliberate divergence, with both sources and what would move it under Server Certificates in IAM.ViewerCertificate.ACMCertificateArnmust name an existing ACM certificate: distribution create and update reject an unknown one withInvalidViewerCertificate. ACM lists the distribution's ARN underInUseBy, andDeleteCertificatereturnsResourceInUseExceptionwhile a distribution references it.- A
ViewerCertificatethat names a certificate is held to the two rules its own entry states. The location isACMCertificateArnorIAMCertificateIdand "not both", and a certificate named in either one "must also specify values for MinimumProtocolVersion and SSLSupportMethod". Both refusals areInvalidViewerCertificate400, which is Floci's reading rather than a published answer:InvalidArgumentandInvalidMinimumProtocolVersionare modelled on the distribution writes as well, and no sentence says which one a caller gets, so both cases read as the certificate the request carries not being valid. The Developer Guide page that enumerates whatInvalidViewerCertificateanswers reaches neither case either: it names the certificate's own trust, its chain, its format and the names it covers. A member carried blank counts as no value, the way a blank location member names no certificate, and a distribution on the CloudFront domain name needs neither member. The rules are read before the certificate is looked up, so a request that breaks one is refused for the rule and not for a certificate nothing matches. - The viewer certificate's two protocol members are held to the values they admit and to the one
pair they cannot carry together. A
MinimumProtocolVersionoutsideSSLv3,TLSv1,TLSv1_2016,TLSv1.1_2016,TLSv1.2_2018,TLSv1.2_2019,TLSv1.2_2021,TLSv1.2_2025andTLSv1.3_2025isInvalidMinimumProtocolVersion400, which is published rather than read: that code's own sentence names this case. AnSSLSupportMethodoutsidesni-only,vipandstatic-iphas no code of its own and isInvalidArgument400, what this service already answers a member outside its shape with.SSLv3alongsidesni-onlyisInvalidProtocolSettings400 onCreateDistribution,CreateDistributionWithTagsandCopyDistribution, whose sentence names that pair and nothing else and which is the same rule as the floor the member states for SNI, "you must specify TLSv1 or higher".UpdateDistributionhas never declared that code and has declaredInvalidMinimumProtocolVersionsince 2015, so the update answers the pair with the code it declares, which is the one a caller's SDK can map, and keeps the pair's published sentence, so the two causes the update answers under one code stay apart. The pair is read for a distribution on a certificate of its own alone, since on the CloudFront certificate the policy is replaced and the value that would make the pair is discarded. Both enumerations are read either way. - A distribution on the CloudFront domain name sets
CloudFrontDefaultCertificateand is told to "leave all other fields empty". The member is declaredboolean, so it is held to the four forms XML gives a boolean,true,false,1and0, and anything else isInvalidArgument400. That refusal is Floci's reading: CloudFront models no error for a malformed document, and reading the member for the wordtruealone would let a request sayingyesdodge every rule below. A certificate named beside it, inACMCertificateArnorIAMCertificateId, contradicts the request's own claim and isInvalidViewerCertificate400, Floci's reading again. AMinimumProtocolVersionbeside it is not refused: the member's entry says CloudFront "automatically sets the security policy to TLSv1 regardless of the value that you set here", so the policy a request asks for there is replaced and the config reads backTLSv1. A distribution created with noViewerCertificateat all reads the same way, the default certificate onTLSv1. Theus-east-1restriction AWS states for ACM certificates is not enforced: a certificate is resolved from whatever region its ARN names, as long as it exists. - Up to 20 custom response headers policies can be created, and one policy can be associated with up to 100 distributions.
- The five AWS managed response headers policy IDs are available and can be selected with
ListResponseHeadersPolicies?Type=managed;Typeuses the AWS lowercasemanagedorcustomvalues.
Configuration
| Property | Env var | Default | Description |
|---|---|---|---|
floci.services.cloudfront.enabled |
FLOCI_SERVICES_CLOUDFRONT_ENABLED |
true |
Enable or disable the service |
floci.services.cloudfront.domain-suffix |
FLOCI_SERVICES_CLOUDFRONT_DOMAIN_SUFFIX |
unset | Domain suffix for generated distribution domain names. Unset, it follows the request's partition: cloudfront.net, or cloudfront.cn in China. A configured suffix applies in every partition |
floci.services.cloudfront.allowed-private-origin-hosts |
FLOCI_SERVICES_CLOUDFRONT_ALLOWED_PRIVATE_ORIGIN_HOSTS |
[] |
Exact custom-origin hosts permitted to resolve to private/non-routable addresses (comma-separated in the environment variable) |
CLI Examples
For an executable OAC example with direct-S3 and unrelated-distribution negative checks, see Private S3 origin example.
export AWS_ENDPOINT_URL=http://localhost:4566
export AWS_DEFAULT_REGION=us-east-1
export AWS_ACCESS_KEY_ID=test
export AWS_SECRET_ACCESS_KEY=test
# Create a distribution with an S3 origin
aws cloudfront create-distribution --distribution-config '{
"CallerReference": "ref-1",
"Enabled": true,
"Comment": "my distribution",
"Origins": {
"Quantity": 1,
"Items": [{
"Id": "my-origin",
"DomainName": "mybucket.s3.amazonaws.com",
"S3OriginConfig": {"OriginAccessIdentity": ""}
}]
},
"DefaultCacheBehavior": {
"TargetOriginId": "my-origin",
"ViewerProtocolPolicy": "redirect-to-https",
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
"AllowedMethods": {"Quantity": 2, "Items": ["GET","HEAD"]},
"Compress": true
}
}'
# Get a distribution
aws cloudfront get-distribution --id E1Z2X3C4V5B6N7
# List distributions
aws cloudfront list-distributions
# Create a cache invalidation
aws cloudfront create-invalidation \
--distribution-id E1Z2X3C4V5B6N7 \
--invalidation-batch '{
"CallerReference": "inv-1",
"Paths": {"Quantity": 1, "Items": ["/*"]}
}'
# Create an OAI (Origin Access Identity)
aws cloudfront create-cloud-front-origin-access-identity \
--cloud-front-origin-access-identity-config \
"CallerReference=oai-1,Comment=my-oai"
# Create an OAC (Origin Access Control)
aws cloudfront create-origin-access-control \
--origin-access-control-config '{
"Name": "my-oac",
"Description": "",
"OriginAccessControlOriginType": "s3",
"SigningBehavior": "always",
"SigningProtocol": "sigv4"
}'
# Create a cache policy
aws cloudfront create-cache-policy --cache-policy-config '{
"Name": "my-cache-policy",
"DefaultTTL": 86400,
"MinTTL": 0,
"MaxTTL": 31536000,
"ParametersInCacheKeyAndForwardedToOrigin": {
"EnableAcceptEncodingGzip": true,
"EnableAcceptEncodingBrotli": true,
"HeadersConfig": {"HeaderBehavior": "none"},
"CookiesConfig": {"CookieBehavior": "none"},
"QueryStringsConfig": {"QueryStringBehavior": "none"}
}
}'
# Disable and delete a distribution
ETAG=$(aws cloudfront get-distribution --id E1Z2X3C4V5B6N7 \
--query 'ETag' --output text)
aws cloudfront update-distribution --id E1Z2X3C4V5B6N7 \
--if-match "$ETAG" \
--distribution-config '...(config with Enabled: false)...'
ETAG=$(aws cloudfront get-distribution --id E1Z2X3C4V5B6N7 \
--query 'ETag' --output text)
aws cloudfront delete-distribution --id E1Z2X3C4V5B6N7 --if-match "$ETAG"
Downloading over HTTPS
A distribution's own domain name ({id}.cloudfront.net by default) resolves to nothing local, so
address the distribution by one of its local delivery hostnames instead. *.cloudfront.localhost.floci.io
resolves to 127.0.0.1 through public DNS and works on Linux, macOS and in containers.
*.cloudfront.localhost needs no DNS at all but only resolves where the runtime handles .localhost
itself, which macOS and browsers do and Debian-based images do not.
Start Floci with TLS enabled and trust its CA once:
docker run -e FLOCI_TLS_ENABLED=true -p 4566:4566 floci/floci:latest
curl -s http://localhost:4566/_floci/ca.pem -o floci-root-ca.pem
Sign the URL of the hostname you download from — the port is part of what a canned policy signs — and fetch it:
HOST=e1z2x3c4v5b6n7.cloudfront.localhost.floci.io:4566
SIGNED=$(aws cloudfront sign \
--url "https://$HOST/hello.txt" \
--key-pair-id K2JCJMDEHXQW5F \
--private-key file://private_key.pem \
--date-less-than 2026-12-31T00:00:00Z)
curl --cacert floci-root-ca.pem "$SIGNED"
To drop the :4566, publish the HTTPS port Floci also binds when TLS is on (-p 443:443, see
FLOCI_TLS_AWS_HTTPS_PORT) and sign https://e1z2x3c4v5b6n7.cloudfront.localhost.floci.io/hello.txt.
Set FLOCI_SERVICES_CLOUDFRONT_DOMAIN_SUFFIX=cloudfront.localhost.floci.io to have
CreateDistribution return that hostname as the DomainName, so test code can sign the API response
as it is.
Behind a reverse proxy
When a proxy terminates HTTPS and forwards HTTP to Floci, sign the browser-visible HTTPS URL,
including its external hostname, port and path. Floci rebuilds the signed resource from the
request scheme and host, so it must receive the external scheme through trusted proxy headers.
A signature made for https:// does not match a resource rebuilt as http://.
For a proxy that preserves Host and sets X-Forwarded-Proto and X-Forwarded-Port,
configure the Floci container with:
environment:
QUARKUS_HTTP_PROXY_PROXY_ADDRESS_FORWARDING: "true"
QUARKUS_HTTP_PROXY_ALLOW_X_FORWARDED: "true"
QUARKUS_HTTP_PROXY_ALLOW_FORWARDED: "false"
QUARKUS_HTTP_PROXY_ENABLE_FORWARDED_HOST: "true"
QUARKUS_HTTP_PROXY_TRUSTED_PROXIES: "<proxy source IP or CIDR>"
Replace the placeholder with the proxy's source address as seen by Floci. In Docker this may
be a bridge or gateway address rather than the host's loopback address. Quarkus ignores forwarded
headers from peers outside QUARKUS_HTTP_PROXY_TRUSTED_PROXIES; a missing proxy address leaves
Floci seeing HTTP and a valid HTTPS URL fails with Signature does not match the policy.
For example, when signing https://e1z2x3c4v5b6n7.cloudfront.localhost.floci.io:19443/hello.txt,
the proxy should forward these headers to Floci:
Host: e1z2x3c4v5b6n7.cloudfront.localhost.floci.io:19443
X-Forwarded-Proto: https
X-Forwarded-Port: 19443
A non-default external port needs X-Forwarded-Port, even when the proxy preserves Host.
Applying X-Forwarded-Proto resets Quarkus' port, so preserving Host alone rebuilds the URL
without :19443 and fails the signature check. Alternatively, send X-Forwarded-Host with
the external hostname and port; the forwarded-host setting above enables its use.
The proxy must replace client-supplied forwarded headers, and the trusted-proxy list should cover only its actual peers. See Quarkus reverse-proxy configuration for other header layouts.
With these settings a valid proxy HTTPS signed URL succeeds; missing, expired or invalid signatures must still return 403. Verify those cases through the proxy after configuring it.
Not Supported (Phase 2)
- Continuous deployment policies (
CreateContinuousDeploymentPolicy, etc.) CopyDistribution(staging distributions)- Real-time log configs (
CreateRealtimeLogConfig, etc.) - Field-level encryption (
CreateFieldLevelEncryptionConfig, etc.) TestFunctionexecution (function is stored, not executed)- Streaming distributions (RTMP — deprecated by AWS)
- VPC origins, Anycast IP lists, key value stores
- Monitoring subscriptions
- CloudFormation provisioning of custom
AWS::CloudFront::ResponseHeadersPolicyresources (literal custom or managed policy IDs are supported on distributions) - Persistent edge caching and global CDN propagation
- Forwarding POST, PUT, PATCH and DELETE to S3 origins. AWS passes them to S3, which evaluates them
against the bucket policy (OAC supports
PUTandDELETE); Floci's in-process S3 origin answers them with 403Access Denied, as S3 does for a request that holds no write grant.