In this video, you’ll see how to create a continuous deployment pipeline using
AWS Service Catalog products for CodePipeline and Amazon Elastic Container Service (Amazon ECS).
With this solution, you can leverage AWS reference architecture from GitHub
to easily set up a continuous integration and deployment (CI/CD) pipeline
that employs a container-based workflow.
We’ll begin from the GitHub repository that contains the AWS Service Catalog reference architecture
for the CI/CD pipeline.
This diagram gives a quick overview of the reference architecture.
To install the reference architecture in your account, click Launch Stack.
A wizard will guide you through some setup steps.
For demonstration purposes, we have already launched the stack and set it up in our AWS account.
Let’s take a look.
The reference architecture created a portfolio with Service Catalog products needed
to create a full DevOps deployment pipeline from code to container deployment in Fargate.
It also provisioned an AWS Cloud9 IDE product.
The first product we’ll deploy is the Container CodePipeline project,
which serves as the basis for the container-based CI/CD workflow.
To do so, let’s launch the product the way an end user would.
Let’s give our CodePipeline instance a custom name.
We’ll retain the default values in the other fields.
Next, we’ll deploy the Cloud9 IDE instance in our portfolio so we can edit code
and push changes to the CodeCommit repository.
Users can, of course, choose to configure their own local development environment for this purpose.
Let’s obtain the Git repository URL so we can associate the repository with the development environment.
Copy the URL.
Launch the Cloud9 development environment.
Now paste the URL we just copied to specify the repo you wish to include in the IDE.
Let’s also specify where in the Git repository folder our project code will live.
Let's skip ahead to when the Cloud9 environment has fully deployed and open it.
For the purposes of this example, we’ll clone a sample Flask web application.
Now let’s push the application’s contents to CodeCommit to begin the CodePipeline execution.
Next, let’s check to make sure the CodePipeline execution triggered.
The pipeline successfully pulled our project code from CodeCommit
and is now building and containerizing the application for deployment on ECS.
Let’s return to Service Catalog to deploy the container services necessary to run our application.
We’ll deploy an ECS Fargate cluster to host the servicesand tasks
that enable our application to run in a containerized workflow.
Next, let’s quickly check the status of our CodePipeline execution.
As you can see, CodePipeline successfully sourced our project code from CodeCommit,
built and containerized the application, and deployed the latest version.
Let’s also check the Amazon Elastic Container Registry (ECR)
to view the container image that was built from our deployment in Service Catalog.
The Service Catalog product created a new ECR repository,
which we’ll use to define the ECS service that will run our containerized web application.
Copy the ECR repository URI.
Return to Service Catalog to provision the ECS service.
Give a custom name to the ECS service.
Paste in the ECR repository URI we copied.
Provide a task definition name for the service.
Launch the product.
Now that the container service has finished provisioning,
our Fargate cluster should be running our web application as a service.
Let’s head back to the cluster’s provisioned products view to see the outputs.
Let’s visit the external URL to verify that the ECS service is executing as expected.
As you can see, our containerized Flask application is running as part of the ECS service we just instantiated.
Next, let’s edit the deployment configurations to associate our sample Flask project
with our ECS Fargate cluster and the ECS service.
This will enable automatic re-deployment and re-execution whenever the CodePipeline executes.
We’ll uncomment the last line and add the ECS Fargate cluster name and the service name.
This association will result in zero-downtime automated deployments
upon every new push to the CodeCommit repository master branch.
Save the changes.
Finally, let’s test our configuration by modifying the Flask application code
to see whether the changes are reflected in the application running in the Fargate cluster service.
We’ll change the index page heading to “Hello CodePipeline!” and update the version number.
Now we’ll push our edits to the CodeCommit repo and execute the CodePipeline.
Now that the pipeline has finished executing, let’s see if our change deployed.
The page now shows the new headline and version number.
You’ve just seen how to create a continuous deployment pipeline using AWS Service Catalog products
for CodePipeline and Amazon ECS.
Thanks for watching. Now it’s your turn to try.