hashicorp / terraform-aws-consul

A Terraform Module for how to run Consul on AWS using Terraform and Packer
Apache License 2.0
401 stars 487 forks source link

How to override instance_role when using consul-cluster module? #231

Open lenew opened 3 years ago

lenew commented 3 years ago

In cn-north-1 region, It should be "ec2.amazonaws.com.cn" instead of "ec2.amazonaws.com" at aws_iam_policy_document. Currently, I modify .terraform/modules/consul_cluster/modules/consul-cluster/main.tf before apply it. Is there a better way to override this value? My code

module "consul_cluster" {
  # TODO: update this to the final URL
  # Use version v0.0.5 of the consul-cluster module
  source = "github.com/hashicorp/terraform-aws-consul//modules/consul-cluster?ref=v0.10.1"

  # Specify the ID of the Consul AMI. You should build this using the scripts in the install-consul module.
  ami_id = "ami-abc"

  # Add this tag to each node in the cluster
  cluster_tag_key   = "consul-cluster"
  cluster_tag_value = "consul-example"

  # Configure and start Consul during boot. It will automatically form a cluster with all nodes that have that same tag.
  user_data = <<-EOF
              #!/bin/bash
              /opt/consul/bin/run-consul --server --cluster-tag-key consul-cluster --cluster-tag-value consul-example
              EOF

  # region = "cn-north-1"
  cluster_name = "my-consul"
  instance_type = "t3.micro"
  vpc_id = "vpc-23e3fd40"
  subnet_ids = ["subnet-dfe6ffad", "subnet-8c143df9"]
  allowed_inbound_cidr_blocks = ["172.31.0.0/16"]
}
brikis98 commented 3 years ago

Ah, this should probably be exposed as an input variable that defaults to ec2.amazonaws.com but can be overridden. PR welcome!