- In Module 1, you deployed a static website to EC2 instances. You had to choose an instance size based on how popular your site is going to be, choose an operating system for the EC2 instance, install and configure nginx and deploy the static site.
- In Module 2, you deployed a container which served your static web site to an ECS cluster. You had to pool some EC2 instances into an ECS cluster, choose CPU and memory for the container(s), build and package the containers, and deploy them to the cluster
-
When you use EC2 instances, or containers, you have to make some decisions on capacity when you are provisioning. You also have to pay for that capacity, and manage and operate those resources. For example in case of EC2, you have to keep the OS and software configured and kepts up to date.
-
What is Serverless? Do not think of the word literally, as there are servers under the hood. You don't manage those servers, and do not have to take decisions on the capacity you might need. Also when you don't use the capacity, you don't pay anything for it.
-
In our case of hosting a static website, we do not perform any dynamic computation. We store some files, and the computing capacity is used to handle web requests and serve the static pages.
-
Simple Storage Service, S3 is an object store. In simple terms, you have the filename which is your key, and the contents of the file is the object. S3 provides you a durable file storage, and provides an API to GET, PUT and DELETE objects. It can act as a web server and serve objects on HTTP GET requests.
In this practical session, we will
- Create a S3 bucket and configure it as a web server.
- Load the static pages of our website to the bucket.
- Set up a pipeline to publish any changes to the code to S3.
Go to Services > S3, then click on "Create Bucket"
Enter a unique bucket name and click "Next". The bucket name has to be globally unique. So use something like yourname-devopsgirls-site
Click "Next" without making any changes.
In the "Manage public permissions" drop down choose "Grant public read access to this bucket". Note that you will have a warning, but since we want to host a public website in this bucket, it is ok. Click "Next".
Review the inputs, and click "Create Bucket"
Go to Services > S3, then click on the bucket you just created
Click on the "Properties" tab, and click on "Static Website Hosting"
Choose "Use this bucket to host a website", enter "index.html" in the "Index document" text box, and click "Save".
If you have not yet done so, clone the DevOps-Girls/devopsgirls-bootcamp3 repo and change working directory to website_files:
$ git clone [email protected]:DevOps-Girls/devopsgirls-bootcamp3.git
$ cd devopsgirls-bootcamp3/website_files
Copy the files to the S3 bucket created above. If you have the AWS CLI client:
$ aws s3 sync . s3://`yourname-devopsgirls-site`
If not, got to https://s3.console.aws.amazon.com/s3/buckets/yourname-devopsgirls-site
and upload the files via the AWS console (keep all the defaults):
Navigate to the S3 bucket in the AWS console, and confirm all the files in the website_files directory are listed there.
Choose all the files, click on "More" and choose "Make Public". When prompted, confirm by clicking "Make Public" again
Note down the public URL of the S3 bucket and click on URL
2.) In the section "Configure your Project", enter a unique "Project name". Something like yourname-module3-devopsgirls
, and enter a "Description". In the section "Source: What to build", choose AWS CodeCommit
as the "Source provider", and choose the CodeCommit repository you created in Module 1.
3.) In the following sections, choose/enter the following values for the fields, and click "Continue"
- Environment: How to build
- Environmnet image -
Use an image managed by AWS CodeBuild
- Operating System -
Ubuntu
- Runtime -
Base
- Runtime version -
aws/codebuild/ubuntu-base:14.04
- Privileged - Do not select check box
- Build specification -
Insert build commands
- Build commands -
aws s3 sync --acl public-read . s3://yourname-devopsgirls-site/ --exclude *.git*
[Update the command with the bucket name of your site you created in Section 1] - Certificate -
Do not install any certificate
- Environmnet image -
- Artifacts: Where to put the artifacts from this build project
- Type -
No artifacts
- Type -
- Cache
- Type -
No cache
- Type -
- Service role
- Choose
Create a service role in your account
, and choose a unique role name likeyourname-module3-devopsgirls
- Choose
- VPC
- VPC -
No VPC
- VPC -