stavxyz / terraform-aws-backend

A Terraform module for your AWS Backend + a guide for bootstrapping your terraform managed project
Apache License 2.0
54 stars 32 forks source link

AWS region as variable #14

Open Vadim-Zenin opened 5 years ago

stavxyz commented 5 years ago

@vadimAnte thanks!

What happens if the variable is unset? I assume it will use AWS_DEFAULT_REGION, and if that is also unset then the tf run will fail?

Vadim-Zenin commented 5 years ago

You are welcome. If you added default value and user started few times it could be hard to change after. If user uses CloudFront better to use default = "us-east-1". If user does not use CloudFront closest location is preferable.

May be better add an example for varibles.tf

variable "backend_region" {
  type = "string"
  description = "AWS region"
  default = "us-east-1"
}

main.tf example:

module "backend" {
  /*
   * Since this example lives in the module repository,
   * we use a relative path '../', but typically we would use
   * the github url, like so:
   *
   * source = "github.com/samstav/terraform-aws-backend"
  */

  # source         = "../../"
  # source = "./modules/backend_aws_s3"
  source = "git::git@github.com:samstav/terraform-aws-backend.git//backend_aws_s3?ref=v1.0"
  backend_bucket = "${var.backend_bucket}"
  backend_region = "${var.backend_region}"
}

The module returns error if variable "backend_region" was hod defined.