More Info:
S3 buckets should use DNS-compliant bucket names in order to adhere to AWS best practices and to benefit from the new S3 features such as S3 Transfer Acceleration, to benefit from operational improvements and to receive support for virtual-host style access to buckets.Risk Level
LowAddress
Operational Maturity, SecurityCompliance Standards
- APRA CPS 234 (Australia)
- BSI C5 (Germany)
- Brazil LGPD
- CIS Critical Security Controls v8
- CMMC 2.0
- CSA Cloud Controls Matrix v4
- Cloudanix Best Practice
- Digital Operational Resilience Act (EU)
- ISO/IEC 27017
- ISO/IEC 27018
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- Sarbanes-Oxley IT General Controls
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Sure, here are the step-by-step instructions to remediate the misconfiguration in AWS:
- Log in to your AWS Management Console.
- Navigate to the S3 service.
- Select the bucket that is non-compliant with DNS naming conventions.
- Click on the “Properties” tab.
- Scroll down to the “Static Website Hosting” section.
- In the “Static website hosting” section, click on the “Edit” button.
- In the “Edit static website hosting” dialog box, select the “Use this bucket to host a website” checkbox.
- In the “Index document” field, enter a valid index document name (e.g. index.html).
- In the “Error document” field, enter a valid error document name (e.g. error.html).
- Click on the “Save changes” button.
Using CLI
Using CLI
To remediate the S3 bucket name non-compliance issue, you need to follow the below steps using AWS CLI:Note: Replace BUCKET_NAME with the name of your S3 bucket.Note: Replace BUCKET_NAME with the name of your non-compliant S3 bucket and NEW_BUCKET_NAME with the new DNS-compliant name you want to give to your S3 bucket.Note: Replace BUCKET_NAME with the name of your non-compliant S3 bucket.If the above command returns no error, it means that your S3 bucket name is now DNS-compliant.
- Open your terminal or command prompt and install the AWS CLI (if not already installed) by following the instructions provided in the AWS documentation.
- After installing AWS CLI, open your terminal or command prompt and enter the following command:
- Once the above command is executed successfully, enter the following command to rename the non-compliant bucket name:
- After executing the above command successfully, enter the following command to delete the non-compliant bucket:
- Finally, verify that the new bucket name is DNS-compliant by entering the following command:
Using Python
Using Python
To remediate this misconfiguration in AWS using Python, you can follow these steps:Note: Make sure to replace “new-dns-compliant-bucket-name” with a DNS-compliant bucket name of your choice. Also, be aware that renaming a bucket can have implications for any applications or services that rely on the original bucket name.
- Install the AWS SDK for Python (boto3) using pip:
- Create an AWS S3 client object:
- List all the S3 buckets in your AWS account:
- Check if the bucket names are DNS-compliant:
- If a bucket name is not DNS-compliant, rename the bucket:
Using Terraform
Using Terraform
- Add the new
aws_s3_bucket(and any related config resources) with a DNS‑compliant name, and update all Terraform references, IAM policies, and application configuration to useNEW_DNS_COMPLIANT_BUCKET_NAME. - Migrate objects between buckets out‑of‑band (e.g., using
aws s3 sync s3://OLD_BUCKET_NAME s3://NEW_DNS_COMPLIANT_BUCKET_NAMEas in the CLI fix). Terraform does not provide an equivalent data-copy resource. - Remove the old bucket resource (
aws_s3_bucket.oldand related resources) from Terraform so that the nextterraform applyissuesDeleteBucket/DeleteObject*API calls and destroys the old bucket. Withforce_destroy = true, this is DESTRUCTIVE and IRREVERSIBLE.
After you introduce the new bucket resource and remove the old one,
terraform plan should show:+creation ofaws_s3_bucket.new_dns_compliant(and its related config resources), and-destruction of the oldaws_s3_bucketand its related resources.

