6

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

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
tangerine3031
  • 71
  • 1
  • 3

1 Answers1

2

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")}"
  }
Marcin
  • 215,873
  • 14
  • 235
  • 294
  • I copy and paste key, cert and intermediate cert two, vim in linux. In the web console I got no error, but through terraform I got this " Error importing certificate: ValidationException: Key provided does not match the certificate. status code: 400 " By the way thanks for let me know the obvious problem in mas last issue. – tangerine3031 Oct 19 '20 at 01:50
  • As I told through the web console importing the same cert I got no errors, unfortunately I have to achieve this with terraform. Suggestions are welcome. Terraform 0.11 :-) – tangerine3031 Oct 19 '20 at 01:55