_This issue was originally opened by @DemonR as hashicorp/terraform#17712. It was migrated here as a result of the provider split. The original body of the issue is below._
According to Elastic Beanstalk documentation, "Name" is one of the default tags and can't be edited. However if the "Name" tag is set in the terraform script, it will still try to apply the change.
$ terraform -v
Terraform v0.11.5
resource "aws_elastic_beanstalk_environment" "xxxxxxx_env" {
name = "${var.service_name}-${var.environment}"
application = "${aws_elastic_beanstalk_application.xxxxxxx.name}"
solution_stack_name = "64bit Amazon Linux 2017.09 v2.6.4 running Python 3.6"
tier = "Worker"
tags {
Environment = "${var.environment}"
Name = "New Tag Name"
}
}
"Name" tag is not applied, or report an error
Elastic Beanstalk:
2018-03-27 16:38:00 UTC-0700 | ERROR | Environment tag update failed.
-- | -- | --
2018-03-27 16:37:59 UTC-0700 | ERROR | Service:AmazonCloudFormation, Message:No updates are to be performed.
2018-03-27 16:37:59 UTC-0700 | INFO | Starting environment tag update.
Terraform:
```Error: Error applying plan:
1 error(s) occurred:
module.xxxxxxx.aws_elastic_beanstalk_environment.xxxxxxx_env: 1 error(s) occurred:
aws_elastic_beanstalk_environment.xxxxxxx_env: Error waiting for Elastic Beanstalk Environment (e-xxxxx) to become ready: 2 error(s) occurred:
2018-03-27 23:37:59.698 +0000 UTC (e-xxxxx) : Service:AmazonCloudFormation, Message:No updates are to be performed.
(in this case changing health monitoring from basic to enhanced)
"Name" tag is not applied, or report an error
Elastic Beanstalk throws the same error as before:
2018-03-28 10:19:35 UTC-0700 | ERROR | Environment tag update failed.
-- | -- | --
2018-03-28 10:19:34 UTC-0700 | ERROR | Service:AmazonCloudFormation, Message:No updates are to be performed.
2018-03-28 10:19:34 UTC-0700 | INFO | Starting environment tag update.
But terraform reports the tag is updated:
tags.Name: "" => "New Tag Name"
terraform initterraform applyThere's also a second (arguably more disturbing) aspect to this bug: if your tag contains the string "Name" at all, it appears in a plan but it is then filtered out. If the environment already exists, apply fails as described above. However, if it's a fresh environment, the tag is just silently not created at all.
I am seeing Case #2 with our projects. This appears to have started with version 1.11. Specifying 1.10 allows me to apply changes without the failure.
Yes even i am seeing this issue with version 1.11 , giving the same Name tag is also failing with the same error...
What could be the workaround by the time this gets fixed?
You can just remove the name tag from your terraform script, since AWS will auto generate/manage the name tag
I have similar issue where I do not have Tag 'Name' in my code.
Tag name is being taken from ElasticBeanstalk 'Name' property and for some reason each time when you run apply terraform thinks it's new value and it's trying to update tags.
Issue is much more than that due to fact that till today I didn't see ticket resolved for Elastic Beanstalk being able to update tags (even tho there is a possibility now to do it using either console or AWS Cli Beanstalk Tags Issue
In my case environment name is created out of 2 tags which I insert as terraform -var argument.
Even tho name is exactly same as one with one which exist already Terraform is trying to update tag (i cannot do it cause it doesn't have that functionality) which is a quite annoying bug cause it makes terraform code for elastic beanstalk unstable (crashes each time you want to do update on existing environment or just rerun it with no changes)
I've been running into a similar issue as @line0, our tag contains the String Name and the same errors are returned from elastic beanstalk and terraform. Is there any progress on a fix for this?
Here is how I strip out items from lists @Chukobyte
For example: If you have a Tag Map for Elastic Beanstalk and it includes Name as one of the keys.
You can strip it out.
## bs_label is from using the labeling module from cloud posse that handles tagging and resource naming.
module "bs_label" {
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.11.1"
attributes = ["${distinct(compact(concat(var.attributes, list("beanstalk", var.application_name))))}"]
context = "${module.label.context}"
enabled = "${var.enabled}"
}
## Beanstalk Applications can't have a Name tag in their tags list.
locals {
keys = "${keys(module.bs_label.tags)}"
name_index = "${index(local.keys, "Name")}"
keys_before = "${slice(local.keys, 0, local.name_index)}"
keys_after = "${slice(local.keys, local.name_index + 1, length(local.keys))}"
values = "${values(module.bs_label.tags)}"
values_before = "${slice(local.values, 0, local.name_index)}"
values_after = "${slice(local.values, local.name_index + 1, length(local.values))}"
tags = "${zipmap(concat(local.keys_before, local.keys_after), concat(local.values_before, local.values_after))}"
}
I ran into a similar issue as @line0 and @Chukobyte: I have a tag MyName and got the error Environment tag update failed. I changed it to MyXXX and/or my-name and everything ran fine.
For now, I'm removing Name from all my tag names. However name seems to be fine.
this is how we remove the Name tag from tags using TF 0.12
https://github.com/cloudposse/terraform-aws-elastic-beanstalk-application/blob/master/main.tf#L15
(could be updated to rename the tag instead of removing if needed)
Most helpful comment
There's also a second (arguably more disturbing) aspect to this bug: if your tag contains the string "Name" at all, it appears in a plan but it is then filtered out. If the environment already exists, apply fails as described above. However, if it's a fresh environment, the tag is just silently not created at all.