Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template provider has been archived #24

Open
dpullman opened this issue Dec 15, 2022 · 2 comments
Open

template provider has been archived #24

dpullman opened this issue Dec 15, 2022 · 2 comments

Comments

@dpullman
Copy link

On at least Mac with M1 processor, starting in m5 (and then in m6 and further) the use of the template provider in the templates.tf file causes an init error:

➜  networking git:(v2) ✗ terraform init -backend-config="path=networking/state/globo-primary"
Initializing modules...
Downloading registry.terraform.io/terraform-aws-modules/vpc/aws 2.78.0 for vpc...
- vpc in .terraform/modules/vpc

Initializing the backend...

Successfully configured the backend "consul"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Finding hashicorp/consul versions matching "~> 2.0"...
- Finding hashicorp/aws versions matching ">= 2.70.0, ~> 3.0"...
- Finding latest version of hashicorp/template...
- Installing hashicorp/aws v3.75.2...
- Installed hashicorp/aws v3.75.2 (signed by HashiCorp)
- Installing hashicorp/consul v2.17.0...
- Installed hashicorp/consul v2.17.0 (signed by HashiCorp)
╷
│ Error: Incompatible provider version
│ 
│ Provider registry.terraform.io/hashicorp/template v2.2.0 does not have a package available for your
│ current platform, darwin_arm64.
│ 
│ Provider releases are separate from Terraform CLI releases, so not all providers are available for all
│ platforms. Other versions of this provider may have different platforms supported.

I'm using a Macbook Pro:

➜  Deep-Dive-Terraform git:(v2) ✗ terraform version
Terraform v1.3.6
on darwin_arm64

The docs say to use templatefile, but not sure how to do that in the current module setup. I'm doing a workaround for now by renaming the templates.tf file to xxxtemplates.tfxxx (taking it out of the config, basically) and adding two lines to locals in resources.tf and changing two lines in the vpc module to use the two local vars:

locals {
  cidr_block   = jsondecode(data.consul_keys.networking.var.networking)["cidr_block"]
  subnet_count = jsondecode(data.consul_keys.networking.var.networking)["subnet_count"]
  public_cidrsubnets = [for subnet in range(local.subnet_count) : cidrsubnet(local.cidr_block, 8, subnet)]
  private_cidrsubnets = [for subnet in range(local.subnet_count) : cidrsubnet(local.cidr_block, 8, subnet +10)]

  common_tags = merge(jsondecode(data.consul_keys.networking.var.common_tags),
    {
      Environment = terraform.workspace
    }
  )
}

##################################################################################
# RESOURCES
##################################################################################

# NETWORKING #
module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "~>2.0"

  name = "globo-primary-${terraform.workspace}"

  cidr            = local.cidr_block
  azs             = slice(data.aws_availability_zones.available.names, 0, local.subnet_count)
  private_subnets = local.private_cidrsubnets
  public_subnets  = local.public_cidrsubnets

  enable_nat_gateway = true

  create_database_subnet_group = false

  tags = local.common_tags
}
@ned1313
Copy link
Owner

ned1313 commented Dec 16, 2022

Thanks for letting me know David! When I published this course, the for expression didn't yet exist, so template_file was a possible workaround. If you don't mind, I'll borrow what you did and update the exercise files shortly.

@dpullman
Copy link
Author

You're welcome, and I was just repurposing something you had used before to get the exercise to work.

I am trying to work out a templatefile approach to these variables, just to keep the idea of the "template" example they were meant to show. But I need to learn how to do that, how to pass the right map in, that sort of thing. I'll update if I can figure that out. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants