If you didn’t know, you can easily setup your static website and host on S3. Just follow these simple instructions and you are done.
https://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html
Now you might want to version control your hosted website and would want to avoid uploading this content again and again.
With the help of Gitlab Runner you can simply remove the hassle of uploading your updated code.
Just create a .gitlab-ci.yml file in your repository, add AWS Access Tokens and push this code to gitlab.
# .gitlab-ci.yml variables: AWS_ACCESS_KEY_ID: "YOUR AWS ACCESS KEY" AWS_SECRET_ACCESS_KEY: "YOUR AWS SECRET ACCESS KEY" AWS_DEFAULT_REGION: "YOUR BUCKET REGION" deploy: image: python:latest script: - pip install awscli - apt-get -qq install jpegoptim - apt-get -qq install optipng - find -type f -name "*.png" -exec optipng {} \; - find -type f -name "*.jpg" -exec jpegoptim {} \; - apt-get -qq install zip - zip -r package.zip . -x ".*" - aws s3 cp ./ s3://<your bucket name> --recursive --exclude '.*' --acl public-read
Now, every time you push your code to Gitlab, your S3 website will be updated as well.
BTW, I have also plugged-in jpegoptim and optipng to compress your JPEG and PNG images before pushing to S3, your welcome.
Bonus:
Follow links below to use CloudFront and to configure free SSL by Amazon.
https://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-cloudfront-walkthrough.html
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html