hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.87k stars 9.21k forks source link

CertificateNotFound when creating ALB https listener. Certificate was issued in ACM #17505

Open satyabhama opened 3 years ago

satyabhama commented 3 years ago

Hi, I've applied AWS ACM certificate(us-east-1), and it was Issued long ago. and it was working before. But now when I am trying to create an HTTPS listener of Application Load Balancer(In us-east-1), it is giving me a Certificate Not Found error. Below is my code snippet:

resource "aws_alb_listener" "GrafanaProxyServerBlueALBListener" {
  default_action {
    target_group_arn = "${aws_alb_target_group.GrafanaProxyServerBlueTG.arn}"
    type             = "forward"
  }

  load_balancer_arn = "${data.terraform_remote_state.MonitoringGrafanaBaseComponents.GrafanaProxyServerAlbArn}"
  port              = "${var.ALBBluePort}"
  protocol          = "${var.ALBProtocol}"
  certificate_arn   = "${var.HTTPSCertificateArn}"
}

aws_alb_listener.GrafanaProxyServerGreenALBListener: Creating... arn: "" => "" certificate_arn: "" => "arn:aws:acm:us-east-1:accountid:certificate/xxxxxxx-c183d2529de1" default_action.#: "" => "1" default_action.0.order: "" => "" default_action.0.target_group_arn: "" => "arn:aws:elasticloadbalancing:us-east-1:accountid:targetgroup/GrafanaProxyServerGreenTG/41ac749fe24a269e" default_action.0.type: "" => "forward" load_balancer_arn: "" => "arn:aws:elasticloadbalancing:us-east-1:accountid:loadbalancer/app/MonitoringGrafanaProxyServerALB/xxxxxxb94" port: "" => "80" protocol: "" => "HTTPS" ssl_policy: "" => "" aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (10s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (10s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (20s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (20s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (30s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (30s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (40s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (40s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (50s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (50s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (1m0s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (1m0s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (1m10s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (1m10s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (1m20s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (1m20s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (1m30s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (1m30s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (1m40s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (1m40s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (1m50s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (1m50s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (2m0s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (2m0s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (2m10s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (2m10s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (2m20s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (2m20s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (2m30s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (2m30s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (2m40s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (2m40s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (2m50s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (2m50s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (3m0s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (3m0s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (3m10s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (3m10s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (3m20s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (3m20s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (3m30s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (3m30s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (3m40s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (3m40s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (3m50s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (3m50s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (4m0s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (4m0s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (4m10s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (4m10s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (4m20s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (4m20s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (4m30s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (4m30s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (4m40s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (4m40s elapsed) aws_alb_listener.GrafanaProxyServerBlueALBListener: Still creating... (4m50s elapsed) aws_alb_listener.GrafanaProxyServerGreenALBListener: Still creating... (4m50s elapsed) Error: Error applying plan: 2 error(s) occurred:

cciotti commented 3 years ago

@satyabhama I had this happen when the cert expired.

gitbisect commented 2 years ago

Since it says CertificateNotFound, it misleads people into searching for the certificate. Usually the certificate is instantly found. But you have to drill down by clicking on the found certificate and you will notice that the expiration is passed. It would have been so much easier if the error was CertificateExpired.

zatarain commented 1 year ago

I know this ticket is 2 years old already, but I want to provide my situation on how I got the same error in case that is useful for somebody else:

So, in my case I have multiple AWS accounts (main, development, staging, production); I use the main account to share resources to the environment accounts (e. g. I register my domain names with my main account) and I was trying to register my SSL certificates in the main account then use them on the environment accounts for the same domain name. Unfortunately, that is not possible, even I didn't tried to export the certificate, I was just using the ARN to refer it with an account with the proper IAM role and permissions and I got the same error 400 CertificateNotFound which I agree is misleading.

Then, I ended up creating a certificate for each apex domain and wildcard domain on each account.