Skip to content

googleComputeManagedSslCertificate

An SslCertificate resource, used for HTTPS load balancing. This resource represents a certificate for which the certificate secrets are created and managed by Google.

For a resource where you provide the key, see the SSL Certificate resource.

To get more information about ManagedSslCertificate, see:

\~> Warning: This resource should be used with extreme caution! Provisioning an SSL certificate is complex. Ensure that you understand the lifecycle of a certificate before attempting complex tasks like cert rotation automatically. This resource will "return" as soon as the certificate object is created, but post-creation the certificate object will go through a "provisioning" process. The provisioning process can complete only when the domain name for which the certificate is created points to a target pool which, itself, points at the certificate. Depending on your DNS provider, this may take some time, and migrating from self-managed certificates to Google-managed certificates may entail some downtime while the certificate provisions.

In conclusion: Be extremely cautious.

Example Usage - Managed Ssl Certificate Basic

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
const googleComputeHttpHealthCheckDefault =
  new google.computeHttpHealthCheck.ComputeHttpHealthCheck(this, "default", {
    check_interval_sec: 1,
    name: "http-health-check",
    request_path: "/",
    timeout_sec: 1,
  });
const googleComputeManagedSslCertificateDefault =
  new google.computeManagedSslCertificate.ComputeManagedSslCertificate(
    this,
    "default_1",
    {
      managed: [
        {
          domains: ["sslcert.tf-test.club."],
        },
      ],
      name: "test-cert",
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleComputeManagedSslCertificateDefault.overrideLogicalId("default");
const googleComputeBackendServiceDefault =
  new google.computeBackendService.ComputeBackendService(this, "default_2", {
    health_checks: [googleComputeHttpHealthCheckDefault.id],
    name: "backend-service",
    port_name: "http",
    protocol: "HTTP",
    timeout_sec: 10,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleComputeBackendServiceDefault.overrideLogicalId("default");
const googleComputeUrlMapDefault = new google.computeUrlMap.ComputeUrlMap(
  this,
  "default_3",
  {
    default_service: googleComputeBackendServiceDefault.id,
    description: "a description",
    host_rule: [
      {
        hosts: ["sslcert.tf-test.club"],
        path_matcher: "allpaths",
      },
    ],
    name: "url-map",
    path_matcher: [
      {
        default_service: googleComputeBackendServiceDefault.id,
        name: "allpaths",
        path_rule: [
          {
            paths: ["/*"],
            service: googleComputeBackendServiceDefault.id,
          },
        ],
      },
    ],
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleComputeUrlMapDefault.overrideLogicalId("default");
const googleComputeTargetHttpsProxyDefault =
  new google.computeTargetHttpsProxy.ComputeTargetHttpsProxy(
    this,
    "default_4",
    {
      name: "test-proxy",
      ssl_certificates: [googleComputeManagedSslCertificateDefault.id],
      url_map: googleComputeUrlMapDefault.id,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleComputeTargetHttpsProxyDefault.overrideLogicalId("default");
const googleComputeGlobalForwardingRuleDefault =
  new google.computeGlobalForwardingRule.ComputeGlobalForwardingRule(
    this,
    "default_5",
    {
      name: "forwarding-rule",
      port_range: 443,
      target: googleComputeTargetHttpsProxyDefault.id,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleComputeGlobalForwardingRuleDefault.overrideLogicalId("default");

Example Usage - Managed Ssl Certificate Recreation

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
import * as random from "./.gen/providers/random";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google, random.
For a more precise conversion please use the --provider flag in convert.*/
const managedDomains = '${tolist(["test.example.com"])}';
const googleComputeHttpHealthCheckDefault =
  new google.computeHttpHealthCheck.ComputeHttpHealthCheck(this, "default", {
    check_interval_sec: 1,
    name: "http-health-check",
    request_path: "/",
    timeout_sec: 1,
  });
const randomIdCertificate = new random.id.Id(this, "certificate", {
  byte_length: 4,
  keepers: [
    {
      domains: `\${join(",", ${managedDomains})}`,
    },
  ],
  prefix: "issue6147-cert-",
});
const googleComputeBackendServiceDefault =
  new google.computeBackendService.ComputeBackendService(this, "default_2", {
    health_checks: [googleComputeHttpHealthCheckDefault.id],
    name: "backend-service",
    port_name: "http",
    protocol: "HTTP",
    timeout_sec: 10,
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleComputeBackendServiceDefault.overrideLogicalId("default");
const googleComputeManagedSslCertificateCert =
  new google.computeManagedSslCertificate.ComputeManagedSslCertificate(
    this,
    "cert",
    {
      managed: [
        {
          domains: managedDomains,
        },
      ],
      name: randomIdCertificate.hex,
    }
  );
googleComputeManagedSslCertificateCert.addOverride("lifecycle", [
  {
    create_before_destroy: true,
  },
]);
const googleComputeUrlMapDefault = new google.computeUrlMap.ComputeUrlMap(
  this,
  "default_4",
  {
    default_service: googleComputeBackendServiceDefault.id,
    description: "a description",
    host_rule: [
      {
        hosts: ["mysite.com"],
        path_matcher: "allpaths",
      },
    ],
    name: "url-map",
    path_matcher: [
      {
        default_service: googleComputeBackendServiceDefault.id,
        name: "allpaths",
        path_rule: [
          {
            paths: ["/*"],
            service: googleComputeBackendServiceDefault.id,
          },
        ],
      },
    ],
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleComputeUrlMapDefault.overrideLogicalId("default");
const googleComputeTargetHttpsProxyDefault =
  new google.computeTargetHttpsProxy.ComputeTargetHttpsProxy(
    this,
    "default_5",
    {
      name: "test-proxy",
      ssl_certificates: [googleComputeManagedSslCertificateCert.id],
      url_map: googleComputeUrlMapDefault.id,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
googleComputeTargetHttpsProxyDefault.overrideLogicalId("default");

Argument Reference

The following arguments are supported:


  • description - (Optional) An optional description of this resource.

  • name - (Optional) Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression [aZ]([AZ09]*[aZ09])? which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash.

    These are in the same namespace as the managed SSL certificates.

  • managed - (Optional) Properties relevant to a managed certificate. These will be used if the certificate is managed (as indicated by a value of managed in type). Structure is documented below.

  • type - (Optional) Enum field whose value is always managed - used to signal to the API which type this is. Default value is managed. Possible values are managed.

  • project - (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

The managed block supports:

  • domains - (Required) Domains for which a managed SSL certificate will be valid. Currently, there can be up to 100 domains in this list.

Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

  • id - an identifier for the resource with format projects/{{project}}/global/sslCertificates/{{name}}

  • creationTimestamp - Creation timestamp in RFC3339 text format.

  • certificateId - The unique identifier for the resource.

  • subjectAlternativeNames - Domains associated with the certificate via Subject Alternative Name.

  • expireTime - Expire time of the certificate in RFC3339 text format.

  • selfLink - The URI of the created resource.

Timeouts

This resource provides the following Timeouts configuration options:

  • create - Default is 30 minutes.
  • delete - Default is 30 minutes.

Import

ManagedSslCertificate can be imported using any of these accepted formats:

$ terraform import google_compute_managed_ssl_certificate.default projects/{{project}}/global/sslCertificates/{{name}}
$ terraform import google_compute_managed_ssl_certificate.default {{project}}/{{name}}
$ terraform import google_compute_managed_ssl_certificate.default {{name}}

User Project Overrides

This resource supports User Project Overrides.