brikis98 / terraform-up-and-running-code

Code samples for the book "Terraform: Up & Running" by Yevgeniy Brikman
http://www.terraformupandrunning.com/
MIT License
2.87k stars 1.92k forks source link

Chapter 2 - webserver cluster - Terraform warning #43

Closed martin-flower closed 4 years ago

martin-flower commented 4 years ago

terraform plan displays the following in 02-intro-to-terraform-syntax/webserver-cluster

Warning: "condition.0.values": [DEPRECATED] use 'host_header' or 'path_pattern' attribute instead
  on main.tf line 113, in resource "aws_lb_listener_rule" "asg":
 113: resource "aws_lb_listener_rule" "asg" {
Terraform v0.12.10
+ provider.aws v2.43.0
macOS 10.15.2

How do I get rid of this message?

brikis98 commented 4 years ago

This was a change introduced in https://github.com/terraform-providers/terraform-provider-aws/pull/8268, which was released in AWS Provider 2.42.0, which came out after the second edition of the book was published. There are two ways you can get rid of this warning:

  1. Do as the warning suggests and switch from this format:

    condition {
      field  = "path-pattern"
      values = ["*"]
    }

    To this format:

    condition {
      path_pattern {
        values = ["*"]
      }
    }
  2. Pin yourself to the older AWS provider version (this is not a good long-term fix):

    provider "aws" {
      version = "= 2.41.0"
    }
martin-flower commented 4 years ago

Thanks Yevgeniy! Very helpful to not only give the solution, but also the explanation. In order to have repeatable build we probably need to pin the terraform and aws-provider versions. Just need to make sure we upgrade regularly.