CloudFront Media Behavior Automation Web PHP v139
Built UTC: 2026-05-20T21:42:54Z
Goal
This is a portable PHP tool: unzip it anywhere PHP can run, update the password and credentials, then use the browser to configure CloudFront media caching and CORS.
Package files
This package intentionally contains only these files:
cloudfront-media-behavior-automation.php — main tool
cloudfront-tool-local-config.php — optional local AWS credential config
README.html — documentation
LICENSE.txt — MIT license
No index.php, no web.config, no Markdown files.
Quick start
- Unzip the package anywhere PHP can run.
- Open
cloudfront-media-behavior-automation.php in your editor.
- Edit the first PHP setting line, immediately after
<?php: const TOOL_PASSWORD_DEFAULT = 'change-this-password-now';
- Open
cloudfront-tool-local-config.php and add AWS credentials, or leave placeholders and enter keys manually in the browser.
- Open
cloudfront-media-behavior-automation.php in your browser.
- Click Load distributions.
- Select the distributions you want.
- Run Dry run.
- If the dry run looks right, run Apply.
Launch URL example
http://localhost/beta/cloudfront-media-behavior-automation-web-php/cloudfront-media-behavior-automation.php
App password
In cloudfront-media-behavior-automation.php, set:
const TOOL_PASSWORD_DEFAULT = 'your-private-tool-password';
Optional local credential file
The tool uses exactly one local credential filename:
cloudfront-tool-local-config.php
Edit it on your trusted private machine:
<?php
return [
'awsAccessKeyId' => 'REAL_AWS_ACCESS_KEY_ID_HERE',
'awsSecretAccessKey' => 'REAL_AWS_SECRET_ACCESS_KEY_HERE',
'awsSessionToken' => '',
];
You can also leave placeholders and enter keys manually in the browser.
What the tool automates
Creates or reuses:
MediaCacheLong1Year
PublicMediaCORSFromEverywhere
JsonNearFresh
DebugNoCache
Adds or updates media, JSON, and debug CloudFront behaviors on selected distributions.
Security
Use local config only on localhost/private IIS. Do not upload filled-in AWS credentials to public hosting or a public repository.
For shared or temporary hosting, enter AWS keys manually at run time, run the tool, delete the tool, and deactivate/delete the temporary AWS key.
v117 package rule
cloudfront-media-behavior-automation.php
cloudfront-tool-local-config.php
README.html
LICENSE.txt
Browser password saving
The tool uses a fixed username so Chrome and other password managers can save the tool password reliably:
cloudfront-media-tool
Do not change the username unless you also want the browser to treat it as a different saved login.
Windows PHP TLS note
If Test AWS credentials reports cURL error 60 or “unable to get local issuer certificate”, the local PHP/cURL build cannot verify AWS TLS certificates.
The tool tries normal PHP/cURL trust first, then Windows native CA support when the PHP/cURL build exposes it.
If that still fails, use a normal HTTPS hosting account or a Windows PHP/cURL build that supports the Windows certificate store.
The tool keeps TLS verification enabled.
v121 restored from full v117 codebase
v121 restores the app from the last full-size codebase, v117, after v118-v120 were built from a reduced source. It also restores the correct AWS-only local config template.
- Restored from
cloudfront-media-behavior-automation-web-php-v139.zip.
- Package includes the standard four files.
cloudfront-tool-local-config.php contains AWS credentials only.
- Tool username/password do not belong in the local config file.
v122 standard status placement
v122 removes the Access-specific status behavior. Access, AWS credentials, and TraceLog now use the same inline status rule and explicit status elements.
- Access status writes only to
toolPasswordStatus.
- AWS status writes only to
awsCredentialStatus.
- No status text is appended into a button cell.
ok, good, bad, and wait status classes all use one common CSS rule set.
v123 advisory verification and direct startup automation
v123 keeps existing app styles and fixes behavior without adding new style systems.
- Post-apply verification is advisory. A verification readback problem no longer means apply failed.
- Startup Access authorization waits for autofill and does not show a false missing-password error.
- Startup AWS test includes the already-authorized tool username/password.
- Startup distribution discovery uses
ajax-discover-distributions directly; it does not trigger the Load distributions button.
- TraceLog viewer uses the existing TraceLog style with a smaller fixed height.
v124 card explanation standardization
v124 restores the Run and Created/reused policies card explanation lines to plain paragraph elements.
- No new style classes.
- No new CSS rules.
- Existing paragraph styling is used.
- Full-size v123 source is preserved.
v125 CORS explanation update
v125 updates the PublicMediaCORSFromEverywhere explanation to mention browser JavaScript apps opened from local files on home PCs.
- No style changes.
- No new CSS rules.
- Full-size v124 source is preserved.
v126 TraceLog spacing standardization
v126 removes TraceLog-specific spacing exceptions that created a large blank gap between the buttons and the trace viewer.
- TraceLog button row uses the standard card gap.
- TraceLog viewer follows immediately after the button row using the same card spacing.
- No standalone empty TraceLog status row is allowed to reserve vertical space.
- No new visual style system is introduced.
v127 TraceLog spacer removal
v127 removes the actual reserved TraceLog spacer by forcing the TraceLog card body to two rows only: button row and trace viewer.
- No hidden middle row between TraceLog buttons and viewer.
- No empty status/spacer row between TraceLog buttons and viewer.
- TraceLog card uses the standard card gap only.
- No new visual style system is introduced.
v128 TraceLog fixed viewer height
v128 restores the TraceLog viewer to a fixed useful height while keeping only the standard card gap between the buttons and the viewer.
- TraceLog viewer is fixed at 260px high.
- No hidden spacer row above the viewer.
- No content-height shrinking.
- TraceLog button row and viewer use the standard gap.
v129 TraceLog reserved-space removal
v129 fixes the remaining TraceLog blank space by making the TraceLog card body a compact vertical flex stack: actions row, then viewer, separated only by the standard gap.
- TraceLog section body no longer uses a reserved grid row or space-between layout.
- TraceLog action row has no padding or minimum-height spacer.
- Trace viewer remains fixed at 260px high.
- No blank spacer/status row remains between buttons and viewer.
v130 TraceLog empty status spacing fix
v130 fixes the actual remaining TraceLog gap. The empty traceStatus element was inheriting full-width fixed-height status styling and making the button row 86px high. Empty TraceLog status now takes no space; non-empty TraceLog status appears inline in the button row.
- Empty TraceLog status display is none.
- Non-empty TraceLog status is inline in the action row.
- TraceLog viewer remains fixed at 260px high.
- Rendered verification confirms the button row is 38px high and the trace viewer begins immediately after it.
v131 TraceLog standard spacing restoration
v131 keeps the v130 empty TraceLog status fix and restores the standard card gap between the TraceLog button row and the fixed trace viewer.
- TraceLog buttons use the same button styling as Access.
- Empty TraceLog status takes no space.
- Button row to trace viewer gap is the standard
var(--gap).
- Trace viewer remains fixed at 260px high.
v132 TraceLog status inline-only correction
v132 makes TraceLog status structurally inline-only. The traceStatus element is inside the trace-actions row, to the right of the buttons. It is never a standalone row between buttons and the trace viewer.
traceStatus parent is .trace-actions.
- Empty TraceLog status takes no space.
- Non-empty TraceLog status appears to the right of the buttons.
- Button row to trace viewer gap remains the standard 10px.
- Trace viewer remains fixed at 260px high.
v133 invisible startup prefetch
v133 starts testing local AWS credentials and downloading distributions immediately in the background. The results remain invisible until the Access password is verified after a one-second Chrome autofill wait.
- Starts local AWS credential/distribution prefetch immediately on startup.
- Waits 1000ms for Chrome to autofill the Access password.
- Shows “Please enter the tool password.” only if the password is still unreadable after the wait.
- Reveals prefetched distributions only after Access authorization succeeds.
- No startup button clicks.
- No style or layout changes.
v134 AWS prefetch status and reveal-after-access
v134 shows AWS credential success as soon as the invisible prefetch succeeds, keeps polling briefly for Chrome to expose the autofilled Access password, and displays already-prefetched distributions as soon as Access becomes authorized by either startup detection or the Test password button.
- AWS status is updated immediately when background prefetch confirms valid local AWS credentials.
- Access password is checked after 1000ms, then polled for up to 5000ms.
- “Please enter the tool password.” appears only after the poll window fails to read a password.
- Clicking Test password also triggers distribution reveal if the password is correct.
- No startup button clicks.
- No style or layout changes.
v135 readable-password startup wait
v135 keeps the invisible AWS/distribution prefetch from v134, but no longer reports a missing Access password while Chrome or a password manager may still be filling the field. The app waits one second, tries Credential Management when available, watches input/change/autofill-related events, and polls for a readable password before showing the missing-password status.
- AWS status still updates as soon as the invisible prefetch proves local AWS credentials are valid.
- The Access password is not treated as missing during the autofill race.
- The app watches the password field for delayed Chrome/password-manager autofill.
- The app tries the browser Credential Management API when available.
- “Please enter the tool password.” appears only after the readable-password watch window expires.
- Manual Test password success still reveals prefetched distributions immediately.
- No style or layout changes.
v136 startup uses same password-test path as button
v136 keeps the invisible AWS/distribution prefetch, but the startup Access check now calls the same password-test request path as the Test password button: ajax-test-tool-password with the current form values. The app calls that function path directly and does not click the button.
- AWS status still updates as soon as background prefetch validates local AWS credentials.
- Startup Access checks call the same password-test path as the Test password button.
- Manual Test password success still reveals prefetched distributions immediately.
- No startup button clicks.
- No style or layout changes.
v137 startup password test uses FormData like the button
v137 changes startup Access testing to serialize the actual form with FormData(form), set mode=ajax-test-tool-password, and post that data. This matches the path that works when the user presses Test password and avoids relying on separate startup reads of password.value.
- Startup Access checks use current form serialization instead of manually copied field values.
- The app still does not click the Test password button.
- AWS prefetch/status behavior is preserved.
- Prefetched distributions reveal after startup Access OK or manual Access OK.
- No style or layout changes.
v138 remove obsolete Load distributions button
v138 removes the visible Load distributions button. Distribution loading is automatic: AWS credentials are prefetched in the background, and the distribution picker is displayed only after Access is authorized.
- Visible Load distributions button removed.
- Distribution picker slot remains for automatic display.
- Automatic invisible AWS/distribution prefetch preserved.
- No style or layout changes.
v139 signed Access authorization cookie
v139 removes the repeat-startup dependency on Chrome exposing autofilled passwords. When the Test password path succeeds, the server sets a signed HttpOnly authorization cookie for 12 hours. On later startup, the app checks that cookie first; if it is valid, Access goes green and prefetched distributions reveal without reading the password field.
- Successful Access password test sets a signed HttpOnly cookie.
- Startup checks the server-side Access cookie before trying Chrome autofill.
- Chrome/password-manager FormData fallback remains available.
- AWS prefetch/status behavior is preserved.
- Visible Load distributions button remains removed.
- No style or layout changes.