Error 400: The SSL certificate could not be parsed

Dear All, I was getting this error while creating ssl certificate for regional load balancer in gcp following the below document:

google_compute_region_ssl_certificate | Resources | hashicorp/google | Terraform | Terraform Registry

script:

resource "google_compute_region_ssl_certificate" "abc" {
  name        = "abc"
  private_key = filebase64("./certs/abc.key")
  certificate = filebase64("./certs/abc.crt")
  project     = "abc"
  region      = "europe-west3"
}

Error:

│ Error: Error creating RegionSslCertificate: googleapi: Error 400: The SSL certificate could not be parsed., sslCertificateCouldNotParseCert
│
│   with google_compute_region_ssl_certificate.csg_cert1,
│   on rlb-central-lb.tf line 234, in resource "google_compute_region_ssl_certificate" "abc":
│  234: resource "google_compute_region_ssl_certificate" "abc" {

certificate files are validated and working with gcloud

gcloud compute ssl-certificates create abc --certificate=./abc.crt --private-key=./abc.key --region=europe-west3 --project=abc

with same files when i try to create via terraform its thorwing above error.
can anyone help me in resolving the issue?

Issue has been rectified.

resource "google_compute_region_ssl_certificate" "abc" {
  name        = "abc"
  private_key = file("./certs/abc.pem")
  certificate = file("./certs/abc.pem")
  project     = "abc"
  region      = "europe-west3"
}

use file function with files in pem format. thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.