Skill 104 · AWS Media Services
Subchapter 104.2
references/service-rules-cloudfront.mdMarkdown10 KBView on GitHub
Loaded conditionally when the task involves CloudFront (media delivery). The cross-service rules in service-rules-core.md are always loaded alongside this file.
../../../); the CloudFront origin path depth MUST match what MediaTailor expects so relative URL resolution in the player still lands on the right cache behaviors. Leaving OriginPath empty is the simplest configuration that works in most cases. If a non-empty OriginPath is used, the cache behavior path patterns MUST be aligned to compensate.ads. and manifestParams.). If using GET-based session init, no additional CloudFront method configuration is needed. If using POST-based session init, AllowedMethods MUST include POST.Origin.Age SampleCount against the content origin’s own access logs, not against Requests (which counts all request types and is not comparable). No documented setting reduces those fetches further, so where the limit binds the lever is a quota increase.Origin.Age because that metric is emitted only when the response came from the origin. Diagnosis and the narrow gzip remedy are in troubleshooting-mediapackage.md.mediatailor.amazonaws.com principal access and mediapackagev2:GetObject first. Scope that service-principal grant against cross-service confused-deputy abuse: agents MUST add an aws:SourceAccount (your account id) condition and SHOULD add aws:SourceArn (the playback-configuration ARN) to the endpoint policy, so only your own MediaTailor configurations can assume the grant.When CloudFront fronts MediaTailor, the AWS-recommended pattern uses multiple origins with path-based routing for optimal caching and performance:
manifests.mediatailor.<region>.amazonaws.com. Serves personalized manifests, per-session media playlists, server-side beacon redirects and server-guided interstitial media. Paths: /v1/* (which covers /v1/master/*, /v1/manifest/*, /v1/dash/*, /v1/session/*, /v1/tracking/* and, at higher precedence, /v1/i-media/*) plus /segment/*. Omitting /v1/manifest/* breaks HLS playback because the per-session media playlist lives there, and omitting /segment/* breaks server-side beaconing.segments.mediatailor.<region>.amazonaws.com. Serves transcoded ad segments on /tm/*./out/v1/* (or whatever the MediaPackage endpoint path prefix is).
Every MediaTailor behavior SHOULD carry a CORS response headers policy. Missing CORS headers on the ad segment behavior breaks playback in browser-based players.MediaTailor rewrites manifests with segment URLs pointing back to CloudFront. If content segments route to MediaTailor instead of MediaPackage, players receive errors because MediaTailor does not serve content segments.
Cache behaviors, in precedence order:
/tm/* → ad segments origin, caching optimized, TTL 24h+, forward nothing (no headers, cookies or query strings in the cache key or origin request), CORS response headers/v1/i-media/* → manifests origin, forward nothing, CORS response headers. Caching optimized only when guided prefetch is not in use. With guided prefetch, caching MUST be disabled on this path: the player’s manifest refresh is the prefetch heartbeat, and a cache hit stops it reaching MediaTailor, which silently disables prefetching/v1/* → manifests origin, caching disabled, forward all viewer headers and query strings, CORS response headers/segment/* → manifests origin, caching disabled, forward all viewer headers and query strings, CORS response headers. This is the server-side reporting redirect, not an ad segment: it MUST reach MediaTailor on every view for the beacon to fire/out/v1/* → MediaPackage v2 origin, TTL=24h+ (segments are immutable), Origin Shield enabledCompression SHOULD stay enabled on the manifest behaviors. Manifests are the highest-request-rate text in the workflow, so compression there is a material delivery cost saving.
MediaTailor CdnConfiguration.ContentSegmentUrlPrefix MUST be set to the CloudFront distribution domain with the full MediaPackage path prefix (e.g., https://<cf-domain>/out/v1/<channel-group>/<channel>/<endpoint>) so that segment URLs in the rewritten manifest route through the correct CloudFront cache behavior to MediaPackage.
Without CdnConfiguration prefixes, MediaTailor emits origin-direct segment URLs, bypassing CloudFront caching. This works but loses CDN caching benefits for segments.
Access-Control-Allow-Origin to the allowed application origins (or * for unrestricted), Access-Control-Allow-Methods to GET, HEAD, OPTIONS, and enable “Override origin” to ensure consistent headers regardless of origin behavior.Strict-Transport-Security: max-age=31536000 (HSTS, 1 year), X-Content-Type-Options: nosniff, X-Frame-Options: DENY (or SAMEORIGIN if the player must be embedded), and Referrer-Policy: strict-origin-when-cross-origin. AWS provides a managed SecurityHeadersPolicy that includes these.X-MediaPackageV2-CDNIdentifier).mediapackagev2.amazonaws.com.Principal: "*" after OAC is configured.