And will add Tags also.
So, finally, we will create the user with the settings mentioned above.
We can see that our User has been created successfully and now we have the Access Key Id and Secret Access Key.
So as our s3admin user is now created, so let’s go back to the command prompt and run the command again.
And now we are done with the configuration part.
SOME USEFUL AWS CLI COMMANDS
Let’s now play with some of the AWS CLI commands for S3
We can use the below command to see the help on s3.
The below command will list all the buckets from the account
We can also see the bucket content using the command
and we can see the only uploaded pdf document.
Now, we will be using S3 to host a static website.
HOSTING STATIC WEBSITE ON AMAZON S3
To host a website on S3, we will be downloading a static template from
https://www.tooplate.com/ and will download a template called “Brunch” and then will extract it.
After extraction, we will go to the extracted folder location.
And here we can see all the files, which we need to copy to the S3 bucket.
Now to copy all this data we can use the cp command, but that may cause an issue if we have a lot of data to copy and if it fails in the middle, then the cp command will again start from 0 to copy all the data. So for such cases, we use the sync command.
To sync the folder with the bucket, we can use the below command where. indicates current directory
sync command will not copy the data again in case of failure, which has already been copied.
And we can see that the sync has started.
If we go back to our S3 bucket in AWS, we can see that the entire data has been synced.
As earlier we have made our dummy pdf object public, similarly, we will have to make all the objects which we have just copied public also. NOTE: We have already made our bucket publicly accessible.
Also, go to the bucket properties and Enable static website hosting for the entire bucket and specify the default page.
And after enabling it, we get the publicly accessible endpoint.
And make all data in the bucket public.
And now we can see that our static website is up and running successfully.
SUMMARY
To conclude we can say that so far we have seen some useful commands of AWS CLI for S3, the difference between copy and sync commands, creating IAM User and the permissions, and finally hosting a static website on S3. So, In the coming article, we will see how we can set up lifecycle rules for the bucket and the replication.
I hope you find this article helpful. Stay tuned for more … Cheers!!