hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.81k stars 9.16k forks source link

aws_elasticache_subnet_group missing tags property #18884

Closed ghost closed 3 years ago

ghost commented 3 years ago

This issue was originally opened by @NJITman as hashicorp/terraform#28380. It was migrated here as a result of the provider split. The original body of the issue is below.


The aws_elasticache_subnet_group resource is missing the tags argument. The tags can be entered using the AWS console or via the AWS CLI or API.

[Terraform Docs] (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_subnet_group)

[AWS CLI2 Docs] (https://awscli.amazonaws.com/v2/documentation/api/latest/reference/elasticache/create-cache-subnet-group.html)

[AWS API Docs] (https://docs.aws.amazon.com/AmazonElastiCache/latest/APIReference/API_CreateCacheSubnetGroup.html)

Example resource block with tags argument added using list format shown in AWS CLI2 doc.

locals {
  cluster_name = "redis-dev"
  private_subnet_ids = [ "subnet-03020100" ]
}

resource "aws_elasticache_subnet_group" "subnet_group" {
  name        = "subnet-group-${local.cluster_name}"
  description = "Subnet Group (${local.cluster_name})"
  subnet_ids  = local.private_subnet_ids
  tags = [
    {
      "key"                 = "Name"
      "value"               = "subnet-group-${local.cluster_name}"
    }
  ]

Terraform Version

Terraform v0.14.10
+ provider registry.terraform.io/hashicorp/aws v3.35.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/hashicorp/template v2.2.0

Terraform Configuration Files

terraform {
  backend "s3" {
    bucket         = "bucket_name"
    key            = "terraform-state.tf"
    dynamodb_table = table_name"
  }
  required_providers {
    aws = {
      version = ">= 3.34.0"
      source  = "hashicorp/aws"
    }
  }
}

Debug Output

Error: Unsupported argument

  on modules\redis\main.tf line 13, in resource "aws_elasticache_subnet_group" "subnet_group":
  13:   tags = [

An argument named "tags" is not expected here.

Expected Behavior

Terraform should have created the subnet group resource with the associated tags.

Actual Behavior

Terraform failed with an error (see above).

Steps to Reproduce

  1. terraform init
  2. terraform plan
NJITman commented 3 years ago

See screenshot of AWS Console below. The cluster was setup with TF, but I was not able to employ my "tag everything" philosophy. 😔

EC_Subnet_Group_Console

NJITman commented 3 years ago

In testing other aspects of the project design, I have run into a few other resources that throw an error when tags attributes are applied, even though the Terraform and AWS documentation indicate tags are a valid attribute.

aws_codedeploy_app

[Terraform Docs] (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_app) [AWS CLI2] (https://awscli.amazonaws.com/v2/documentation/api/latest/reference/deploy/create-application.html)

Error: Unsupported argument

  on modules\code-pipeline-vm\main.tf line 75, in resource "aws_codedeploy_app" "deployment_app":
  75:   tags = {

An argument named "tags" is not expected here.

aws_codedeploy_deployment_group

[Terraform Docs] (https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/codedeploy_deployment_group) [AWS CLI2] (https://awscli.amazonaws.com/v2/documentation/api/latest/reference/deploy/create-deployment-group.html)

Error: Unsupported argument

  on modules\code-pipeline-vm\main.tf line 106, in resource "aws_codedeploy_deployment_group" "deployment_group":
 106:   tags = {

An argument named "tags" is not expected here.

All other conditions apply as the OP (same project).

Although these tags are shown as valid in the docs, you cannot enter them via the console. I was going to try adding tags to the resources in AWS and then importing them back into the TF state to see if the tags would come along.

ghost commented 3 years ago

This has been released in version 3.38.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

github-actions[bot] commented 3 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.