I have deployed my React app on s3. I am using Cloudfront to use a certificate and reach my s3 bucket through HTTPS.
After struggling setting it all up, I managed to set it all up, it is now working well.
Now I updated my project, created a new version of bundle.js, uploaded it to s3.
My issue now is that mydomain.com points to the V1 of bundle.js
So what I tried to dig up a little bit more, and here is what I found:
mydomain.com points to V1xxxxx.cloudfront.net points to V1mydomain.com.s3-website-eu-west-1.amazonaws.com points to V2So my guess is that for some reason, cloudfront points to the V1, but why ? Is there some cache somewhere in there ?
Here is the config, in case it helps:
Route53 Type A points to xxxxxx.cloudfront.netcloudfront domain is xxxxxx.cloudfront.netcloudfront CNAMES are mydomain.com and www.mydomain.comcloudfront origin domain name and path is mydomain.com.s3-website-eu-west-1.amazonaws.coms3 bucket is mydomain.comPS : Just to double check that the issue was not only coming from bundle.js, I deleted the background image from the bucket, but somehow, it is still found and used when accessing mydomain.com (so showing the V1)
As @Joe Clay confirmed, Cloudfront was caching everything.
To force clear the cache using the AWS console (I found in some docs that it can be done using their API), here are the steps I followed:
AWS consoleCloudfront and see details of your distributioninvalidations tab, and click on Create invalidation* and savemydomain.com (might need to clean the browser cache)Hope this answer can help anyone stuck with the same problem!
I know this is old question. But i found a way to automate this process using my deployment script. Heres an entry from my package.json file
"deploy": "npm run build && aws s3 sync --delete build/ s3://bucket-name && npm run invalidateCache",
"invalidateCache": "aws cloudfront create-invalidation --distribution-id E23232323 --paths '/*'",
After this all you have to do is to run npm run deploy.
Explanation of commands.
/* so that it clears cache for all paths.

Hope this helps :)
I know this is an old question. This can also be achieved using lambda fn which will invalidate the cloudfront cache for any update in the source origin s3 bucket.
Code snippet is here for the same.
from __future__ import print_function
import boto3
import time
def lambda_handler(event, context):
path = []
for items in event["Records"]:
if items["s3"]["object"]["key"] == "index.html":
path.append("/")
else:
path.append("/" + items["s3"]["object"]["key"])
print(path)
client = boto3.client('cloudfront')
invalidation = client.create_invalidation(DistributionId='cloudfrontdistribution id',
InvalidationBatch={
'Paths': {
'Quantity': 1,
'Items': path
},
'CallerReference': str(time.time())
})