I have certificate in aws certificate manager.

How I connect this certificate to aws_alb_listener in terraform?
Right now I take the certs from files in my computer.
resource "aws_alb_listener" "alb_front_https" {
load_balancer_arn = "${aws_alb.demo_eu_alb.arn}"
port = "443"
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-TLS-1-2-Ext-2018-06"
certificate_arn = "${aws_iam_server_certificate.lb_cert.arn}"
default_action {
target_group_arn = "${aws_alb_target_group.nginx.arn}"
type = "forward"
}
}
resource "aws_iam_server_certificate" "lb_cert" {
name = "lb_cert-${var.app}"
certificate_body = "${file("./www.xxx.com/cert.pem")}"
private_key = "${file("./www.xxx.com/privkey.pem")}"
certificate_chain = "${file("./www.xxx.com/chain.pem")}"
}
I want to aws_alb_listener to use certificate on aws certificate manager.
How to do that in terraform?
You can get the certificate ARN using,
data "aws_acm_certificate" "certificate" {
domain = "your.domain"
statuses = ["ISSUED"]
most_recent = true
}
and then attach it to listener
resource "aws_lb_listener_certificate" "ssl_certificate" {
listener_arn = aws_lb_listener.alb_front_https.arn
certificate_arn = data.aws_acm_certificate.certificate.arn
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With