Getty Images/iStockphoto

Try this AWS Proton tutorial to build templates quickly

AWS Proton enables IT admins to create templates for environments and the services that live in them. Follow this tutorial and learn to do both.

AWS Proton is an automated application delivery service primarily focused on containers and serverless workloads. The tool enables platform teams to enforce controls and best practices on the underlying infrastructure and technology stack with templates.

AWS Proton provides all the benefits of infrastructure as code, CI/CD and monitoring, while providing an efficient way to deploy containerized and serverless applications via preapproved environment and service templates. These templates can replicate easily across development, staging and production environments.

Development teams can use Proton to ship services faster by focusing only on code, rather than the underlying infrastructure deployments and management overhead. Teams can use AWS Proton through the AWS Management Console, Boto3 -- the AWS SDK for Python -- and the AWS CLI to start service deployments.

How does it work?

To understand how AWS Proton works, we must understand the perspective of various use cases mentioned below. But the goal remains the same across the board: to enable users to create environment and service templates that are easy, fast and safe to deploy to multiple environments with minimum overhead.

Platform teams and administrators

AWS Proton enables platform teams to define and publish environment templates, which AWS Proton then consumes to create environments replicable via those templates. The tool also enables platform teams to create service templates that are compatible with environment templates and define CI/CD.

This process enables admins and platform teams to create standardized, versioned infrastructure templates to enforce guardrails on the tech stack and best practices. At the same time, it balances controls and flexibility to enable developers to focus on code and development.

Developer teams

From here onward, developer teams can choose one of the published service templates and connect their source code repository to create a service. AWS Proton deploys the source code as service instances and manages the overall service.

Thus, developers can set up continuous integration with their source code repository, likely from providers such as BitBucket and GitHub; AWS deployments are completely automated or part of a continuous delivery pipeline without leaving the AWS portal.

Deploying a Node.js application using AWS Proton

Let's use a simple Node.js containerized application for this AWS Proton tutorial to explore how it works and some of the important concepts.

This application uses a minimalistic web framework called Express.js to deploy a simple web service, which is then containerized using Docker.

Find the index.js file in this GitHub repository, which has the Node.js code and the Dockerfile to build containers. Please fork this repository to use the code in this AWS Proton tutorial.

Create account role for CI/CD pipeline

  1. Log into the AWS Proton Console.
  2. Click Account Settings under the hamburger menu on the left, and then click Configure.
Screenshot of the AWS Proton portal user interface, with highlights on (1) AWS Proton and (2) Account settings in the left-side menu and (3) the Configure button on the right.
Figure 1
  1. Under Configure CI/CD pipeline role, the New service role radio button is enabled by default. Please provide an appropriate role name and check the I Agree box.
  2. Save these changes to configure an account role for the CI/CD pipeline.
Screenshot of the Configure page, accessed from Account settings, with highlights on (1) the menu page; (2) New service role; (3) Pipeline service role name, with hello-world-svc-role input; (4) 'I agree' checkbox; (5) 'Save changes' button.
Figure 2

Create an environment template

  1. From the AWS Proton Console's left sidebar, under the Templates drop-down menu, choose the Environment templates menu.
  2. Click the Create environment template button.
  3. From the Create environment template screen, choose Create a template for provisioning new environments under the Template options section.
  4. Choose Environment for deploying web services that run on Fargate under the Sample template bundle source section.
Screenshot of the Template options section with highlights calling out steps 3 and 4.
Figure 3
  1. On the same page, provide a template name and create the environment template. Create an environment template called hello-world-env-template. Select the template version 1.0 and click on Publish.
Screenshot of the created template with callouts on the name, version number and Publish button.
Figure 4

These steps publish the first version of the environment template, as demonstrated in Figure 5.

Screenshot of updated template profile with the version 1.0 highlighted with its status of Published.
Figure 5

Create a service template

  1. In the left sidebar of the AWS Proton Console, under the Templates drop-down, choose the Service templates menu. Then click on Create a service template.
Screenshot of the 'Service templates' screen of the AWS Proton Console with the 'Create a service template' button selected.
Figure 6
  1. From the Create a service template page, choose Use one of our sample template bundles under the Sample template bundle source section, and A web service on Fargate via the Sample template bundle radio button.
Screenshot of the Service templates options with highlights on the instructions from step 11.
Figure 7
  1. Provide a name for the template and choose from the drop-down the environment template created in the previous subsection. Click Create a service template to deploy it.
Screenshot of Template details, with 'hello-world-svc-template' filled into the Template name textbox, with the 'hello-world-env-template' Environment template marked as compatible.
Figure 8
  1. Once the service template is created, don't forget to select Template version 1.0 and click the Publish button. This step publishes the service template in a few seconds and enables users to validate that "published" status on the landing page.
Screenshot of the created Service template with the name, Template version number and 'Publish' buttons in callout boxes.
Figure 9

Create an environment

  1. From the left sidebar, select Environments and then select Create environment. Choose the environment template created in one of the previous subsections and click Configure.
Screenshot of the environment selection options, with the 'hello-world-env-template' selected.
Figure 10
  1. To configure your environment, provide an environment name. Choose one of the existing service roles created in the first subsection and click the Next button.
Screenshot of the 'Configure environment' screen, with the indicated deployment account, Environment settings and Environment roles highlighted.
Figure 11
  1. Click Next again and then Create to spin up an environment.

Create a service and service instance

  1. Now that we have created an environment, let's go to the sidebar and choose the Services menu. Select Create service.
  2. Select the service template we just created and configure it on this screen.
Screenshot of 'Create service' screen with the created Service template 'hello-world-svc-template,' version 1.0 highlighted.
Figure 12
  1. To configure your service, provide a service name under Service Settings. Under the Service repository settings menu, fill in the information for Branch name, Repository ID and Repository connection -- this source code will connect to the demo Node.js repository on GitHub used for this AWS Proton tutorial. If you have not created a repository connection already, add a new source connection using the URL highlighted in Figure 13 to set one up.
Screenshot displaying Service settings and Service repository settings, with Step 19's information highlighted; the listed Repository connection is github-aws-conn.
Figure 13
  1. Clicking on the Next button takes you to set up new service instances. Provide a unique name and select the newly created environment. There are some optional inputs in this page as well, which you can fill in as per your individual requirements.
Screenshot of the 'Service instances' options with each relevant detail from Step 20 highlighted.
Figure 14
  1. We will leave the Dockerfile listed under Pipeline inputs, which is the default value as mentioned above. Click on the Next and then Create buttons to create service instances.

Verify the service deployment and CI/CD

  1. Service endpoint creation takes a while to complete, but when you see Service status listed as "Active" and Provisioning status as "Successful," open up the service instance screen.
Screenshot of the hello-world-svc service overview screen, with status values highlighted.
Figure 15

On the service instance page, under the "Outputs" section, you will see "ServiceEndpoint."

Screenshot of hello-world-svc-instance-01 focused on the 'Service instance details' box, with 'Service instance name' highlighted, and the 'Value' input under the 'Outputs' section.
Figure 16
  1. Copy and paste this value into the URL bar in your web browser. You should see the Node.js Hello World application, as demonstrated in Figure 17.
Screenshot of the web page created, displaying the URL bar and the text Hello World!
Figure 17
  1. To validate if CI/CD is functional, I modified your index.js file in the GitHub repository, which will trigger a new build and deployment.
Screenshot of the GitHub repository with the URL, latest commit history and edited line of code highlighted.
Figure 18
  1. Once deployment is complete -- and it might take a few minutes -- you can verify completion by refreshing the service endpoint in your browser, as demonstrated in Figure 19.
Screenshot of updated web page, which now displays Hello World! from AWS Proton, with an arrow that points to the 'from AWS Proton' addition.
Figure 19

Dig Deeper on Systems automation and orchestration

Software Quality
App Architecture
Cloud Computing
SearchAWS
TheServerSide.com
Data Center
Close