Steps To Perform Invalidation in AWS CloudFront
Step 1: Create an EC2 instance. Use the below script to install Apache on your ec2 instance. This script will also create an index.html in /var/www/html/ path.
#!/bin/bash
sudo yum update -y
sudo yum install httpd -y
echo "In this article I will perform invalidation in AWS CloudFront" >/var/www/html/index.html
sudo systemctl start httpd
sudo systemctl enable httpd
After successful creation of EC2 instance you can then access the Public IP of EC2 instance to see the website content .
Step 2 : Copy the DNS of EC2 instance .
Step 3 : Go to CloudFront and create a CloudFront distribution using EC2 instance as origin . First paste the copied DNS in the origin block . Then create a cache policy . Attach the cache policy to CloudFront distribution . At the end give the root object that is index.html .
Step 4 : Wait until the CloudFront distribution is deployed . After successful deployment access the website using CloudFront distribution URL .
Step 5 : Now make some changes in the website content . Connect EC2 instance and go inside the path /var/www/html/ . Edit the index.html .
sudo su
cd /var/www/html/
vi index.html
Step 6 : Now access the updated website through Public IP of EC2 instance .
Step 7 : Now try to access the website through CloudFront URL but you will see there are no updates in the website content .
Step 8 : Go to CloudFront distribution and select invalidations .
Step 9 : Create invalidation . Add /* to delete all the cache contents .
Step 10 : Wait for sometime until the CloudFront distribution is deployed successfully . Then access the CloudFront URL , now you can see the updated website .
AWS CloudFront Create-Invalidation
AWS CloudFront is a CDN service that accelerates content delivery globally. Invalidation is a key feature of AWS CloudFront which allows you to promptly remove outdated content from the edge locations. In this article, you will explore what is AWS CloudFront, how CloudFront works, and the significance of invalidation. I will also provide the steps to perform invalidation in AWS CloudFront manage your content effectively and ensure seamless user experiences.