Skip to content

Commit

Permalink
ec2 client module enhancements (#95)
Browse files Browse the repository at this point in the history
Allow installing release candidate versions of Consul on the ec2 client node.
  • Loading branch information
riddhi89 authored Oct 20, 2023
1 parent 6070243 commit a758622
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 44 deletions.
6 changes: 3 additions & 3 deletions examples/hcp-ec2-demo/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource "hcp_hvn" "main" {

module "aws_hcp_consul" {
source = "hashicorp/hcp-consul/aws"
version = "~> 0.12.1"
version = "~> 0.13.0"

hvn = hcp_hvn.main
vpc_id = module.vpc.vpc_id
Expand Down Expand Up @@ -66,7 +66,7 @@ resource "local_file" "ssh_key" {

module "aws_ec2_consul_client" {
source = "hashicorp/hcp-consul/aws//modules/hcp-ec2-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

allowed_http_cidr_blocks = ["0.0.0.0/0"]
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
Expand All @@ -88,7 +88,7 @@ module "hashicups" {
count = var.install_demo_app ? 1 : 0

source = "hashicorp/hcp-consul/aws//modules/ec2-demo-app"
version = "~> 0.12.1"
version = "~> 0.13.0"

depends_on = [
module.aws_ec2_consul_client
Expand Down
4 changes: 2 additions & 2 deletions examples/hcp-ecs-demo/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resource "hcp_hvn" "main" {

module "aws_hcp_consul" {
source = "hashicorp/hcp-consul/aws"
version = "~> 0.12.1"
version = "~> 0.13.0"

hvn = hcp_hvn.main
vpc_id = module.vpc.vpc_id
Expand All @@ -52,7 +52,7 @@ resource "hcp_consul_cluster_root_token" "token" {

module "aws_ecs_cluster" {
source = "hashicorp/hcp-consul/aws//modules/hcp-ecs-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

allowed_http_cidr_blocks = ["0.0.0.0/0"]
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
Expand Down
6 changes: 3 additions & 3 deletions examples/hcp-eks-demo/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ resource "hcp_hvn" "main" {
# Note: Uncomment the below module to setup peering for connecting to a private HCP Consul cluster
# module "aws_hcp_consul" {
# source = "hashicorp/hcp-consul/aws"
# version = "~> 0.12.1"
# version = "~> 0.13.0"
#
# hvn = hcp_hvn.main
# vpc_id = module.vpc.vpc_id
Expand All @@ -91,7 +91,7 @@ resource "hcp_consul_cluster_root_token" "token" {

module "eks_consul_client" {
source = "hashicorp/hcp-consul/aws//modules/hcp-eks-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

boostrap_acl_token = hcp_consul_cluster_root_token.token.secret_id
cluster_id = hcp_consul_cluster.main.cluster_id
Expand All @@ -110,7 +110,7 @@ module "eks_consul_client" {
module "demo_app" {
count = var.install_demo_app ? 1 : 0
source = "hashicorp/hcp-consul/aws//modules/k8s-demo-app"
version = "~> 0.12.1"
version = "~> 0.13.0"

depends_on = [module.eks_consul_client]
}
6 changes: 3 additions & 3 deletions hcp-ui-templates/ec2-existing-vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ resource "hcp_hvn" "main" {

module "aws_hcp_consul" {
source = "hashicorp/hcp-consul/aws"
version = "~> 0.12.1"
version = "~> 0.13.0"

hvn = hcp_hvn.main
vpc_id = local.vpc_id
Expand Down Expand Up @@ -88,7 +88,7 @@ resource "local_file" "ssh_key" {

module "aws_ec2_consul_client" {
source = "hashicorp/hcp-consul/aws//modules/hcp-ec2-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

allowed_http_cidr_blocks = ["0.0.0.0/0"]
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
Expand All @@ -110,7 +110,7 @@ module "hashicups" {
count = local.install_demo_app ? 1 : 0

source = "hashicorp/hcp-consul/aws//modules/ec2-demo-app"
version = "~> 0.12.1"
version = "~> 0.13.0"

depends_on = [
module.aws_ec2_consul_client
Expand Down
6 changes: 3 additions & 3 deletions hcp-ui-templates/ec2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ resource "hcp_hvn" "main" {

module "aws_hcp_consul" {
source = "hashicorp/hcp-consul/aws"
version = "~> 0.12.1"
version = "~> 0.13.0"

hvn = hcp_hvn.main
vpc_id = module.vpc.vpc_id
Expand Down Expand Up @@ -103,7 +103,7 @@ resource "local_file" "ssh_key" {

module "aws_ec2_consul_client" {
source = "hashicorp/hcp-consul/aws//modules/hcp-ec2-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

allowed_http_cidr_blocks = ["0.0.0.0/0"]
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
Expand All @@ -125,7 +125,7 @@ module "hashicups" {
count = local.install_demo_app ? 1 : 0

source = "hashicorp/hcp-consul/aws//modules/ec2-demo-app"
version = "~> 0.12.1"
version = "~> 0.13.0"

depends_on = [
module.aws_ec2_consul_client
Expand Down
4 changes: 2 additions & 2 deletions hcp-ui-templates/ecs-existing-vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ resource "hcp_hvn" "main" {

module "aws_hcp_consul" {
source = "hashicorp/hcp-consul/aws"
version = "~> 0.12.1"
version = "~> 0.13.0"

hvn = hcp_hvn.main
vpc_id = local.vpc_id
Expand All @@ -68,7 +68,7 @@ resource "hcp_consul_cluster_root_token" "token" {

module "aws_ecs_cluster" {
source = "hashicorp/hcp-consul/aws//modules/hcp-ecs-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

allowed_http_cidr_blocks = ["0.0.0.0/0"]
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
Expand Down
4 changes: 2 additions & 2 deletions hcp-ui-templates/ecs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ resource "hcp_hvn" "main" {

module "aws_hcp_consul" {
source = "hashicorp/hcp-consul/aws"
version = "~> 0.12.1"
version = "~> 0.13.0"

hvn = hcp_hvn.main
vpc_id = module.vpc.vpc_id
Expand All @@ -83,7 +83,7 @@ resource "hcp_consul_cluster_root_token" "token" {

module "aws_ecs_cluster" {
source = "hashicorp/hcp-consul/aws//modules/hcp-ecs-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

allowed_http_cidr_blocks = ["0.0.0.0/0"]
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
Expand Down
6 changes: 3 additions & 3 deletions hcp-ui-templates/eks-existing-vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ resource "hcp_hvn" "main" {
# Note: Uncomment the below module to setup peering for connecting to a private HCP Consul cluster
# module "aws_hcp_consul" {
# source = "hashicorp/hcp-consul/aws"
# version = "~> 0.12.1"
# version = "~> 0.13.0"
#
# hvn = hcp_hvn.main
# vpc_id = local.vpc_id
Expand All @@ -135,7 +135,7 @@ resource "hcp_consul_cluster_root_token" "token" {

module "eks_consul_client" {
source = "hashicorp/hcp-consul/aws//modules/hcp-eks-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

boostrap_acl_token = hcp_consul_cluster_root_token.token.secret_id
cluster_id = hcp_consul_cluster.main.cluster_id
Expand All @@ -154,7 +154,7 @@ module "eks_consul_client" {
module "demo_app" {
count = local.install_demo_app ? 1 : 0
source = "hashicorp/hcp-consul/aws//modules/k8s-demo-app"
version = "~> 0.12.1"
version = "~> 0.13.0"

depends_on = [module.eks_consul_client]
}
Expand Down
6 changes: 3 additions & 3 deletions hcp-ui-templates/eks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ resource "hcp_hvn" "main" {
# Note: Uncomment the below module to setup peering for connecting to a private HCP Consul cluster
# module "aws_hcp_consul" {
# source = "hashicorp/hcp-consul/aws"
# version = "~> 0.12.1"
# version = "~> 0.13.0"
#
# hvn = hcp_hvn.main
# vpc_id = module.vpc.vpc_id
Expand All @@ -153,7 +153,7 @@ resource "hcp_consul_cluster_root_token" "token" {

module "eks_consul_client" {
source = "hashicorp/hcp-consul/aws//modules/hcp-eks-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

boostrap_acl_token = hcp_consul_cluster_root_token.token.secret_id
cluster_id = hcp_consul_cluster.main.cluster_id
Expand All @@ -172,7 +172,7 @@ module "eks_consul_client" {
module "demo_app" {
count = local.install_demo_app ? 1 : 0
source = "hashicorp/hcp-consul/aws//modules/k8s-demo-app"
version = "~> 0.12.1"
version = "~> 0.13.0"

depends_on = [module.eks_consul_client]
}
Expand Down
8 changes: 6 additions & 2 deletions modules/hcp-ec2-client/templates/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ setup_deps () {
add-apt-repository universe -y

# Add HashiCorp repository
curl -fSL --retry 3 https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
curl -fSL --retry 3 https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
# test repo for release candidate versions
apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) test"
curl -L --retry 3 'https://deb.dl.getenvoy.io/public/gpg.8115BA8E629CC074.key' | gpg --dearmor -o /usr/share/keyrings/getenvoy-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/getenvoy-keyring.gpg] https://deb.dl.getenvoy.io/public/deb/ubuntu $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/getenvoy.list
apt update -y

# Install Consul, Nomad, Envoy, and Nginx
version="${consul_version}"
# Note: apt is unable to find packages if '-rc*' is used. Hence trimming '-rc' from version which is present only in case
# of candidate release versions.
version=$(sed -r 's/-rc([0-9]*)//g'<<<${consul_version})
consul_package="consul-enterprise="$${version:1}"*"
apt install -y apt-transport-https gnupg2 curl lsb-release nomad $${consul_package} getenvoy-envoy unzip jq apache2-utils nginx

Expand Down
4 changes: 2 additions & 2 deletions scripts/module_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# SPDX-License-Identifier: MPL-2.0


old="0\.12\.0"
new=0.12.1
old="0\.12\.1"
new=0.13.0

for platform in ec2 ecs eks; do
file=examples/hcp-$platform-demo/main.tf
Expand Down
6 changes: 3 additions & 3 deletions test/hcp/testdata/ec2-existing-vpc.golden
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ resource "hcp_hvn" "main" {

module "aws_hcp_consul" {
source = "hashicorp/hcp-consul/aws"
version = "~> 0.12.1"
version = "~> 0.13.0"

hvn = hcp_hvn.main
vpc_id = local.vpc_id
Expand Down Expand Up @@ -88,7 +88,7 @@ resource "local_file" "ssh_key" {

module "aws_ec2_consul_client" {
source = "hashicorp/hcp-consul/aws//modules/hcp-ec2-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

allowed_http_cidr_blocks = ["0.0.0.0/0"]
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
Expand All @@ -110,7 +110,7 @@ module "hashicups" {
count = local.install_demo_app ? 1 : 0

source = "hashicorp/hcp-consul/aws//modules/ec2-demo-app"
version = "~> 0.12.1"
version = "~> 0.13.0"

depends_on = [
module.aws_ec2_consul_client
Expand Down
6 changes: 3 additions & 3 deletions test/hcp/testdata/ec2.golden
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ resource "hcp_hvn" "main" {

module "aws_hcp_consul" {
source = "hashicorp/hcp-consul/aws"
version = "~> 0.12.1"
version = "~> 0.13.0"

hvn = hcp_hvn.main
vpc_id = module.vpc.vpc_id
Expand Down Expand Up @@ -103,7 +103,7 @@ resource "local_file" "ssh_key" {

module "aws_ec2_consul_client" {
source = "hashicorp/hcp-consul/aws//modules/hcp-ec2-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

allowed_http_cidr_blocks = ["0.0.0.0/0"]
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
Expand All @@ -125,7 +125,7 @@ module "hashicups" {
count = local.install_demo_app ? 1 : 0

source = "hashicorp/hcp-consul/aws//modules/ec2-demo-app"
version = "~> 0.12.1"
version = "~> 0.13.0"

depends_on = [
module.aws_ec2_consul_client
Expand Down
4 changes: 2 additions & 2 deletions test/hcp/testdata/ecs-existing-vpc.golden
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ resource "hcp_hvn" "main" {

module "aws_hcp_consul" {
source = "hashicorp/hcp-consul/aws"
version = "~> 0.12.1"
version = "~> 0.13.0"

hvn = hcp_hvn.main
vpc_id = local.vpc_id
Expand All @@ -68,7 +68,7 @@ resource "hcp_consul_cluster_root_token" "token" {

module "aws_ecs_cluster" {
source = "hashicorp/hcp-consul/aws//modules/hcp-ecs-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

allowed_http_cidr_blocks = ["0.0.0.0/0"]
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
Expand Down
4 changes: 2 additions & 2 deletions test/hcp/testdata/ecs.golden
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ resource "hcp_hvn" "main" {

module "aws_hcp_consul" {
source = "hashicorp/hcp-consul/aws"
version = "~> 0.12.1"
version = "~> 0.13.0"

hvn = hcp_hvn.main
vpc_id = module.vpc.vpc_id
Expand All @@ -83,7 +83,7 @@ resource "hcp_consul_cluster_root_token" "token" {

module "aws_ecs_cluster" {
source = "hashicorp/hcp-consul/aws//modules/hcp-ecs-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

allowed_http_cidr_blocks = ["0.0.0.0/0"]
allowed_ssh_cidr_blocks = ["0.0.0.0/0"]
Expand Down
6 changes: 3 additions & 3 deletions test/hcp/testdata/eks-existing-vpc.golden
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ resource "hcp_hvn" "main" {
# Note: Uncomment the below module to setup peering for connecting to a private HCP Consul cluster
# module "aws_hcp_consul" {
# source = "hashicorp/hcp-consul/aws"
# version = "~> 0.12.1"
# version = "~> 0.13.0"
#
# hvn = hcp_hvn.main
# vpc_id = local.vpc_id
Expand All @@ -135,7 +135,7 @@ resource "hcp_consul_cluster_root_token" "token" {

module "eks_consul_client" {
source = "hashicorp/hcp-consul/aws//modules/hcp-eks-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

boostrap_acl_token = hcp_consul_cluster_root_token.token.secret_id
cluster_id = hcp_consul_cluster.main.cluster_id
Expand All @@ -154,7 +154,7 @@ module "eks_consul_client" {
module "demo_app" {
count = local.install_demo_app ? 1 : 0
source = "hashicorp/hcp-consul/aws//modules/k8s-demo-app"
version = "~> 0.12.1"
version = "~> 0.13.0"

depends_on = [module.eks_consul_client]
}
Expand Down
6 changes: 3 additions & 3 deletions test/hcp/testdata/eks.golden
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ resource "hcp_hvn" "main" {
# Note: Uncomment the below module to setup peering for connecting to a private HCP Consul cluster
# module "aws_hcp_consul" {
# source = "hashicorp/hcp-consul/aws"
# version = "~> 0.12.1"
# version = "~> 0.13.0"
#
# hvn = hcp_hvn.main
# vpc_id = module.vpc.vpc_id
Expand All @@ -153,7 +153,7 @@ resource "hcp_consul_cluster_root_token" "token" {

module "eks_consul_client" {
source = "hashicorp/hcp-consul/aws//modules/hcp-eks-client"
version = "~> 0.12.1"
version = "~> 0.13.0"

boostrap_acl_token = hcp_consul_cluster_root_token.token.secret_id
cluster_id = hcp_consul_cluster.main.cluster_id
Expand All @@ -172,7 +172,7 @@ module "eks_consul_client" {
module "demo_app" {
count = local.install_demo_app ? 1 : 0
source = "hashicorp/hcp-consul/aws//modules/k8s-demo-app"
version = "~> 0.12.1"
version = "~> 0.13.0"

depends_on = [module.eks_consul_client]
}
Expand Down

0 comments on commit a758622

Please sign in to comment.