gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
8.01k stars 971 forks source link

AutoInit does not detect provider version changes #606

Open yorinasub17 opened 5 years ago

yorinasub17 commented 5 years ago

Related to https://github.com/gruntwork-io/terragrunt/issues/605

AutoInit does not appear to detect when the provider version changes in a module.

Minimal example:

# /modules/app/main.tf
provider "aws" {
  region  = "us-west-2"
  version = "~> 1.43.0"
}

data "aws_ami" "ubuntu" {
  most_recent = true

  filter {
    name   = "name"
    values = ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"]
  }

  filter {
    name   = "virtualization-type"
    values = ["hvm"]
  }

  owners = ["099720109477"] # Canonical
}

resource "aws_instance" "web" {
  ami           = "${data.aws_ami.ubuntu.id}"
  instance_type = "t2.micro"

  tags {
    Name = "yori-test"
  }
}
# /live/app/terraform.tfvars
terragrunt = {
  terraform {
    source = "../../modules/app"
  }
}

Repro steps

  1. Run terragrunt plan. This will run terraform init and download the provider version indicated.
  2. Update the provider version (use 1.42.0)
  3. Run terragrunt plan.

Expected Behavior:

terraform init runs because the module source changed.

Actual Behavior

terraform init doesn't run, so you get an error indicating provider version mismatch.

brikis98 commented 5 years ago

Might be a dupe of https://github.com/gruntwork-io/terragrunt/issues/388