In this module you'll use the AWS CodeStar service to create a project that will include:
- An AWS CodeCommit Git repository, pre-populated with a sample RESTful API written in Node.js
- An AWS CodeBuild build project
- An AWS CodePipeline continuous delivery pipeline
Each of the following sections provide an implementation overview and detailed, step-by-step instructions. The overview should provide enough context for you to complete the implementation if you're already familiar with the AWS Management Console or you want to explore the services yourself without following a walkthrough.
If you're using the latest version of the Chrome, Firefox, or Safari web browsers the step-by-step instructions won't be visible until you expand the section.
This workshop can be deployed in any AWS region that supports the following services:
- Amazon API Gateway
- Amazon DynamoDB
- Amazon S3
- AWS CodeBuild
- AWS CodePipeline
- AWS CodeStar
- AWS Lambda
- AWS X-Ray
You can refer to the region table in the AWS documentation to see which regions have the supported services. Among the supported regions you can choose are N. Virginia, Ohio, N. California, Oregon, Ireland, Frankfurt, Singapore, and Sydney.
Once you've chosen a region, you should deploy all of the resources for this workshop there. Make sure you select your region from the dropdown in the upper right corner of the AWS Console before getting started.
Use the AWS Console to create a CodeStar project called uni-api
using the Node.js Lambda Webservice template. Use an HTTP client to confirm that the API Gateway endpoint created by CodeStar returns the message, {"Output":"Hello World!"}
, in it's response.
Step-by-step instructions (expand for details)
-
In the AWS Management Console choose Services then select CodeStar under Developer Tools.
-
If this is not your first CodeStar project, please skip to step 4 to create a new project. If this is your first CodeStar project, you will see the CodeStar welcome screen below. Click the Start a project button to get started.
-
If this is your first CodeStar project, you will be prompted to confirm that you are granting CodeStar permission to create other AWS resources on your behalf, such as CodeCommit repositories, CodePipeline pipelines, and CodeBuild projects. Click Yes, create role to proceed.
-
If you have previously created CodeStar projects, you will see them listed in the project list. Click Create a new project to proceed.
-
To narrow the choices for CodeStar projects, select Web service, Node.js, and AWS Lambda in the left navigation. This should narrow the project options to the Express.js web service project, using AWS Lambda. Select this box to proceed.
-
Type
uni-api
as the Project name and click the Create Project button in the lower right corner of the browser window to proceed. -
Your IAM user name (not pictured below) will be displayed. Type a user Display Name and Email in the according text boxes and click the Next button in the lower right corner of the browser window to proceed.
-
The next screen asks how you will edit your project code. You will come back to this configuration later in this module and can click the Skip button in the lower right corner of the browser window to proceed.
-
The screen below is your CodeStar project dashboard. After creating a new project, there will be a short delay as CodeStar provisions the resources for CodeCommit, CodeBuild, CodePipeline, and additional resources related to your project template, Lambda functions in this case. When the progress bar in the upper right of the browser window reaches 100% complete, the provisioning phase of project creation is complete.
-
Once provisioning is complete, there will be a brief delay as the CodePipeline pipeline executes for the first time. The pipeline consists of three stages:
- Source stage: source code is copied from the CodeCommit repository
- Build stage: a CodeBuild project executes the commands defined in the project's buildspec.yml to compile the source code into a deployable artifact, in this case, a Serverless Application Model (SAM) artifact in this case
- Deploy stage: CloudFormation is used to deploy the SAM artifact, representing Lambda functions and an API Gateway environment.
When these stages are complete, an API Gateway Application endpoint will appear in the dashboard.
-
Open the Application endpoint in a browser window and confirm the response message to read
{"Output":"Hello World!"}
-
Congratulations! You have successfully create a serverless web service project using CodeStar. In the next section, you will use a Git client to clone the repository to your workstation.
From the CodeStar project dashboard for the uni-api
, find the CodeCommit instructions to clone the Git repository to your local workstation.
Step-by-step instructions (expand for details)
-
In the upper right corner of the CodeStar project dashboard browser window, click the Connect Tools button.
If you've used CodeStar before, the link to Connect is also available in the bottom left corner of the *Commit project tile.
-
You can select instructions to clone the CodeCommit respository using Visual Studio, Eclipse, or Command line tools. There are instructions for macOS, Windows, and Linux operating systems, as well as HTTPS and SSH access methods. Follow the instructions to clone the Git repository to your local workstation.
-
Congratulations! You have successfully cloned the
uni-api
project to your local workstation. In future modules, you will use this local version to commit changes to the source code, push them to the project Git repository, and trigger automatic execution of the project's continuous delivery pipeline.
Congratulations! You have successfully created a CodeStar project, tested the sample REST API, and cloned the project Git repository to your workstation. In the next Serverless Application Model (SAM) Module, you will learn more about SAM and how to use it change and deploy the API.