I have a static website consisting of multiple HTML, CSS, and media files uploaded to a private S3 bucket. I would like to access the website using my web browser.
I'm currently using boto3 to generate a presigned URL for a single HTML file. How do I access the entire application without making the bucket public?
s3client = boto3.client('s3')
url = s3client.generate_presigned_url(
ClientMethod='get_object',
Params={
'Bucket': 'my-bucket',
'Key': 'my-website/index.html',
}
) # url shows html content but no CSS styling or media files
If you consistently access from the same location (same public IP), you could allow full read access to the S3 bucket contents for your public IP (using a bucket policy with an IpAddress condition).
This is going to be the easiest way to accomplish what you want.
If you need something more robust look into the authentication options that CloudFront supports. Signed Cookies might be an option, but add a level of complexity that is probably unnecessary for a static site.