Score:0

How do I open a private static website using boto3?

il flag

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
Tim avatar
gp flag
Tim
If it's not a public bucket you'll need to use credentials or assume a role.
Score:1
af flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.