Triage and Remediation
Remediation
Using Console
Using Console
The misconfiguration is that the web application is not using a Content Delivery Network (CDN) which can lead to slower load times and higher latency for users. Here are the step-by-step instructions to remediate this issue for AWS using the AWS console:
- Log in to the AWS Management Console.
- Navigate to the Amazon CloudFront service.
- Click on the “Create Distribution” button.
- Select the “Web” option for the type of distribution.
- In the “Origin Domain Name” field, enter the domain name of your web application.
- In the “Origin Protocol Policy” field, select “HTTPS Only” to ensure that all traffic to your web application is encrypted.
- In the “Viewer Protocol Policy” field, select “Redirect HTTP to HTTPS” to ensure that all traffic is encrypted.
- In the “Allowed HTTP Methods” field, select “GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE” to allow all necessary HTTP methods.
- In the “Price Class” field, select the appropriate price class for your needs.
- In the “Alternate Domain Names (CNAMEs)” field, enter any alternate domain names that you want to use for your web application.
- In the “Default Root Object” field, enter the name of the default file that should be served when a user accesses your web application.
- Click on the “Create Distribution” button to create your CDN distribution.
Using CLI
Using CLI
To remediate the misconfiguration “Web Applications Should Use CDNs” for AWS using AWS CLI, follow these steps:Replace Replace Replace Replace
- Login to AWS CLI using your AWS account credentials.
- Identify the web application that needs to be configured with CDN.
- Create an S3 bucket that will store the static content of the web application. Use the following AWS CLI command to create an S3 bucket:
<bucket-name>
with a unique name for your S3 bucket and <region>
with the region where you want to create the bucket.- Upload the static content of the web application to the S3 bucket. Use the following AWS CLI command to upload the files:
<local-path>
with the local path of the static files and <bucket-name>
with the name of the S3 bucket you created in step 3.- Create a CloudFront distribution for the S3 bucket. Use the following AWS CLI command to create a CloudFront distribution:
<bucket-name>
with the name of the S3 bucket you created in step 3.- Update the DNS settings of the web application to point to the CloudFront distribution. Use the following AWS CLI command to get the CloudFront distribution domain name:
<distribution-id>
with the ID of the CloudFront distribution you created in step 5.- Update the DNS settings of the web application to point to the CloudFront distribution domain name obtained in step 6.
Using Python
Using Python
To remediate the misconfiguration “Web Applications Should Use CDNs” for AWS using Python, you can follow these steps:
- Create an AWS CloudFront distribution:
- Update DNS records:
- Test the distribution: