├── .gitmodules ├── .metadata ├── .nojekyll ├── .taskcat.yml ├── CODEOWNERS ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── docs ├── generated │ ├── parameters │ │ └── index.adoc │ ├── regions │ │ └── index.adoc │ └── services │ │ ├── index.adoc │ │ └── metadata.adoc ├── images │ ├── architecture_diagram.png │ ├── aws-quickstart-graphic.png │ └── cfn_outputs.png └── partner_editable │ ├── _settings.adoc │ ├── additional_info.adoc │ ├── architecture.adoc │ ├── deploy_steps.adoc │ ├── deployment_options.adoc │ ├── faq_troubleshooting.adoc │ ├── licenses.adoc │ ├── overview_target_and_usage.adoc │ ├── pre-reqs.adoc │ ├── product_description.adoc │ ├── regions.adoc │ ├── service_limits.adoc │ └── specialized_knowledge.adoc └── templates ├── quickstart-hashicorp-consul-master.template ├── quickstart-hashicorp-consul-master.template.yaml ├── quickstart-hashicorp-consul.template └── quickstart-hashicorp-consul.template.yaml /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "submodules/quickstart-aws-vpc"] 2 | path = submodules/quickstart-aws-vpc 3 | url = https://github.com/aws-quickstart/quickstart-aws-vpc.git 4 | branch = main 5 | [submodule "submodules/quickstart-linux-bastion"] 6 | path = submodules/quickstart-linux-bastion 7 | url = https://github.com/aws-quickstart/quickstart-linux-bastion.git 8 | branch = main 9 | [submodule "docs/boilerplate"] 10 | path = docs/boilerplate 11 | url = https://github.com/aws-quickstart/quickstart-documentation-base-common.git 12 | branch = main 13 | [submodule "submodules/quickstart-aws-acm-certificate"] 14 | path = submodules/quickstart-aws-acm-certificate 15 | url = https://github.com/aws-quickstart/quickstart-aws-acm-certificate.git 16 | branch = main 17 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | language_type: cloudformation 2 | -------------------------------------------------------------------------------- /.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-quickstart/quickstart-hashicorp-consul/8fd3bbef51698f98ec87c24f64a9b8ef47dbc96e/.nojekyll -------------------------------------------------------------------------------- /.taskcat.yml: -------------------------------------------------------------------------------- 1 | project: 2 | name: quickstart-hashicorp-consul 3 | owner: quickstart-eng@amazon.com 4 | package_lambda: false 5 | s3_regional_buckets: false 6 | regions: 7 | - us-west-2 8 | - us-east-1 9 | - us-east-2 10 | - ap-south-1 11 | - eu-west-1 12 | - eu-north-1 13 | - eu-central-1 14 | - eu-west-3 15 | - eu-west-2 16 | - ap-southeast-1 17 | - ap-northeast-1 18 | - ap-southeast-2 19 | - ap-northeast-2 20 | - sa-east-1 21 | tests: 22 | consul: 23 | parameters: 24 | AccessCIDR: 0.0.0.0/0 25 | AvailabilityZones: $[taskcat_genaz_3] 26 | ConsulClientNodes: '3' 27 | ConsulServerNodes: '3' 28 | HostedZoneID: overrides 29 | KeyPairName: tonynv 30 | LoadBalancerFQDN: dummy.dns.name.com 31 | QSS3BucketName: $[taskcat_autobucket] 32 | QSS3KeyPrefix: quickstart-hashicorp-consul/ 33 | SSLCertificateArn: '' 34 | regions: 35 | - us-west-2 36 | - us-east-1 37 | - us-east-2 38 | - ap-south-1 39 | - eu-west-1 40 | - eu-north-1 41 | - eu-central-1 42 | - eu-west-3 43 | - eu-west-2 44 | - ap-southeast-1 45 | - ap-northeast-1 46 | - ap-southeast-2 47 | - ap-northeast-2 48 | - sa-east-1 49 | template: templates/quickstart-hashicorp-consul-master.template.yaml 50 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @aws-quickstart/aws_quickstart_team @gargana 2 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2016-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | 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 4 | 5 | http://aws.amazon.com/apache2.0/ 6 | 7 | or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # quickstart-hashicorp-consul 2 | ## This repository has been deprecated in favor of https://github.com/aws-ia/cfn-ps-hashicorp-consul. 3 | ***We will archive this repository and keep it publicly available until May 1, 2024.*** 4 | -------------------------------------------------------------------------------- /docs/generated/parameters/index.adoc: -------------------------------------------------------------------------------- 1 | // placeholder 2 | -------------------------------------------------------------------------------- /docs/generated/regions/index.adoc: -------------------------------------------------------------------------------- 1 | // placeholder 2 | -------------------------------------------------------------------------------- /docs/generated/services/index.adoc: -------------------------------------------------------------------------------- 1 | // placeholder 2 | -------------------------------------------------------------------------------- /docs/generated/services/metadata.adoc: -------------------------------------------------------------------------------- 1 | // placeholder 2 | -------------------------------------------------------------------------------- /docs/images/architecture_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-quickstart/quickstart-hashicorp-consul/8fd3bbef51698f98ec87c24f64a9b8ef47dbc96e/docs/images/architecture_diagram.png -------------------------------------------------------------------------------- /docs/images/aws-quickstart-graphic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-quickstart/quickstart-hashicorp-consul/8fd3bbef51698f98ec87c24f64a9b8ef47dbc96e/docs/images/aws-quickstart-graphic.png -------------------------------------------------------------------------------- /docs/images/cfn_outputs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aws-quickstart/quickstart-hashicorp-consul/8fd3bbef51698f98ec87c24f64a9b8ef47dbc96e/docs/images/cfn_outputs.png -------------------------------------------------------------------------------- /docs/partner_editable/_settings.adoc: -------------------------------------------------------------------------------- 1 | :quickstart-project-name: quickstart-documentation-base 2 | :partner-product-name: Example Product Name 3 | :partner-company-name: Example Company Name, Ltd. 4 | :doc-month: May 5 | :doc-year: 2020 6 | :partner-contributors: John Doe and Jane Doe 7 | :quickstart-contributors: Jim Smith - AWS Global Partner SA, AWS + Joe Jones - Technical Product Manager, AWS 8 | :deployment_time: 30 minutes / 1 hour 9 | :default_deployment_region: us-east-1 10 | // Uncomment these two attributes if you are leveraging 11 | // - an AWS Marketplace listing. 12 | // Additional content will be auto-generated based on these attributes. 13 | // :marketplace_subscription: 14 | // :marketplace_listing_url: https://example.com/ 15 | -------------------------------------------------------------------------------- /docs/partner_editable/additional_info.adoc: -------------------------------------------------------------------------------- 1 | // Add steps as necessary for accessing the software, post-configuration, and testing. Don’t include full usage instructions for your software, but add links to your product documentation for that information. 2 | //Should any sections not be applicable, remove them 3 | 4 | == Test the deployment 5 | // If steps are required to test the deployment, add them here. If not, remove the heading 6 | 7 | == Post deployment steps 8 | // If Post-deployment steps are required, add them here. If not, remove the heading 9 | 10 | == Best practices for using {partner-product-name} on AWS 11 | // Provide post-deployment best practices for using the technology on AWS, including considerations such as migrating data, backups, ensuring high performance, high availability, etc. Link to software documentation for detailed information. 12 | 13 | _Add any best practices for using the software._ 14 | 15 | == Security 16 | // Provide post-deployment best practices for using the technology on AWS, including considerations such as migrating data, backups, ensuring high performance, high availability, etc. Link to software documentation for detailed information. 17 | 18 | _Add any security-related information._ 19 | 20 | == Other useful information 21 | //Provide any other information of interest to users, especially focusing on areas where AWS or cloud usage differs from on-premises usage. 22 | 23 | _Add any other details that will help the customer use the software on AWS._ -------------------------------------------------------------------------------- /docs/partner_editable/architecture.adoc: -------------------------------------------------------------------------------- 1 | Deploying this Quick Start for a new virtual private cloud (VPC) with 2 | *default parameters* builds the following _{partner-product-name}_ environment in the 3 | AWS Cloud. 4 | 5 | // Replace this example diagram with your own. Send us your source PowerPoint file. Be sure to follow our guidelines here : http://(we should include these points on our contributors giude) 6 | [#architecture1] 7 | .Quick Start architecture for _{partner-product-name}_ on AWS 8 | [link=images/architecture_diagram.png] 9 | image::../images/architecture_diagram.png[Architecture,width=648,height=439] 10 | 11 | As shown in Figure 1, the Quick Start sets up the following: 12 | 13 | * A highly available architecture that spans two Availability Zones.* 14 | * A VPC configured with public and private subnets, according to AWS 15 | best practices, to provide you with your own virtual network on AWS.* 16 | 17 | In the public subnets: 18 | 19 | * Managed network address translation (NAT) gateways to allow outbound 20 | internet access for resources in the private subnets.* 21 | * A Linux bastion host in an Auto Scaling group to allow inbound Secure 22 | Shell (SSH) access to EC2 instances in public and private subnets.* 23 | 24 | In the private subnets: 25 | // Add bullet points for any additional components that are included in the deployment. Make sure that the additional components are also represented in the architecture diagram. 26 | * . 27 | 28 | *The template that deploys the Quick Start into an existing VPC skips 29 | the components marked by asterisks and prompts you for your existing VPC 30 | configuration. 31 | -------------------------------------------------------------------------------- /docs/partner_editable/deploy_steps.adoc: -------------------------------------------------------------------------------- 1 | // We need to work around Step numbers here if we are going to potentially exclude the AMI subscription 2 | === Sign in to your AWS account 3 | 4 | . Sign in to your AWS account at https://aws.amazon.com with an IAM user role that has the necessary permissions. For details, see link:#planning-the-deployment[Planning the deployment] earlier in this guide. 5 | . Make sure that your AWS account is configured correctly, as discussed in the link:#technical-requirements[Technical requirements] section. 6 | 7 | // Optional based on Marketplace listing. Not to be edited 8 | ifdef::marketplace_subscription[] 9 | === Subscribe to the {partner-product-name} AMI 10 | 11 | This Quick Start requires a subscription to the AMI for {partner-product-name} in AWS Marketplace. 12 | 13 | . Sign in to your AWS account. 14 | . {marketplace_listing_url}[Open the page for the {partner-product-name} AMI in AWS Marketplace], and then choose *Continue to Subscribe*. 15 | . Review the terms and conditions for software usage, and then choose *Accept Terms*. + 16 | A confirmation page loads, and an email confirmation is sent to the account owner. For detailed subscription instructions, see the https://aws.amazon.com/marketplace/help/200799470[AWS Marketplace documentation]. 17 | 18 | . When the subscription process is complete, exit out of AWS Marketplace without further action. *Do not* provision the software from AWS Marketplace—the Quick Start deploys the AMI for you. 19 | endif::marketplace_subscription[] 20 | // \Not to be edited 21 | 22 | === Launch the Quick Start 23 | 24 | NOTE: You are responsible for the cost of the AWS services used while running this Quick Start reference deployment. There is no additional cost for using this Quick Start. For full details, see the pricing pages for each AWS service used by this Quick Start. Prices are subject to change. 25 | 26 | . Sign in to your AWS account, and choose one of the following options to launch the AWS CloudFormation template. For help with choosing an option, see link:#_Automated_Deployment[deployment options] earlier in this guide. 27 | 28 | [cols=",] 29 | |=== 30 | |http://qs_launch_link[Deploy {partner-product-name} into a new VPC on AWS^] 31 | |http://qs_launch_link[Deploy {partner-product-name} into an existing VPC on AWS^] 32 | |=== 33 | 34 | WARNING: If you’re deploying {partner-product-name} into an existing VPC, make sure that your VPC has two private subnets in different Availability Zones for the workload instances, and that the subnets aren’t shared. This Quick Start doesn’t support https://docs.aws.amazon.com/vpc/latest/userguide/vpc-sharing.html[shared subnets]. These subnets require https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html[NAT gateways] in their route tables, to allow the instances to download packages and software without exposing them to the internet. 35 | 36 | Also, make sure that the domain name option in the DHCP options is configured as explained in the http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_DHCP_Options.html[Amazon VPC documentation]. You provide your VPC settings when you launch the Quick Start. 37 | 38 | Each deployment takes about {deployment_time} to complete. 39 | 40 | [start=2] 41 | . Check the AWS Region that’s displayed in the upper-right corner of the navigation bar, and change it if necessary. This is where the network infrastructure for {partner-product-name} will be built. The template is launched in the {default_deployment_region} Region by default. 42 | 43 | // *Note:* This deployment includes Amazon EFS, which isn’t currently supported in all AWS Regions. For a current list of supported Regions, see the https://docs.aws.amazon.com/general/latest/gr/elasticfilesystem.html[endpoints and quotas webpage]. 44 | 45 | [start=3] 46 | . On the *Create stack* page, keep the default setting for the template URL, and then choose *Next*. 47 | . 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. 48 | 49 | // In the following tables, parameters are listed by category and described separately for the two deployment options: 50 | 51 | // * Parameters for deploying {partner-product-name} into a new VPC 52 | // * Parameters for deploying {partner-product-name} into an existing VPC -------------------------------------------------------------------------------- /docs/partner_editable/deployment_options.adoc: -------------------------------------------------------------------------------- 1 | // There are generally two deployment options. If additional are required, add them here 2 | 3 | This Quick Start provides two deployment options: 4 | 5 | * *Deploy {partner-product-name} into a new VPC (end-to-end deployment)*. This option builds a new AWS environment consisting of the VPC, subnets, NAT gateways, security groups, bastion hosts, and other infrastructure components. It then deploys {partner-product-name} into this new VPC. 6 | * *Deploy {partner-product-name} into an existing VPC*. This option provisions {partner-product-name} in your existing AWS infrastructure. 7 | 8 | The Quick Start provides separate templates for these options. It also lets you configure Classless Inter-Domain Routing (CIDR) blocks, instance types, and {partner-product-name} settings, as discussed later in this guide. -------------------------------------------------------------------------------- /docs/partner_editable/faq_troubleshooting.adoc: -------------------------------------------------------------------------------- 1 | // Add any tips or answers to anticipated questions. This could include the following troubleshooting information. If you don’t have any other Q&A to add, change “FAQ” to “Troubleshooting.” 2 | 3 | == FAQ 4 | 5 | *Q.* I encountered a *CREATE_FAILED* error when I launched the Quick Start. 6 | 7 | *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.) 8 | // If you’re deploying on Linux instances, provide the location for log files on Linux, or omit this sentence. 9 | 10 | WARNING: 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. 11 | 12 | For additional information, see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/troubleshooting.html[Troubleshooting AWS CloudFormation] on the AWS website. 13 | 14 | *Q.* I encountered a size limitation error when I deployed the AWS CloudFormation templates. 15 | 16 | *A.* We recommend that you launch the Quick Start 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 http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html[AWS documentation]. 17 | 18 | 19 | == Troubleshooting 20 | 21 | -------------------------------------------------------------------------------- /docs/partner_editable/licenses.adoc: -------------------------------------------------------------------------------- 1 | // Include details about the license and how they can sign up. If no license is required, clarify that. 2 | 3 | These two paragraphs provide an example of the details you can provide. Provide links as appropriate. 4 | 5 | 6 | Example content below: 7 | 8 | _This Quick Start requires a license for {partner-product-name}. To use the Quick Start in your production environment, sign up for a license at . When you launch the Quick Start, place the license key in an S3 bucket and specify its location._ 9 | 10 | _If you don’t have a license, the Quick Start deploys with a trial license. The trial license gives you days of free usage in a non-production environment. After this time, you can upgrade to a production license by following the instructions at ._ 11 | 12 | // Or, if the deployment uses an AMI, update this paragraph. If it doesn’t, remove the paragraph. 13 | _The Quick Start requires a subscription to the Amazon Machine Image (AMI) for {partner-product-name}, which is available from https://aws.amazon.com/marketplace/[AWS Marketplace]. Additional pricing, terms, and conditions may apply. For instructions, see link:#step-2.-subscribe-to-the-software-ami[step 2] in the deployment section._ 14 | -------------------------------------------------------------------------------- /docs/partner_editable/overview_target_and_usage.adoc: -------------------------------------------------------------------------------- 1 | // Replace the content in <> 2 | // Identify your target audience and explain how/why they would use this Quick Start. 3 | //Avoid borrowing text from third-party websites (copying text from AWS service documentation is fine). Also, avoid marketing-speak, focusing instead on the technical aspect. 4 | 5 | This Quick Start is for users who -------------------------------------------------------------------------------- /docs/partner_editable/pre-reqs.adoc: -------------------------------------------------------------------------------- 1 | // If no preperation is required, remove all content from here 2 | 3 | ==== Prepare your AWS account 4 | 5 | _Describe any setup required in the AWS account prior to template launch_ 6 | 7 | ==== Prepare your {partner-company-name} account 8 | 9 | _Describe any setup required in the partner portal/account prior to template launch_ 10 | -------------------------------------------------------------------------------- /docs/partner_editable/product_description.adoc: -------------------------------------------------------------------------------- 1 | // Replace the content in <> 2 | // Briefly describe the software. Use consistent and clear branding. 3 | // Include the benefits of using the software on AWS, and provide details on usage scenarios. 4 | 5 | 6 | -------------------------------------------------------------------------------- /docs/partner_editable/regions.adoc: -------------------------------------------------------------------------------- 1 | - _us-east-1 (N. Virginia)_ (EXAMPLE) 2 | - _us-east-2 (Ohio)_ (EXAMPLE) 3 | -------------------------------------------------------------------------------- /docs/partner_editable/service_limits.adoc: -------------------------------------------------------------------------------- 1 | // Replace the in each row to specify the number of resources used in this deployment. Remove the rows for resources that aren’t used. 2 | |=== 3 | |Resource |This deployment uses 4 | 5 | // Space needed to maintain table headers 6 | |VPCs | 7 | |Elastic IP addresses | 8 | |AWS Identity and Access Management (IAM) security groups | 9 | |IAM roles | 10 | |Auto Scaling groups | 11 | |Application Load Balancers | 12 | |Network Load Balancers | 13 | | instances | 14 | |=== 15 | -------------------------------------------------------------------------------- /docs/partner_editable/specialized_knowledge.adoc: -------------------------------------------------------------------------------- 1 | // Replace the content in <> 2 | // Describe or link to specific knowledge requirements; for example: “familiarity with basic concepts in the areas of networking, database operations, and data encryption” or “familiarity with .” 3 | 4 | This Quick Start assumes familiarity with . 5 | 6 | 7 | -------------------------------------------------------------------------------- /templates/quickstart-hashicorp-consul-master.template: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | Description: 'HashiCorp Consul + VPC Aug,28,2019 (qs-1qup6ra81)' 3 | Metadata: 4 | QuickStartDocumentation: 5 | EntrypointName: "Launch into a new VPC" 6 | LICENSE: 'Apache License, Version 2.0' 7 | 'AWS::CloudFormation::Interface': 8 | ParameterGroups: 9 | - Label: 10 | default: 'VPC network configuration' 11 | Parameters: 12 | - AvailabilityZones 13 | - VPCCIDR 14 | - PrivateSubnet1CIDR 15 | - PrivateSubnet2CIDR 16 | - PrivateSubnet3CIDR 17 | - PublicSubnet1CIDR 18 | - PublicSubnet2CIDR 19 | - PublicSubnet3CIDR 20 | - AccessCIDR 21 | - Label: 22 | default: Consul setup 23 | Parameters: 24 | - ConsulInstanceType 25 | - ConsulVersion 26 | - ConsulTemplateVersion 27 | - ConsulServerNodes 28 | - ConsulClientNodes 29 | - KeyPairName 30 | - EnablegRPC 31 | - Label: 32 | default: "DNS and SSL configuration" 33 | Parameters: 34 | - LoadBalancerFQDN 35 | - HostedZoneID 36 | - SSLCertificateArn 37 | - Label: 38 | default: AWS Quick Start configuration 39 | Parameters: 40 | - QSS3BucketName 41 | - QSS3KeyPrefix 42 | - QSS3BucketRegion 43 | ParameterLabels: 44 | AccessCIDR: 45 | default: Permitted IP range 46 | AvailabilityZones: 47 | default: Availability Zones 48 | KeyPairName: 49 | default: Key name 50 | PrivateSubnet1CIDR: 51 | default: Private Subnet 1 CIDR 52 | PrivateSubnet2CIDR: 53 | default: Private Subnet 2 CIDR 54 | PrivateSubnet3CIDR: 55 | default: Private Subnet 3 CIDR 56 | PublicSubnet1CIDR: 57 | default: Public Subnet 1 CIDR 58 | PublicSubnet2CIDR: 59 | default: Public Subnet 2 CIDR 60 | PublicSubnet3CIDR: 61 | default: Public Subnet 3 CIDR 62 | QSS3BucketName: 63 | default: Quick Start S3 bucket name 64 | QSS3KeyPrefix: 65 | default: Quick Start S3 key prefix 66 | QSS3BucketRegion: 67 | default: Quick Start S3 bucket Region 68 | VPCCIDR: 69 | default: VPC CIDR 70 | SSLCertificateArn: 71 | default: SSL certificate ARN 72 | HostedZoneID: 73 | default: Route 53 hosted zone ID 74 | LoadBalancerFQDN: 75 | default: Load Balancer FQDN 76 | ConsulInstanceType: 77 | default: Consul cluster node instance type 78 | ConsulVersion: 79 | default: Consul version 80 | ConsulTemplateVersion: 81 | default: Consul template version 82 | ConsulServerNodes: 83 | default: Number of Consul server nodes 84 | ConsulClientNodes: 85 | default: Number of Consul client nodes 86 | EnablegRPC: 87 | default: Enable gRPC 88 | Parameters: 89 | AvailabilityZones: 90 | Description: >- 91 | List of Availability Zones to use for the subnets in the VPC. 92 | Note: The logical order is preserved. (3 Three Availability 93 | ZonesAZs are used for this deployment.) 94 | Type: 'List' 95 | AccessCIDR: 96 | AllowedPattern: >- 97 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 98 | Description: >- 99 | The CIDR IP range that is permitted to access Consul. Note: a value of 100 | 0.0.0.0/0 will allow access from ANY ip address 101 | Type: String 102 | ConsulVersion: 103 | Type: String 104 | Description: The version of Consul to be created. 105 | AllowedValues: 106 | - '1.7.0' 107 | - '1.12.0' 108 | Default: '1.12.0' 109 | ConsulTemplateVersion: 110 | Type: String 111 | Description: The version of Consul template to be used. 112 | AllowedValues: 113 | - '0.24.0' 114 | - '0.29.0' 115 | Default: '0.29.0' 116 | ConsulServerNodes: 117 | Type: String 118 | Description: The number of Consul server nodes that will be created. You can choose 3, 5, or 7 nodes. 119 | AllowedValues: 120 | - '3' 121 | - '5' 122 | - '7' 123 | Default: '3' 124 | ConsulClientNodes: 125 | Type: String 126 | Description: The number of Consul client nodes that will be created. 127 | Default: '0' 128 | ConsulInstanceType: 129 | Type: String 130 | Default: m5.large 131 | Description: The EC2 instance type for the Consul instances. 132 | AllowedValues: 133 | - t2.micro 134 | - t2.small 135 | - t2.medium 136 | - t2.large 137 | - m5.large 138 | - m5.xlarge 139 | - m4.xlarge 140 | - m4.large 141 | - m4.xlarge 142 | - m3.medium 143 | - m3.large 144 | - m3.xlarge 145 | - m3.2xlarge 146 | - c4.large 147 | - c4.xlarge 148 | - c4.2xlarge 149 | - c4.4xlarge 150 | - c4.8xlarge 151 | - c3.large 152 | - c3.xlarge 153 | - c3.2xlarge 154 | - c3.4xlarge 155 | - c3.8xlarge 156 | - r3.large 157 | - r3.xlarge 158 | - r3.2xlarge 159 | - r3.4xlarge 160 | - r3.8xlarge 161 | - i2.xlarge 162 | - i2.2xlarge 163 | - i2.4xlarge 164 | - i2.8xlarge 165 | ConstraintDescription: Choose an instance type. m3.medium or larger recommended. 166 | KeyPairName: 167 | Description: >- 168 | Public/private key pairs allow you to securely connect to your instance 169 | after it launches 170 | Type: 'AWS::EC2::KeyPair::KeyName' 171 | #MinLength: 1 172 | PrivateSubnet1CIDR: 173 | AllowedPattern: >- 174 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 175 | Default: 10.0.0.0/19 176 | Description: CIDR block for private subnet 1 located in Availability Zone 1. 177 | Type: String 178 | PrivateSubnet2CIDR: 179 | AllowedPattern: >- 180 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 181 | Default: 10.0.32.0/19 182 | Description: CIDR block for private subnet 2 located in Availability Zone 2. 183 | Type: String 184 | PrivateSubnet3CIDR: 185 | AllowedPattern: >- 186 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 187 | Default: 10.0.64.0/19 188 | Description: CIDR block for private subnet 3 located in Availability Zone 3. 189 | Type: String 190 | PublicSubnet1CIDR: 191 | AllowedPattern: >- 192 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 193 | Default: 10.0.128.0/20 194 | Description: CIDR block for the public DMZ subnet 1 located in Availability Zone 1 195 | Type: String 196 | PublicSubnet2CIDR: 197 | AllowedPattern: >- 198 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 199 | Default: 10.0.144.0/20 200 | Description: CIDR block for the public DMZ subnet 2 located in Availability Zone 2 201 | Type: String 202 | PublicSubnet3CIDR: 203 | AllowedPattern: >- 204 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 205 | Default: 10.0.160.0/20 206 | Description: CIDR block for the public DMZ subnet 3 located in Availability Zone 3 207 | Type: String 208 | QSS3BucketName: 209 | AllowedPattern: '^[0-9a-zA-Z]+([0-9a-zA-Z-]*[0-9a-zA-Z])*$' 210 | ConstraintDescription: >- 211 | Quick Start bucket name can include numbers, lowercase letters, uppercase 212 | letters, and hyphens (-). It cannot start or end with a hyphen (-). 213 | Default: aws-quickstart 214 | Description: >- 215 | S3 bucket name for the Quick Start assets. Quick Start bucket name can 216 | include numbers, lowercase letters, uppercase letters, and hyphens (-). It 217 | cannot start or end with a hyphen (-). 218 | Type: String 219 | QSS3BucketRegion: 220 | Default: 'us-east-1' 221 | Description: "Region where the Quick Start S3 bucket (QSS3BucketName) is hosted. If you use your own bucket, specify the applicable Region." 222 | Type: String 223 | QSS3KeyPrefix: 224 | AllowedPattern: '^[0-9a-zA-Z-/]*$' 225 | ConstraintDescription: >- 226 | Quick Start key prefix can include numbers, lowercase letters, uppercase 227 | letters, hyphens (-), and forward slash (/). 228 | Default: quickstart-hashicorp-consul/ 229 | Description: >- 230 | S3 key prefix for the Quick Start assets. Quick Start key prefix can 231 | include numbers, lowercase letters, uppercase letters, hyphens (-), and 232 | forward slash (/). 233 | Type: String 234 | VPCCIDR: 235 | AllowedPattern: >- 236 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 237 | Default: 10.0.0.0/16 238 | Description: CIDR block for the VPC 239 | Type: String 240 | SSLCertificateArn: 241 | Description: The Amazon resource Name(ARN) of the SSL certificate to use for the load balancer. Use 'SSLCertificateArn' if you are not using 'LoadBalancerFQDN' and 'HostedZoneID'. 242 | Type: String 243 | Default: '' 244 | HostedZoneID: 245 | Description: Route 53 Hosted Zone ID of the domain name. Used in conjunction with 'LoadBalancerFQDN'. 246 | Type: String 247 | MaxLength: 32 248 | Default: '' 249 | LoadBalancerFQDN: 250 | Description: The fully qualified domain name for the load balancer. Use with 'HostedZoneID' if you are NOT using SSL. 251 | Type: String 252 | Default: '' 253 | EnablegRPC: 254 | Description: Enable gRPC on the Consul server cluster. 255 | Type: String 256 | Default: "false" 257 | AllowedValues: 258 | - "true" 259 | - "false" 260 | Conditions: 261 | UsingDefaultBucket: !Equals [!Ref QSS3BucketName, 'aws-quickstart'] 262 | GovCloudCondition: !Equals 263 | - !Ref AWS::Region 264 | - us-gov-west-1 265 | SetupRoute53: !And 266 | - !Not 267 | - !Equals 268 | - !Ref 'HostedZoneID' 269 | - '' 270 | - !Not 271 | - !Equals 272 | - !Ref 'LoadBalancerFQDN' 273 | - '' 274 | # Rules: 275 | # DomainNamePresentWithHostedID: 276 | # Assertions: 277 | # - Assert: !Or 278 | # - !Equals [!Ref HostedZoneID, ''] 279 | # - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 280 | # AssertDescription: "Please specify a 'Domain Name' if you specify 'Route 53 Hosted Zone ID'" 281 | # GenerateOrProvideSSL: 282 | # Assertions: 283 | # - Assert: !Or 284 | # - !Not [!Equals [!Ref SSLCertificateArn, '']] 285 | # - !And 286 | # - !Not [!Equals [!Ref HostedZoneID, '']] 287 | # - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 288 | # - !And 289 | # - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 290 | # - !Equals [!Ref SSLCertificateArn, ''] 291 | # AssertDescription: "Using an SSL certificate is enforced. A CertificateArn or a HostedZoneID and LoadBalancerFQDN must be provided." 292 | # ProvideSSHKey: 293 | # Assertions: 294 | # - Assert: !Not [!Equals [ !Ref KeyPairName, '']] 295 | # AssertDescription: "KeyPairName must be provided." 296 | Resources: 297 | VPCStack: 298 | Properties: 299 | Parameters: 300 | AvailabilityZones: 301 | Fn::Join: 302 | - "," 303 | - Ref: AvailabilityZones 304 | KeyPairName: 305 | Ref: KeyPairName 306 | NumberOfAZs: '3' 307 | PrivateSubnet1ACIDR: 308 | Ref: PrivateSubnet1CIDR 309 | PrivateSubnet2ACIDR: 310 | Ref: PrivateSubnet2CIDR 311 | PrivateSubnet3ACIDR: 312 | Ref: PrivateSubnet3CIDR 313 | PublicSubnet1CIDR: 314 | Ref: PublicSubnet1CIDR 315 | PublicSubnet2CIDR: 316 | Ref: PublicSubnet2CIDR 317 | PublicSubnet3CIDR: 318 | Ref: PublicSubnet3CIDR 319 | VPCCIDR: 320 | Ref: VPCCIDR 321 | TemplateURL: 322 | !Sub 323 | - 'https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}submodules/quickstart-aws-vpc/templates/aws-vpc.template' 324 | - S3Region: !If [UsingDefaultBucket, !Ref 'AWS::Region', !Ref QSS3BucketRegion] 325 | S3Bucket: !If [UsingDefaultBucket, !Sub '${QSS3BucketName}-${AWS::Region}', !Ref QSS3BucketName] 326 | Type: AWS::CloudFormation::Stack 327 | BastionStack: 328 | Type: 'AWS::CloudFormation::Stack' 329 | Properties: 330 | TemplateURL: !Sub >- 331 | https://${QSS3BucketName}.s3.amazonaws.com/${QSS3KeyPrefix}submodules/quickstart-linux-bastion/templates/linux-bastion.template 332 | Parameters: 333 | BastionAMIOS: Ubuntu-Server-20.04-LTS-HVM 334 | BastionInstanceType: 't3.medium' 335 | KeyPairName: !Ref KeyPairName 336 | PublicSubnet1ID: !GetAtt 337 | - VPCStack 338 | - Outputs.PublicSubnet1ID 339 | PublicSubnet2ID: !GetAtt 340 | - VPCStack 341 | - Outputs.PublicSubnet2ID 342 | QSS3BucketName: !Ref QSS3BucketName 343 | QSS3KeyPrefix: !Sub '${QSS3KeyPrefix}submodules/quickstart-linux-bastion/' 344 | RemoteAccessCIDR: !Ref AccessCIDR 345 | VPCID: !GetAtt 346 | - VPCStack 347 | - Outputs.VPCID 348 | HashiCorpConsulStack: 349 | Type: 'AWS::CloudFormation::Stack' 350 | Properties: 351 | TemplateURL: !Sub >- 352 | https://${QSS3BucketName}.s3.amazonaws.com/${QSS3KeyPrefix}templates/quickstart-hashicorp-consul.template.yaml 353 | Parameters: 354 | BastionSecurityGroupID: !GetAtt 355 | - BastionStack 356 | - Outputs.BastionSecurityGroupID 357 | PrivateSubnet1ID: !GetAtt 358 | - VPCStack 359 | - Outputs.PrivateSubnet1AID 360 | PrivateSubnet2ID: !GetAtt 361 | - VPCStack 362 | - Outputs.PrivateSubnet2AID 363 | PrivateSubnet3ID: !GetAtt 364 | - VPCStack 365 | - Outputs.PrivateSubnet3AID 366 | PublicSubnet1ID: !GetAtt 367 | - VPCStack 368 | - Outputs.PublicSubnet1ID 369 | PublicSubnet2ID: !GetAtt 370 | - VPCStack 371 | - Outputs.PublicSubnet2ID 372 | PublicSubnet3ID: !GetAtt 373 | - VPCStack 374 | - Outputs.PublicSubnet3ID 375 | VPCID: !GetAtt 376 | - VPCStack 377 | - Outputs.VPCID 378 | VPCCIDR: !Ref VPCCIDR 379 | ConsulVersion: !Ref ConsulVersion 380 | ConsulTemplateVersion: !Ref ConsulTemplateVersion 381 | ConsulServerNodes: !Ref ConsulServerNodes 382 | ConsulClientNodes: !Ref ConsulClientNodes 383 | ConsulInstanceType: !Ref ConsulInstanceType 384 | EnablegRPC: !Ref EnablegRPC 385 | KeyPair: !Ref KeyPairName 386 | ConsulEc2RetryTagKey: "quickstart-consul-cluster" 387 | ConsulEc2RetryTagValue: "consul-member-node" 388 | QSS3BucketName: !Ref QSS3BucketName 389 | QSS3KeyPrefix: !Ref QSS3KeyPrefix 390 | SSLCertificateArn: !Ref SSLCertificateArn 391 | HostedZoneID: !Ref HostedZoneID 392 | LoadBalancerFQDN: !Ref LoadBalancerFQDN 393 | Outputs: 394 | ConsulEc2RetryTagKey: 395 | Value: !GetAtt "HashiCorpConsulStack.Outputs.ConsulEc2RetryTagKey" 396 | Description: The EC2 instance tag key to filter on when joining to other Consul nodes. 397 | ConsulEc2RetryTagValue: 398 | Value: !GetAtt "HashiCorpConsulStack.Outputs.ConsulEc2RetryTagValue" 399 | Description: The EC2 instance tag value to filter on when joining to other Consul nodes. 400 | ConsulServerELB: 401 | Description: The public URL of your Consul Load Balancer. Create a CNAME record pointing at this Load Balancer. 402 | Value: !GetAtt "HashiCorpConsulStack.Outputs.ConsulServerELB" 403 | ConsulServerFQDN: 404 | Condition: SetupRoute53 405 | Description: The public CNAME pointing to your Consul Load Balancer. 406 | Value: !GetAtt "HashiCorpConsulStack.Outputs.ConsulServerFQDN" -------------------------------------------------------------------------------- /templates/quickstart-hashicorp-consul-master.template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | Description: 'HashiCorp Consul + VPC Aug,28,2019 (qs-1qup6ra81)' 3 | Metadata: 4 | QuickStartDocumentation: 5 | EntrypointName: "Launch into a new VPC" 6 | LICENSE: 'Apache License, Version 2.0' 7 | 'AWS::CloudFormation::Interface': 8 | ParameterGroups: 9 | - Label: 10 | default: 'VPC network configuration' 11 | Parameters: 12 | - AvailabilityZones 13 | - VPCCIDR 14 | - PrivateSubnet1CIDR 15 | - PrivateSubnet2CIDR 16 | - PrivateSubnet3CIDR 17 | - PublicSubnet1CIDR 18 | - PublicSubnet2CIDR 19 | - PublicSubnet3CIDR 20 | - AccessCIDR 21 | - Label: 22 | default: Consul setup 23 | Parameters: 24 | - ConsulInstanceType 25 | - ConsulVersion 26 | - ConsulTemplateVersion 27 | - ConsulServerNodes 28 | - ConsulClientNodes 29 | - KeyPairName 30 | - EnablegRPC 31 | - Label: 32 | default: "DNS and SSL configuration" 33 | Parameters: 34 | - LoadBalancerFQDN 35 | - HostedZoneID 36 | - SSLCertificateArn 37 | - Label: 38 | default: AWS Quick Start configuration 39 | Parameters: 40 | - QSS3BucketName 41 | - QSS3KeyPrefix 42 | - QSS3BucketRegion 43 | ParameterLabels: 44 | AccessCIDR: 45 | default: Permitted IP range 46 | AvailabilityZones: 47 | default: Availability Zones 48 | KeyPairName: 49 | default: Key name 50 | PrivateSubnet1CIDR: 51 | default: Private Subnet 1 CIDR 52 | PrivateSubnet2CIDR: 53 | default: Private Subnet 2 CIDR 54 | PrivateSubnet3CIDR: 55 | default: Private Subnet 3 CIDR 56 | PublicSubnet1CIDR: 57 | default: Public Subnet 1 CIDR 58 | PublicSubnet2CIDR: 59 | default: Public Subnet 2 CIDR 60 | PublicSubnet3CIDR: 61 | default: Public Subnet 3 CIDR 62 | QSS3BucketName: 63 | default: Quick Start S3 bucket name 64 | QSS3KeyPrefix: 65 | default: Quick Start S3 key prefix 66 | QSS3BucketRegion: 67 | default: Quick Start S3 bucket Region 68 | VPCCIDR: 69 | default: VPC CIDR 70 | SSLCertificateArn: 71 | default: SSL certificate ARN 72 | HostedZoneID: 73 | default: Route 53 hosted zone ID 74 | LoadBalancerFQDN: 75 | default: Load Balancer FQDN 76 | ConsulInstanceType: 77 | default: Consul cluster node instance type 78 | ConsulVersion: 79 | default: Consul version 80 | ConsulTemplateVersion: 81 | default: Consul template version 82 | ConsulServerNodes: 83 | default: Number of Consul server nodes 84 | ConsulClientNodes: 85 | default: Number of Consul client nodes 86 | EnablegRPC: 87 | default: Enable gRPC 88 | Parameters: 89 | AvailabilityZones: 90 | Description: >- 91 | List of Availability Zones to use for the subnets in the VPC. 92 | Note: The logical order is preserved. (3 Three Availability 93 | ZonesAZs are used for this deployment.) 94 | Type: 'List' 95 | AccessCIDR: 96 | AllowedPattern: >- 97 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 98 | Description: >- 99 | The CIDR IP range that is permitted to access Consul. Note: a value of 100 | 0.0.0.0/0 will allow access from ANY ip address 101 | Type: String 102 | ConsulVersion: 103 | Type: String 104 | Description: The version of Consul to be created. 105 | AllowedValues: 106 | - '1.7.0' 107 | - '1.12.0' 108 | Default: '1.12.0' 109 | ConsulTemplateVersion: 110 | Type: String 111 | Description: The version of Consul template to be used. 112 | AllowedValues: 113 | - '0.24.0' 114 | - '0.29.0' 115 | Default: '0.29.0' 116 | ConsulServerNodes: 117 | Type: String 118 | Description: The number of Consul server nodes that will be created. You can choose 3, 5, or 7 nodes. 119 | AllowedValues: 120 | - '3' 121 | - '5' 122 | - '7' 123 | Default: '3' 124 | ConsulClientNodes: 125 | Type: String 126 | Description: The number of Consul client nodes that will be created. 127 | Default: '0' 128 | ConsulInstanceType: 129 | Type: String 130 | Default: m5.large 131 | Description: The EC2 instance type for the Consul instances. 132 | AllowedValues: 133 | - t2.micro 134 | - t2.small 135 | - t2.medium 136 | - t2.large 137 | - m5.large 138 | - m5.xlarge 139 | - m4.xlarge 140 | - m4.large 141 | - m4.xlarge 142 | - m3.medium 143 | - m3.large 144 | - m3.xlarge 145 | - m3.2xlarge 146 | - c4.large 147 | - c4.xlarge 148 | - c4.2xlarge 149 | - c4.4xlarge 150 | - c4.8xlarge 151 | - c3.large 152 | - c3.xlarge 153 | - c3.2xlarge 154 | - c3.4xlarge 155 | - c3.8xlarge 156 | - r3.large 157 | - r3.xlarge 158 | - r3.2xlarge 159 | - r3.4xlarge 160 | - r3.8xlarge 161 | - i2.xlarge 162 | - i2.2xlarge 163 | - i2.4xlarge 164 | - i2.8xlarge 165 | ConstraintDescription: Choose an instance type. m3.medium or larger recommended. 166 | KeyPairName: 167 | Description: >- 168 | Public/private key pairs allow you to securely connect to your instance 169 | after it launches 170 | Type: 'AWS::EC2::KeyPair::KeyName' 171 | #MinLength: 1 172 | PrivateSubnet1CIDR: 173 | AllowedPattern: >- 174 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 175 | Default: 10.0.0.0/19 176 | Description: CIDR block for private subnet 1 located in Availability Zone 1. 177 | Type: String 178 | PrivateSubnet2CIDR: 179 | AllowedPattern: >- 180 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 181 | Default: 10.0.32.0/19 182 | Description: CIDR block for private subnet 2 located in Availability Zone 2. 183 | Type: String 184 | PrivateSubnet3CIDR: 185 | AllowedPattern: >- 186 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 187 | Default: 10.0.64.0/19 188 | Description: CIDR block for private subnet 3 located in Availability Zone 3. 189 | Type: String 190 | PublicSubnet1CIDR: 191 | AllowedPattern: >- 192 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 193 | Default: 10.0.128.0/20 194 | Description: CIDR block for the public DMZ subnet 1 located in Availability Zone 1 195 | Type: String 196 | PublicSubnet2CIDR: 197 | AllowedPattern: >- 198 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 199 | Default: 10.0.144.0/20 200 | Description: CIDR block for the public DMZ subnet 2 located in Availability Zone 2 201 | Type: String 202 | PublicSubnet3CIDR: 203 | AllowedPattern: >- 204 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 205 | Default: 10.0.160.0/20 206 | Description: CIDR block for the public DMZ subnet 3 located in Availability Zone 3 207 | Type: String 208 | QSS3BucketName: 209 | AllowedPattern: '^[0-9a-zA-Z]+([0-9a-zA-Z-]*[0-9a-zA-Z])*$' 210 | ConstraintDescription: >- 211 | Quick Start bucket name can include numbers, lowercase letters, uppercase 212 | letters, and hyphens (-). It cannot start or end with a hyphen (-). 213 | Default: aws-quickstart 214 | Description: >- 215 | S3 bucket name for the Quick Start assets. Quick Start bucket name can 216 | include numbers, lowercase letters, uppercase letters, and hyphens (-). It 217 | cannot start or end with a hyphen (-). 218 | Type: String 219 | QSS3BucketRegion: 220 | Default: 'us-east-1' 221 | Description: "Region where the Quick Start S3 bucket (QSS3BucketName) is hosted. If you use your own bucket, specify the applicable Region." 222 | Type: String 223 | QSS3KeyPrefix: 224 | AllowedPattern: '^[0-9a-zA-Z-/]*$' 225 | ConstraintDescription: >- 226 | Quick Start key prefix can include numbers, lowercase letters, uppercase 227 | letters, hyphens (-), and forward slash (/). 228 | Default: quickstart-hashicorp-consul/ 229 | Description: >- 230 | S3 key prefix for the Quick Start assets. Quick Start key prefix can 231 | include numbers, lowercase letters, uppercase letters, hyphens (-), and 232 | forward slash (/). 233 | Type: String 234 | VPCCIDR: 235 | AllowedPattern: >- 236 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 237 | Default: 10.0.0.0/16 238 | Description: CIDR block for the VPC 239 | Type: String 240 | SSLCertificateArn: 241 | Description: The Amazon resource Name(ARN) of the SSL certificate to use for the load balancer. Use 'SSLCertificateArn' if you are not using 'LoadBalancerFQDN' and 'HostedZoneID'. 242 | Type: String 243 | Default: '' 244 | HostedZoneID: 245 | Description: Route 53 Hosted Zone ID of the domain name. Used in conjunction with 'LoadBalancerFQDN'. 246 | Type: String 247 | MaxLength: 32 248 | Default: '' 249 | LoadBalancerFQDN: 250 | Description: The fully qualified domain name for the load balancer. Use with 'HostedZoneID' if you are NOT using SSL. 251 | Type: String 252 | Default: '' 253 | EnablegRPC: 254 | Description: Enable gRPC on the Consul server cluster. 255 | Type: String 256 | Default: "false" 257 | AllowedValues: 258 | - "true" 259 | - "false" 260 | Conditions: 261 | UsingDefaultBucket: !Equals [!Ref QSS3BucketName, 'aws-quickstart'] 262 | GovCloudCondition: !Equals 263 | - !Ref AWS::Region 264 | - us-gov-west-1 265 | SetupRoute53: !And 266 | - !Not 267 | - !Equals 268 | - !Ref 'HostedZoneID' 269 | - '' 270 | - !Not 271 | - !Equals 272 | - !Ref 'LoadBalancerFQDN' 273 | - '' 274 | # Rules: 275 | # DomainNamePresentWithHostedID: 276 | # Assertions: 277 | # - Assert: !Or 278 | # - !Equals [!Ref HostedZoneID, ''] 279 | # - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 280 | # AssertDescription: "Please specify a 'Domain Name' if you specify 'Route 53 Hosted Zone ID'" 281 | # GenerateOrProvideSSL: 282 | # Assertions: 283 | # - Assert: !Or 284 | # - !Not [!Equals [!Ref SSLCertificateArn, '']] 285 | # - !And 286 | # - !Not [!Equals [!Ref HostedZoneID, '']] 287 | # - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 288 | # - !And 289 | # - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 290 | # - !Equals [!Ref SSLCertificateArn, ''] 291 | # AssertDescription: "Using an SSL certificate is enforced. A CertificateArn or a HostedZoneID and LoadBalancerFQDN must be provided." 292 | # ProvideSSHKey: 293 | # Assertions: 294 | # - Assert: !Not [!Equals [ !Ref KeyPairName, '']] 295 | # AssertDescription: "KeyPairName must be provided." 296 | Resources: 297 | VPCStack: 298 | Properties: 299 | Parameters: 300 | AvailabilityZones: 301 | Fn::Join: 302 | - "," 303 | - Ref: AvailabilityZones 304 | KeyPairName: 305 | Ref: KeyPairName 306 | NumberOfAZs: '3' 307 | PrivateSubnet1ACIDR: 308 | Ref: PrivateSubnet1CIDR 309 | PrivateSubnet2ACIDR: 310 | Ref: PrivateSubnet2CIDR 311 | PrivateSubnet3ACIDR: 312 | Ref: PrivateSubnet3CIDR 313 | PublicSubnet1CIDR: 314 | Ref: PublicSubnet1CIDR 315 | PublicSubnet2CIDR: 316 | Ref: PublicSubnet2CIDR 317 | PublicSubnet3CIDR: 318 | Ref: PublicSubnet3CIDR 319 | VPCCIDR: 320 | Ref: VPCCIDR 321 | TemplateURL: 322 | !Sub 323 | - 'https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}submodules/quickstart-aws-vpc/templates/aws-vpc.template' 324 | - S3Region: !If [UsingDefaultBucket, !Ref 'AWS::Region', !Ref QSS3BucketRegion] 325 | S3Bucket: !If [UsingDefaultBucket, !Sub '${QSS3BucketName}-${AWS::Region}', !Ref QSS3BucketName] 326 | Type: AWS::CloudFormation::Stack 327 | BastionStack: 328 | Type: 'AWS::CloudFormation::Stack' 329 | Properties: 330 | TemplateURL: !Sub >- 331 | https://${QSS3BucketName}.s3.amazonaws.com/${QSS3KeyPrefix}submodules/quickstart-linux-bastion/templates/linux-bastion.template 332 | Parameters: 333 | BastionAMIOS: Ubuntu-Server-20.04-LTS-HVM 334 | BastionInstanceType: 't3.medium' 335 | KeyPairName: !Ref KeyPairName 336 | PublicSubnet1ID: !GetAtt 337 | - VPCStack 338 | - Outputs.PublicSubnet1ID 339 | PublicSubnet2ID: !GetAtt 340 | - VPCStack 341 | - Outputs.PublicSubnet2ID 342 | QSS3BucketName: !Ref QSS3BucketName 343 | QSS3KeyPrefix: !Sub '${QSS3KeyPrefix}submodules/quickstart-linux-bastion/' 344 | RemoteAccessCIDR: !Ref AccessCIDR 345 | VPCID: !GetAtt 346 | - VPCStack 347 | - Outputs.VPCID 348 | HashiCorpConsulStack: 349 | Type: 'AWS::CloudFormation::Stack' 350 | Properties: 351 | TemplateURL: !Sub >- 352 | https://${QSS3BucketName}.s3.amazonaws.com/${QSS3KeyPrefix}templates/quickstart-hashicorp-consul.template 353 | Parameters: 354 | BastionSecurityGroupID: !GetAtt 355 | - BastionStack 356 | - Outputs.BastionSecurityGroupID 357 | PrivateSubnet1ID: !GetAtt 358 | - VPCStack 359 | - Outputs.PrivateSubnet1AID 360 | PrivateSubnet2ID: !GetAtt 361 | - VPCStack 362 | - Outputs.PrivateSubnet2AID 363 | PrivateSubnet3ID: !GetAtt 364 | - VPCStack 365 | - Outputs.PrivateSubnet3AID 366 | PublicSubnet1ID: !GetAtt 367 | - VPCStack 368 | - Outputs.PublicSubnet1ID 369 | PublicSubnet2ID: !GetAtt 370 | - VPCStack 371 | - Outputs.PublicSubnet2ID 372 | PublicSubnet3ID: !GetAtt 373 | - VPCStack 374 | - Outputs.PublicSubnet3ID 375 | VPCID: !GetAtt 376 | - VPCStack 377 | - Outputs.VPCID 378 | VPCCIDR: !Ref VPCCIDR 379 | ConsulVersion: !Ref ConsulVersion 380 | ConsulTemplateVersion: !Ref ConsulTemplateVersion 381 | ConsulServerNodes: !Ref ConsulServerNodes 382 | ConsulClientNodes: !Ref ConsulClientNodes 383 | ConsulInstanceType: !Ref ConsulInstanceType 384 | EnablegRPC: !Ref EnablegRPC 385 | KeyPair: !Ref KeyPairName 386 | ConsulEc2RetryTagKey: "quickstart-consul-cluster" 387 | ConsulEc2RetryTagValue: "consul-member-node" 388 | QSS3BucketName: !Ref QSS3BucketName 389 | QSS3KeyPrefix: !Ref QSS3KeyPrefix 390 | SSLCertificateArn: !Ref SSLCertificateArn 391 | HostedZoneID: !Ref HostedZoneID 392 | LoadBalancerFQDN: !Ref LoadBalancerFQDN 393 | Outputs: 394 | ConsulEc2RetryTagKey: 395 | Value: !GetAtt "HashiCorpConsulStack.Outputs.ConsulEc2RetryTagKey" 396 | Description: The EC2 instance tag key to filter on when joining to other Consul nodes. 397 | ConsulEc2RetryTagValue: 398 | Value: !GetAtt "HashiCorpConsulStack.Outputs.ConsulEc2RetryTagValue" 399 | Description: The EC2 instance tag value to filter on when joining to other Consul nodes. 400 | ConsulServerELB: 401 | Description: The public URL of your Consul Load Balancer. Create a CNAME record pointing at this Load Balancer. 402 | Value: !GetAtt "HashiCorpConsulStack.Outputs.ConsulServerELB" 403 | ConsulServerFQDN: 404 | Condition: SetupRoute53 405 | Description: The public CNAME pointing to your Consul Load Balancer. 406 | Value: !GetAtt "HashiCorpConsulStack.Outputs.ConsulServerFQDN" -------------------------------------------------------------------------------- /templates/quickstart-hashicorp-consul.template: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | Description: "HashiCorp Consul (Please do not remove) Aug,28,2019 (qs-1qup6ra8j)" 3 | Metadata: 4 | QuickStartDocumentation: 5 | EntrypointName: "Launch into an existing VPC" 6 | LICENSE: "Apache License, Version 2.0" 7 | 'AWS::CloudFormation::Interface': 8 | ParameterGroups: 9 | - Label: 10 | default: 'VPC network configuration' 11 | Parameters: 12 | - VPCID 13 | - VPCCIDR 14 | - PrivateSubnet1ID 15 | - PrivateSubnet2ID 16 | - PrivateSubnet3ID 17 | - PublicSubnet1ID 18 | - PublicSubnet2ID 19 | - PublicSubnet3ID 20 | - Label: 21 | default: "Bastion host configuration" 22 | Parameters: 23 | - BastionSecurityGroupID 24 | - Label: 25 | default: Consul Setup 26 | Parameters: 27 | - ConsulInstanceType 28 | - ConsulVersion 29 | - ConsulTemplateVersion 30 | - ConsulServerNodes 31 | - ConsulClientNodes 32 | - ConsulEc2RetryTagKey 33 | - ConsulEc2RetryTagValue 34 | - KeyPair 35 | - EnablegRPC 36 | - Label: 37 | default: "DNS and SSL configuration" 38 | Parameters: 39 | - LoadBalancerFQDN 40 | - HostedZoneID 41 | - SSLCertificateArn 42 | - Label: 43 | default: AWS Quick Start configuration 44 | Parameters: 45 | - QSS3BucketName 46 | - QSS3KeyPrefix 47 | - QSS3BucketRegion 48 | ParameterLabels: 49 | KeyPair: 50 | default: Key name 51 | PrivateSubnet1ID: 52 | default: Private Subnet 1 ID 53 | PrivateSubnet2ID: 54 | default: Private Subnet 2 ID 55 | PrivateSubnet3ID: 56 | default: Private Subnet 3 ID 57 | PublicSubnet1ID: 58 | default: Public Subnet 1 ID 59 | PublicSubnet2ID: 60 | default: Public Subnet 2 ID 61 | PublicSubnet3ID: 62 | default: Public Subnet 3 ID 63 | QSS3BucketName: 64 | default: Quick Start S3 bucket name 65 | QSS3KeyPrefix: 66 | default: Quick Start S3 key prefix 67 | QSS3BucketRegion: 68 | default: Quick Start S3 bucket Region 69 | VPCID: 70 | default: VPC ID 71 | VPCCIDR: 72 | default: VPC CIDR block 73 | SSLCertificateArn: 74 | default: SSL certificate ARN 75 | HostedZoneID: 76 | default: Route 53 hosted zone ID 77 | LoadBalancerFQDN: 78 | default: Load Balancer FQDN 79 | EnablegRPC: 80 | default: Enable gRPC on Consul 81 | ConsulInstanceType: 82 | default: Consul cluster node instance type 83 | ConsulVersion: 84 | default: Consul version 85 | ConsulTemplateVersion: 86 | default: Consul template version 87 | ConsulServerNodes: 88 | default: Number of Consul server nodes 89 | ConsulClientNodes: 90 | default: Number of Consul client nodes 91 | ConsulEc2RetryTagKey: 92 | default: Tag key for Consul cluster nodes 93 | ConsulEc2RetryTagValue: 94 | default: Tag value for Consul cluster nodes 95 | BastionSecurityGroupID: 96 | default: Bastion host security group ID 97 | Parameters: 98 | BastionSecurityGroupID: 99 | Description: ID of the bastion host security group to enable SSH connections (e.g., sg-7f16e910) 100 | Type: "AWS::EC2::SecurityGroup::Id" 101 | ConsulInstanceType: 102 | Type: String 103 | Description: The EC2 instance type for the Consul instances. 104 | AllowedValues: 105 | - t2.micro 106 | - t2.small 107 | - t2.medium 108 | - t2.large 109 | - m5.large 110 | - m5.xlarge 111 | - m5.2xlarge 112 | - m4.large 113 | - m4.xlarge 114 | - m3.medium 115 | - m3.large 116 | - m3.xlarge 117 | - m3.2xlarge 118 | - c4.large 119 | - c4.xlarge 120 | - c4.2xlarge 121 | - c4.4xlarge 122 | - c4.8xlarge 123 | - c3.large 124 | - c3.xlarge 125 | - c3.2xlarge 126 | - c3.4xlarge 127 | - c3.8xlarge 128 | - r3.large 129 | - r3.xlarge 130 | - r3.2xlarge 131 | - r3.4xlarge 132 | - r3.8xlarge 133 | - i2.xlarge 134 | - i2.2xlarge 135 | - i2.4xlarge 136 | - i2.8xlarge 137 | ConstraintDescription: Choose an instance type. 138 | Default: m5.large 139 | ConsulEc2RetryTagKey: 140 | Description: 141 | The EC2 instance tag key to filter on when joining to other Consul 142 | nodes. 143 | Type: String 144 | Default: "quickstart-consul-cluster" 145 | ConstraintDescription: Must match EC2 Tag Name requirements. 146 | ConsulEc2RetryTagValue: 147 | Description: 148 | The EC2 instance tag value to filter on when joining to other Consul 149 | nodes. 150 | Type: String 151 | Default: "consul-member-node" 152 | ConstraintDescription: Must match EC2 Tag Name requirements. 153 | KeyPair: 154 | Description: Name of an existing EC2 KeyPair to enable SSH access to the instances 155 | Type: "AWS::EC2::KeyPair::KeyName" 156 | # MinLength: 1 157 | ConstraintDescription: Must be the name of an existing EC2 KeyPair. 158 | PrivateSubnet1ID: 159 | Description: "ID of the private subnet 1 in Availability Zone 1 (e.g., subnet-xxxxxxxx)" 160 | Type: "AWS::EC2::Subnet::Id" 161 | PrivateSubnet2ID: 162 | Description: "ID of the private subnet 2 in Availability Zone 2 (e.g., subnet-xxxxxxxx)" 163 | Type: "AWS::EC2::Subnet::Id" 164 | PrivateSubnet3ID: 165 | Description: "ID of the private subnet 3 in Availability Zone 3 (e.g., subnet-xxxxxxxx)" 166 | Type: "AWS::EC2::Subnet::Id" 167 | PublicSubnet1ID: 168 | Description: "ID of the public subnet 1 in Availability Zone 1 (e.g., subnet-xxxxxxxx)" 169 | Type: "AWS::EC2::Subnet::Id" 170 | PublicSubnet2ID: 171 | Description: "ID of the public subnet 2 in Availability Zone 2 (e.g., subnet-xxxxxxxx)" 172 | Type: "AWS::EC2::Subnet::Id" 173 | PublicSubnet3ID: 174 | Description: "ID of the public subnet 3 in Availability Zone 3 (e.g., subnet-xxxxxxxx)" 175 | Type: "AWS::EC2::Subnet::Id" 176 | QSS3BucketName: 177 | AllowedPattern: "^[0-9a-zA-Z]+([0-9a-zA-Z-]*[0-9a-zA-Z])*$" 178 | ConstraintDescription: >- 179 | Quick Start bucket name can include numbers, lowercase letters, uppercase 180 | letters, and hyphens (-). It cannot start or end with a hyphen (-). 181 | Default: "aws-quickstart" 182 | Description: >- 183 | S3 bucket name for the Quick Start assets. Quick Start bucket name can 184 | include numbers, lowercase letters, uppercase letters, and hyphens (-). It 185 | cannot start or end with a hyphen (-). 186 | Type: String 187 | QSS3KeyPrefix: 188 | AllowedPattern: "^[0-9a-zA-Z-/]*$" 189 | ConstraintDescription: >- 190 | Quick Start key prefix can include numbers, lowercase letters, uppercase 191 | letters, hyphens (-), and forward slash (/). 192 | Default: "quickstart-hashicorp-consul/" 193 | Description: >- 194 | S3 key prefix for the Quick Start assets. Quick Start key prefix can 195 | include numbers, lowercase letters, uppercase letters, hyphens (-), and 196 | forward slash (/). 197 | Type: String 198 | QSS3BucketRegion: 199 | Default: 'us-east-1' 200 | Description: 'AWS Region where the Quick Start S3 bucket (QSS3BucketName) is hosted. When using your own bucket, you must specify this value.' 201 | Type: String 202 | VPCID: 203 | Description: VPC ID 204 | Type: "AWS::EC2::VPC::Id" 205 | VPCCIDR: 206 | AllowedPattern: >- 207 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 208 | Description: CIDR block for the VPC 209 | Type: String 210 | ConsulVersion: 211 | Type: String 212 | Description: The version of Consul to be created. 213 | AllowedValues: 214 | - '1.7.0' 215 | - '1.12.0' 216 | Default: '1.12.0' 217 | ConsulTemplateVersion: 218 | Type: String 219 | Description: The version of Consul template to be used. 220 | AllowedValues: 221 | - '0.24.0' 222 | - '0.29.0' 223 | Default: '0.29.0' 224 | ConsulServerNodes: 225 | Type: String 226 | Description: The number of Consul server nodes that will be created. You can choose 3, 5, or 7 nodes. 227 | AllowedValues: 228 | - "3" 229 | - "5" 230 | - "7" 231 | Default: "3" 232 | ConsulClientNodes: 233 | Type: String 234 | Description: The number of Consul client nodes that will be created. 235 | Default: "0" 236 | SSLCertificateArn: 237 | Description: The Amazon Resource Name (ARN) of the SSL certificate to use for the load balancer. Use 'SSLCertificateArn' if you are not using 'LoadBalancerFQDN' and 'HostedZoneID'. 238 | Type: String 239 | Default: '' 240 | HostedZoneID: 241 | Description: Route 53 Hosted Zone ID of the domain name. Used in conjunction with 'LoadBalancerFQDN'. 242 | Type: String 243 | MaxLength: 32 244 | Default: '' 245 | LoadBalancerFQDN: 246 | Description: The fully qualified domain name for the consul load balancer. Use with 'HostedZoneID' if you are not using SSL. 247 | Type: String 248 | Default: '' 249 | EnablegRPC: 250 | Description: Enable gRPC on the Consul server cluster. 251 | Type: String 252 | Default: "false" 253 | AllowedValues: 254 | - "true" 255 | - "false" 256 | Mappings: 257 | RegionELBAccountId: 258 | ap-east-1: 259 | AccountId: "754344448648" 260 | ap-northeast-1: 261 | AccountId: "582318560864" 262 | ap-northeast-2: 263 | AccountId: "600734575887" 264 | ap-northeast-3: 265 | AccountId: "383597477331" 266 | ap-southeast-1: 267 | AccountId: "114774131450" 268 | ap-southeast-2: 269 | AccountId: "783225319266" 270 | ap-south-1: 271 | AccountId: "718504428378" 272 | me-south-1: 273 | AccountId: "076674570225" 274 | ca-central-1: 275 | AccountId: "985666609251" 276 | eu-central-1: 277 | AccountId: "054676820928" 278 | eu-north-1: 279 | AccountId: "897822967062" 280 | eu-west-1: 281 | AccountId: "156460612806" 282 | eu-west-2: 283 | AccountId: "652711504416" 284 | eu-west-3: 285 | AccountId: "009996457667" 286 | sa-east-1: 287 | AccountId: "507241528517" 288 | us-east-1: 289 | AccountId: "127311923021" 290 | us-east-2: 291 | AccountId: "033677994240" 292 | us-west-1: 293 | AccountId: "027434742980" 294 | us-west-2: 295 | AccountId: "797873946194" 296 | AWSAMIRegionMap: 297 | ap-east-1: 298 | US1604HVM: ami-e5256594 299 | ap-northeast-1: 300 | US1604HVM: ami-078648cce0d33c256 301 | ap-northeast-2: 302 | US1604HVM: ami-0539a1389fedcbdc8 303 | ap-southeast-1: 304 | US1604HVM: ami-05f112c29645f0812 305 | ap-southeast-2: 306 | US1604HVM: ami-0e4bc04bd401729d6 307 | me-south-1: 308 | US1604HVM: ami-0054116010789ce83 309 | ap-south-1: 310 | US1604HVM: ami-03b8a287edc0c1253 311 | ca-central-1: 312 | US1604HVM: ami-0e2df0719252d4491 313 | eu-central-1: 314 | US1604HVM: ami-05ed2c1359acd8af6 315 | eu-north-1: 316 | US1604HVM: ami-094ac8f5eb69dd943 317 | eu-west-1: 318 | US1604HVM: ami-008320af74136c628 319 | eu-west-2: 320 | US1604HVM: ami-004c1e61ae5d76090 321 | eu-west-3: 322 | US1604HVM: ami-08eebff62e61110b7 323 | sa-east-1: 324 | US1604HVM: ami-0ddec8b41a3411374 325 | us-east-1: 326 | US1604HVM: ami-0a0ddd875a1ea2c7f 327 | us-east-2: 328 | US1604HVM: ami-04781752c9b20ea41 329 | us-west-1: 330 | US1604HVM: ami-0c1e832407373333f 331 | us-west-2: 332 | US1604HVM: ami-0a4df59262c92cf19 333 | Conditions: 334 | UsingDefaultBucket: !Equals [!Ref QSS3BucketName, 'aws-quickstart'] 335 | gRPCCondition: !Equals [!Ref EnablegRPC, "true"] 336 | GovCloudCondition: !Equals 337 | - !Ref AWS::Region 338 | - us-gov-west-1 339 | GenerateSSL: !And 340 | - !Equals [!Ref SSLCertificateArn, ''] 341 | - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 342 | SetupRoute53: !And 343 | - !Not 344 | - !Equals 345 | - !Ref 'HostedZoneID' 346 | - '' 347 | - !Not 348 | - !Equals 349 | - !Ref 'LoadBalancerFQDN' 350 | - '' 351 | # Rules: 352 | # DomainNamePresentWithHostedID: 353 | # Assertions: 354 | # - Assert: !Or 355 | # - !Equals [!Ref HostedZoneID, ''] 356 | # - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 357 | # AssertDescription: "Please specify a 'Domain Name' if you specify 'Route 53 Hosted Zone ID'" 358 | # GenerateOrProvideSSL: 359 | # Assertions: 360 | # - Assert: !Or 361 | # - !Not [!Equals [!Ref SSLCertificateArn, '']] 362 | # - !And 363 | # - !Not [!Equals [!Ref HostedZoneID, '']] 364 | # - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 365 | # - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 366 | # AssertDescription: "Using an SSL certificate is enforced. A CertificateArn or a HostedZoneID and LoadBalancerFQDN must be provided." 367 | # ProvideSSHKey: 368 | # Assertions: 369 | # - Assert: 370 | # - !Not [!Equals [ !Ref KeyPair, '']] 371 | # AssertDescription: "KeyPair must be provided." 372 | Resources: 373 | ConsulSecGroup: 374 | Type: "AWS::EC2::SecurityGroup" 375 | Properties: 376 | GroupDescription: Enables SSH access. 377 | VpcId: !Ref VPCID 378 | SecurityGroupIngress: 379 | - IpProtocol: tcp 380 | FromPort: 22 381 | ToPort: 22 382 | SourceSecurityGroupId: !Ref BastionSecurityGroupID 383 | - IpProtocol: tcp 384 | FromPort: 0 385 | ToPort: 65535 386 | CidrIp: !Ref VPCCIDR 387 | Tags: 388 | - Key: Name 389 | Value: !Join 390 | - "-" 391 | - - !Ref "AWS::StackName" 392 | - ConsulSecGroup 393 | ConsulServerAsg: 394 | Type: "AWS::AutoScaling::AutoScalingGroup" 395 | Properties: 396 | LaunchConfigurationName: !Ref ConsulServerLC 397 | MinSize: !Ref ConsulServerNodes 398 | MaxSize: !Ref ConsulServerNodes 399 | DesiredCapacity: !Ref ConsulServerNodes 400 | LoadBalancerNames: [!Ref ConsulServerELB] 401 | VPCZoneIdentifier: 402 | - !Ref PrivateSubnet1ID 403 | - !Ref PrivateSubnet2ID 404 | - !Ref PrivateSubnet3ID 405 | Tags: 406 | - Key: Name 407 | Value: !Join 408 | - "-" 409 | - - !Ref "AWS::StackName" 410 | - Consul-Server 411 | PropagateAtLaunch: true 412 | - Key: !Ref ConsulEc2RetryTagKey 413 | Value: !Ref ConsulEc2RetryTagValue 414 | PropagateAtLaunch: true 415 | CreationPolicy: 416 | ResourceSignal: 417 | Count: !Ref ConsulServerNodes 418 | Timeout: PT20M 419 | ConsulClientAsg: 420 | Type: "AWS::AutoScaling::AutoScalingGroup" 421 | Properties: 422 | LaunchConfigurationName: !Ref ConsulClientLC 423 | MinSize: !Ref ConsulClientNodes 424 | MaxSize: !Ref ConsulClientNodes 425 | DesiredCapacity: !Ref ConsulClientNodes 426 | VPCZoneIdentifier: 427 | - !Ref PrivateSubnet1ID 428 | - !Ref PrivateSubnet2ID 429 | - !Ref PrivateSubnet3ID 430 | Tags: 431 | - Key: Name 432 | Value: !Join 433 | - "-" 434 | - - !Ref "AWS::StackName" 435 | - Consul-Client 436 | PropagateAtLaunch: true 437 | CreationPolicy: 438 | ResourceSignal: 439 | Count: !Ref ConsulClientNodes 440 | Timeout: PT20M 441 | ConsulServerELB: 442 | Type: AWS::ElasticLoadBalancing::LoadBalancer 443 | Properties: 444 | Scheme: "internet-facing" 445 | Subnets: 446 | - !Ref PublicSubnet1ID 447 | - !Ref PublicSubnet2ID 448 | - !Ref PublicSubnet3ID 449 | SecurityGroups: 450 | - !Ref ConsulServerELBSecGroup 451 | CrossZone: true 452 | Listeners: 453 | - LoadBalancerPort: "80" 454 | InstancePort: "8500" 455 | Protocol: HTTP 456 | - LoadBalancerPort: "443" 457 | InstancePort: "8500" 458 | Protocol: HTTPS 459 | SSLCertificateId: 460 | !If 461 | - GenerateSSL 462 | - !GetAtt ACMCertificate.Outputs.ACMCertificate 463 | - !Ref SSLCertificateArn 464 | HealthCheck: 465 | Target: HTTP:8500/v1/status/leader 466 | HealthyThreshold: "3" 467 | UnhealthyThreshold: "2" 468 | Interval: "30" 469 | Timeout: "5" 470 | ConnectionDrainingPolicy: 471 | Enabled: true 472 | Timeout: 300 473 | AccessLoggingPolicy: 474 | S3BucketName: !Ref ConsulServerLogsBucket 475 | S3BucketPrefix: ConsulELBLogs 476 | Enabled: true 477 | EmitInterval: 60 478 | Tags: 479 | - Key: Name 480 | Value: !Join 481 | - "-" 482 | - - !Ref "AWS::StackName" 483 | - ConsulServerELB 484 | DependsOn: ConsulServerLogsBucketPolicy 485 | ConsulServerLogsBucket: 486 | Type: AWS::S3::Bucket 487 | DeletionPolicy: Retain 488 | UpdateReplacePolicy: Retain 489 | ConsulServerLogsBucketPolicy: 490 | Type: AWS::S3::BucketPolicy 491 | Properties: 492 | Bucket: !Ref ConsulServerLogsBucket 493 | PolicyDocument: 494 | Version: 2012-10-17 495 | Statement: 496 | - Sid: ConsulQSGELBAccessLogs 497 | Action: 498 | - "s3:PutObject" 499 | Effect: Allow 500 | Resource: 501 | !Join [ 502 | "", 503 | [ 504 | "arn:aws:s3:::", 505 | !Ref "ConsulServerLogsBucket", 506 | "/ConsulELBLogs", 507 | "/*", 508 | ], 509 | ] 510 | Principal: 511 | AWS: 512 | !Join [ 513 | "", 514 | [ 515 | "arn:aws:iam::", 516 | !FindInMap [ 517 | RegionELBAccountId, 518 | !Ref "AWS::Region", 519 | AccountId, 520 | ], 521 | ":root", 522 | ], 523 | ] 524 | ConsulServerELBSecGroup: 525 | Type: AWS::EC2::SecurityGroup 526 | Properties: 527 | GroupDescription: Enables ELB Access to cluster instances. 528 | VpcId: !Ref VPCID 529 | SecurityGroupIngress: 530 | # - IpProtocol: tcp 531 | # FromPort: 80 532 | # ToPort: 80 533 | # CidrIp: 0.0.0.0/0 534 | - IpProtocol: tcp 535 | FromPort: 443 536 | ToPort: 443 537 | CidrIp: 0.0.0.0/0 538 | SecurityGroupEgress: 539 | - IpProtocol: "-1" 540 | CidrIp: 0.0.0.0/0 541 | Tags: 542 | - Key: Name 543 | Value: !Join 544 | - "-" 545 | - - !Ref "AWS::StackName" 546 | - ConsulServerELBSecGroup 547 | ConsulServerLC: 548 | Type: AWS::AutoScaling::LaunchConfiguration 549 | Metadata: 550 | AWS::CloudFormation::Init: 551 | configSets: 552 | cs_install: 553 | - install_and_enable_cfn_hup 554 | - create_consul_group_user_dir 555 | - install_consul 556 | - install_consul_template 557 | - consul_bootstrap 558 | - setup_dnsmasq 559 | install_and_enable_cfn_hup: 560 | files: 561 | /etc/cfn/cfn-hup.conf: 562 | content: !Join 563 | - "" 564 | - - | 565 | [main] 566 | - stack= 567 | - !Ref "AWS::StackId" 568 | - |+ 569 | 570 | - region= 571 | - !Ref "AWS::Region" 572 | - |+ 573 | mode: "000400" 574 | owner: root 575 | group: root 576 | /etc/cfn/hooks.d/cfn-auto-reloader.conf: 577 | content: !Join 578 | - "" 579 | - - | 580 | [cfn-auto-reloader-hook] 581 | - | 582 | triggers=post.update 583 | - > 584 | path=Resources.ConsulClientLC.Metadata.AWS::CloudFormation::Init 585 | - "action=/usr/local/bin/cfn-init -v " 586 | - " --stack " 587 | - !Ref "AWS::StackName" 588 | - " --resource ConsulClientLC " 589 | - " --configsets cs_install " 590 | - " --region " 591 | - !Ref "AWS::Region" 592 | - |+ 593 | 594 | - | 595 | runas=root 596 | /lib/systemd/system/cfn-hup.service: 597 | content: !Join 598 | - "" 599 | - - | 600 | [Unit] 601 | - |+ 602 | Description=cfn-hup daemon 603 | 604 | - | 605 | [Service] 606 | - | 607 | Type=simple 608 | - | 609 | ExecStart=/usr/local/bin/cfn-hup 610 | - |+ 611 | Restart=always 612 | - | 613 | [Install] 614 | - WantedBy=multi-user.target 615 | commands: 616 | 01enable_cfn_hup: 617 | command: systemctl enable cfn-hup.service 618 | 02start_cfn_hup: 619 | command: systemctl start cfn-hup.service 620 | create_consul_group_user_dir: 621 | users: 622 | consul: 623 | homeDir: /srv/consul 624 | commands: 625 | 01_create_data_dir: 626 | command: mkdir -p /opt/consul/data 627 | install_consul: 628 | sources: 629 | /usr/bin/: !Sub https://releases.hashicorp.com/consul/${ConsulVersion}/consul_${ConsulVersion}_linux_amd64.zip 630 | install_consul_template: 631 | sources: 632 | /usr/bin/: !Sub https://releases.hashicorp.com/consul-template/${ConsulTemplateVersion}/consul-template_${ConsulTemplateVersion}_linux_amd64.zip 633 | consul_bootstrap: 634 | files: 635 | /opt/consul/config/server.json: 636 | content: !Sub | 637 | { 638 | "advertise_addr": "PrivateIpAddress", 639 | "bind_addr": "PrivateIpAddress", 640 | "node_name": "InstanceId", 641 | "datacenter": "${AWS::Region}", 642 | "server": true, 643 | "ui": true, 644 | "leave_on_terminate" : true, 645 | "skip_leave_on_interrupt" : true, 646 | "disable_update_check": true, 647 | "log_level": "warn", 648 | "data_dir": "/opt/consul/data", 649 | "client_addr": "0.0.0.0", 650 | "bootstrap_expect": ${ConsulServerNodes}, 651 | "retry_join": ["provider=aws region=${AWS::Region} tag_key=${ConsulEc2RetryTagKey} tag_value=${ConsulEc2RetryTagValue}"], 652 | "addresses": { 653 | "http": "0.0.0.0" 654 | }, 655 | "connect": { 656 | "enabled": true 657 | }, 658 | "autopilot": { 659 | "cleanup_dead_servers": true, 660 | "last_contact_threshold": "200ms", 661 | "max_trailing_logs": 250, 662 | "server_stabilization_time": "10s", 663 | "redundancy_zone_tag": "az", 664 | "disable_upgrade_migration": false, 665 | "upgrade_version_tag": "" 666 | } 667 | } 668 | 669 | mode: 000644 670 | /etc/systemd/system/consul.service: 671 | content: !Join 672 | - "" 673 | - - | 674 | [Unit] 675 | - | 676 | Description="HashiCorp Consul - A service mesh solution" 677 | - | 678 | Documentation=https://www.consul.io/ 679 | - | 680 | Requires=network-online.target 681 | - | 682 | After=network-online.target 683 | - | 684 | ConditionFileNotEmpty=/opt/consul/config/server.json 685 | - |+ 686 | [Service] 687 | - | 688 | Type=notify 689 | - | 690 | User=consul 691 | - | 692 | Group=consul 693 | - | 694 | ExecStart=/usr/bin/consul agent -config-dir /opt/consul/config -data-dir /opt/consul/data 695 | - | 696 | ExecReload=/usr/bin/consul reload 697 | - | 698 | KillMode=process 699 | - | 700 | Restart=on-failure 701 | - | 702 | TimeoutSec=300s 703 | - | 704 | LimitNOFILE=65536 705 | - |+ 706 | [Install] 707 | - WantedBy=multi-user.target 708 | commands: 709 | 00_fill_consul_config_ip: 710 | command: myip=`echo $(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)` && sed -i "s/PrivateIpAddress/${myip}/g" /opt/consul/config/server.json 711 | 01_fill_consul_config_instance_id: 712 | command: myid=`echo $(curl -s http://169.254.169.254/latest/meta-data/instance-id)` && sed -i "s/InstanceId/${myid}/g" /opt/consul/config/server.json 713 | 02_change_ownership: 714 | command: chown -R consul:consul /opt/consul 715 | 03_reload_systemd: 716 | command: systemctl daemon-reload 717 | 04_start_consul: 718 | command: systemctl enable consul 719 | 05_start_consul: 720 | command: systemctl start consul 721 | setup_dnsmasq: 722 | files: 723 | /etc/dnsmasq.d/consul: 724 | content: !Join 725 | - "" 726 | - - | 727 | server=/consul/127.0.0.1#8600 728 | - | 729 | listen-address=127.0.0.1 730 | - | 731 | bind-interfaces 732 | - | 733 | packages: 734 | apt: 735 | dnsmasq-base: [] 736 | dnsmasq: [] 737 | jq: [] 738 | commands: 739 | 01_start_dnsmasq: 740 | command: service dnsmasq restart 741 | Properties: 742 | InstanceType: !Ref ConsulInstanceType 743 | AssociatePublicIpAddress: false 744 | SecurityGroups: 745 | - !Ref ConsulSecGroup 746 | KeyName: !Ref KeyPair 747 | ImageId: !FindInMap 748 | - AWSAMIRegionMap 749 | - !Ref "AWS::Region" 750 | - US1604HVM 751 | IamInstanceProfile: !Ref ConsulServerProfile 752 | UserData: 753 | Fn::Base64: !Sub 754 | - | 755 | #!/bin/bash -x 756 | #CFN Functions 757 | function cfn_fail 758 | { 759 | cfn-signal -e 1 --stack ${AWS::StackName} --region ${AWS::Region} --resource ConsulServerAsg 760 | exit 1 761 | } 762 | function cfn_success 763 | { 764 | cfn-signal -e 0 --stack ${AWS::StackName} --region ${AWS::Region} --resource ConsulServerAsg 765 | exit 0 766 | } 767 | S3URI=https://${QSS3BucketName}.${S3Region}.amazonaws.com/${QSS3KeyPrefix} 768 | apt-get -y update 769 | # Install git 770 | apt-get install -y git jq 771 | #Load Linux utils 772 | until git clone https://github.com/aws-quickstart/quickstart-linux-utilities.git ; do echo "Retrying"; done 773 | cd /quickstart-linux-utilities && source quickstart-cfn-tools.source 774 | # Prep operating systems 775 | qs_update-os || qs_err 776 | qs_bootstrap_pip || qs_err 777 | qs_aws-cfn-bootstrap || qs_err 778 | #cfn-init 779 | echo "Executing config-sets" 780 | cfn-init -v --stack ${AWS::StackName} --resource ConsulServerLC --configsets cs_install --region ${AWS::Region} || (cfn_fail || (journalctl -b --no-pager -u consul && cat /opt/consul/config/server.json)) 781 | # Signal cfn-init (final check) 782 | [ $(qs_status) == 0 ] && cfn_success || cfn_fail 783 | - S3Region: !If [GovCloudCondition, s3-us-gov-west-1, s3] 784 | ConsulClientLC: 785 | Type: AWS::AutoScaling::LaunchConfiguration 786 | Metadata: 787 | AWS::CloudFormation::Init: 788 | configSets: 789 | cs_install: 790 | - install_and_enable_cfn_hup 791 | - create_consul_group_user_dir 792 | - install_consul 793 | - install_consul_template 794 | - consul_bootstrap 795 | - setup_dnsmasq 796 | install_and_enable_cfn_hup: 797 | files: 798 | /etc/cfn/cfn-hup.conf: 799 | content: !Join 800 | - "" 801 | - - | 802 | [main] 803 | - stack= 804 | - !Ref "AWS::StackId" 805 | - |+ 806 | 807 | - region= 808 | - !Ref "AWS::Region" 809 | - |+ 810 | mode: "000400" 811 | owner: root 812 | group: root 813 | /etc/cfn/hooks.d/cfn-auto-reloader.conf: 814 | content: !Join 815 | - "" 816 | - - | 817 | [cfn-auto-reloader-hook] 818 | - | 819 | triggers=post.update 820 | - > 821 | path=Resources.ConsulClientLC.Metadata.AWS::CloudFormation::Init 822 | - "action=/usr/local/bin/cfn-init -v " 823 | - " --stack " 824 | - !Ref "AWS::StackName" 825 | - " --resource ConsulClientLC " 826 | - " --configsets cs_install " 827 | - " --region " 828 | - !Ref "AWS::Region" 829 | - |+ 830 | 831 | - | 832 | runas=root 833 | /lib/systemd/system/cfn-hup.service: 834 | content: !Join 835 | - "" 836 | - - | 837 | [Unit] 838 | - |+ 839 | Description=cfn-hup daemon 840 | 841 | - | 842 | [Service] 843 | - | 844 | Type=simple 845 | - | 846 | ExecStart=/usr/local/bin/cfn-hup 847 | - |+ 848 | Restart=always 849 | - | 850 | [Install] 851 | - WantedBy=multi-user.target 852 | commands: 853 | 01enable_cfn_hup: 854 | command: systemctl enable cfn-hup.service 855 | 02start_cfn_hup: 856 | command: systemctl start cfn-hup.service 857 | create_consul_group_user_dir: 858 | users: 859 | consul: 860 | homeDir: /srv/consul 861 | commands: 862 | 01_create_data_dir: 863 | command: mkdir -p /opt/consul/data 864 | install_consul: 865 | sources: 866 | /usr/bin/: !Sub https://releases.hashicorp.com/consul/${ConsulVersion}/consul_${ConsulVersion}_linux_amd64.zip 867 | install_consul_template: 868 | sources: 869 | /usr/bin/: !Sub https://releases.hashicorp.com/consul-template/${ConsulTemplateVersion}/consul-template_${ConsulTemplateVersion}_linux_amd64.zip 870 | consul_bootstrap: 871 | files: 872 | /opt/consul/config/client.json: 873 | content: !Sub 874 | - | 875 | { 876 | "advertise_addr": "PrivateIpAddress", 877 | "bind_addr": "PrivateIpAddress", 878 | "node_name": "InstanceId", 879 | "datacenter": "${AWS::Region}", 880 | "server": false, 881 | "ui" : false, 882 | "leave_on_terminate" : true, 883 | "skip_leave_on_interrupt" : false, 884 | "disable_update_check": true, 885 | "log_level": "warn", 886 | "enable_local_script_checks": true, 887 | "data_dir": "/opt/consul/data", 888 | "client_addr": "0.0.0.0", 889 | "retry_join": ["provider=aws region=${AWS::Region} tag_key=${ConsulEc2RetryTagKey} tag_value=${ConsulEc2RetryTagValue}"], 890 | "addresses": { 891 | "http": "0.0.0.0" 892 | }${gRPC} 893 | } 894 | - gRPC: !If [ gRPCCondition, "\"ports\": ,{ \"grpc\": 8502 },", "" ] 895 | mode: 000644 896 | /etc/systemd/system/consul.service: 897 | content: !Join 898 | - "" 899 | - - | 900 | [Unit] 901 | - | 902 | Description="HashiCorp Consul - A service mesh solution" 903 | - | 904 | Documentation=https://www.consul.io/ 905 | - | 906 | Requires=network-online.target 907 | - | 908 | After=network-online.target 909 | - | 910 | ConditionFileNotEmpty=/opt/consul/config/client.json 911 | - |+ 912 | [Service] 913 | - | 914 | Type=notify 915 | - | 916 | User=consul 917 | - | 918 | Group=consul 919 | - | 920 | ExecStart=/usr/bin/consul agent -config-dir /opt/consul/config -data-dir /opt/consul/data 921 | - | 922 | ExecReload=/usr/bin/consul reload 923 | - | 924 | KillMode=process 925 | - | 926 | Restart=on-failure 927 | - | 928 | TimeoutSec=300s 929 | - | 930 | LimitNOFILE=65536 931 | - |+ 932 | [Install] 933 | - WantedBy=multi-user.target 934 | commands: 935 | 00_fill_consul_config_ip: 936 | command: myip=`echo $(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)` && sed -i "s/PrivateIpAddress/${myip}/g" /opt/consul/config/client.json 937 | 01_fill_consul_config_instance_id: 938 | command: myid=`echo $(curl -s http://169.254.169.254/latest/meta-data/instance-id)` && sed -i "s/InstanceId/${myid}/g" /opt/consul/config/client.json 939 | 02_change_ownership: 940 | command: chown -R consul:consul /opt/consul 941 | 03_reload_systemd: 942 | command: systemctl daemon-reload 943 | 04_enable_consul: 944 | command: systemctl enable consul 945 | 05_start_consul: 946 | command: systemctl start consul 947 | setup_dnsmasq: 948 | files: 949 | /etc/dnsmasq.d/consul: 950 | content: !Join 951 | - "" 952 | - - | 953 | server=/consul/127.0.0.1#8600 954 | - | 955 | listen-address=127.0.0.1 956 | - | 957 | bind-interfaces 958 | - | 959 | packages: 960 | apt: 961 | dnsmasq-base: [] 962 | dnsmasq: [] 963 | commands: 964 | 01_start_dnsmasq: 965 | command: service dnsmasq restart 966 | Properties: 967 | InstanceType: !Ref ConsulInstanceType 968 | AssociatePublicIpAddress: false 969 | SecurityGroups: 970 | - !Ref ConsulSecGroup 971 | KeyName: !Ref KeyPair 972 | ImageId: !FindInMap 973 | - AWSAMIRegionMap 974 | - !Ref "AWS::Region" 975 | - US1604HVM 976 | IamInstanceProfile: !Ref ConsulClientProfile 977 | UserData: 978 | Fn::Base64: !Sub 979 | - | 980 | #!/bin/bash -x 981 | #CFN Functions 982 | function cfn_fail 983 | { 984 | cfn-signal -e 1 --stack ${AWS::StackName} --region ${AWS::Region} --resource ConsulClientAsg 985 | } 986 | function cfn_success 987 | { 988 | cfn-signal -e 0 --stack ${AWS::StackName} --region ${AWS::Region} --resource ConsulClientAsg 989 | exit 0 990 | } 991 | S3URI=https://${QSS3BucketName}.${S3Region}.amazonaws.com/${QSS3KeyPrefix} 992 | apt-get -y update 993 | # Install git 994 | apt-get install -y git jq 995 | #Load Linux utils 996 | until git clone https://github.com/aws-quickstart/quickstart-linux-utilities.git ; do echo "Retrying"; done 997 | cd /quickstart-linux-utilities && source quickstart-cfn-tools.source 998 | # Prep operating systems 999 | qs_update-os || qs_err 1000 | qs_bootstrap_pip || qs_err 1001 | qs_aws-cfn-bootstrap || qs_err 1002 | #cfn-init 1003 | echo "Executing config-sets" 1004 | cfn-init -v --stack ${AWS::StackName} --resource ConsulClientLC --configsets cs_install --region ${AWS::Region} 1005 | STATUS=$? 1006 | echo signal cfn success/failure 1007 | [ $STATUS == 0 ] || cfn_fail 1008 | echo log info on failure 1009 | [ $STATUS == 0 ] || (journalctl -b --no-pager -u consul && cat /opt/consul/config/client.json && systemctl status consul.service) 1010 | 1011 | # Signal cfn-init (final check) 1012 | [ $(qs_status) == 0 ] && cfn_success || cfn_fail 1013 | - S3Region: !If [GovCloudCondition, s3-us-gov-west-1, s3] 1014 | ConsulClientRole: 1015 | Type: AWS::IAM::Role 1016 | Properties: 1017 | AssumeRolePolicyDocument: 1018 | Statement: 1019 | - Action: "sts:AssumeRole" 1020 | Principal: 1021 | Service: ec2.amazonaws.com 1022 | Effect: Allow 1023 | Sid: "" 1024 | Policies: 1025 | - PolicyDocument: 1026 | Version: 2012-10-17 1027 | Statement: 1028 | - Action: 1029 | - "s3:GetObject" 1030 | Resource: !Sub "arn:aws:s3:::${QSS3BucketName}/${QSS3KeyPrefix}*" 1031 | Effect: Allow 1032 | PolicyName: AuthenticatedS3GetObjects 1033 | ConsulClientPolicy: 1034 | Type: AWS::IAM::Policy 1035 | Properties: 1036 | PolicyName: consul-client 1037 | PolicyDocument: 1038 | Statement: 1039 | - Effect: Allow 1040 | Action: "ec2:DescribeInstances" 1041 | Resource: "*" 1042 | Roles: 1043 | - !Ref ConsulClientRole 1044 | ConsulClientProfile: 1045 | Type: AWS::IAM::InstanceProfile 1046 | Properties: 1047 | Path: / 1048 | Roles: 1049 | - !Ref ConsulClientRole 1050 | ConsulServerRole: 1051 | Type: AWS::IAM::Role 1052 | Properties: 1053 | AssumeRolePolicyDocument: 1054 | Statement: 1055 | - Action: "sts:AssumeRole" 1056 | Principal: 1057 | Service: ec2.amazonaws.com 1058 | Effect: Allow 1059 | Sid: "" 1060 | Policies: 1061 | - PolicyDocument: 1062 | Version: 2012-10-17 1063 | Statement: 1064 | - Action: 1065 | - "s3:GetObject" 1066 | Resource: !Sub "arn:aws:s3:::${QSS3BucketName}/${QSS3KeyPrefix}*" 1067 | Effect: Allow 1068 | PolicyName: AuthenticatedS3GetObjects 1069 | ConsulServerPolicy: 1070 | Type: AWS::IAM::Policy 1071 | Properties: 1072 | PolicyName: consul-server 1073 | PolicyDocument: 1074 | Statement: 1075 | - Effect: Allow 1076 | Action: 1077 | - "ec2:DescribeInstances" 1078 | Resource: "*" 1079 | Roles: 1080 | - !Ref ConsulServerRole 1081 | ConsulServerProfile: 1082 | Type: AWS::IAM::InstanceProfile 1083 | Properties: 1084 | Path: / 1085 | Roles: 1086 | - !Ref ConsulServerRole 1087 | LoadBalancerFQDNRecord: 1088 | Condition: SetupRoute53 1089 | Type: AWS::Route53::RecordSet 1090 | Properties: 1091 | Type: A 1092 | Name: !Ref 'LoadBalancerFQDN' 1093 | AliasTarget: 1094 | HostedZoneId: !GetAtt 'ConsulServerELB.CanonicalHostedZoneNameID' 1095 | DNSName: !GetAtt 'ConsulServerELB.DNSName' 1096 | HostedZoneId: !Ref 'HostedZoneID' 1097 | ACMCertificate: 1098 | Metadata: 1099 | cfn-lint: 1100 | config: 1101 | ignore_checks: 1102 | - W9198 1103 | Type: AWS::CloudFormation::Stack 1104 | Condition: GenerateSSL 1105 | Properties: 1106 | TemplateURL: 1107 | !Sub 1108 | - 'https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}submodules/quickstart-aws-acm-certificate/templates/quickstart-aws-acm-certificate.template.yml' 1109 | - S3Region: !If [UsingDefaultBucket, !Ref 'AWS::Region', !Ref QSS3BucketRegion] 1110 | S3Bucket: !If [UsingDefaultBucket, !Sub '${QSS3BucketName}-${AWS::Region}', !Ref QSS3BucketName] 1111 | Parameters: 1112 | QSS3BucketName: !Ref QSS3BucketName 1113 | QSS3BucketRegion: !Ref QSS3BucketRegion 1114 | QSS3KeyPrefix: !Sub ${QSS3KeyPrefix}submodules/quickstart-aws-acm-certificate/ 1115 | DomainName: !Ref LoadBalancerFQDN 1116 | HostedZoneID: !Ref HostedZoneID 1117 | Outputs: 1118 | ConsulEc2RetryTagKey: 1119 | Value: !Ref ConsulEc2RetryTagKey 1120 | Description: The EC2 instance tag key to filter on when joining to other Consul nodes. 1121 | ConsulEc2RetryTagValue: 1122 | Value: !Ref ConsulEc2RetryTagValue 1123 | Description: The EC2 instance tag value to filter on when joining to other Consul nodes. 1124 | ConsulServerELB: 1125 | Description: The public URL of your Consul Load Balancer. Create a CNAME record pointing at this Load Balancer. 1126 | Value: !Join ["", ["https://", !GetAtt ConsulServerELB.DNSName]] 1127 | ConsulServerFQDN: 1128 | Condition: SetupRoute53 1129 | Description: The public CNAME pointing to your Consul Load Balancer. 1130 | Value: !Join ["", ["https://", !Ref LoadBalancerFQDN]] -------------------------------------------------------------------------------- /templates/quickstart-hashicorp-consul.template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | Description: "HashiCorp Consul (Please do not remove) Aug,28,2019 (qs-1qup6ra8j)" 3 | Metadata: 4 | QuickStartDocumentation: 5 | EntrypointName: "Launch into an existing VPC" 6 | LICENSE: "Apache License, Version 2.0" 7 | 'AWS::CloudFormation::Interface': 8 | ParameterGroups: 9 | - Label: 10 | default: 'VPC network configuration' 11 | Parameters: 12 | - VPCID 13 | - VPCCIDR 14 | - PrivateSubnet1ID 15 | - PrivateSubnet2ID 16 | - PrivateSubnet3ID 17 | - PublicSubnet1ID 18 | - PublicSubnet2ID 19 | - PublicSubnet3ID 20 | - Label: 21 | default: "Bastion host configuration" 22 | Parameters: 23 | - BastionSecurityGroupID 24 | - Label: 25 | default: Consul Setup 26 | Parameters: 27 | - ConsulInstanceType 28 | - ConsulVersion 29 | - ConsulTemplateVersion 30 | - ConsulServerNodes 31 | - ConsulClientNodes 32 | - ConsulEc2RetryTagKey 33 | - ConsulEc2RetryTagValue 34 | - KeyPair 35 | - EnablegRPC 36 | - Label: 37 | default: "DNS and SSL configuration" 38 | Parameters: 39 | - LoadBalancerFQDN 40 | - HostedZoneID 41 | - SSLCertificateArn 42 | - Label: 43 | default: AWS Quick Start configuration 44 | Parameters: 45 | - QSS3BucketName 46 | - QSS3KeyPrefix 47 | - QSS3BucketRegion 48 | ParameterLabels: 49 | KeyPair: 50 | default: Key name 51 | PrivateSubnet1ID: 52 | default: Private Subnet 1 ID 53 | PrivateSubnet2ID: 54 | default: Private Subnet 2 ID 55 | PrivateSubnet3ID: 56 | default: Private Subnet 3 ID 57 | PublicSubnet1ID: 58 | default: Public Subnet 1 ID 59 | PublicSubnet2ID: 60 | default: Public Subnet 2 ID 61 | PublicSubnet3ID: 62 | default: Public Subnet 3 ID 63 | QSS3BucketName: 64 | default: Quick Start S3 bucket name 65 | QSS3KeyPrefix: 66 | default: Quick Start S3 key prefix 67 | QSS3BucketRegion: 68 | default: Quick Start S3 bucket Region 69 | VPCID: 70 | default: VPC ID 71 | VPCCIDR: 72 | default: VPC CIDR block 73 | SSLCertificateArn: 74 | default: SSL certificate ARN 75 | HostedZoneID: 76 | default: Route 53 hosted zone ID 77 | LoadBalancerFQDN: 78 | default: Load Balancer FQDN 79 | EnablegRPC: 80 | default: Enable gRPC on Consul 81 | ConsulInstanceType: 82 | default: Consul cluster node instance type 83 | ConsulVersion: 84 | default: Consul version 85 | ConsulTemplateVersion: 86 | default: Consul template version 87 | ConsulServerNodes: 88 | default: Number of Consul server nodes 89 | ConsulClientNodes: 90 | default: Number of Consul client nodes 91 | ConsulEc2RetryTagKey: 92 | default: Tag key for Consul cluster nodes 93 | ConsulEc2RetryTagValue: 94 | default: Tag value for Consul cluster nodes 95 | BastionSecurityGroupID: 96 | default: Bastion host security group ID 97 | Parameters: 98 | BastionSecurityGroupID: 99 | Description: ID of the bastion host security group to enable SSH connections (e.g., sg-7f16e910) 100 | Type: "AWS::EC2::SecurityGroup::Id" 101 | ConsulInstanceType: 102 | Type: String 103 | Description: The EC2 instance type for the Consul instances. 104 | AllowedValues: 105 | - t2.micro 106 | - t2.small 107 | - t2.medium 108 | - t2.large 109 | - m5.large 110 | - m5.xlarge 111 | - m5.2xlarge 112 | - m4.large 113 | - m4.xlarge 114 | - m3.medium 115 | - m3.large 116 | - m3.xlarge 117 | - m3.2xlarge 118 | - c4.large 119 | - c4.xlarge 120 | - c4.2xlarge 121 | - c4.4xlarge 122 | - c4.8xlarge 123 | - c3.large 124 | - c3.xlarge 125 | - c3.2xlarge 126 | - c3.4xlarge 127 | - c3.8xlarge 128 | - r3.large 129 | - r3.xlarge 130 | - r3.2xlarge 131 | - r3.4xlarge 132 | - r3.8xlarge 133 | - i2.xlarge 134 | - i2.2xlarge 135 | - i2.4xlarge 136 | - i2.8xlarge 137 | ConstraintDescription: Choose an instance type. 138 | Default: m5.large 139 | ConsulEc2RetryTagKey: 140 | Description: 141 | The EC2 instance tag key to filter on when joining to other Consul 142 | nodes. 143 | Type: String 144 | Default: "quickstart-consul-cluster" 145 | ConstraintDescription: Must match EC2 Tag Name requirements. 146 | ConsulEc2RetryTagValue: 147 | Description: 148 | The EC2 instance tag value to filter on when joining to other Consul 149 | nodes. 150 | Type: String 151 | Default: "consul-member-node" 152 | ConstraintDescription: Must match EC2 Tag Name requirements. 153 | KeyPair: 154 | Description: Name of an existing EC2 KeyPair to enable SSH access to the instances 155 | Type: "AWS::EC2::KeyPair::KeyName" 156 | # MinLength: 1 157 | ConstraintDescription: Must be the name of an existing EC2 KeyPair. 158 | PrivateSubnet1ID: 159 | Description: "ID of the private subnet 1 in Availability Zone 1 (e.g., subnet-xxxxxxxx)" 160 | Type: "AWS::EC2::Subnet::Id" 161 | PrivateSubnet2ID: 162 | Description: "ID of the private subnet 2 in Availability Zone 2 (e.g., subnet-xxxxxxxx)" 163 | Type: "AWS::EC2::Subnet::Id" 164 | PrivateSubnet3ID: 165 | Description: "ID of the private subnet 3 in Availability Zone 3 (e.g., subnet-xxxxxxxx)" 166 | Type: "AWS::EC2::Subnet::Id" 167 | PublicSubnet1ID: 168 | Description: "ID of the public subnet 1 in Availability Zone 1 (e.g., subnet-xxxxxxxx)" 169 | Type: "AWS::EC2::Subnet::Id" 170 | PublicSubnet2ID: 171 | Description: "ID of the public subnet 2 in Availability Zone 2 (e.g., subnet-xxxxxxxx)" 172 | Type: "AWS::EC2::Subnet::Id" 173 | PublicSubnet3ID: 174 | Description: "ID of the public subnet 3 in Availability Zone 3 (e.g., subnet-xxxxxxxx)" 175 | Type: "AWS::EC2::Subnet::Id" 176 | QSS3BucketName: 177 | AllowedPattern: "^[0-9a-zA-Z]+([0-9a-zA-Z-]*[0-9a-zA-Z])*$" 178 | ConstraintDescription: >- 179 | Quick Start bucket name can include numbers, lowercase letters, uppercase 180 | letters, and hyphens (-). It cannot start or end with a hyphen (-). 181 | Default: "aws-quickstart" 182 | Description: >- 183 | S3 bucket name for the Quick Start assets. Quick Start bucket name can 184 | include numbers, lowercase letters, uppercase letters, and hyphens (-). It 185 | cannot start or end with a hyphen (-). 186 | Type: String 187 | QSS3KeyPrefix: 188 | AllowedPattern: "^[0-9a-zA-Z-/]*$" 189 | ConstraintDescription: >- 190 | Quick Start key prefix can include numbers, lowercase letters, uppercase 191 | letters, hyphens (-), and forward slash (/). 192 | Default: "quickstart-hashicorp-consul/" 193 | Description: >- 194 | S3 key prefix for the Quick Start assets. Quick Start key prefix can 195 | include numbers, lowercase letters, uppercase letters, hyphens (-), and 196 | forward slash (/). 197 | Type: String 198 | QSS3BucketRegion: 199 | Default: 'us-east-1' 200 | Description: 'AWS Region where the Quick Start S3 bucket (QSS3BucketName) is hosted. When using your own bucket, you must specify this value.' 201 | Type: String 202 | VPCID: 203 | Description: VPC ID 204 | Type: "AWS::EC2::VPC::Id" 205 | VPCCIDR: 206 | AllowedPattern: >- 207 | ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$ 208 | Description: CIDR block for the VPC 209 | Type: String 210 | ConsulVersion: 211 | Type: String 212 | Description: The version of Consul to be created. 213 | AllowedValues: 214 | - '1.7.0' 215 | - '1.12.0' 216 | Default: '1.12.0' 217 | ConsulTemplateVersion: 218 | Type: String 219 | Description: The version of Consul template to be used. 220 | AllowedValues: 221 | - '0.24.0' 222 | - '0.29.0' 223 | Default: '0.29.0' 224 | ConsulServerNodes: 225 | Type: String 226 | Description: The number of Consul server nodes that will be created. You can choose 3, 5, or 7 nodes. 227 | AllowedValues: 228 | - "3" 229 | - "5" 230 | - "7" 231 | Default: "3" 232 | ConsulClientNodes: 233 | Type: String 234 | Description: The number of Consul client nodes that will be created. 235 | Default: "0" 236 | SSLCertificateArn: 237 | Description: The Amazon Resource Name (ARN) of the SSL certificate to use for the load balancer. Use 'SSLCertificateArn' if you are not using 'LoadBalancerFQDN' and 'HostedZoneID'. 238 | Type: String 239 | Default: '' 240 | HostedZoneID: 241 | Description: Route 53 Hosted Zone ID of the domain name. Used in conjunction with 'LoadBalancerFQDN'. 242 | Type: String 243 | MaxLength: 32 244 | Default: '' 245 | LoadBalancerFQDN: 246 | Description: The fully qualified domain name for the consul load balancer. Use with 'HostedZoneID' if you are not using SSL. 247 | Type: String 248 | Default: '' 249 | EnablegRPC: 250 | Description: Enable gRPC on the Consul server cluster. 251 | Type: String 252 | Default: "false" 253 | AllowedValues: 254 | - "true" 255 | - "false" 256 | Mappings: 257 | RegionELBAccountId: 258 | ap-east-1: 259 | AccountId: "754344448648" 260 | ap-northeast-1: 261 | AccountId: "582318560864" 262 | ap-northeast-2: 263 | AccountId: "600734575887" 264 | ap-northeast-3: 265 | AccountId: "383597477331" 266 | ap-southeast-1: 267 | AccountId: "114774131450" 268 | ap-southeast-2: 269 | AccountId: "783225319266" 270 | ap-south-1: 271 | AccountId: "718504428378" 272 | me-south-1: 273 | AccountId: "076674570225" 274 | ca-central-1: 275 | AccountId: "985666609251" 276 | eu-central-1: 277 | AccountId: "054676820928" 278 | eu-north-1: 279 | AccountId: "897822967062" 280 | eu-west-1: 281 | AccountId: "156460612806" 282 | eu-west-2: 283 | AccountId: "652711504416" 284 | eu-west-3: 285 | AccountId: "009996457667" 286 | sa-east-1: 287 | AccountId: "507241528517" 288 | us-east-1: 289 | AccountId: "127311923021" 290 | us-east-2: 291 | AccountId: "033677994240" 292 | us-west-1: 293 | AccountId: "027434742980" 294 | us-west-2: 295 | AccountId: "797873946194" 296 | AWSAMIRegionMap: 297 | ap-east-1: 298 | US1604HVM: ami-e5256594 299 | ap-northeast-1: 300 | US1604HVM: ami-078648cce0d33c256 301 | ap-northeast-2: 302 | US1604HVM: ami-0539a1389fedcbdc8 303 | ap-southeast-1: 304 | US1604HVM: ami-05f112c29645f0812 305 | ap-southeast-2: 306 | US1604HVM: ami-0e4bc04bd401729d6 307 | me-south-1: 308 | US1604HVM: ami-0054116010789ce83 309 | ap-south-1: 310 | US1604HVM: ami-03b8a287edc0c1253 311 | ca-central-1: 312 | US1604HVM: ami-0e2df0719252d4491 313 | eu-central-1: 314 | US1604HVM: ami-05ed2c1359acd8af6 315 | eu-north-1: 316 | US1604HVM: ami-094ac8f5eb69dd943 317 | eu-west-1: 318 | US1604HVM: ami-008320af74136c628 319 | eu-west-2: 320 | US1604HVM: ami-004c1e61ae5d76090 321 | eu-west-3: 322 | US1604HVM: ami-08eebff62e61110b7 323 | sa-east-1: 324 | US1604HVM: ami-0ddec8b41a3411374 325 | us-east-1: 326 | US1604HVM: ami-0a0ddd875a1ea2c7f 327 | us-east-2: 328 | US1604HVM: ami-04781752c9b20ea41 329 | us-west-1: 330 | US1604HVM: ami-0c1e832407373333f 331 | us-west-2: 332 | US1604HVM: ami-0a4df59262c92cf19 333 | Conditions: 334 | UsingDefaultBucket: !Equals [!Ref QSS3BucketName, 'aws-quickstart'] 335 | gRPCCondition: !Equals [!Ref EnablegRPC, "true"] 336 | GovCloudCondition: !Equals 337 | - !Ref AWS::Region 338 | - us-gov-west-1 339 | GenerateSSL: !And 340 | - !Equals [!Ref SSLCertificateArn, ''] 341 | - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 342 | SetupRoute53: !And 343 | - !Not 344 | - !Equals 345 | - !Ref 'HostedZoneID' 346 | - '' 347 | - !Not 348 | - !Equals 349 | - !Ref 'LoadBalancerFQDN' 350 | - '' 351 | # Rules: 352 | # DomainNamePresentWithHostedID: 353 | # Assertions: 354 | # - Assert: !Or 355 | # - !Equals [!Ref HostedZoneID, ''] 356 | # - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 357 | # AssertDescription: "Please specify a 'Domain Name' if you specify 'Route 53 Hosted Zone ID'" 358 | # GenerateOrProvideSSL: 359 | # Assertions: 360 | # - Assert: !Or 361 | # - !Not [!Equals [!Ref SSLCertificateArn, '']] 362 | # - !And 363 | # - !Not [!Equals [!Ref HostedZoneID, '']] 364 | # - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 365 | # - !Not [!Equals [!Ref LoadBalancerFQDN, '']] 366 | # AssertDescription: "Using an SSL certificate is enforced. A CertificateArn or a HostedZoneID and LoadBalancerFQDN must be provided." 367 | # ProvideSSHKey: 368 | # Assertions: 369 | # - Assert: 370 | # - !Not [!Equals [ !Ref KeyPair, '']] 371 | # AssertDescription: "KeyPair must be provided." 372 | Resources: 373 | ConsulSecGroup: 374 | Type: "AWS::EC2::SecurityGroup" 375 | Properties: 376 | GroupDescription: Enables SSH access. 377 | VpcId: !Ref VPCID 378 | SecurityGroupIngress: 379 | - IpProtocol: tcp 380 | FromPort: 22 381 | ToPort: 22 382 | SourceSecurityGroupId: !Ref BastionSecurityGroupID 383 | - IpProtocol: tcp 384 | FromPort: 0 385 | ToPort: 65535 386 | CidrIp: !Ref VPCCIDR 387 | Tags: 388 | - Key: Name 389 | Value: !Join 390 | - "-" 391 | - - !Ref "AWS::StackName" 392 | - ConsulSecGroup 393 | ConsulServerAsg: 394 | Type: "AWS::AutoScaling::AutoScalingGroup" 395 | Properties: 396 | LaunchConfigurationName: !Ref ConsulServerLC 397 | MinSize: !Ref ConsulServerNodes 398 | MaxSize: !Ref ConsulServerNodes 399 | DesiredCapacity: !Ref ConsulServerNodes 400 | LoadBalancerNames: [!Ref ConsulServerELB] 401 | VPCZoneIdentifier: 402 | - !Ref PrivateSubnet1ID 403 | - !Ref PrivateSubnet2ID 404 | - !Ref PrivateSubnet3ID 405 | Tags: 406 | - Key: Name 407 | Value: !Join 408 | - "-" 409 | - - !Ref "AWS::StackName" 410 | - Consul-Server 411 | PropagateAtLaunch: true 412 | - Key: !Ref ConsulEc2RetryTagKey 413 | Value: !Ref ConsulEc2RetryTagValue 414 | PropagateAtLaunch: true 415 | CreationPolicy: 416 | ResourceSignal: 417 | Count: !Ref ConsulServerNodes 418 | Timeout: PT20M 419 | ConsulClientAsg: 420 | Type: "AWS::AutoScaling::AutoScalingGroup" 421 | Properties: 422 | LaunchConfigurationName: !Ref ConsulClientLC 423 | MinSize: !Ref ConsulClientNodes 424 | MaxSize: !Ref ConsulClientNodes 425 | DesiredCapacity: !Ref ConsulClientNodes 426 | VPCZoneIdentifier: 427 | - !Ref PrivateSubnet1ID 428 | - !Ref PrivateSubnet2ID 429 | - !Ref PrivateSubnet3ID 430 | Tags: 431 | - Key: Name 432 | Value: !Join 433 | - "-" 434 | - - !Ref "AWS::StackName" 435 | - Consul-Client 436 | PropagateAtLaunch: true 437 | CreationPolicy: 438 | ResourceSignal: 439 | Count: !Ref ConsulClientNodes 440 | Timeout: PT20M 441 | ConsulServerELB: 442 | Type: AWS::ElasticLoadBalancing::LoadBalancer 443 | Properties: 444 | Scheme: "internet-facing" 445 | Subnets: 446 | - !Ref PublicSubnet1ID 447 | - !Ref PublicSubnet2ID 448 | - !Ref PublicSubnet3ID 449 | SecurityGroups: 450 | - !Ref ConsulServerELBSecGroup 451 | CrossZone: true 452 | Listeners: 453 | - LoadBalancerPort: "80" 454 | InstancePort: "8500" 455 | Protocol: HTTP 456 | - LoadBalancerPort: "443" 457 | InstancePort: "8500" 458 | Protocol: HTTPS 459 | SSLCertificateId: 460 | !If 461 | - GenerateSSL 462 | - !GetAtt ACMCertificate.Outputs.ACMCertificate 463 | - !Ref SSLCertificateArn 464 | HealthCheck: 465 | Target: HTTP:8500/v1/status/leader 466 | HealthyThreshold: "3" 467 | UnhealthyThreshold: "2" 468 | Interval: "30" 469 | Timeout: "5" 470 | ConnectionDrainingPolicy: 471 | Enabled: true 472 | Timeout: 300 473 | AccessLoggingPolicy: 474 | S3BucketName: !Ref ConsulServerLogsBucket 475 | S3BucketPrefix: ConsulELBLogs 476 | Enabled: true 477 | EmitInterval: 60 478 | Tags: 479 | - Key: Name 480 | Value: !Join 481 | - "-" 482 | - - !Ref "AWS::StackName" 483 | - ConsulServerELB 484 | DependsOn: ConsulServerLogsBucketPolicy 485 | ConsulServerLogsBucket: 486 | Type: AWS::S3::Bucket 487 | DeletionPolicy: Retain 488 | UpdateReplacePolicy: Retain 489 | Properties: 490 | VersioningConfiguration: 491 | Status: Enabled 492 | BucketEncryption: 493 | ServerSideEncryptionConfiguration: 494 | - ServerSideEncryptionByDefault: 495 | SSEAlgorithm: AES256 496 | PublicAccessBlockConfiguration: 497 | BlockPublicAcls: true 498 | BlockPublicPolicy: true 499 | IgnorePublicAcls: true 500 | RestrictPublicBuckets: true 501 | ConsulServerLogsBucketPolicy: 502 | Type: AWS::S3::BucketPolicy 503 | Properties: 504 | Bucket: !Ref ConsulServerLogsBucket 505 | PolicyDocument: 506 | Version: 2012-10-17 507 | Statement: 508 | - Sid: ConsulQSGELBAccessLogs 509 | Action: 510 | - "s3:PutObject" 511 | Effect: Allow 512 | Resource: 513 | !Join [ 514 | "", 515 | [ 516 | "arn:aws:s3:::", 517 | !Ref "ConsulServerLogsBucket", 518 | "/ConsulELBLogs", 519 | "/*", 520 | ], 521 | ] 522 | Principal: 523 | AWS: 524 | !Join [ 525 | "", 526 | [ 527 | "arn:aws:iam::", 528 | !FindInMap [ 529 | RegionELBAccountId, 530 | !Ref "AWS::Region", 531 | AccountId, 532 | ], 533 | ":root", 534 | ], 535 | ] 536 | ConsulServerELBSecGroup: 537 | Type: AWS::EC2::SecurityGroup 538 | Properties: 539 | GroupDescription: Enables ELB Access to cluster instances. 540 | VpcId: !Ref VPCID 541 | SecurityGroupIngress: 542 | # - IpProtocol: tcp 543 | # FromPort: 80 544 | # ToPort: 80 545 | # CidrIp: 0.0.0.0/0 546 | - IpProtocol: tcp 547 | FromPort: 443 548 | ToPort: 443 549 | CidrIp: 0.0.0.0/0 550 | SecurityGroupEgress: 551 | - IpProtocol: "-1" 552 | CidrIp: 0.0.0.0/0 553 | Tags: 554 | - Key: Name 555 | Value: !Join 556 | - "-" 557 | - - !Ref "AWS::StackName" 558 | - ConsulServerELBSecGroup 559 | ConsulServerLC: 560 | Type: AWS::AutoScaling::LaunchConfiguration 561 | Metadata: 562 | AWS::CloudFormation::Init: 563 | configSets: 564 | cs_install: 565 | - install_and_enable_cfn_hup 566 | - create_consul_group_user_dir 567 | - install_consul 568 | - install_consul_template 569 | - consul_bootstrap 570 | - setup_dnsmasq 571 | install_and_enable_cfn_hup: 572 | files: 573 | /etc/cfn/cfn-hup.conf: 574 | content: !Join 575 | - "" 576 | - - | 577 | [main] 578 | - stack= 579 | - !Ref "AWS::StackId" 580 | - |+ 581 | 582 | - region= 583 | - !Ref "AWS::Region" 584 | - |+ 585 | mode: "000400" 586 | owner: root 587 | group: root 588 | /etc/cfn/hooks.d/cfn-auto-reloader.conf: 589 | content: !Join 590 | - "" 591 | - - | 592 | [cfn-auto-reloader-hook] 593 | - | 594 | triggers=post.update 595 | - > 596 | path=Resources.ConsulClientLC.Metadata.AWS::CloudFormation::Init 597 | - "action=/usr/local/bin/cfn-init -v " 598 | - " --stack " 599 | - !Ref "AWS::StackName" 600 | - " --resource ConsulClientLC " 601 | - " --configsets cs_install " 602 | - " --region " 603 | - !Ref "AWS::Region" 604 | - |+ 605 | 606 | - | 607 | runas=root 608 | /lib/systemd/system/cfn-hup.service: 609 | content: !Join 610 | - "" 611 | - - | 612 | [Unit] 613 | - |+ 614 | Description=cfn-hup daemon 615 | 616 | - | 617 | [Service] 618 | - | 619 | Type=simple 620 | - | 621 | ExecStart=/usr/local/bin/cfn-hup 622 | - |+ 623 | Restart=always 624 | - | 625 | [Install] 626 | - WantedBy=multi-user.target 627 | commands: 628 | 01enable_cfn_hup: 629 | command: systemctl enable cfn-hup.service 630 | 02start_cfn_hup: 631 | command: systemctl start cfn-hup.service 632 | create_consul_group_user_dir: 633 | users: 634 | consul: 635 | homeDir: /srv/consul 636 | commands: 637 | 01_create_data_dir: 638 | command: mkdir -p /opt/consul/data 639 | install_consul: 640 | sources: 641 | /usr/bin/: !Sub https://releases.hashicorp.com/consul/${ConsulVersion}/consul_${ConsulVersion}_linux_amd64.zip 642 | install_consul_template: 643 | sources: 644 | /usr/bin/: !Sub https://releases.hashicorp.com/consul-template/${ConsulTemplateVersion}/consul-template_${ConsulTemplateVersion}_linux_amd64.zip 645 | consul_bootstrap: 646 | files: 647 | /opt/consul/config/server.json: 648 | content: !Sub | 649 | { 650 | "advertise_addr": "PrivateIpAddress", 651 | "bind_addr": "PrivateIpAddress", 652 | "node_name": "InstanceId", 653 | "datacenter": "${AWS::Region}", 654 | "server": true, 655 | "ui": true, 656 | "leave_on_terminate" : true, 657 | "skip_leave_on_interrupt" : true, 658 | "disable_update_check": true, 659 | "log_level": "warn", 660 | "data_dir": "/opt/consul/data", 661 | "client_addr": "0.0.0.0", 662 | "bootstrap_expect": ${ConsulServerNodes}, 663 | "retry_join": ["provider=aws region=${AWS::Region} tag_key=${ConsulEc2RetryTagKey} tag_value=${ConsulEc2RetryTagValue}"], 664 | "addresses": { 665 | "http": "0.0.0.0" 666 | }, 667 | "connect": { 668 | "enabled": true 669 | }, 670 | "autopilot": { 671 | "cleanup_dead_servers": true, 672 | "last_contact_threshold": "200ms", 673 | "max_trailing_logs": 250, 674 | "server_stabilization_time": "10s", 675 | "redundancy_zone_tag": "az", 676 | "disable_upgrade_migration": false, 677 | "upgrade_version_tag": "" 678 | } 679 | } 680 | 681 | mode: 000644 682 | /etc/systemd/system/consul.service: 683 | content: !Join 684 | - "" 685 | - - | 686 | [Unit] 687 | - | 688 | Description="HashiCorp Consul - A service mesh solution" 689 | - | 690 | Documentation=https://www.consul.io/ 691 | - | 692 | Requires=network-online.target 693 | - | 694 | After=network-online.target 695 | - | 696 | ConditionFileNotEmpty=/opt/consul/config/server.json 697 | - |+ 698 | [Service] 699 | - | 700 | Type=notify 701 | - | 702 | User=consul 703 | - | 704 | Group=consul 705 | - | 706 | ExecStart=/usr/bin/consul agent -config-dir /opt/consul/config -data-dir /opt/consul/data 707 | - | 708 | ExecReload=/usr/bin/consul reload 709 | - | 710 | KillMode=process 711 | - | 712 | Restart=on-failure 713 | - | 714 | TimeoutSec=300s 715 | - | 716 | LimitNOFILE=65536 717 | - |+ 718 | [Install] 719 | - WantedBy=multi-user.target 720 | commands: 721 | 00_fill_consul_config_ip: 722 | command: myip=`echo $(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)` && sed -i "s/PrivateIpAddress/${myip}/g" /opt/consul/config/server.json 723 | 01_fill_consul_config_instance_id: 724 | command: myid=`echo $(curl -s http://169.254.169.254/latest/meta-data/instance-id)` && sed -i "s/InstanceId/${myid}/g" /opt/consul/config/server.json 725 | 02_change_ownership: 726 | command: chown -R consul:consul /opt/consul 727 | 03_reload_systemd: 728 | command: systemctl daemon-reload 729 | 04_start_consul: 730 | command: systemctl enable consul 731 | 05_start_consul: 732 | command: systemctl start consul 733 | setup_dnsmasq: 734 | files: 735 | /etc/dnsmasq.d/consul: 736 | content: !Join 737 | - "" 738 | - - | 739 | server=/consul/127.0.0.1#8600 740 | - | 741 | listen-address=127.0.0.1 742 | - | 743 | bind-interfaces 744 | - | 745 | packages: 746 | apt: 747 | dnsmasq-base: [] 748 | dnsmasq: [] 749 | jq: [] 750 | commands: 751 | 01_start_dnsmasq: 752 | command: service dnsmasq restart 753 | Properties: 754 | InstanceType: !Ref ConsulInstanceType 755 | AssociatePublicIpAddress: false 756 | SecurityGroups: 757 | - !Ref ConsulSecGroup 758 | KeyName: !Ref KeyPair 759 | ImageId: !FindInMap 760 | - AWSAMIRegionMap 761 | - !Ref "AWS::Region" 762 | - US1604HVM 763 | IamInstanceProfile: !Ref ConsulServerProfile 764 | UserData: 765 | Fn::Base64: !Sub 766 | - | 767 | #!/bin/bash -x 768 | #CFN Functions 769 | function cfn_fail 770 | { 771 | cfn-signal -e 1 --stack ${AWS::StackName} --region ${AWS::Region} --resource ConsulServerAsg 772 | exit 1 773 | } 774 | function cfn_success 775 | { 776 | cfn-signal -e 0 --stack ${AWS::StackName} --region ${AWS::Region} --resource ConsulServerAsg 777 | exit 0 778 | } 779 | S3URI=https://${QSS3BucketName}.${S3Region}.amazonaws.com/${QSS3KeyPrefix} 780 | apt-get -y update 781 | # Install git 782 | apt-get install -y git jq 783 | #Load Linux utils 784 | until git clone https://github.com/aws-quickstart/quickstart-linux-utilities.git ; do echo "Retrying"; done 785 | cd /quickstart-linux-utilities && source quickstart-cfn-tools.source 786 | # Prep operating systems 787 | qs_update-os || qs_err 788 | qs_bootstrap_pip || qs_err 789 | qs_aws-cfn-bootstrap || qs_err 790 | #cfn-init 791 | echo "Executing config-sets" 792 | cfn-init -v --stack ${AWS::StackName} --resource ConsulServerLC --configsets cs_install --region ${AWS::Region} || (cfn_fail || (journalctl -b --no-pager -u consul && cat /opt/consul/config/server.json)) 793 | # Signal cfn-init (final check) 794 | [ $(qs_status) == 0 ] && cfn_success || cfn_fail 795 | - S3Region: !If [GovCloudCondition, s3-us-gov-west-1, s3] 796 | ConsulClientLC: 797 | Type: AWS::AutoScaling::LaunchConfiguration 798 | Metadata: 799 | AWS::CloudFormation::Init: 800 | configSets: 801 | cs_install: 802 | - install_and_enable_cfn_hup 803 | - create_consul_group_user_dir 804 | - install_consul 805 | - install_consul_template 806 | - consul_bootstrap 807 | - setup_dnsmasq 808 | install_and_enable_cfn_hup: 809 | files: 810 | /etc/cfn/cfn-hup.conf: 811 | content: !Join 812 | - "" 813 | - - | 814 | [main] 815 | - stack= 816 | - !Ref "AWS::StackId" 817 | - |+ 818 | 819 | - region= 820 | - !Ref "AWS::Region" 821 | - |+ 822 | mode: "000400" 823 | owner: root 824 | group: root 825 | /etc/cfn/hooks.d/cfn-auto-reloader.conf: 826 | content: !Join 827 | - "" 828 | - - | 829 | [cfn-auto-reloader-hook] 830 | - | 831 | triggers=post.update 832 | - > 833 | path=Resources.ConsulClientLC.Metadata.AWS::CloudFormation::Init 834 | - "action=/usr/local/bin/cfn-init -v " 835 | - " --stack " 836 | - !Ref "AWS::StackName" 837 | - " --resource ConsulClientLC " 838 | - " --configsets cs_install " 839 | - " --region " 840 | - !Ref "AWS::Region" 841 | - |+ 842 | 843 | - | 844 | runas=root 845 | /lib/systemd/system/cfn-hup.service: 846 | content: !Join 847 | - "" 848 | - - | 849 | [Unit] 850 | - |+ 851 | Description=cfn-hup daemon 852 | 853 | - | 854 | [Service] 855 | - | 856 | Type=simple 857 | - | 858 | ExecStart=/usr/local/bin/cfn-hup 859 | - |+ 860 | Restart=always 861 | - | 862 | [Install] 863 | - WantedBy=multi-user.target 864 | commands: 865 | 01enable_cfn_hup: 866 | command: systemctl enable cfn-hup.service 867 | 02start_cfn_hup: 868 | command: systemctl start cfn-hup.service 869 | create_consul_group_user_dir: 870 | users: 871 | consul: 872 | homeDir: /srv/consul 873 | commands: 874 | 01_create_data_dir: 875 | command: mkdir -p /opt/consul/data 876 | install_consul: 877 | sources: 878 | /usr/bin/: !Sub https://releases.hashicorp.com/consul/${ConsulVersion}/consul_${ConsulVersion}_linux_amd64.zip 879 | install_consul_template: 880 | sources: 881 | /usr/bin/: !Sub https://releases.hashicorp.com/consul-template/${ConsulTemplateVersion}/consul-template_${ConsulTemplateVersion}_linux_amd64.zip 882 | consul_bootstrap: 883 | files: 884 | /opt/consul/config/client.json: 885 | content: !Sub 886 | - | 887 | { 888 | "advertise_addr": "PrivateIpAddress", 889 | "bind_addr": "PrivateIpAddress", 890 | "node_name": "InstanceId", 891 | "datacenter": "${AWS::Region}", 892 | "server": false, 893 | "ui" : false, 894 | "leave_on_terminate" : true, 895 | "skip_leave_on_interrupt" : false, 896 | "disable_update_check": true, 897 | "log_level": "warn", 898 | "enable_local_script_checks": true, 899 | "data_dir": "/opt/consul/data", 900 | "client_addr": "0.0.0.0", 901 | "retry_join": ["provider=aws region=${AWS::Region} tag_key=${ConsulEc2RetryTagKey} tag_value=${ConsulEc2RetryTagValue}"], 902 | "addresses": { 903 | "http": "0.0.0.0" 904 | }${gRPC} 905 | } 906 | - gRPC: !If [ gRPCCondition, "\"ports\": ,{ \"grpc\": 8502 },", "" ] 907 | mode: 000644 908 | /etc/systemd/system/consul.service: 909 | content: !Join 910 | - "" 911 | - - | 912 | [Unit] 913 | - | 914 | Description="HashiCorp Consul - A service mesh solution" 915 | - | 916 | Documentation=https://www.consul.io/ 917 | - | 918 | Requires=network-online.target 919 | - | 920 | After=network-online.target 921 | - | 922 | ConditionFileNotEmpty=/opt/consul/config/client.json 923 | - |+ 924 | [Service] 925 | - | 926 | Type=notify 927 | - | 928 | User=consul 929 | - | 930 | Group=consul 931 | - | 932 | ExecStart=/usr/bin/consul agent -config-dir /opt/consul/config -data-dir /opt/consul/data 933 | - | 934 | ExecReload=/usr/bin/consul reload 935 | - | 936 | KillMode=process 937 | - | 938 | Restart=on-failure 939 | - | 940 | TimeoutSec=300s 941 | - | 942 | LimitNOFILE=65536 943 | - |+ 944 | [Install] 945 | - WantedBy=multi-user.target 946 | commands: 947 | 00_fill_consul_config_ip: 948 | command: myip=`echo $(curl -s http://169.254.169.254/latest/meta-data/local-ipv4)` && sed -i "s/PrivateIpAddress/${myip}/g" /opt/consul/config/client.json 949 | 01_fill_consul_config_instance_id: 950 | command: myid=`echo $(curl -s http://169.254.169.254/latest/meta-data/instance-id)` && sed -i "s/InstanceId/${myid}/g" /opt/consul/config/client.json 951 | 02_change_ownership: 952 | command: chown -R consul:consul /opt/consul 953 | 03_reload_systemd: 954 | command: systemctl daemon-reload 955 | 04_enable_consul: 956 | command: systemctl enable consul 957 | 05_start_consul: 958 | command: systemctl start consul 959 | setup_dnsmasq: 960 | files: 961 | /etc/dnsmasq.d/consul: 962 | content: !Join 963 | - "" 964 | - - | 965 | server=/consul/127.0.0.1#8600 966 | - | 967 | listen-address=127.0.0.1 968 | - | 969 | bind-interfaces 970 | - | 971 | packages: 972 | apt: 973 | dnsmasq-base: [] 974 | dnsmasq: [] 975 | commands: 976 | 01_start_dnsmasq: 977 | command: service dnsmasq restart 978 | Properties: 979 | InstanceType: !Ref ConsulInstanceType 980 | AssociatePublicIpAddress: false 981 | SecurityGroups: 982 | - !Ref ConsulSecGroup 983 | KeyName: !Ref KeyPair 984 | ImageId: !FindInMap 985 | - AWSAMIRegionMap 986 | - !Ref "AWS::Region" 987 | - US1604HVM 988 | IamInstanceProfile: !Ref ConsulClientProfile 989 | UserData: 990 | Fn::Base64: !Sub 991 | - | 992 | #!/bin/bash -x 993 | #CFN Functions 994 | function cfn_fail 995 | { 996 | cfn-signal -e 1 --stack ${AWS::StackName} --region ${AWS::Region} --resource ConsulClientAsg 997 | } 998 | function cfn_success 999 | { 1000 | cfn-signal -e 0 --stack ${AWS::StackName} --region ${AWS::Region} --resource ConsulClientAsg 1001 | exit 0 1002 | } 1003 | S3URI=https://${QSS3BucketName}.${S3Region}.amazonaws.com/${QSS3KeyPrefix} 1004 | apt-get -y update 1005 | # Install git 1006 | apt-get install -y git jq 1007 | #Load Linux utils 1008 | until git clone https://github.com/aws-quickstart/quickstart-linux-utilities.git ; do echo "Retrying"; done 1009 | cd /quickstart-linux-utilities && source quickstart-cfn-tools.source 1010 | # Prep operating systems 1011 | qs_update-os || qs_err 1012 | qs_bootstrap_pip || qs_err 1013 | qs_aws-cfn-bootstrap || qs_err 1014 | #cfn-init 1015 | echo "Executing config-sets" 1016 | cfn-init -v --stack ${AWS::StackName} --resource ConsulClientLC --configsets cs_install --region ${AWS::Region} 1017 | STATUS=$? 1018 | echo signal cfn success/failure 1019 | [ $STATUS == 0 ] || cfn_fail 1020 | echo log info on failure 1021 | [ $STATUS == 0 ] || (journalctl -b --no-pager -u consul && cat /opt/consul/config/client.json && systemctl status consul.service) 1022 | 1023 | # Signal cfn-init (final check) 1024 | [ $(qs_status) == 0 ] && cfn_success || cfn_fail 1025 | - S3Region: !If [GovCloudCondition, s3-us-gov-west-1, s3] 1026 | ConsulClientRole: 1027 | Type: AWS::IAM::Role 1028 | Properties: 1029 | AssumeRolePolicyDocument: 1030 | Statement: 1031 | - Action: "sts:AssumeRole" 1032 | Principal: 1033 | Service: ec2.amazonaws.com 1034 | Effect: Allow 1035 | Sid: "" 1036 | Policies: 1037 | - PolicyDocument: 1038 | Version: 2012-10-17 1039 | Statement: 1040 | - Action: 1041 | - "s3:GetObject" 1042 | Resource: !Sub "arn:${AWS::Partition}:s3:::${QSS3BucketName}/${QSS3KeyPrefix}*" 1043 | Effect: Allow 1044 | PolicyName: AuthenticatedS3GetObjects 1045 | ConsulClientPolicy: 1046 | Type: AWS::IAM::Policy 1047 | Properties: 1048 | PolicyName: consul-client 1049 | PolicyDocument: 1050 | Statement: 1051 | - Effect: Allow 1052 | Action: "ec2:DescribeInstances" 1053 | Resource: "*" 1054 | Roles: 1055 | - !Ref ConsulClientRole 1056 | ConsulClientProfile: 1057 | Type: AWS::IAM::InstanceProfile 1058 | Properties: 1059 | Path: / 1060 | Roles: 1061 | - !Ref ConsulClientRole 1062 | ConsulServerRole: 1063 | Type: AWS::IAM::Role 1064 | Properties: 1065 | AssumeRolePolicyDocument: 1066 | Statement: 1067 | - Action: "sts:AssumeRole" 1068 | Principal: 1069 | Service: ec2.amazonaws.com 1070 | Effect: Allow 1071 | Sid: "" 1072 | Policies: 1073 | - PolicyDocument: 1074 | Version: 2012-10-17 1075 | Statement: 1076 | - Action: 1077 | - "s3:GetObject" 1078 | Resource: !Sub "arn:${AWS::Partition}:s3:::${QSS3BucketName}/${QSS3KeyPrefix}*" 1079 | Effect: Allow 1080 | PolicyName: AuthenticatedS3GetObjects 1081 | ConsulServerPolicy: 1082 | Type: AWS::IAM::Policy 1083 | Properties: 1084 | PolicyName: consul-server 1085 | PolicyDocument: 1086 | Statement: 1087 | - Effect: Allow 1088 | Action: 1089 | - "ec2:DescribeInstances" 1090 | Resource: "*" 1091 | Roles: 1092 | - !Ref ConsulServerRole 1093 | ConsulServerProfile: 1094 | Type: AWS::IAM::InstanceProfile 1095 | Properties: 1096 | Path: / 1097 | Roles: 1098 | - !Ref ConsulServerRole 1099 | LoadBalancerFQDNRecord: 1100 | Condition: SetupRoute53 1101 | Type: AWS::Route53::RecordSet 1102 | Properties: 1103 | Type: A 1104 | Name: !Ref 'LoadBalancerFQDN' 1105 | AliasTarget: 1106 | HostedZoneId: !GetAtt 'ConsulServerELB.CanonicalHostedZoneNameID' 1107 | DNSName: !GetAtt 'ConsulServerELB.DNSName' 1108 | HostedZoneId: !Ref 'HostedZoneID' 1109 | ACMCertificate: 1110 | Metadata: 1111 | cfn-lint: 1112 | config: 1113 | ignore_checks: 1114 | - W9198 1115 | Type: AWS::CloudFormation::Stack 1116 | Condition: GenerateSSL 1117 | Properties: 1118 | TemplateURL: 1119 | !Sub 1120 | - 'https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}submodules/quickstart-aws-acm-certificate/templates/quickstart-aws-acm-certificate.template.yml' 1121 | - S3Region: !If [UsingDefaultBucket, !Ref 'AWS::Region', !Ref QSS3BucketRegion] 1122 | S3Bucket: !If [UsingDefaultBucket, !Sub '${QSS3BucketName}-${AWS::Region}', !Ref QSS3BucketName] 1123 | Parameters: 1124 | QSS3BucketName: !Ref QSS3BucketName 1125 | QSS3BucketRegion: !Ref QSS3BucketRegion 1126 | QSS3KeyPrefix: !Sub ${QSS3KeyPrefix}submodules/quickstart-aws-acm-certificate/ 1127 | DomainName: !Ref LoadBalancerFQDN 1128 | HostedZoneID: !Ref HostedZoneID 1129 | Outputs: 1130 | ConsulEc2RetryTagKey: 1131 | Value: !Ref ConsulEc2RetryTagKey 1132 | Description: The EC2 instance tag key to filter on when joining to other Consul nodes. 1133 | ConsulEc2RetryTagValue: 1134 | Value: !Ref ConsulEc2RetryTagValue 1135 | Description: The EC2 instance tag value to filter on when joining to other Consul nodes. 1136 | ConsulServerELB: 1137 | Description: The public URL of your Consul Load Balancer. Create a CNAME record pointing at this Load Balancer. 1138 | Value: !Join ["", ["https://", !GetAtt ConsulServerELB.DNSName]] 1139 | ConsulServerFQDN: 1140 | Condition: SetupRoute53 1141 | Description: The public CNAME pointing to your Consul Load Balancer. 1142 | Value: !Join ["", ["https://", !Ref LoadBalancerFQDN]] --------------------------------------------------------------------------------