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

[Bug]: aws_lb_trust_store not waiting for state active #36825

Closed
gcuberes opened this issue Apr 10, 2024 · 4 comments · Fixed by #38332
Closed

[Bug]: aws_lb_trust_store not waiting for state active #36825

gcuberes opened this issue Apr 10, 2024 · 4 comments · Fixed by #38332
Labels
bug Addresses a defect in current functionality. service/elbv2 Issues and PRs that pertain to the elbv2 service.
Milestone

Comments

@gcuberes
Copy link

gcuberes commented Apr 10, 2024

Terraform Core Version

1.7.5

AWS Provider Version

5.44.0

Affected Resource(s)

  • aws_lb_trust_store

Expected Behavior

It should be possible to create the dependent aws_lb_listener and aws_lb_trust_store in the same apply without errors.

Actual Behavior

When aws_lb_trust_store is used to directly pass its ARN to aws_lb_listener, it's returning the ARN when the trusted store is not active yet, and hence the creation (or update) of the listener fails, as it requires the trust store to be active.

Relevant Error/Panic Output Snippet

│ Error: creating ELBv2 Listener (arn:aws:elasticloadbalancing:eu-central-1:[REDACTED]:loadbalancer/app/test-mtls-lb/[REDACTED]): operation error Elastic Load Balancing v2: CreateListener, https response error StatusCode: 400, RequestID: 24b49dd8-a256-482c-8c52-adc6cdb3b62f, TrustStoreNotReady: Trust store with ARN 'arn:aws:elasticloadbalancing:eu-central-1:[REDACTED]:truststore/mtls-test/[REDACTED]' is not in ACTIVE state

Terraform Configuration Files

First create the ALB and required cert:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "5.44.0"
    }
  }
}

provider "aws" {
  region = "eu-central-1"
}

resource "aws_lb" "test" {
  name               = "test-mtls-lb"
  load_balancer_type = "application"
  subnets            = [....]
  tags               = local.tags
}

resource "tls_private_key" "mtls_ca" {
  algorithm   = "ECDSA"
  ecdsa_curve = "P256"
}

resource "tls_self_signed_cert" "mtls_ca" {
  private_key_pem = tls_private_key.mtls_ca.private_key_pem

  is_ca_certificate = true

  subject {
    common_name  = "mTLS testing CA"
    organization = "mTLS testing CA"
  }

  validity_period_hours = 24 * 365 * 20

  allowed_uses = [
    "crl_signing",
    "digital_signature",
    "cert_signing",
  ]
}

Then the trusted store and the listener:

resource "aws_s3_bucket" "test" {
  bucket        = "test-mtls"
  force_destroy = true
}

resource "aws_s3_object" "test" {
  bucket       = aws_s3_bucket.test.bucket
  key          = "ca.crt"
  content      = tls_self_signed_cert.mtls_ca.cert_pem
  content_type = "text/plain"
}

resource "aws_lb_trust_store" "test" {
  name                             = "mtls-test"
  ca_certificates_bundle_s3_bucket = aws_s3_bucket.test.bucket
  ca_certificates_bundle_s3_key    = aws_s3_object.test.key
}

resource "aws_lb_listener" "test" {
  load_balancer_arn = aws_lb.test.arn
  port              = "443"
  protocol          = "HTTPS"
  ssl_policy        = "ELBSecurityPolicy-TLS13-1-2-2021-06"
  certificate_arn   = "..."

  default_action {
    type = "fixed-response"

    fixed_response {
      content_type = "text/plain"
      message_body = "Not found"
      status_code  = "404"
    }
  }

  mutual_authentication {
    mode            = "verify"
    trust_store_arn = aws_lb_trust_store.test.arn
  }
}

Steps to Reproduce

  1. Create an empty AWS ALB.
  2. Create in the same apply an aws_lb_trust_store and an aws_lb_listener with mutual_authentication in verify mode and a trust_store_arn.
  3. Notice the creation fails in the first run because the aws_lb_trust_store con't be in active state when terraform tries to create the aws_lb_listener .
  4. In a second run it works, because the trust store had time to be active.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No

@gcuberes gcuberes added the bug Addresses a defect in current functionality. label Apr 10, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added service/elbv2 Issues and PRs that pertain to the elbv2 service. service/s3 Issues and PRs that pertain to the s3 service. labels Apr 10, 2024
@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Apr 10, 2024
@justinretzolk justinretzolk removed service/s3 Issues and PRs that pertain to the s3 service. needs-triage Waiting for first response or review from a maintainer. labels Apr 15, 2024
Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.59.0 milestone Jul 12, 2024
Copy link

This functionality has been released in v5.59.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. Thank you!

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 Aug 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/elbv2 Issues and PRs that pertain to the elbv2 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants