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

aws_lb_target_group with aws_lb (unable to disable stickiness not supported in NLB) #10494

Closed
zicodes opened this issue Oct 13, 2019 · 9 comments
Labels
service/elbv2 Issues and PRs that pertain to the elbv2 service.
Milestone

Comments

@zicodes
Copy link

zicodes commented Oct 13, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.12.10 provider.aws v2.32.0

Affected Resource(s)

  • aws_lb (load_balancer_type = "network")
  • aws_lb_target_group

Terraform Configuration Files

resource "aws_lb" "nlb_web" {
  name               = "nlb"
  internal           = false
  load_balancer_type = "network"
  subnets            = "${module.vpc.public_subnets_ids}"

  enable_deletion_protection = true
}

Expected Behavior

Setting stickiness block with "enabled" set to "false" should not send the stickiness attributes to AWS API if the set protocol is TCP or TLS (or another protocol that do not support stickiness).

The target groups should be created without stickiness attribute, and network load balancer should then be created.

Actual Behavior

Please see below.

Steps to Reproduce

resource "aws_lb_target_group" "tg_web" {
  name     = "${var.name}"
  port     = "${var.port}"
  protocol = "${var.protocol}"
  vpc_id   = "${var.vpc_id}"
  stickiness = []
}

produces below error:

An argument named "stickiness" is not expected here. Did you mean to define a
block of type "stickiness"?

If I define block stickiness as such:

resource "aws_lb_target_group" "tg_web" {
  name     = "${var.name}"
  port     = "${var.port}"
  protocol = "${var.protocol}"
  vpc_id   = "${var.vpc_id}"

  stickiness {
    enabled = false # stickiness not supported in NLB
    type    = "lb_cookie"
  }
}

I get:

Error: Error modifying Target Group Attributes: InvalidConfigurationRequest: The provided target group attribute is not supported
	status code: 400, request id: d52a5f5c-a967-478c-a902-7d70185d8625

  on ../../modules/tg/main.tf line 4, in resource "aws_lb_target_group" "tg_web":
   4: resource "aws_lb_target_group" "tg_web" {

I have contacted AWS support and they verified that AWS API is receiving the following:

 "eventTime": "2019-10-13T17:38:11Z",
    "eventSource": "elasticloadbalancing.amazonaws.com ",
    "eventName": "ModifyTargetGroupAttributes",
    "awsRegion": "eu-west-1",
    "sourceIPAddress": "xxx",
    "userAgent": "aws-sdk-go/1.25.4 (go1.13; linux; amd64) APN/1.0 HashiCorp/1.0 Terraform/0.12.10 (+https://www.terraform.io)",
    "errorCode": "InvalidConfigurationRequestException",
    "errorMessage": "The provided target group attribute is not supported",
    "requestParameters": {
        "attributes": [
            {
                "value": "300",
                "key": "deregistration_delay.timeout_seconds"
            },
            {
                "value": "false",
                "key": "stickiness.enabled"
            },
            {
                "value": "lb_cookie",
                "key": "stickiness.type"
            },
            {
                "value": "86400",
                "key": "stickiness.lb_cookie.duration_seconds"
            }
        ],
        "targetGroupArn": "arn:aws:elasticloadbalancing:eu-west-1:5xx9883:targetgroup/prod-wp-https-tg/5cfdfxx784aacc"
    },

TCP/TLS target groups cannot have "stickiness" attribute hence the error.

Finally, if I don't include stickiness argument or block, I get:

Error: Network Load Balancers do not support Stickiness

  on ../../modules/tg/main.tf line 4, in resource "aws_lb_target_group" "tg_web":
   4: resource "aws_lb_target_group" "tg_web" {

Which looks like stickiness is enabled by default by Terraform.

References

Closed ticket from 2017/2018 with suggested workarounds, which don't work in my case:

@ghost ghost added the service/elbv2 Issues and PRs that pertain to the elbv2 service. label Oct 13, 2019
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 13, 2019
@zicodes
Copy link
Author

zicodes commented Oct 13, 2019

Okay, I managed to get past this.

Using:

resource "aws_lb_target_group" "tg_web" {
  name     = "${var.name}"
  port     = "${var.port}"
  protocol = "TLS"
  vpc_id   = "${var.vpc_id}"
  target_type = "instance"
}
  1. terraform destroy (WARNING: will destroy all terraform managed resources)
  2. Changed:
provider "aws" {
  region = "eu-west-1"
}

to

provider "aws" {
  region = "eu-west-1"
  version = "~> 2.0"
}
  1. terraform apply (this created all resources correctly)

  2. I then attempted removing the version number (back to just having region under aws provider), destroying and applying again, and it successfully completed again.

I will leave the issue open as I feel there might be an issue with terraform managing the resources. Feel free to close it if you think it's appropriate.

Thank you

etwillbefine added a commit to goci-io/aws-api-gateway-proxy that referenced this issue Nov 2, 2019
throws Error modifying Target Group Attributes: InvalidConfigurationRequest: The provided target group attribute is not supported otherwise
hashicorp/terraform-provider-aws#10494
@atoms42
Copy link

atoms42 commented Dec 30, 2019

For what it's worth, we had been adding

stickiness = []

to the target group for our network load balancer to work around #2746.
However, when upgrading to Terraform 0.12 (using the 0.12upgrade command), the stickiness attribute was removed from the target group. We are still able create the load balancer and target group (and I was able to use the Terraform 0.12 version of our code to update a workspace that had been deployed with Terraform 0.11).

I tested this with Terraform 0.12.9 and 0.12.18 using AWS provider version 2.43

@illegalnumbers
Copy link

In Terraform 0.12.20 this does not appear to work and the resource seems to be unusable for NLB's.

@illegalnumbers
Copy link

I was not able to use the solution of setting stickiness to a disabled block or to an empty array. Also upgrading to the latest AWS provider didn't help either.

@siliconsheep
Copy link

As mentioned above, the workaround of setting stickiness to an empty array or a disabled block does no longer work. Old workflows where the NLB was already created still work fine, but new deployments break because of this.

@hangxie
Copy link

hangxie commented Jun 24, 2020

Running v2.58.0 now and I'm able to create target group with stickiness disabled by not providing stickiness parameter, I've been following this topic for a while but I'm not sure which TF release fixed this problem.

@madpipeline
Copy link
Contributor

This seems like a duplicate of #9093

@YakDriver YakDriver added this to the v3.11.0 milestone Oct 13, 2020
@YakDriver YakDriver removed the needs-triage Waiting for first response or review from a maintainer. label Oct 13, 2020
@YakDriver
Copy link
Member

I'm closing this issue since this problem is fixed with #15295 in v3.10.0.

@ghost
Copy link

ghost commented Nov 12, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Nov 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/elbv2 Issues and PRs that pertain to the elbv2 service.
Projects
None yet
Development

No branches or pull requests

7 participants