Securing s3 buckets

From mouadja02/skills · View interactive version

Securing s3 buckets is an AI agent skill from the GitHub repository mouadja02/skills. Create and secure S3 buckets following AWS best practices for access control, encryption, monitoring, and remediation of misconfigurations. Use when the user wants to secure a new bucket, audit an existing bucket, fix a security finding, configure encryption, or enable logging and monitoring. Do NOT

How to use this skill

Skill file

Securing S3 Buckets

Attribution: Sourced from aws/agent-toolkit-for-aws by Amazon Web Services, licensed Apache-2.0. Modified for this collection.

Overview

Implements layered S3 security controls across five workflows: securing new buckets,

auditing existing configurations, remediating findings, configuring encryption, and

enabling monitoring. Follows AWS Well-Architected security best practices.

Execute commands using the AWS MCP server when connected (sandboxed execution, audit logging, observability). Fall back to AWS CLI or shell otherwise.

Common Tasks

0. Verify Dependencies

Check for required tools before starting.

Constraints:

See references/iam-permissions.md for IAM permissions by workflow.

1. Classify the Request

| User intent | Workflow |

|---|---|

| Secure a new bucket | A: Secure New Bucket |

| Audit / review existing bucket | B: Audit Existing Bucket |

| Fix a specific finding | C: Remediate Issue |

| Configure encryption | D: Configure Encryption |

| Enable logging / monitoring | E: Enable Monitoring |

Constraints:

put-bucket-policy Safety Rules

These rules apply to ALL workflows that call put-bucket-policy:

2. Workflow A — Secure New Bucket

See references/workflows.md for full CLI steps.

Required steps (execute in order, do not skip):

  1. Create bucket with --bucket-namespace account-regional
  2. Enable versioning
  3. Enable encryption (SSE-S3 + Bucket Keys + block SSE-C)
  4. Enable logging (ask user which option — conditional)
  5. Enforce HTTPS-only via DenyInsecureTransport bucket policy
  6. Enable ABAC

Constraints:

```

aws s3api create-bucket --bucket <name> --bucket-namespace account-regional --region <region>

```

```

aws s3api put-bucket-policy --bucket <name> --policy '{"Version":"2012-10-17","Statement":[{"Sid":"DenyInsecureTransport","Effect":"Deny","Principal":"","Action":"s3:","Resource":["arn:aws:s3:::<name>/*","arn:aws:s3:::<name>"],"Condition":{"Bool":{"aws:SecureTransport":"false"}}}]}'

```

3. Workflow B — Audit Existing Bucket

See references/audit-checklist.md for the full checklist.

Constraints:

4. Workflow C — Remediate Issue

See references/remediation.md for fix commands by issue type.

Constraints:

5. Workflow D — Configure Encryption

See references/encryption.md for encryption options and commands.

Constraints:

6. Workflow E — Enable Monitoring

See references/workflows.md for full CLI steps.

Constraints:

Troubleshooting

ObjectLockConfigurationNotFoundError — Object Lock is not enabled. Treat as NOT CONFIGURED, not a failure.

AccessDenied on audit commands — Check IAM policy, bucket policy, Block Public Access, VPC endpoint policy, and SCPs/RCPs. Use aws iam simulate-principal-policy to diagnose.

put-bucket-policy silently removes existing statements — See put-bucket-policy safety rules.

GuardDuty BadRequestException: detector already exists — Run aws guardduty list-detectors first; only call create-detector if empty.

CloudTrail changes not taking effect — Verify you are using --region <trail-home-region>, not the bucket's region. Find it with aws cloudtrail describe-trails --query 'trailList[*].[Name,HomeRegion]'.

Additional Resources

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.