s3-bucket-policy-deployer
Provisions S3 bucket policies with production defaults: policy structure (Principal, Action, Resource, Condition), common patterns (HTTPS-only via aws:SecureTransport Deny, cross-account with external ID, VPC-endpoint-only via aws:SourceVpce, CloudFront Origin Access Control, AWS service access), policy vs ACL (policy preferred — ACLs are legacy), 20 KB policy size limit, condition keys (aws:SourceIp, aws:SourceVpc, aws:SourceVpce, s3:x-amz-acl, aws:SecureTransport), S3 Access Points policy delegation, S3 Multi-Region Access Point (MRAP) policy. Emits a READY_TO_DEPLOY checklist with verification commands. Use when attaching a bucket policy, enforcing HTTPS-only, restricting to a VPC endpoint, granting CloudFront OAC, or delegating via Access Points. Triggers: S3 bucket policy, put-bucket-policy, aws:SecureTransport, cross-account S3, VPC endpoint only, S3 CloudFront OAC, S3 Access Points delegation, MRAP policy.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-24
- Stars
- ★ 4
- Forks
- 0
01 前言 Front Matter
- name
- s3-bucket-policy-deployer
- license
- Apache-2.0
- metadata
- { "tags": "aws, s3, bucket-policy, cloudfront-oac, vpc-endpoint, cloudops, deploy, storage", "phase": "1", "author": "Jacky Chan — AWS Community Builder", "domain": "aws-cloudops", "family": "Storage", "version": "0.1.0", "keywords": "aws, s3, bucket policy, aws:SecureTransport, cross-account, vpc endpoint, aws:SourceVpce, aws:SourceVpc, aws:SourceIp, cloudfront oac, origin access control, s3:x-amz-acl, access points delegation, mrap policy, policy size limit, cloudops, deploy", "task_type": "deploy", "complexity": "high", "entry_point": "false", "skill_class": "capability", "when_to_use": "Invoke when the user wants to attach or replace an S3 bucket policy: enforcing HTTPS-only access (aws:SecureTransport Deny), granting cross-account access with conditions, restricting to a VPC endpoint (aws:SourceVpce), configuring CloudFront Origin Access Control (OAC), granting AWS service access, delegating via S3 Access Points, or configuring a Multi-Region Access Point policy. Do NOT invoke for bucket-level hardening without a policy (use s3-secure-bucket-deployer), for access point creation (use s3-access-points-deployer), for S3 ACLs (legacy — policies are preferred), or for auditing existing policies (use s3-public-access-auditor).", "dependencies": "aws-orchestrator", "requires_llm": "true", "verdict_shape": "READY_TO_DEPLOY | PREREQUISITES_MISSING", "lifecycle_status": "active", "supports_pipeline": "true" }
- description
- Provisions S3 bucket policies with production defaults: policy structure (Principal, Action, Resource, Condition), common patterns (HTTPS-only via aws:SecureTransport Deny, cross-account with external ID, VPC-endpoint-only via aws:SourceVpce, CloudFront Origin Access Control, AWS service access), policy vs ACL (policy preferred — ACLs are legacy), 20 KB policy size limit, condition keys (aws:SourceIp, aws:SourceVpc, aws:SourceVpce, s3:x-amz-acl, aws:SecureTransport), S3 Access Points policy delegation, S3 Multi-Region Access Point (MRAP) policy. Emits a READY_TO_DEPLOY checklist with verification commands. Use when attaching a bucket policy, enforcing HTTPS-only, restricting to a VPC endpoint, granting CloudFront OAC, or delegating via Access Points. Triggers: S3 bucket policy, put-bucket-policy, aws:SecureTransport, cross-account S3, VPC endpoint only, S3 CloudFront OAC, S3 Access Points delegation, MRAP policy.
- compatibility
- Agent runtime that reads SKILL.md (Claude Code, Cursor, Windsurf, Codex, Gemini). Live provisioning uses AWS CLI v2 with s3api (put-bucket-policy, get-bucket-policy, delete-bucket-policy), s3control (put-access-point-policy, put-multi-region-access-point-policy), cloudfront (get-origin-access-control). Works with Terraform aws_s3_bucket_policy and CloudFormation AWS::S3::BucketPolicy.
02 资源文件 19
- 参考文档eval/test-cases.yaml5.1 KB
- 参考文档evals/baselines/cloudfront-oac-policy.md928 B
- 参考文档evals/baselines/cross-account-external-id.md869 B
- 参考文档evals/baselines/https-only-secure-transport.md853 B
- 参考文档evals/baselines/policy-size-limit-exceeded.md588 B
- 参考文档evals/baselines/vpc-endpoint-only-access.md891 B
- 参考文档evals/eval_config.yaml1.7 KB
- 参考文档evals/evals.json9.6 KB
- 参考文档evals/prompts/cloudfront-oac-policy.md529 B
- 参考文档evals/prompts/cross-account-external-id.md516 B
- 参考文档evals/prompts/https-only-secure-transport.md456 B
- 参考文档evals/prompts/policy-size-limit-exceeded.md437 B
- 参考文档evals/prompts/vpc-endpoint-only-access.md436 B
- 参考文档examples/README.md5.7 KB
- 参考文档references/advanced-patterns.md6.8 KB
- 参考文档references/error-handling.md1.1 KB
- 参考文档references/policy-patterns.md8.4 KB
- 参考文档references/provisioning-cli-commands.md8.1 KB
- 参考文档skill.usf.yaml4.3 KB
03 SKILL.md 正文
S3 Bucket Policy Deployer
An AWS CloudOps agent skill that provisions S3 bucket policies with correct security defaults. The skill walks the operator through policy structure validation, common access patterns (HTTPS-only, cross-account, VPC-endpoint-only, CloudFront-OAC, service-access), condition key selection, the 20 KB policy size limit, Access Points policy delegation, and MRAP policies. It captures each policy decision, explains why each default matters, and emits a READY_TO_DEPLOY checklist with copy-pasteable verification commands.
Activation keywords
S3 bucket policy, put-bucket-policy, aws:SecureTransport, HTTPS-only S3, cross-account S3 access, VPC endpoint only S3, aws:SourceVpce, aws:SourceVpc, aws:SourceIp, s3:x-amz-acl, CloudFront OAC, Origin Access Control, AWS service access, S3 Access Points delegation, MRAP policy, Multi-Region Access Point policy, policy size limit, 20 KB bucket policy.
STRICT output contract
When this skill is invoked with a bucket-policy provisioning
request (a bucket name, access pattern, or a partial policy), the
agent MUST respond with the READY_TO_DEPLOY checklist defined in
the "Output format" section using the literal all-caps labels
BUCKET_POLICY:, VERDICT:, CHECKLIST:, and
VERIFICATION_COMMANDS:. Do NOT preface the checklist with prose,
headings, or disclaimers — emit the block as the first lines of the
response. This contract is what assertion-based evals and downstream
provisioning pipelines rely on; deviating from the literal labels
breaks automation silently.
If any prerequisite is missing, the verdict is
PREREQUISITES_MISSING with a specific gap citation in the
checklist (marked [✗]), and READY_TO_DEPLOY MUST NOT also
appear.
Quick navigation
| Section | When to read |
|---|---|
| Prerequisites | Always — verify before provisioning |
| Step 1 — Policy structure | Principal, Action, Resource, Condition |
| Step 2 — HTTPS-only (aws:SecureTransport) | Enforce TLS |
| Step 3 — Cross-account access | Grant another account |
| Step 4 — VPC-endpoint-only (aws:SourceVpce) | Private network |
| Step 5 — CloudFront OAC | CDN origin |
| Step 6 — AWS service access | Lambda, KMS, logging |
| Step 7 — Policy vs ACL | Policy preferred |
| Step 8 — 20 KB size limit | Large policies |
| Step 9 — Access Points delegation | Per-team policies |
| Step 10 — MRAP policy | Multi-region |
| Step 11 — Recent features | Latest |
| NEVER do these things | Review before signing off |
| Output format | The literal checklist template |
| references/policy-patterns.md | Pattern deep dive |
| references/provisioning-cli-commands.md | Copy-pasteable CLI |
Mindset
One-line takeaway: A bucket policy is a JSON access-control document attached directly to an S3 bucket. It is evaluated alongside the IAM policy of the caller — effective permission is the intersection. Bucket policies are the primary mechanism for cross-account access, network-source restrictions, and enforcing TLS; ACLs are legacy and should not be used.
The three misconceptions in full (bucket policy vs IAM policy override, Principal: * + Condition scoping, ACLs vs policies): references/advanced-patterns.md.
Configuration dependency graph (novel heuristic)
Bucket-policy configurations are NOT independent. Many silently no-op without their prerequisite; others conflict with each other. Use this graph to sequence provisioning and debug "why is my policy not taking effect?" later.
| Configuration | Hard dependencies (API error without) | Silent failure / immutability | Enables downstream |
|---|---|---|---|
| Bucket policy | bucket exists; policy is valid JSON < 20 KB | policy > 20 KB is rejected by put-bucket-policy with MalformedPolicy |
access control |
Principal: * + Condition |
valid condition key | Principal: * with aws:SourceVpce still allows any identity in the VPC — not identity-scoped |
network-source restriction |
aws:SecureTransport: false Deny |
n/a | Deny without Bool operator using StringNotEquals silently matches wrong values — use Bool |
HTTPS enforcement |
aws:SourceVpce condition |
VPC endpoint exists | wrong endpoint ID silently blocks ALL traffic or allows ALL if negated incorrectly | VPC-only access |
aws:SourceVpc condition |
request comes through a VPC endpoint with private DNS | requests NOT through a VPC endpoint do not have aws:SourceVpc set — condition silently does not match |
VPC-scoped access |
aws:SourceIp condition |
valid CIDR | aws:SourceIp is NOT populated for requests through a NAT gateway in some configs — use aws:SourceVpc or aws:SourceVpce for VPC traffic |
IP-based restriction |
| CloudFront OAC | OAC config exists in CloudFront | legacy OAI (Origin Access Identity) and OAC are different — OAC policy with an OAI principal silently fails | CDN origin access |
| Block Public Access | n/a | BPA RestrictPublicBuckets silently blocks public policies even if the policy allows them — BPA is a guardrail above the policy |
public-access guardrail |
| Access Points delegation | access points exist | bucket policy is still evaluated cumulatively with AP policy — a Deny in the bucket policy cannot be overridden by the AP policy | per-team scoping |
| MRAP policy | MRAP exists | MRAP policy and bucket policy are separate documents — MRAP policy does not replace bucket policy | multi-region access |
The aws:SecureTransport and aws:SourceVpce rows are the ones
a baseline model misses. Using StringNotEquals instead of Bool
for SecureTransport, and using aws:SourceVpc for non-endpoint
traffic, both produce policies that look correct but silently match
the wrong condition. The procedure below forces the correct
condition operator for each pattern.
Cross-dependency gotchas:
- A bucket policy with
Effect: DenyCANNOT be overridden by any IAM Allow. Deny wins in all cases. This is why overly broad Deny statements are dangerous. Principal: *makes the policy public — it allows any AWS identity (including from other accounts) subject to conditions. Always pair with conditions for non-public buckets.- Block Public Access (BPA) at the bucket or account level is a
guardrail ABOVE the policy. If BPA
RestrictPublicBucketsis on, a policy withPrincipal: *is silently blocked even if the policy explicitly allows it.
Expert heuristic: the aws:SecureTransport condition operator
The aws:SecureTransport operator deep dive (correct Bool vs wrong StringNotEquals, why, complete HTTPS-only Deny, key implication): references/advanced-patterns.md.
Expert heuristic: aws:SourceVpce vs aws:SourceVpc vs aws:SourceIp
The aws:SourceVpce vs aws:SourceVpc vs aws:SourceIp comparison table, the endpoint-only-population gotcha, the correct VPC-endpoint-only pattern, and the SourceIp-through-endpoint caveat: references/advanced-patterns.md.
Expert heuristic: policy vs ACL — policy always preferred
The policy-vs-ACL comparison table and the BucketOwnerEnforced production default: references/advanced-patterns.md.
Prerequisites (verify before provisioning)
Before emitting provisioning commands, verify these prerequisites. If any are missing, the verdict is PREREQUISITES_MISSING with a specific gap citation.
| Prerequisite | How to verify |
|---|---|
| Bucket exists | aws s3api head-bucket --bucket <name> |
| Account ID | aws sts get-caller-identity --query Account |
| Policy JSON valid | python3 -m json.tool policy.json |
| Policy size < 20 KB | wc -c policy.json |
| VPC endpoint ID (if using aws:SourceVpce) | aws ec2 describe-vpc-endpoints --vpc-endpoint-ids <id> |
| CloudFront OAC config (if using OAC) | aws cloudfront get-origin-access-control --id <id> |
| Block Public Access posture | aws s3api get-public-access-block --bucket <name> |
| Object ownership (BucketOwnerEnforced) | aws s3api get-bucket-ownership-controls --bucket <name> |
If any prerequisite is missing, output VERDICT: PREREQUISITES_MISSING
and cite the specific gap.
Step 1 — Policy structure (Principal, Action, Resource, Condition)
Every bucket policy is a JSON document with a Version and a
Statement array. Each statement has four core elements.
Canonical four-element policy JSON example: references/policy-patterns.md.
Element rules:
- Version: always
"2012-10-17"(NOT2008-10-17— the older version lacks support for policy variables). - Effect:
AlloworDeny. Deny overrides any Allow. - Principal: the identity being granted/denied access. Use a
specific ARN for identity-scoped access. Use
"*"for everyone (public) — always pair with a Condition. - Action: S3 actions (
s3:GetObject,s3:PutObject,s3:ListBucket, etc.). Use fully-qualified names. - Resource: the bucket ARN (
arn:aws:s3:::my-bucket) for bucket-level actions and object ARN (arn:aws:s3:::my-bucket/*) for object-level actions. List both for policies that cover both. - Condition: optional. See the expert heuristics for
aws:SecureTransport,aws:SourceVpce,aws:SourceVpc.
Common mistake: listing only the bucket ARN (arn:aws:s3:::bucket)
but omitting the object ARN (arn:aws:s3:::bucket/*). Bucket-level
actions (s3:ListBucket) use the bucket ARN; object-level actions
(s3:GetObject, s3:PutObject) use the object ARN. A policy with
only the bucket ARN will deny all object operations.
Step 2 — HTTPS-only (aws:SecureTransport)
See the "Expert heuristic: the aws:SecureTransport condition
operator" section. The canonical HTTPS-only Deny — always use
Bool, never StringNotEquals:
{
"Sid": "DenyInsecureTransport",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"],
"Condition": { "Bool": { "aws:SecureTransport": "false" } }
}
Step 3 — Cross-account access
To grant another account access, use the foreign account's role ARN as Principal. Both sides must allow (bucket policy AND the foreign role's IAM policy).
{
"Sid": "AllowCrossAccountRead",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::998877665544:role/PartnerRole" },
"Action": ["s3:GetObject", "s3:ListBucket"],
"Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/shared/*"],
"Condition": { "StringEquals": { "aws:ExternalId": "unique-external-id" } }
}
Key rules: use aws:ExternalId for third-party access (prevents
confused-deputy). Scope Resource to specific prefixes when
possible. Common mistake: granting :root instead of a specific
role ARN — :root delegates to the ENTIRE foreign account.
Step 4 — VPC-endpoint-only (aws:SourceVpce)
See the "Expert heuristic: aws:SourceVpce vs aws:SourceVpc vs aws:SourceIp" section. The VPC-endpoint-only Deny:
{
"Sid": "DenyNotFromVpcEndpoint",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"],
"Condition": { "StringNotEquals": { "aws:SourceVpce": "vpce-0abc123def456" } }
}
Key rule: this Deny blocks ALL traffic not from the specified VPC endpoint. Verify the endpoint ID before applying — a wrong ID blocks all access.
Step 5 — CloudFront Origin Access Control (OAC)
CloudFront OAC is the successor to the legacy Origin Access Identity (OAI). OAC supports SSE-KMS and all CloudFront features.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowCloudFrontServicePrincipalReadOnly",
"Effect": "Allow",
"Principal": { "Service": "cloudfront.amazonaws.com" },
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::123456789012:distribution/E123ABCDEF456"
}
}
}
]
}
Key rules:
- Use
Principal: { "Service": "cloudfront.amazonaws.com" }(not the OAI canonical user ID). - The
AWS:SourceArncondition restricts access to a specific CloudFront distribution. Without it, ANY CloudFront distribution in the account can access the bucket. - OAC supports SSE-KMS (OAI did not).
- The OAC configuration must exist in CloudFront first
(
create-origin-access-control).
Common mistake: using the legacy OAI principal (canonical user
ID c4c1ede66af53448b93e28bd014fbedd65) instead of the OAC
service principal. OAI is legacy; always use OAC.
Step 6 — AWS service access
To grant an AWS service (Lambda, KMS, Config, logging) access to a bucket, use the service principal with a condition.
{
"Sid": "AllowLambdaLogging",
"Effect": "Allow",
"Principal": { "Service": "logging.amazonaws.com" },
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::my-bucket/logs/*",
"Condition": {
"StringEquals": { "s3:x-amz-acl": "bucket-owner-full-control" }
}
}
Key rule: s3:x-amz-acl: bucket-owner-full-control ensures the
bucket owner (not the writing service) owns the objects — critical
for cross-account logging. Without it, the service account owns
the objects and the bucket account cannot read them.
Step 7 — Policy vs ACL (policy preferred)
See the "Expert heuristic: policy vs ACL" section. Production
default: disable ACLs with BucketOwnerEnforced ownership:
Disable-ACLs CLI (put-bucket-ownership-controls with BucketOwnerEnforced): references/provisioning-cli-commands.md.
This disables ACLs entirely — all access control flows through bucket policies and IAM.
Step 8 — 20 KB policy size limit
S3 bucket policies have a maximum size of 20 KB. Policies exceeding
this limit are rejected by put-bucket-policy with
MalformedPolicy.
Mitigations for large policies:
| Strategy | When to use |
|---|---|
| Use wildcard prefixes | When many prefixes share the same access pattern |
| Use S3 Access Points | When different teams need different policies on the same bucket |
| Use IAM policies instead | When the policy grants access to specific roles (not cross-account) |
| Reduce statement count | Merge similar statements with multi-action / multi-resource arrays |
Policy-size verification commands (wc -c, 20 KB limit): references/provisioning-cli-commands.md.
Common mistake: adding a statement per team/department until the policy exceeds 20 KB. Use Access Points (Step 9) to delegate per-team policies instead of cramming everything into one bucket policy.
Step 9 — Access Points policy delegation
S3 Access Points allow attaching separate policies to named entry points on a bucket. Each access point has its own policy, evaluated alongside (not instead of) the bucket policy. Use Access Points to avoid exceeding the 20 KB bucket-policy limit with per-team rules.
aws s3control put-access-point-policy \
--account-id 123456789012 \
--name team-a-ap \
--policy file://ap-policy.json
The access point policy uses the access point ARN (not the bucket ARN) as the resource:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::123456789012:role/TeamARole" },
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:us-east-1:123456789012:accesspoint/team-a-ap/team-a/*"
}]
}
Key rule: the bucket policy is still evaluated. A Deny in the
bucket policy cannot be overridden by the AP policy. See
s3-access-points-deployer for the full access point procedure.
Step 10 — MRAP policy
A Multi-Region Access Point (MRAP) has its own policy, separate from the underlying bucket policies.
aws s3control put-multi-region-access-point-policy \
--account-id 123456789012 \
--details Name=my-mrap,Policy=file://mrap-policy.json
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::123456789012:role/GlobalApp" },
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3::123456789012:accesspoint/my-mrap"
}]
}
Key rules: MRAP ARN format differs — arn:aws:s3::account:accesspoint/name
(no region). MRAP policy does NOT replace bucket policies. MRAP
routes to nearest region; pre-existing objects NOT backfilled.
Step 11 — Recent features
Recent AWS features detail (CloudFront OAC, BucketOwnerEnforced, Access Points delegation, MRAP policies, SourceVpc/SourceVpce, Batch Operations for ACL migration): references/advanced-patterns.md.
NEVER do these things
-
NEVER use
StringNotEqualsforaws:SecureTransport. Use theBooloperator instead.aws:SecureTransportis a boolean key;Boolevaluates it canonically.StringNotEqualsis fragile and can silently fail on edge-case clients. The correct pattern is"Bool": { "aws:SecureTransport": "false" }in a Deny statement. -
NEVER use S3 ACLs for access control. ACLs are legacy, limited to 100 grants, cannot express conditions, and are ignored when Block Public Access is enabled. Always use bucket policies. Disable ACLs with
BucketOwnerEnforcedownership. -
NEVER use
aws:SourceIpfor VPC-endpoint traffic. The source IP becomes the endpoint's internal IP, not the client's. For VPC-based restrictions, useaws:SourceVpce(specific endpoint) oraws:SourceVpc(VPC-scoped).aws:SourceIponly works for direct internet requests. -
NEVER omit the object ARN (
arn:aws:s3:::bucket/*) from the Resource list. Bucket-level actions (s3:ListBucket) use the bucket ARN; object-level actions (s3:GetObject,s3:PutObject) use the object ARN. A policy with only the bucket ARN silently denies all object operations. -
NEVER use the legacy CloudFront OAI canonical user ID as the Principal. OAI is legacy and does not support SSE-KMS. Always use OAC with
Principal: { "Service": "cloudfront.amazonaws.com" }andAWS:SourceArncondition.
Output format
BUCKET_POLICY: <bucket-name> (<n> statements, <size> KB)
VERDICT: READY_TO_DEPLOY | PREREQUISITES_MISSING
CHECKLIST:
[✓|✗] Bucket exists: <name>
[✓|✗] Policy version: 2012-10-17
[✓|✗] Policy size: <n> KB (< 20 KB limit)
[✓|✗] HTTPS-only (aws:SecureTransport Deny with Bool): present | not needed
[✓|✗] Cross-account: <account-id> (<role-arn>, external-id: <id>)
[✓|✗] VPC-endpoint-only (aws:SourceVpce): vpce-<id> | not needed
[✓|✗] CloudFront OAC: distribution <arn> | not needed
[✓|✗] Service access: <service> (s3:x-amz-acl: bucket-owner-full-control)
[✓|✗] ACLs disabled: BucketOwnerEnforced
[✓|✗] Block Public Access: all 4 settings True
[✓|✗] Access Points delegation: <n> APs | none
[✓|✗] MRAP policy: <mrap-name> | none
VERIFICATION_COMMANDS:
aws s3api get-bucket-policy --bucket <name>
aws s3api get-public-access-block --bucket <name>
aws s3api get-bucket-ownership-controls --bucket <name>
Worked example — HTTPS-only + cross-account + CloudFront OAC
BUCKET_POLICY: prod-shared-data (3 statements, 1.8 KB)
VERDICT: READY_TO_DEPLOY
CHECKLIST:
[✓] Bucket exists: prod-shared-data
[✓] Policy version: 2012-10-17
[✓] Policy size: 1.8 KB (< 20 KB limit)
[✓] HTTPS-only (aws:SecureTransport Deny with Bool): present
[✓] Cross-account: 998877665544 (arn:aws:iam::998877665544:role/PartnerRole, external-id: partner-ext-123)
[✓] CloudFront OAC: distribution arn:aws:cloudfront::123456789012:distribution/E123ABCDEF456
[✓] ACLs disabled: BucketOwnerEnforced
[✓] Block Public Access: all 4 settings True
VERIFICATION_COMMANDS:
aws s3api get-bucket-policy --bucket prod-shared-data
aws s3api get-public-access-block --bucket prod-shared-data
aws s3api get-bucket-ownership-controls --bucket prod-shared-data
aws cloudfront get-origin-access-control --id E123ABCDEF456
Error handling
All five failure scenarios (MalformedPolicy, applied-but-denied, SourceVpce not matching, CloudFront OAC 403, cross-account denied despite policy): references/error-handling.md.
References (load on demand)
- Advanced patterns — the three Mindset misconceptions, the aws:SecureTransport / SourceVpce-vs-SourceVpc-vs-SourceIp / policy-vs-ACL expert heuristics, recent AWS features
- Error handling — put-bucket-policy failure scenarios and their diagnosis
- Policy patterns — pattern comparison, per-pattern JSON, canonical policy-structure example
- Provisioning CLI commands — full copy-pasteable CLI sequence, Terraform equivalent
Domain
AWS CloudOps / S3 Bucket Policy Provisioning & Storage Access Control Management.
AWS documentation
- Bucket policies — https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html
- Policy conditions — https://docs.aws.amazon.com/AmazonS3/latest/userguide/amazon-s3-policy-keys.html
- aws:SecureTransport — https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-securetransport
- CloudFront OAC — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html
- Object Ownership — https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership.html
- Access Points policies — https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-points-policies.html
- MRAP policies — https://docs.aws.amazon.com/AmazonS3/latest/userguide/MrapPolicy.html
- Block Public Access — https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-control-block-public-access.html
04 同仓库更多 Skills
xray-tracing-deployer
Deploys AWS X-Ray distributed tracing with production-grade configuration: X-Ray daemon deployment (EC2 systemd, ECS sidecar, EKS DaemonSet, Lambda built-in), SDK instrumentation (Java, Python, Node.js, Go, .NET) with annotations and metadata, sampling rules (default reservoir + rate vs custom rules with URL / method / service-name predicates), service map generation, trace query and retrieval, groups and insights, CloudWatch ServiceLens integration, IAM permissions (PutTraceSegments, GetSamplingRules), and latest features (Lambda Powertools tracing, OpenTelemetry / ADOT Collector support, W3C trace context). Emits a READY_TO_DEPLOY checklist with every configuration item verified. Use when enabling X-Ray on a new application, adding tracing to ECS / EKS / Lambda, validating a sampling configuration, or generating daemon deployment CLI and IaC templates. Triggers: X-Ray, distributed tracing, X-Ray daemon, sampling rules, service map, X-Ray SDK, OpenTelemetry, ADOT, Lambda Powertools, CloudWatch ServiceLens.
wellarchitected-workload-auditor
Audits AWS Well-Architected Tool workloads for review staleness, per-pillar high-risk issue counts, milestone tracking gaps, and remediation plan completeness. Emits a deterministic verdict (STALE_REVIEW | HIGH_RISK | CONFIG_GAP | OK) per workload with per-pillar risk breakdown, milestone trend analysis, and specific remediation. Use when reviewing Well-Architected workloads, checking WA review freshness, auditing high-risk issues per pillar, validating milestone coverage, or tracking remediation plans.
wellarchitected-review-operator
Operates AWS Well-Architected Tool reviews end-to-end — creates workloads, runs pillar reviews (operational excellence, security, reliability, performance, cost optimization, sustainability, Prosperity), answers questions with risk-tier rationale, generates reports and improvement plans, creates milestones, and integrates with Trusted Advisor and Well-Architected Labs. Runs deterministic pre-checks (workload existence, lens availability, pillar coverage), emits the exact update-answer / get-consolidated-report CLI behind a CONFIRM gate, and verifies risk-tier transitions. Emits READY | BLOCKED | COMPLETED. Use when creating a workload, answering pillar questions, generating an improvement plan, creating a milestone, or integrating with Trusted Advisor. Triggers: well-architected tool, well architected review, workload review, pillar, operational excellence, security, reliability, performance, cost optimization, sustainability, prosperity, improvement plan, milestone, trusted advisor.
wafv2-web-acl-deployer
Provisions AWS WAFv2 Web ACLs with correct production defaults: scope selection (CLOUDFRONT vs REGIONAL), managed rule groups (AWSManagedRulesCommonRuleSet, SQLiRuleSet, LinuxRuleSet, WindowsRuleSet, IPReputationList, BotControlRuleSet, AmazonIpReputationList, ATP), custom rules (byte match, IP set, regex pattern, geo match, size constraint, rate-based), rule priority ordering, logging destinations (Kinesis Firehose, CloudWatch Logs, S3), resource association (ALB, API Gateway, CloudFront), rate-based rules with aggregate keys (IP, forwarded IP), Challenge and CAPTCHA actions, and account takeover prevention. Emits a READY_TO_DEPLOY checklist. Use when creating a Web ACL, attaching managed rules, configuring rate limiting, enabling WAF logging, associating a Web ACL with an ALB/API Gateway/CloudFront, or configuring CAPTCHA/Challenge actions. Triggers: create WAF Web ACL, WAFv2, managed rule groups, WAF rate limiting, WAF logging, WAF CAPTCHA, WAF Challenge action, bot control, ATP managed rules.
wafv2-web-acl-auditor
Audits AWS WAFv2 Web ACL configurations to determine whether the ACL provides effective protection: default-action posture (Allow vs Block), managed-rule-group coverage gaps, rule effectiveness (BLOCK vs COUNT, shadow/bypass rules, stale exclusions), rate-based rule correctness, logging and visibility configuration, and text-transformation bypass vectors. Emits a deterministic verdict per Web ACL. Use when reviewing a WAFv2 Web ACL for security posture, checking managed-rule coverage, validating rate-limit configuration, auditing WAF logging, or hardening a WAF before production deployment. Triggers: WAF, WAFv2, Web ACL, managed rule group, AWSManagedRules, rate-based rule, CAPTCHA, Challenge, OverrideAction, Count mode, forwarded IP, Bot Control, ATP, text transformation, WAF logging, WAF visibility, OWASP, SQLi, XSS, RFI.
waf-rule-deployer
Provisions AWS WAFv2 rule sets with production defaults: Web ACL creation (CloudFront scope in us-east-1 vs Regional scope), rule groups (managed vs custom) with capacity planning in WCU (Web ACL Capacity Units, 1500 default per ACL), managed rule groups (AWSManagedRulesCommonRuleSet, AWSManagedRulesSQLiRuleSet, AWSManagedRulesAmazonIpReputationList, AWSManagedRulesLinuxRuleSet, AWSManagedRulesWindowsRuleSet, AWSManagedRulesUnixRuleSet), custom rules (byte-match, regex pattern set, geo-match, rate-based), IP set and regex pattern set resources, rule priority ordering (lowest number evaluated first), action types (allow, block, count, CAPTCHA, Challenge), bot control managed rule group, account takeover. Triggers: create WAF rule, WAF managed rule group, WAF custom rule, WAF byte match, WAF geo match, WAF rate based rule, WAF IP set, WAF regex pattern set, WAF WCU budget, WAF CloudFront ACL, WAF logging Kinesis Firehose, WAF bot control, WAF ATP, WAF label matching, WAF Challenge action, WAF CAPTCHA.