Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.digitalocean.kotlin.Certificate.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.digitalocean.kotlin
import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
/**
* Builder for [Certificate].
*/
@PulumiTagMarker
public class CertificateResourceBuilder internal constructor() {
public var name: String? = null
public var args: CertificateArgs = CertificateArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend CertificateArgsBuilder.() -> Unit) {
val builder = CertificateArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
}
internal fun build(): Certificate {
val builtJavaResource = com.pulumi.digitalocean.Certificate(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Certificate(builtJavaResource)
}
}
/**
* Provides a DigitalOcean Certificate resource that allows you to manage
* certificates for configuring TLS termination in Load Balancers.
* Certificates created with this resource can be referenced in your
* Load Balancer configuration via their ID. The certificate can either
* be a custom one provided by you or automatically generated one with
* Let's Encrypt.
* ## Example Usage
* ### Custom Certificate
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
* import * as std from "@pulumi/std";
* const cert = new digitalocean.Certificate("cert", {
* name: "custom-example",
* type: digitalocean.CertificateType.Custom,
* privateKey: std.file({
* input: "/Users/myuser/certs/privkey.pem",
* }).then(invoke => invoke.result),
* leafCertificate: std.file({
* input: "/Users/myuser/certs/cert.pem",
* }).then(invoke => invoke.result),
* certificateChain: std.file({
* input: "/Users/myuser/certs/fullchain.pem",
* }).then(invoke => invoke.result),
* });
* ```
* ```python
* import pulumi
* import pulumi_digitalocean as digitalocean
* import pulumi_std as std
* cert = digitalocean.Certificate("cert",
* name="custom-example",
* type=digitalocean.CertificateType.CUSTOM,
* private_key=std.file(input="/Users/myuser/certs/privkey.pem").result,
* leaf_certificate=std.file(input="/Users/myuser/certs/cert.pem").result,
* certificate_chain=std.file(input="/Users/myuser/certs/fullchain.pem").result)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using DigitalOcean = Pulumi.DigitalOcean;
* using Std = Pulumi.Std;
* return await Deployment.RunAsync(() =>
* {
* var cert = new DigitalOcean.Certificate("cert", new()
* {
* Name = "custom-example",
* Type = DigitalOcean.CertificateType.Custom,
* PrivateKey = Std.File.Invoke(new()
* {
* Input = "/Users/myuser/certs/privkey.pem",
* }).Apply(invoke => invoke.Result),
* LeafCertificate = Std.File.Invoke(new()
* {
* Input = "/Users/myuser/certs/cert.pem",
* }).Apply(invoke => invoke.Result),
* CertificateChain = Std.File.Invoke(new()
* {
* Input = "/Users/myuser/certs/fullchain.pem",
* }).Apply(invoke => invoke.Result),
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
* "github.com/pulumi/pulumi-std/sdk/go/std"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* invokeFile, err := std.File(ctx, &std.FileArgs{
* Input: "/Users/myuser/certs/privkey.pem",
* }, nil)
* if err != nil {
* return err
* }
* invokeFile1, err := std.File(ctx, &std.FileArgs{
* Input: "/Users/myuser/certs/cert.pem",
* }, nil)
* if err != nil {
* return err
* }
* invokeFile2, err := std.File(ctx, &std.FileArgs{
* Input: "/Users/myuser/certs/fullchain.pem",
* }, nil)
* if err != nil {
* return err
* }
* _, err = digitalocean.NewCertificate(ctx, "cert", &digitalocean.CertificateArgs{
* Name: pulumi.String("custom-example"),
* Type: pulumi.String(digitalocean.CertificateTypeCustom),
* PrivateKey: pulumi.String(invokeFile.Result),
* LeafCertificate: pulumi.String(invokeFile1.Result),
* CertificateChain: pulumi.String(invokeFile2.Result),
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.digitalocean.Certificate;
* import com.pulumi.digitalocean.CertificateArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* var cert = new Certificate("cert", CertificateArgs.builder()
* .name("custom-example")
* .type("custom")
* .privateKey(StdFunctions.file(FileArgs.builder()
* .input("/Users/myuser/certs/privkey.pem")
* .build()).result())
* .leafCertificate(StdFunctions.file(FileArgs.builder()
* .input("/Users/myuser/certs/cert.pem")
* .build()).result())
* .certificateChain(StdFunctions.file(FileArgs.builder()
* .input("/Users/myuser/certs/fullchain.pem")
* .build()).result())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* cert:
* type: digitalocean:Certificate
* properties:
* name: custom-example
* type: custom
* privateKey:
* fn::invoke:
* Function: std:file
* Arguments:
* input: /Users/myuser/certs/privkey.pem
* Return: result
* leafCertificate:
* fn::invoke:
* Function: std:file
* Arguments:
* input: /Users/myuser/certs/cert.pem
* Return: result
* certificateChain:
* fn::invoke:
* Function: std:file
* Arguments:
* input: /Users/myuser/certs/fullchain.pem
* Return: result
* ```
*
* ### Let's Encrypt Certificate
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
* const cert = new digitalocean.Certificate("cert", {
* name: "le-example",
* type: digitalocean.CertificateType.LetsEncrypt,
* domains: ["example.com"],
* });
* ```
* ```python
* import pulumi
* import pulumi_digitalocean as digitalocean
* cert = digitalocean.Certificate("cert",
* name="le-example",
* type=digitalocean.CertificateType.LETS_ENCRYPT,
* domains=["example.com"])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using DigitalOcean = Pulumi.DigitalOcean;
* return await Deployment.RunAsync(() =>
* {
* var cert = new DigitalOcean.Certificate("cert", new()
* {
* Name = "le-example",
* Type = DigitalOcean.CertificateType.LetsEncrypt,
* Domains = new[]
* {
* "example.com",
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* _, err := digitalocean.NewCertificate(ctx, "cert", &digitalocean.CertificateArgs{
* Name: pulumi.String("le-example"),
* Type: pulumi.String(digitalocean.CertificateTypeLetsEncrypt),
* Domains: pulumi.StringArray{
* pulumi.String("example.com"),
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.digitalocean.Certificate;
* import com.pulumi.digitalocean.CertificateArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* var cert = new Certificate("cert", CertificateArgs.builder()
* .name("le-example")
* .type("lets_encrypt")
* .domains("example.com")
* .build());
* }
* }
* ```
* ```yaml
* resources:
* cert:
* type: digitalocean:Certificate
* properties:
* name: le-example
* type: lets_encrypt
* domains:
* - example.com
* ```
*
* ### Use with Other Resources
* Both custom and Let's Encrypt certificates can be used with other resources
* including the `digitalocean.LoadBalancer` and `digitalocean.Cdn` resources.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
* const cert = new digitalocean.Certificate("cert", {
* name: "le-example",
* type: digitalocean.CertificateType.LetsEncrypt,
* domains: ["example.com"],
* });
* // Create a new Load Balancer with TLS termination
* const _public = new digitalocean.LoadBalancer("public", {
* name: "secure-loadbalancer-1",
* region: digitalocean.Region.NYC3,
* dropletTag: "backend",
* forwardingRules: [{
* entryPort: 443,
* entryProtocol: "https",
* targetPort: 80,
* targetProtocol: "http",
* certificateName: cert.name,
* }],
* });
* ```
* ```python
* import pulumi
* import pulumi_digitalocean as digitalocean
* cert = digitalocean.Certificate("cert",
* name="le-example",
* type=digitalocean.CertificateType.LETS_ENCRYPT,
* domains=["example.com"])
* # Create a new Load Balancer with TLS termination
* public = digitalocean.LoadBalancer("public",
* name="secure-loadbalancer-1",
* region=digitalocean.Region.NYC3,
* droplet_tag="backend",
* forwarding_rules=[{
* "entry_port": 443,
* "entry_protocol": "https",
* "target_port": 80,
* "target_protocol": "http",
* "certificate_name": cert.name,
* }])
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using DigitalOcean = Pulumi.DigitalOcean;
* return await Deployment.RunAsync(() =>
* {
* var cert = new DigitalOcean.Certificate("cert", new()
* {
* Name = "le-example",
* Type = DigitalOcean.CertificateType.LetsEncrypt,
* Domains = new[]
* {
* "example.com",
* },
* });
* // Create a new Load Balancer with TLS termination
* var @public = new DigitalOcean.LoadBalancer("public", new()
* {
* Name = "secure-loadbalancer-1",
* Region = DigitalOcean.Region.NYC3,
* DropletTag = "backend",
* ForwardingRules = new[]
* {
* new DigitalOcean.Inputs.LoadBalancerForwardingRuleArgs
* {
* EntryPort = 443,
* EntryProtocol = "https",
* TargetPort = 80,
* TargetProtocol = "http",
* CertificateName = cert.Name,
* },
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* cert, err := digitalocean.NewCertificate(ctx, "cert", &digitalocean.CertificateArgs{
* Name: pulumi.String("le-example"),
* Type: pulumi.String(digitalocean.CertificateTypeLetsEncrypt),
* Domains: pulumi.StringArray{
* pulumi.String("example.com"),
* },
* })
* if err != nil {
* return err
* }
* // Create a new Load Balancer with TLS termination
* _, err = digitalocean.NewLoadBalancer(ctx, "public", &digitalocean.LoadBalancerArgs{
* Name: pulumi.String("secure-loadbalancer-1"),
* Region: pulumi.String(digitalocean.RegionNYC3),
* DropletTag: pulumi.String("backend"),
* ForwardingRules: digitalocean.LoadBalancerForwardingRuleArray{
* &digitalocean.LoadBalancerForwardingRuleArgs{
* EntryPort: pulumi.Int(443),
* EntryProtocol: pulumi.String("https"),
* TargetPort: pulumi.Int(80),
* TargetProtocol: pulumi.String("http"),
* CertificateName: cert.Name,
* },
* },
* })
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.digitalocean.Certificate;
* import com.pulumi.digitalocean.CertificateArgs;
* import com.pulumi.digitalocean.LoadBalancer;
* import com.pulumi.digitalocean.LoadBalancerArgs;
* import com.pulumi.digitalocean.inputs.LoadBalancerForwardingRuleArgs;
* import java.util.List;
* import java.util.ArrayList;
* import java.util.Map;
* import java.io.File;
* import java.nio.file.Files;
* import java.nio.file.Paths;
* public class App {
* public static void main(String[] args) {
* Pulumi.run(App::stack);
* }
* public static void stack(Context ctx) {
* var cert = new Certificate("cert", CertificateArgs.builder()
* .name("le-example")
* .type("lets_encrypt")
* .domains("example.com")
* .build());
* // Create a new Load Balancer with TLS termination
* var public_ = new LoadBalancer("public", LoadBalancerArgs.builder()
* .name("secure-loadbalancer-1")
* .region("nyc3")
* .dropletTag("backend")
* .forwardingRules(LoadBalancerForwardingRuleArgs.builder()
* .entryPort(443)
* .entryProtocol("https")
* .targetPort(80)
* .targetProtocol("http")
* .certificateName(cert.name())
* .build())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* cert:
* type: digitalocean:Certificate
* properties:
* name: le-example
* type: lets_encrypt
* domains:
* - example.com
* # Create a new Load Balancer with TLS termination
* public:
* type: digitalocean:LoadBalancer
* properties:
* name: secure-loadbalancer-1
* region: nyc3
* dropletTag: backend
* forwardingRules:
* - entryPort: 443
* entryProtocol: https
* targetPort: 80
* targetProtocol: http
* certificateName: ${cert.name}
* ```
*
* ## Import
* Certificates can be imported using the certificate `name`, e.g.
* ```sh
* $ pulumi import digitalocean:index/certificate:Certificate mycertificate cert-01
* ```
*/
public class Certificate internal constructor(
override val javaResource: com.pulumi.digitalocean.Certificate,
) : KotlinCustomResource(javaResource, CertificateMapper) {
/**
* The full PEM-formatted trust chain
* between the certificate authority's certificate and your domain's TLS
* certificate. Only valid when type is `custom`.
*/
public val certificateChain: Output?
get() = javaResource.certificateChain().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* List of fully qualified domain names (FQDNs) for
* which the certificate will be issued. The domains must be managed using
* DigitalOcean's DNS. Only valid when type is `lets_encrypt`.
*/
public val domains: Output>?
get() = javaResource.domains().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0
})
}).orElse(null)
})
/**
* The contents of a PEM-formatted public
* TLS certificate. Only valid when type is `custom`.
*/
public val leafCertificate: Output?
get() = javaResource.leafCertificate().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* The name of the certificate for identification.
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* The expiration date of the certificate
*/
public val notAfter: Output
get() = javaResource.notAfter().applyValue({ args0 -> args0 })
/**
* The contents of a PEM-formatted private-key
* corresponding to the SSL certificate. Only valid when type is `custom`.
*/
public val privateKey: Output?
get() = javaResource.privateKey().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* The SHA-1 fingerprint of the certificate
*/
public val sha1Fingerprint: Output
get() = javaResource.sha1Fingerprint().applyValue({ args0 -> args0 })
public val state: Output
get() = javaResource.state().applyValue({ args0 -> args0 })
/**
* The type of certificate to provision. Can be either
* `custom` or `lets_encrypt`. Defaults to `custom`.
*/
public val type: Output?
get() = javaResource.type().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* The UUID of the certificate
*/
public val uuid: Output
get() = javaResource.uuid().applyValue({ args0 -> args0 })
}
public object CertificateMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.digitalocean.Certificate::class == javaResource::class
override fun map(javaResource: Resource): Certificate = Certificate(
javaResource as
com.pulumi.digitalocean.Certificate,
)
}
/**
* @see [Certificate].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [Certificate].
*/
public suspend fun certificate(name: String, block: suspend CertificateResourceBuilder.() -> Unit): Certificate {
val builder = CertificateResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [Certificate].
* @param name The _unique_ name of the resulting resource.
*/
public fun certificate(name: String): Certificate {
val builder = CertificateResourceBuilder()
builder.name(name)
return builder.build()
}