Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikaeelkhalid/s3-bucket-policy-aws-cdk
This project demonstrates how to create and manage S3 bucket policies using AWS CDK (Cloud Development Kit) in both explicit and implicit ways. The project is structured to provide a clear and reusable approach for defining bucket policies.
https://github.com/mikaeelkhalid/s3-bucket-policy-aws-cdk
aws aws-cdk cdk iac iam iam-policy s3 typescript
Last synced: about 1 month ago
JSON representation
This project demonstrates how to create and manage S3 bucket policies using AWS CDK (Cloud Development Kit) in both explicit and implicit ways. The project is structured to provide a clear and reusable approach for defining bucket policies.
- Host: GitHub
- URL: https://github.com/mikaeelkhalid/s3-bucket-policy-aws-cdk
- Owner: mikaeelkhalid
- Created: 2024-06-08T14:32:11.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-08T15:20:14.000Z (7 months ago)
- Last Synced: 2024-06-09T16:17:51.465Z (7 months ago)
- Topics: aws, aws-cdk, cdk, iac, iam, iam-policy, s3, typescript
- Language: TypeScript
- Homepage: https://blog.mikaeels.com/implementing-s3-bucket-policies-using-aws-cdk
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# S3 Bucket Policy with AWS CDK
[![Mikaeel Khalid](https://badgen.now.sh/badge/by/mikaeelkhalid/purple)](https://github.com/mikaeelkhalid)
This project demonstrates how to create and manage S3 bucket policies using AWS CDK (Cloud Development Kit) in both explicit and implicit ways. The project is structured to provide a clear and reusable approach for defining bucket policies.
## Prerequisites
Ensure you have the following installed:
- AWS CDK
- Node.js
- TypeScript## Installation
1. Clone the repository:
```bash
git clone https://github.com/mikaeelkhalid/s3-bucket-policy-aws-cdk.git
cd s3-bucket-policy-aws-cdk
```2. Install the dependencies:
```bash
npm install
```## Usage
### Explicit Bucket Policy
The explicit approach involves creating a separate `BucketPolicy` resource and attaching it to the S3 bucket.
Code for this can be found in `stacks/s3-bucket-policy-explicit-stack.ts`.
### Implicit Bucket Policy
The implicit approach involves adding the bucket policy directly to the bucket resource.
Code for this can be found in `stacks/s3-bucket-policy-implicit-stack.ts`.
### Deploying the Stacks
1. Bootstrap the CDK environment:
```bash
cdk bootstrap
```2. Deploy the implicit stack:
```bash
cdk deploy S3BucketPolicyImplicitStack
```3. Deploy the explicit stack:
```bash
cdk deploy S3BucketPolicyExplicitStack
```## Cleanup
To delete the stacks and cleanup resources:
```bash
cdk destroy S3BucketPolicyImplicitStack
cdk destroy S3BucketPolicyExplicitStack
```## Contributing
Contributions are welcome! Please open an issue or submit a pull request.