Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Enable Consul Connect on terraform-aws-consul #173

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ff3a7e7
First commit, updated READMEs
7hacker May 14, 2020
09b16dd
Is Atom snipping off ws?
7hacker May 14, 2020
16781ed
Is Atom snipping off ws?
7hacker May 14, 2020
02a4c57
revert it works?
7hacker May 14, 2020
09656be
disabled ws package
7hacker May 14, 2020
995b63e
set up connect
7hacker May 14, 2020
893e24c
Example scripts
7hacker May 14, 2020
22cb4d9
Basic test that only verifies that a consul cluster with connect turn…
7hacker May 14, 2020
548eda7
testing if a CA comes up
7hacker May 14, 2020
cef1e03
fix tests
7hacker May 14, 2020
05fa6ed
I think this is a good first refactor to tease out the connect tests.…
7hacker May 14, 2020
042ec0a
clean up names
7hacker May 14, 2020
351283f
start 2 servies and their proxies in a user-data client
7hacker May 14, 2020
4b618ca
need to register services before starting the proxies
7hacker May 14, 2020
aee822c
addressing some comments in PR
7hacker May 14, 2020
4bf4132
Updated the readme with production notes
7hacker May 14, 2020
ea11497
clean up my keys/amis
7hacker May 14, 2020
6bb88de
more cleanup
7hacker May 14, 2020
b80d789
Update modules/run-consul/README.md
7hacker May 15, 2020
943b3dd
Update examples/example-with-consul-connect/user-data-client.sh
7hacker May 15, 2020
4a3a982
added a paragraph on running services and proxies in the run-consul r…
7hacker May 15, 2020
6156505
Update examples/example-with-consul-connect/main.tf
7hacker May 15, 2020
7be86c1
Update examples/example-with-consul-connect/README.md
7hacker May 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions examples/example-with-consul-connect/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Consul Cluster with Connect service mesh

This folder shows an example of Terraform code that uses the [run-consul module](https://github.com/hashicorp/terraform-aws-consul/tree/master/modules/consul-cluster) to deploy
a [Consul](https://www.consul.io/) cluster in [AWS](https://aws.amazon.com/) with the Consul Connect Service Mesh turned on. The cluster consists of three Services with
side-proxies and Intentions that enable secure service mesh connections.

You will need to create an [Amazon Machine Image (AMI)](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html)
that has Consul installed, which you can do using the [consul-ami example](https://github.com/hashicorp/terraform-aws-consul/tree/master/examples/consul-ami)). Note that to keep
this example simple, both the server ASG and client ASG are running the exact same AMI. In real-world usage, you'd
probably have multiple client ASGs, and each of those ASGs would run a different AMI that has the Consul agent
installed alongside your apps.

For more info on how the Consul cluster works, check out the [consul-cluster](https://github.com/hashicorp/terraform-aws-consul/tree/master/modules/consul-cluster) documentation.



## Quick start

To deploy a Consul Cluster:

1. `git clone` this repo to your computer.
1. Optional: build a Consul AMI. See the [consul-ami example](https://github.com/hashicorp/terraform-aws-consul/tree/master/examples/consul-ami) documentation for instructions. Make sure to
note down the ID of the AMI.
1. Install [Terraform](https://www.terraform.io/).
1. Open `variables.tf`, set the environment variables specified at the top of the file, and fill in any other variables that
don't have a default. If you built a custom AMI, put the AMI ID into the `ami_id` variable. Otherwise, one of our
public example AMIs will be used by default. These AMIs are great for learning/experimenting, but are NOT
recommended for production use.
1. Run `terraform init`.
1. Run `terraform apply`.
1. Run the [consul-examples-helper.sh script](https://github.com/hashicorp/terraform-aws-consul/tree/master/examples/consul-examples-helper/consul-examples-helper.sh) to
print out the IP addresses of the Consul servers and some example commands you can run to interact with the cluster:
`../consul-examples-helper/consul-examples-helper.sh`.
3 changes: 2 additions & 1 deletion modules/run-consul/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ The `run-consul` script accepts the following arguments:
* `ca-file-path` (optional): Path to the CA file used to verify outgoing connections. Must be specified with `enable-rpc-encryption`, `cert-file-path` and `key-file-path`.
* `cert-file-path` (optional): Path to the certificate file used to verify incoming connections. Must be specified with `enable-rpc-encryption`, `ca-file-path`, and `key-file-path`.
* `key-file-path` (optional): Path to the certificate key used to verify incoming connections. Must be specified with `enable-rpc-encryption`, `ca-file-path` and `cert-file-path`.
* `enable-connect` (optional): If this flag is set, turn on Consul Connect when bootstrapping a cluster. To specify your own CA, specify an override config as outlined below.
7hacker marked this conversation as resolved.
Show resolved Hide resolved
* `skip-consul-config` (optional): If this flag is set, don't generate a Consul configuration file. This is useful if
you have a custom configuration file and don't want to use any of of the default settings from `run-consul`.

Expand Down Expand Up @@ -276,4 +277,4 @@ track other servers. A server is considered healthy when:
There are Autopilot settings called [upgrade migrations](https://www.consul.io/docs/guides/autopilot.html#upgrade-migrations)
that are useful when adding new members to the cluster either with newer configurations or using
newer versions of Consul. These configurations manage how Consul will promote new servers and demote
old ones. These settings, however, are only available at the Consul Enterprise version.
old ones. These settings, however, are only available at the Consul Enterprise version.
5 changes: 2 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
variable "ami_id" {
description = "The ID of the AMI to run in the cluster. This should be an AMI built from the Packer template under examples/consul-ami/consul.json. To keep this example simple, we run the same AMI on both server and client nodes, but in real-world usage, your client nodes would also run your apps. If the default value is used, Terraform will look up the latest AMI build automatically."
type = string
default = null
default = "ami-0d2cef6a8db479d82"
}

variable "cluster_name" {
Expand Down Expand Up @@ -45,7 +45,7 @@ variable "cluster_tag_key" {
variable "ssh_key_name" {
description = "The name of an EC2 Key Pair that can be used to SSH to the EC2 Instances in this cluster. Set to an empty string to not associate a Key Pair."
type = string
default = null
default = "nt-trial"
}

variable "vpc_id" {
Expand All @@ -59,4 +59,3 @@ variable "spot_price" {
type = number
default = null
}