S3 is a very cost effective way to host static web content, but it requires multiple configuration changes to properly prepare a s3 bucket for web hosting. This is a simple cli tool to make it easier to prepare s3 bucket for static website hosting.
- Creates a s3 bucket for a given dns name(This should be the name you want to expose your content).
- Enables s3 bucket webhosting and sets up default files as index.html and default error file as error.html.
- Create DNS entries in route53 for the given dns name.
webup create -n www.testwebsite.devops.lk -z Z1TI4H711TUXXX
Starting to set up bucket
2022/04/05 21:52:13 Bucket www.testwebsite.devops.lk created
2022/04/05 21:52:14 DNS www.testwebsite.devops.lk created
Done setting up bucket
webup upload -w www.testwebsiteamilaku870306.devops.lk
webup upload -r true -w www.testwebsiteamilaku870306.devops.lk
output
2022/04/08 00:12:20 create s3 client new s3 upload
2022/04/08 00:12:20 Opened file: webcontent/index.html
2022/04/08 00:12:20 Trying to upload file: index.html to s3
2022/04/08 00:12:21 Upload file: index.html to s3, object version: 0xc000550020
- create s3 bucket
- configure for web hosting
- create r53 entries
- initialize directory upload content
- upload files to s3
- Upload content
This currently only updates index.html file in webcontent folder and sets public access ACL in S3 bucket, it needs to be able to upload any file available in webcontent folder.