Analysis of HashiCorp's Official Consul CloudFormation
-
The AMI is an ubuntu image
-
creates a systemd named consul. bin at /usr/bin, config at /etc/consul/config, data at /etc/consul/data
-
Sample config. This goes to /etc/consul/server.json
{
"server": true,
"ui": true,
"data_dir": "/opt/consul/data",
"client_addr": "0.0.0.0",
"bootstrap_expect": __BOOTSTRAP_EXPECT__,
"retry_join_ec2": {
"tag_key": "__CONSUL_TAG_KEY__",
"tag_value": "__CONSUL_TAG_VALUE__"
}
[Unit]
Description=Consul
Requires=network-online.target
After=network-online.target
[Service]
Restart=on-failure
ExecStart=/usr/bin/consul agent -config-dir /etc/consul
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=SIGTERM
[Install]
WantedBy=multi-user.target
-
The launch configuration uses EC2 health check instead of health endpoint,i.e., potentially there might be case where instance is up, but process is down
-
For consul client machines, client shares the same consul.service file, but gives a different configuration. This goes to /etc/consul/client.json in the config dir.
{
"server": false,
"ui": true,
"data_dir": "/opt/consul/data",
"client_addr": "0.0.0.0",
"retry_join_ec2": {
"tag_key": "__CONSUL_TAG_KEY__",
"tag_value": "__CONSUL_TAG_VALUE__"
}
}
-
IAM role for consul client and server
-
s3:GetObject - to get scripts and binaries
-
ec2:DescribeInstances - need to get tag information
-