Hi,
I have enabled CloudFront to improve the file fetching speed from S3. However, I'm facing an issue when trying to run an invalidation query in CloudFront after deleting a file from S3.
Steps Taken:
- Enabled CloudFront: Configured CloudFront to speed up file retrieval from S3.
- CORS Configuration: Configured the CORS policy for my S3 bucket as follows:
[ { "AllowedHeaders": ["*"], "AllowedMethods": ["PUT", "POST", "DELETE"], "AllowedOrigins": ["https://*.retool.com"], "ExposeHeaders": [] }, { "AllowedHeaders": [], "AllowedMethods": ["GET"], "AllowedOrigins": ["*"], "ExposeHeaders": [] } ]
Problem:
To run the invalidation query in CloudFront for the deleted file, I need to load the AWS SDK. However, I am encountering issues with loading the SDK in Retool due to CORS policy restrictions.
Steps Tried:
-
Using CDN URL:
- Added
https://sdk.amazonaws.com/js/aws-sdk-2.880.0.min.js
to the JavaScript Libraries in Retool. - Resulted in a CORS policy error:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
- Added
-
Alternative CDN:
- Tried using
https://cdn.jsdelivr.net/npm/aws-sdk@2.880.0/dist/aws-sdk.min.js
. - Still faced similar CORS issues.
- Tried using
-
Direct Embedding:
- Attempted to directly include the contents of
aws-sdk.min.js
in a JavaScript query within Retool. - Encountered issues with script execution and no logs indicating the AWS SDK was loaded.
- Attempted to directly include the contents of
Could you please provide guidance on how to correctly load the AWS SDK in Retool to run the CloudFront invalidation query? Any help to resolve the CORS issues or alternative methods to achieve this would be greatly appreciated.
Thanks in advance.