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

Tag names containing dots are always deleted #2143

Closed
gar1t opened this issue May 29, 2015 · 28 comments
Closed

Tag names containing dots are always deleted #2143

gar1t opened this issue May 29, 2015 · 28 comments

Comments

@gar1t
Copy link

gar1t commented May 29, 2015

This tags definition:

tags {                                                                      
    "foo.bar" = "123"                                                       
}

Will cause an existing tag named "foo.bar" to be deleted. terraform apply always shows this:

tags.foo.bar: "<existing value>" => ""
@mitchellh
Copy link
Contributor

There is another issue tracking this, but the unfortunate thing is that periods in tag names simply can't be supported with the current state format. It'd be a silly dance to do so. We'll add an error.

We're working on fixing this but in the short term could you not use dots? :( sorry.

@gar1t
Copy link
Author

gar1t commented May 29, 2015

-Shakes fist at universe- ;)

Yeah, unfortunately we're using tag names from another application and making that change would be very hard indeed as it's managing servers in independent contexts.

I'm wondering about an escaping mechanism in your names that could be used to specify unicode characters, which could be passed along to AWS [1] - crazy?

[1] http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html

@gar1t
Copy link
Author

gar1t commented May 30, 2015

One other thought here - if Terraform didn't insist on its tags being the entire tagset, this would not be an issue either. Terraform could concede that other applications may use tags and act only to ensure that its tagset is a correct subset. If someone wants to delete a tag explicitly, they can specify the name with an empty string.

To maintain compatibility with the current regime, you might call this thing "ExtraTags" (or similar).

@tony612
Copy link

tony612 commented May 30, 2015

👍

@pdf
Copy link

pdf commented Jun 23, 2015

This limitation of the parser has wider implications too - if you need to pass keys containing periods to a provider, you have to make users do some dance where they replace periods with some other character - that must not be reserved, or overlap with any other valid characters - and then replace them before sending to the backend.

I'd really like to have quoted keys in maps treated as literals (syntactically preferable IMO), or failing that, allow periods to be escaped via \., but I don't know how realistic either option is.

@marekrogala
Copy link

👍
pretty important to me

@tony612
Copy link

tony612 commented Jan 11, 2016

I just wonder is there any progress for this problem? Dot is a convention for the names of our tags, so it's not easy to change :(

@ghost
Copy link

ghost commented Feb 16, 2016

👍
Also breaks out tag name convention based on dots...

sodre added a commit to zeroae/infrastructure that referenced this issue Apr 10, 2016
It outputs the host, port and user information for later plugin
into terraform's connection map.

It can't take advantage of Triton's CNS because of issue
hashicorp/terraform#2143.

It will not "converge" because the system fails to detect the
firewall_enabled flag from Triton's CloudAPI, issue
hashicorp/terraform#6109.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Your branch is up-to-date with 'origin/master'.
#
# Changes to be committed:
#	deleted:    bastion/bastion-user-script.sh
#	modified:   bastion/main.tf
#	new file:   bastion/ssh.config.in
#	new file:   bastion/user-script.sh
#
@bigkraig
Copy link
Contributor

👍 this is important for the api gateway

@coen-hyde
Copy link

coen-hyde commented Apr 14, 2016

As linked above this is breaking advanced_options for AWS's Elasticsearch service. Would be great to get this fixed.

@nicolai86
Copy link
Contributor

@mitchellh any guidance on how we can support hashicorp in solving this issues?

@jen20
Copy link
Contributor

jen20 commented May 4, 2016

I think #6322 should fix this, though I've not tested anyspecific cases. I'll add some tests around this issue and #6471 to the dev-0.7 branch and see what we can do. At minimum, the actual limitation is possible to remove now the internal representation of maps has changed, so this should be possible to support now.

@nicolai86
Copy link
Contributor

@jen20 that sounds great. this is a missing piece in a great aws_api_gateway implementation, so any progress on this front makes my day, literally, b/c I can start improving terraform again :)

@jen20
Copy link
Contributor

jen20 commented May 4, 2016

@nicolai86 I just verified that at least in the simple case it works. I'll test with actual resources shortly and close up this issue by adding some tests if all is well.

@sodre
Copy link
Contributor

sodre commented May 5, 2016

@jen20 I am also trying to fix this issue for PR #6115. Can you point how you would expect the provider code would have to change in view for #6322 ?

@BillBrady
Copy link

Any news on this issue? A customer has several . in their tag names as a company wide convention and it is a worry for them. Any updates appreciated greatly.
Thanks ~Bill

@justinsb
Copy link

justinsb commented Jun 8, 2016

I just tested the 0.7-rc release, and this is not fixed. Is there a new syntax I should be using?

Here is a simple test case:

resource "aws_ebs_volume" "myvolume" {
  availability_zone = "us-east-1b"
  size = 20
  type = "gp2"

  tags = {
    "a.b" = "c"
  }
}
terraform --version
Terraform v0.7.0-rc1 (301da85f30239e87b30db254a25706a6d41c2522)

If the parser can't be fixed, a workaround is to do what other AWS resources (e.g. autoscaling groups) do. They can be tagged arbitrarily, because instead of a map they use a list of objects [{key="a.b", value="c"} ... ].

@jen20
Copy link
Contributor

jen20 commented Jun 11, 2016

As of #6322 this has been fixed - 0.7.0-rc1 does not exhibit this behaviour:

Configuration:

provider "aws" {
    region = "us-west-2"
}

variable "tags" {
    default = {
        Name = "Test"
        Environment = "Production"
        Test.With.Dot = "Test Value"
    }
}

resource "aws_vpc" "test" {
    cidr_block = "10.0.0.0/16"

    tags = "${var.tags}"
}

Output:

$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but
will not be persisted to local or remote state storage.


The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed. Cyan entries are data sources to be read.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

+ aws_vpc.test
    cidr_block:                "10.0.0.0/16"
    default_network_acl_id:    "<computed>"
    default_security_group_id: "<computed>"
    dhcp_options_id:           "<computed>"
    enable_classiclink:        "<computed>"
    enable_dns_hostnames:      "<computed>"
    enable_dns_support:        "<computed>"
    instance_tenancy:          "<computed>"
    main_route_table_id:       "<computed>"
    tags.%:                    "3"
    tags.Environment:          "Production"
    tags.Name:                 "Test"
    tags.Test.With.Dot:        "Test Value"


Plan: 1 to add, 0 to change, 0 to destroy.

$ terraform apply
aws_vpc.test: Creating...
  cidr_block:                "" => "10.0.0.0/16"
  default_network_acl_id:    "" => "<computed>"
  default_security_group_id: "" => "<computed>"
  dhcp_options_id:           "" => "<computed>"
  enable_classiclink:        "" => "<computed>"
  enable_dns_hostnames:      "" => "<computed>"
  enable_dns_support:        "" => "<computed>"
  instance_tenancy:          "" => "<computed>"
  main_route_table_id:       "" => "<computed>"
  tags.%:                    "" => "3"
  tags.Environment:          "" => "Production"
  tags.Name:                 "" => "Test"
  tags.Test.With.Dot:        "" => "Test Value"
aws_vpc.test: Creation complete

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path: terraform.tfstate


$ aws ec2 describe-vpcs --region us-west-2
{
    "Vpcs": [
        {
            "VpcId": "vpc-cafb69ae",
            "InstanceTenancy": "default",
            "Tags": [
                {
                    "Value": "Test Value",
                    "Key": "Test.With.Dot"
                },
                {
                    "Value": "Test",
                    "Key": "Name"
                },
                {
                    "Value": "Production",
                    "Key": "Environment"
                }
            ],
            // Unnecessary output removed

@jen20 jen20 closed this as completed Jun 11, 2016
@sodre
Copy link
Contributor

sodre commented Jun 11, 2016

@jen20, can you verify if the code still works if you write

provider "aws" {
    region = "us-west-2"
}
resource "aws_vpc" "test" {
    cidr_block = "10.0.0.0/16"

    tags = {
        Name = "Test"
        Environment = "Production"
        Test.With.Dot = "Test Value"
    }
}

I was not able to get it to work with the triton provider. I just want to make sure it is not an issue on how that provider code is parsing the tags.

@mitchellh
Copy link
Contributor

@sodre I believe you have to wrap fields with dots in double quotes, but I'm not certain.

@sodre
Copy link
Contributor

sodre commented Jun 11, 2016

@mitchellh With quotes it still does not work.

@jen20
Copy link
Contributor

jen20 commented Jun 11, 2016

Hi @sodre - the code you posted works for me (with a build from master). I have not tried with the Triton provider - it's possible there is something in there preventing it working. If you have a repro could you open a new issue about this? Thanks!

@sodre
Copy link
Contributor

sodre commented Jun 12, 2016

@jen20 Thank you, I am working on a AccTest for using "dots" in the Triton provider. I will continue posting it to PR #6115.

@tony612
Copy link

tony612 commented Jun 21, 2016

@jen20 Hi, sodre's code doesn't work for me (Terraform 0.7.0-rc2):

$ terraform plan

+ aws_vpc.test
    cidr_block:                "" => "10.0.0.0/16"
    default_network_acl_id:    "" => "<computed>"
    default_security_group_id: "" => "<computed>"
    dhcp_options_id:           "" => "<computed>"
    enable_classiclink:        "" => "<computed>"
    enable_dns_hostnames:      "" => "<computed>"
    enable_dns_support:        "" => "<computed>"
    instance_tenancy:          "" => "<computed>"
    main_route_table_id:       "" => "<computed>"
    tags.#:                    "" => "3"
    tags.Environment:          "" => "Production"
    tags.Name:                 "" => "Test"
    tags.Test.With.Dot:        "" => ""


Plan: 1 to add, 0 to change, 0 to destroy.

And it still doesn't work with quotes

@justinsb
Copy link

Can we please reopen? This is still not fixed, even building from source:

resource "aws_ebs_volume" "myvolume" {
  availability_zone = "us-east-1b"
  size = 20
  type = "gp2"

  tags = {
    "a.b" = "c"
  }
}

plan gives:

+ aws_ebs_volume.myvolume
    availability_zone: "us-east-1b"
    encrypted:         "<computed>"
    iops:              "<computed>"
    kms_key_id:        "<computed>"
    size:              "20"
    snapshot_id:       "<computed>"
    tags.%:            "1"
    tags.a.b:          ""
    type:              "gp2"

@sodre
Copy link
Contributor

sodre commented Jun 28, 2016

@stack72,
Can you investigate this issue again? It seems I am not the only one who has not been able to replicate the fix that @jen20 mentioned.

Also, note that there is an open PR #7130 that shows the issue is not fixed at least the triton provider. We could enrich the PR to include the VPC test by @tony612 and EBS test by @justinsb.

@tony612
Copy link

tony612 commented Jul 18, 2016

It works now 👍

radeksimko pushed a commit that referenced this issue Aug 11, 2016
* provider/aws: Re-implement api gateway parameter handling

this PR cleans up some left overs from PR #4295, namely the parameter handling.

now that GH-2143 is finally closed this PR does away with the ugly
`request_parameters_in_json` and `response_parameters_in_json` hack.

* Add deprecation message and conflictsWith settings

following @radeksimko s advice, keeping the old code around with a deprecation
warning.

this should be cleaned up in a few releases

* provider/aws: fix missing append operation

* provider/aws: mark old parameters clearly as deprecated

* provider/aws work around #8104

following @radeksimko s lead

* provider/aws fix cnp error
grubernaut pushed a commit to TritonDataCenter/terraform-provider-triton that referenced this issue Jun 6, 2017
- Tests for issue hashicorp/terraform#2143.
- Fixed package names since Triton deprecated the g3-series.
- Must supply SDC_URL when invoking tests.

Test will fail on metadata_3 but not on _2 as discussed with
@jen20 on 11 June 2016.
@ghost
Copy link

ghost commented Apr 24, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 24, 2020
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