cloudposse / terraform-aws-elasticache-redis

Terraform module to provision an ElastiCache Redis Cluster
https://cloudposse.com/accelerate
Apache License 2.0
142 stars 246 forks source link

An argument named "availability_zones" is not expected here. #199

Closed muhammadasgharaliqureshi closed 1 year ago

muhammadasgharaliqureshi commented 1 year ago

Describe the Bug

In module code at line 25 we have

availability_zones         = length(var.availability_zones) == 0 ? null : [for n in range(0, var.cluster_size) : element(var.availability_zones, n)]

for terraform resource aws_elasticache_replication_group but this argument is no more available for terraform resource aws_elasticcache_replication_group here

image

Expected Behavior

Terraform validate and terraform apply should work on module example

Steps to Reproduce

Just try running following module example https://github.com/cloudposse/terraform-aws-elasticache-redis/tree/main/examples/complete

Screenshots

image

Environment

Additional Context

No response

mbilal-xgrid commented 1 year ago

+1

AbuBakkarBinAkmal commented 1 year ago

+1

adeelshahzad125 commented 1 year ago

+1

muhammadasgharaliqureshi commented 1 year ago

Related to https://github.com/cloudposse/terraform-aws-elasticache-redis/issues/173 and https://github.com/cloudposse/terraform-aws-elasticache-redis/issues/197

TheSantacloud commented 1 year ago

This is because AWS has released provider version 5.x and it has some breaking changes (major change) To resolve it, change your AWS provider (probably in providers.tf)

terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "~> 4.67.0"
    }
  }
}

provider "aws" {
  # Configuration options
}

and then run terraform init -upgrade and it should be fine

rajatrj16 commented 1 year ago

Upgrading the provider won't help I am still getting

╷
│ Error: Unsupported argument
│ 
│   on .terraform/modules/elasticache_redis.elasticache-redis/main.tf line 125, in resource "aws_elasticache_replication_group" "default":
│  125:   availability_zones         = length(var.availability_zones) == 0 ? null : [for n in range(0, var.cluster_size) : element(var.availability_zones, n)]
│ 
│ An argument named "availability_zones" is not expected here.
╵

I have tried to replace availability_zones with preferred_cache_cluster_azs as mentioned in the issue-197 but then getting

╷
│ Error: Unsupported argument
│ 
│   on ../../modules/elastic-cache/main.tf line 22, in module "elasticache-redis":
│   22:   preferred_cache_cluster_azs          = var.availability_zones
│ 
│ An argument named "preferred_cache_cluster_azs" is not expected here.
╵
ervinb commented 1 year ago

If you happen to use Terragrunt, you can overwrite this module's version-contraint, so the aws module stays below 5.x (as per the comment above):

terraform {
  source = "git::https://github.com/cloudposse/terraform-aws-elasticache-redis//.?ref=0.51.0"
}

generate "versions" {
  path = "versions.tf"
  if_exists = "overwrite"

  contents = <<-EOF
  terraform {
    required_version = ">= 0.14.0"

    required_providers {
      aws = {
        source  = "hashicorp/aws"
        version = "~> 4.18"
      }
    }
  }
  EOF
}

locals {...}

inputs = {...}
milldr commented 1 year ago

198 should have resolved breaking changes from AWS provider v5. Please update to the latest and retry

muhammadasgharaliqureshi commented 1 year ago

Thanks @milldr yes looks good now, closing this issue now.