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

Add support for default_tags in provider #625

Closed
antonbabenko opened this issue Apr 9, 2021 · 6 comments
Closed

Add support for default_tags in provider #625

antonbabenko opened this issue Apr 9, 2021 · 6 comments

Comments

@antonbabenko
Copy link
Member

Is your request related to a new offering from AWS?

default_tags in provider were introduced in v3.33.0 - hashicorp/terraform-provider-aws#17974

Is your request related to a problem? Please describe.

There are several related issues:
hashicorp/terraform-provider-aws#18311
hashicorp/terraform-provider-aws#18366

Describe the solution you'd like.

Unsure. Some research is required.

@yermulnik
Copy link

yermulnik commented May 12, 2021

@eriepasquare
Copy link

I know the description is still "Unsure. Some research is required" but was hoping to gain some momentum by highlighting this proposed work-a-round in the original provider issue:

hashicorp/terraform-provider-aws#19204 (comment)

This vpc module is the last module preventing my company from utilizing the default_tags feature of the AWS Provider.

@bgaillard
Copy link

I also encountered problems using default_tags with this module.

╷
│ Error: 1 error occurred:
│       * "tags" are identical to those in the "default_tags" configuration block of the provider: please de-duplicate and try again
│
│
│
│   with module.vpc.aws_vpc.this[0],
│   on .terraform/modules/vpc/main.tf line 25, in resource "aws_vpc" "this":
│   25: resource "aws_vpc" "this" {
│
╵

Here is the workaround I used to fix the problem.

locals {
    default_tags = {
        DefaultTag1 = "value1"
        DefaultTags2 = "value2"
    }
}

# AWS provider to use everywhere except with the 'terraform-aws-vpc' module.
provider "aws" {
  default_tags {
    tags = local.default_tags
  }
}

# AWS provider to be used with the 'terraform-aws-vpc' module to prevent an error with 'default_tags'.
#
# see https://github.com/terraform-aws-modules/terraform-aws-vpc/issues/625
provider "aws" {
  alias  = "vpc"
}

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "3.7.0"

  ...

  public_subnet_tags = merge(
    local.default_tags,
    {
      "PublicSubNetTag1" = "xxxx"
    }
  )

  private_subnet_tags = merge(
    local.default_tags,
    {
      "PrivateSubnetTag1" = "xxxx"
    }
  )

  tags = local.default_tags

  providers = {
    aws = aws.vpc
  }
}

Hope this helps.

@github-actions
Copy link

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

@github-actions github-actions bot added the stale label Feb 11, 2022
@github-actions
Copy link

This issue was automatically closed because of stale in 10 days

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants