Back to Course
Securing Amazon S3 Data
0% Complete
0/0 Steps
-
Introduction to Amazon S3
What is Amazon S3? -
Amazon S3 Basics[LAB] Creating Buckets and Uploading Objects - AWS Console
-
[LAB] Creating Buckets and Uploading Objects - Using the CLI
-
[LAB] Creating Buckets and Uploading Objects - Assuming Roles
-
[LAB] S3 Versioning - AWS Console
-
[LAB] S3 Versioning - CLI
-
[LAB] S3 Server Access Logs - AWS Console
-
[LAB] S3 Server Access Logs - CLI
-
S3 Security Scenarios[LAB] S3 Presigned URLs
-
[LAB] Encrypting S3 Data with SSE-KMS - AWS Console
-
[LAB] Encrypting S3 Data with SSE-KMS - CLI
-
[LAB] Encrypting S3 Data with SSE-C - CLI
-
[LAB] Controlling access to S3 data with Bucket Policies - CLI
-
S3 Security Assessments[LAB] Find S3 Security Misconfigurations with Prowler
-
[LAB] Instantly query AWS accounts for S3 security issues using Steampipe
-
S3 Pentesting & Red Teaming Activities[DEMO] S3 subdomain takeover
-
[DEMO] Discovering S3 buckets
-
[LAB] Backdoor an S3 Bucket via its Bucket Policy
-
[LAB] S3 ransomware simulation through batch file deletion
-
[LAB] S3 ransomware simulation through client-side encryption
-
S3 Infrastructure as Code (IaC)[LAB] Create a Static S3 Website Using Terraform
-
S3 Automated Remediation[LAB] Automated S3 Remediation to Enforce Block Public Access
Lesson 21 of 22
In Progress
This was awesome! I’m looking to learn more and build more things!!
You came to the right place! Happy learning!
This was fun. Looking forward to more IaC and maybe some CI/CD 😉
Excellent lab!
Glad you liked it! Thanks for the feedback!
Ran into a few issues on this one while trying to follow long by manually typing and incrementally adding / applying as the lab went along.
When you have the writeup and a terminal side by side the code “aws_s3_bucket_website_configuration.website_config.website_endpo
int” looks more like “aws_s3_bucket_website_configuration.website_config.website_
int” which presented an error on terraform apply.
While following along incrementally, I had created a bucket that and all steps were working except for 1 error:
aws_s3_bucket_policy.bucket-policy: Creating…
aws_s3_bucket_public_access_block.public_access_block: Creating…
aws_s3_bucket_website_configuration.website_config: Creating…
aws_s3_object.index: Creating…
aws_s3_object.index: Creation complete after 1s [id=index.html]
aws_s3_bucket_public_access_block.public_access_block: Creation complete after 1s [id=add-unique-bucket-lizzie]
aws_s3_bucket_website_configuration.website_config: Creation complete after 1s [id=add-unique-bucket-lizzie]
â•·
│ Error: putting S3 Bucket (add-unique-bucket-lizzie) Policy: operation error S3: PutBucketPolicy, https response error StatusCode: 403, RequestID: FA6KY5PWKZ5ZWAWA, HostID: sCP2cVc7ifxvkXDQ/bgiPwOGxwky5Q4KoD/XNTlJD3SEmolrJzDmYjoVVT+2cl34sN/KXQ2NMNs=, api error AccessDenied: User: arn:aws:iam::921234892411:user/create-a-static-s3-website-using-terrafor-MyIAMUser-hwdtLj8mlDDn is not authorized to perform: s3:PutBucketPolicy on resource: “arn:aws:s3:::add-unique-bucket-lizzie” because public policies are blocked by the BlockPublicPolicy block public access setting.
I believe this was because the bucket was already created and terraform tried to put a policy rather than just creating the resource with that policy already.
Hey Lizzie, I thought it was due to our wordwrapping, but actually, it seems that a line break was accidentally added when we copy/pasted the code here. Sorry about that! Fixed the line and also disabled wordwrap for good measure
In the main.tf file, while updating it follow the proper sequence for the Step 2 as mentioned below
2. Enabling S3 public access
# make the bucket publicly accessible
resource “aws_s3_bucket_public_access_block” “public_access_block” {
bucket = aws_s3_bucket.bucket.id
block_public_acls = false
block_public_policy = false
ignore_public_acls = false
restrict_public_buckets = false
}
# allow public read access to all objects in the bucket
resource “aws_s3_bucket_policy” “bucket_policy” {
bucket = aws_s3_bucket.bucket.id
policy = jsonencode({
Version = “2012-10-17”
Statement = [
{
Sid = “PublicReadGetObject”,
Effect = “Allow”,
Principal = “*”,
Action = “s3:GetObject”,
Resource = “${aws_s3_bucket.bucket.arn}/*”,
},
],
})
}
Otherwise you could get an error
│ Error: putting S3 Bucket (terraformbuckets324aug4) Policy: operation error S3: PutBucketPolicy, https response error StatusCode: 403, RequestID: FYMNFYE78AMZVAAR, HostID: Bt1r5C06JsHSFEDmiZ4yR7pfWcrHdll4aTXJczoWd52ZmnNtudSRb6Tpw59bd+SrrD/X3jLKGsw=, api error AccessDenied: User: arn:aws:iam::872863893867:user/create-a-static-s3-website-using-terrafor-MyIAMUser-M575LpMOdbFA is not authorized to perform: s3:PutBucketPolicy on resource: “arn:aws:s3:::terraformbuckets324aug4” because public policies are prevented by the BlockPublicPolicy setting in S3 Block Public Access.