Terraform、AWS 和导入现有 SSL 证书

tan*_*031 7 ssl terraform aws-certificate-manager terraform-provider-aws aws-application-load-balancer

我正在从事一个项目,但我遇到了无法成功之路的情况。

事实上,我正在通过管道运行 terraform 代码,该代码依赖于通过 AWS Web 控制台添加的一堆证书,因此我拥有证书、私钥和证书链文件。

(我删除它们并尝试通过terraform导入)

谷歌搜索一下我得到了这些:

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

使用 terraform 上传 ssl 证书

我添加了代码,提交它并在 terraform plan 命令中收到如下错误

“解析错误... 2:15 未知令牌:IDENT 文件” “解析错误...2:17 未知令牌:IDENT 文件”

任何应该如何完成这些工作的建议或示例将非常感激。我也阅读了 terraform 文档,但它对我不起作用。

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

Mar*_*cin 3

如果您使用 terraform 0.11,则您的语法不正确。它仅适用于 0.12 及更高版本。对于旧版本,它应该是:

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