Updating a static website hosted on an AWS S3 Bucket

时光怂恿深爱的人放手 提交于 2020-01-25 03:58:31

问题


I need a better way to update a static website that is hosted in an AWS S3 bucket.

Whenever I am wanting to update my personal site that I have hosted through a S3 bucket, I have to deleting the index.html file and the assets folder from the S3 bucket, then re-upload the new files. I am doing this through the AWS web interface. Is there a way to use a different AWS service to do this in a way similar to git where I can push updated code? Possibly with lambda?


回答1:


You cant automate the whole process using Continous Integration and Deployment. The architecture in the simplest form looks like this :

  1. Setup AWS Code Pipeline to trigger a lambda function on any new code commit in your repo(github,bitbucket,etc)
  2. The lambda can do the task of updating your S3 content

A more sophisticated architecture can be referred at https://github.com/alestic/aws-git-backed-static-website. Here is the architecture sourced from the same source




回答2:


You can use AWC CLI tools for update code in S3 bucket. You Need to configure AWS CLI in your local system with your AWS account. you can download the AWS CLI from below links

  1. For Windows 64 bit: https://s3.amazonaws.com/aws-cli/AWSCLI64.msi
  2. For Windows 32 bit: https://s3.amazonaws.com/aws-cli/AWSCLI32.msi

you can copy your code to your bucket like

aws s3 cp yourcode s3://yourbucket/yourcode


来源:https://stackoverflow.com/questions/58552560/updating-a-static-website-hosted-on-an-aws-s3-bucket

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!