HashiCorp Consul on AWS

Partner Solution Deployment Guide


September 2022
HashiCorp and AWS Integration & Automation team

Refer to the GitHub repository to view source files, report bugs, submit feature ideas, and post feedback about this Partner Solution. To comment on the documentation, refer to Feedback.

This Partner Solution was created by HashiCorp in collaboration with Amazon Web Services (AWS). Partner Solutions are automated reference deployments that help people deploy popular technologies on AWS according to AWS best practices. If you’re unfamiliar with AWS Partner Solutions, refer to the AWS Partner Solution General Information Guide.


This Partner Solution deploys HashiCorp Consul on the AWS Cloud. This guide covers the steps necessary to deploy this Partner Solution.

Costs and licenses

There is no cost to use this Partner Solution, but you will be billed for any AWS services or resources that this Partner Solution deploys. For more information, refer to the AWS Partner Solution General Information Guide.

The AWS CloudFormation template for this Partner Solution includes configuration parameters that you can customize. Some of these settings, such as instance type, will affect the cost of deployment. See the pricing pages for each AWS service you will be using for cost estimates.

This Partner Solution uses the open-source version of HashiCorp Consul, which doesn’t require a license.


Deploying this Partner Solution with default parameters builds the following Consul environment in the AWS Cloud.

Figure 1. Partner Solution architecture for HashiCorp Consul on AWS

As shown in Figure 1, this Partner Solution sets up the following:

  • A highly available architecture that spans three Availability Zones.

  • A VPC configured with public and private subnets according to AWS best practices, to provide you with your own virtual network on AWS.*

  • In the public subnets:

    • Managed network address translation (NAT) gateways to allow outbound internet access for resources in the private subnets.*

    • A Linux bastion host in an Auto Scaling group to allow inbound Secure Shell (SSH) access to EC2 instances in public and private subnets.*

  • A Classic Load Balancer to distribute traffic among Consul client nodes in the private subnets.

  • In the private subnets:

    • Consul client nodes deployed to Amazon Elastic Compute Cloud (Amazon EC2) instances in an Auto Scaling group.

    • Consul server nodes deployed to Amazon EC2 instances in an Auto Scaling group. You can choose to deploy 3, 5, or 7 server nodes (3 shown).

    • Consul template installed to client and server nodes to integrate applications with the Consul service catalog and key/value store (not shown).

    • Dnsmasq installed to client and server nodes to integrate applications with the Consul Domain Name System (DNS) interface for service discovery (not shown).

    • Amazon Certificate Manager (ACM) to create or import a Secure Sockets Layer (SSL) certificate to associate with the Classic Load Balancer.

* The template that deploys this Partner Solution into an existing VPC skips the components marked by asterisks and prompts you for your existing VPC configuration.

Deployment options

This Partner Solution provides the following deployment options:

  • Deploy Consul into a new VPC. This option builds a new AWS environment that consists of the VPC, subnets, NAT gateways, security groups, bastion hosts, and other infrastructure components. It then deploys Consul into this new VPC.

  • Deploy Consul into an existing VPC. This option provisions Consul in your existing AWS infrastructure.

This Partner Solution provides separate templates for these options. It also lets you configure Classless Inter-Domain Routing (CIDR) blocks, instance types, and Consul settings.

Predeployment steps

Refer to Planning the deployment in the AWS Partner Solutions General Information Guide.

Deployment steps

  1. Sign in to your AWS account, and launch this Partner Solution, as described under Deployment options. The AWS CloudFormation console opens with a prepopulated template.

  2. Choose the correct AWS Region, and then choose Next.

  3. On the Create stack page, keep the default setting for the template URL, and then choose Next.

  4. On the Specify stack details page, change the stack name if needed. Review the parameters for the template. Provide values for the parameters that require input. For all other parameters, review the default settings and customize them as necessary. When you finish reviewing and customizing the parameters, choose Next.

    Unless you’re customizing the Partner Solution templates or are instructed otherwise in this guide’s Predeployment section, don’t change the default settings for the following parameters: QSS3BucketName, QSS3BucketRegion, and QSS3KeyPrefix. Changing the values of these parameters will modify code references that point to the Amazon Simple Storage Service (Amazon S3) bucket name and key prefix. For more information, refer to the AWS Partner Solutions Contributor’s Guide.
  5. On the Configure stack options page, you can specify tags (key-value pairs) for resources in your stack and set advanced options. When you finish, choose Next.

  6. On the Review page, review and confirm the template settings. Under Capabilities, select all of the check boxes to acknowledge that the template creates AWS Identity and Access Management (IAM) resources that might require the ability to automatically expand macros.

  7. Choose Create stack. The stack takes about 30 minutes / 1 hour to deploy.

  8. Monitor the stack’s status, and when the status is CREATE_COMPLETE, the HashiCorp Consul deployment is ready.

  9. To view the created resources, choose the Outputs tab.

Postdeployment steps

Access Consul using SSH (Secure Shell)

To access the Consul environment, first connect to one of the deployed bastion hosts. Then, use an SSH agent to forward your private key on connection. For more information on SSH agents, refer to Generating a new SSH key and adding it to the ssh-agent.

Do not copy your private key to the bastion host.

To use an SSH agent to access the Consul dashboard on macOS or Linux, complete the following steps.

  1. Run the following command.

    ssh-add ~/.ssh/id_rsa

  1. Enter your passphrase or press Enter.

  1. In the Amazon EC2 console, choose Instances from the left navigation pane.

  2. Choose one of the two deployed bastion hosts (LinuxBastion1 or LinuxBastion2). Note the Elastic IP value for the selected instance. You will enter this in Step 5. In the example shown in Figure 2, the elastic IP address of the selected bastion host is

    Figure 2. Elastic IP address for a bastion host instance
  1. Run the following command. Substitute your Elastic IP value from Step 4 for <bastion-host-ip-address>.

    ssh –A ubuntu@<bastion-host-ip-address>

    For example, ssh –A ubuntu@

  1. Enter yes when prompted to continue connecting.

  1. In the Amazon EC2 console, choose a Consul-Server or Consul-Client instance and note its Private IPs value. You will enter this in Step 8. In the example shown in Figure 3, the Private IPs value for the selected instance is

    Figure 3. Finding the private IP address for Consul-Server
  1. From the bastion host, connect to the Consul-Server or Consul-Client host using Ubuntu as the user. Substitute your Private IPs value from Step 7 for <consul-private-ip-address>.

    ssh –A ubuntu@<consul-private-ip-address>

    For example, ssh –A ubuntu@

    Figure 4. Connecting to Consul-Server or Consul-Client
  1. Run the following command to view a list of current Consul members.

    consul members

    Figure 5. Consul members

Test the deployment

Test the deployment by accessing the Consul dashboard.

  1. Sign in to the AWS Management Console. Then open the Amazon CloudFormation console.

  2. Choose Stacks from the left navigation pane.

  3. Choose the Hashicorp Consul stack.

  4. Choose the Outputs tab.

  5. To access the Consul dashboard, navigate to the URL in the Value column for the ConsulServerELB key.

    Figure 6. ConsulServerELB

    The landing page for the Consul dashboard is the Services page. For more information, refer to Explore the Consul UI.

Get started with Consul

  • To integrate Consul with your environment and get started with Consul services, refer to Register a Service with Consul Service Discovery.

  • To set up a service on the Consul client nodes, you must register the service and proxy with Consul. For more information, refer to Register a Service with Consul Service Discovery

  • Autopilot operator command is enabled by default with the following settings.

    "autopilot": {
     "cleanup_dead_servers": true,
     "last_contact_threshold": "200ms",
     "max_trailing_logs": 250,
     "server_stabilization_time": "10s",
     "redundancy_zone_tag": "az",
     "disable_upgrade_migration": false,
     "upgrade_version_tag": ""

    For more information, refer to Consul Operator Autopilot.


For troubleshooting common Partner Solution issues, refer to the AWS Partner Solution General Information Guide and Troubleshooting CloudFormation.

Q. I encountered a CREATE_FAILED error when I launched the Partner Solution.

A. If AWS CloudFormation fails to create the stack, we recommend that you relaunch the template with Rollback on failure set to No. (This setting is under Advanced in the AWS CloudFormation console, Options page.) With this setting, the stack’s state is retained and the instance is left running, so you can troubleshoot the issue. (For Windows, look at the log files in %ProgramFiles%\Amazon\EC2ConfigService and C:\cfn\log.)

When you set Rollback on failure to Disabled, you continue to incur AWS charges for this stack. Please make sure to delete the stack when you finish troubleshooting.

For additional information, see Troubleshooting AWS CloudFormation on the AWS website.

Q. I encountered a size limitation error when I deployed the AWS CloudFormation templates.

A. We recommend that you launch the Partner Solution templates from the links in this guide or from another S3 bucket. If you deploy the templates from a local copy on your computer or from a location other than an S3 bucket, you might encounter template size limitations. For more information about AWS CloudFormation quotas, see the AWS documentation.

Customer responsibility

After you deploy a Partner Solution, confirm that your resources and services are updated and configured—including any required patches—to meet your security and other needs. For more information, refer to the Shared Responsibility Model.


To submit feature ideas and report bugs, use the Issues section of the GitHub repository for this Partner Solution. To submit code, refer to the Partner Solution Contributor’s Guide. To submit feedback on this deployment guide, use the following GitHub links:


This document is provided for informational purposes only. It represents current AWS product offerings and practices as of the date of issue of this document, which are subject to change without notice. Customers are responsible for making their own independent assessment of the information in this document and any use of AWS products or services, each of which is provided "as is" without warranty of any kind, whether expressed or implied. This document does not create any warranties, representations, contractual commitments, conditions, or assurances from AWS, its affiliates, suppliers, or licensors. The responsibilities and liabilities of AWS to its customers are controlled by AWS agreements, and this document is not part of, nor does it modify, any agreement between AWS and its customers.

The software included with this paper is licensed under the Apache License, version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at https://aws.amazon.com/apache2.0/ or in the accompanying "license" file. This code is distributed on an "as is" basis, without warranties or conditions of any kind, either expressed or implied. Refer to the License for specific language governing permissions and limitations.