Terraform, AWS and importing existing SSL certificates

12.4k views Asked by At

I'm working in a project where I have gotten a situation which I can't get the path to succeed.

Truth is I'm running terraform code through a pipeline, this code depends on a bunch of certificates that have been added through AWS web console, so I have the certificate, the private key and the certificate chain files.

(I delete them and tried to import through terraform)

Googling a bit I got these:

resource "aws_acm_certificate" "tch-cert" {
  private_key=file("private.key")
  certificate_body = file("actual_cert.cer")
  certificate_chain=file("inter.cer")
  }

Upload ssl certs using terraform

I added the code, commit it and got error like the following in the terraform plan command

"error parsing ... 2:15 Unknown token: IDENT File" "error parsing ... 2:17 Unknown token: IDENT File"

Any advice or example how these should be done would be really appreciate it. I read the terraform doc also but it's not working for me.

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/acm_certificate

1

There are 1 answers

2
Marcin On

If you use terraform 0.11, then your syntax is incorrect. It works only for 0.12 and higher. For old versions, it should be:

resource "aws_acm_certificate" "tch-cert" {
  private_key = "${file("private.key")}"
  certificate_body = "${file("actual_cert.cer")}"
  certificate_chain = "${file("inter.cer")}"
  }