1
votes

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?

2

2 Answers

2
votes

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

enter image description here

1
votes

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