https://github.com/kjenney/private_s3_bucket
Create a private s3 bucket with Terraform
https://github.com/kjenney/private_s3_bucket
Last synced: 3 months ago
JSON representation
Create a private s3 bucket with Terraform
- Host: GitHub
- URL: https://github.com/kjenney/private_s3_bucket
- Owner: kjenney
- Created: 2023-03-10T02:28:32.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-19T02:55:03.000Z (about 2 years ago)
- Last Synced: 2025-01-07T20:12:50.232Z (5 months ago)
- Language: HCL
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pivate_s3_bucket
Creates an S3 bucket that can be accessed by an IAM role in the same account and an IAM role or user in another account.
Use:
```
module "private_s3_bucket" {
source = "../../"
external_arn = "arn:aws:iam::111111111111:role/crossrole"
external_id = "AROAEXAMPLEID"
internal_user_id = "AIDAEXAMPLEID"
}
```Where external_arn and external_id is an IAM role or user in a different account than the bucket that you'd like to use to access the newly created bucket.
External ID can get retrieved by using either `RoleId` with `aws iam get-role` or `UserId` with `aws iam get-user`.
You an optionally set the bucket name with variable `bucket_name`.
## Test accessing the bucket
Get the bucket name by running: `terraform output`.
Once the AWS Instance is up and running you can connect with Session Manager and run:
```
aws s3 ls s3://$bucketnamefromterraformoutput
```