All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.digitalocean.kotlin.SshKeyArgs.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.digitalocean.kotlin

import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.digitalocean.SshKeyArgs.builder
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import kotlin.String
import kotlin.Suppress
import kotlin.jvm.JvmName

/**
 * Provides a DigitalOcean SSH key resource to allow you to manage SSH
 * keys for Droplet access. Keys created with this resource
 * can be referenced in your Droplet configuration via their ID or
 * fingerprint.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as digitalocean from "@pulumi/digitalocean";
 * import * as std from "@pulumi/std";
 * // Create a new SSH key
 * const _default = new digitalocean.SshKey("default", {
 *     name: "Example",
 *     publicKey: std.file({
 *         input: "/Users/myuser/.ssh/id_rsa.pub",
 *     }).then(invoke => invoke.result),
 * });
 * // Create a new Droplet using the SSH key
 * const web = new digitalocean.Droplet("web", {
 *     image: "ubuntu-18-04-x64",
 *     name: "web-1",
 *     region: digitalocean.Region.NYC3,
 *     size: digitalocean.DropletSlug.DropletS1VCPU1GB,
 *     sshKeys: [_default.fingerprint],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_digitalocean as digitalocean
 * import pulumi_std as std
 * # Create a new SSH key
 * default = digitalocean.SshKey("default",
 *     name="Example",
 *     public_key=std.file(input="/Users/myuser/.ssh/id_rsa.pub").result)
 * # Create a new Droplet using the SSH key
 * web = digitalocean.Droplet("web",
 *     image="ubuntu-18-04-x64",
 *     name="web-1",
 *     region=digitalocean.Region.NYC3,
 *     size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB,
 *     ssh_keys=[default.fingerprint])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using DigitalOcean = Pulumi.DigitalOcean;
 * using Std = Pulumi.Std;
 * return await Deployment.RunAsync(() =>
 * {
 *     // Create a new SSH key
 *     var @default = new DigitalOcean.SshKey("default", new()
 *     {
 *         Name = "Example",
 *         PublicKey = Std.File.Invoke(new()
 *         {
 *             Input = "/Users/myuser/.ssh/id_rsa.pub",
 *         }).Apply(invoke => invoke.Result),
 *     });
 *     // Create a new Droplet using the SSH key
 *     var web = new DigitalOcean.Droplet("web", new()
 *     {
 *         Image = "ubuntu-18-04-x64",
 *         Name = "web-1",
 *         Region = DigitalOcean.Region.NYC3,
 *         Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
 *         SshKeys = new[]
 *         {
 *             @default.Fingerprint,
 *         },
 *     });
 * });
 * ```
 * ```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/.ssh/id_rsa.pub",
 * 		}, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// Create a new SSH key
 * 		_, err = digitalocean.NewSshKey(ctx, "default", &digitalocean.SshKeyArgs{
 * 			Name:      pulumi.String("Example"),
 * 			PublicKey: pulumi.String(invokeFile.Result),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		// Create a new Droplet using the SSH key
 * 		_, err = digitalocean.NewDroplet(ctx, "web", &digitalocean.DropletArgs{
 * 			Image:  pulumi.String("ubuntu-18-04-x64"),
 * 			Name:   pulumi.String("web-1"),
 * 			Region: pulumi.String(digitalocean.RegionNYC3),
 * 			Size:   pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
 * 			SshKeys: pulumi.StringArray{
 * 				_default.Fingerprint,
 * 			},
 * 		})
 * 		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.SshKey;
 * import com.pulumi.digitalocean.SshKeyArgs;
 * import com.pulumi.digitalocean.Droplet;
 * import com.pulumi.digitalocean.DropletArgs;
 * 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) {
 *         // Create a new SSH key
 *         var default_ = new SshKey("default", SshKeyArgs.builder()
 *             .name("Example")
 *             .publicKey(StdFunctions.file(FileArgs.builder()
 *                 .input("/Users/myuser/.ssh/id_rsa.pub")
 *                 .build()).result())
 *             .build());
 *         // Create a new Droplet using the SSH key
 *         var web = new Droplet("web", DropletArgs.builder()
 *             .image("ubuntu-18-04-x64")
 *             .name("web-1")
 *             .region("nyc3")
 *             .size("s-1vcpu-1gb")
 *             .sshKeys(default_.fingerprint())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   # Create a new SSH key
 *   default:
 *     type: digitalocean:SshKey
 *     properties:
 *       name: Example
 *       publicKey:
 *         fn::invoke:
 *           Function: std:file
 *           Arguments:
 *             input: /Users/myuser/.ssh/id_rsa.pub
 *           Return: result
 *   # Create a new Droplet using the SSH key
 *   web:
 *     type: digitalocean:Droplet
 *     properties:
 *       image: ubuntu-18-04-x64
 *       name: web-1
 *       region: nyc3
 *       size: s-1vcpu-1gb
 *       sshKeys:
 *         - ${default.fingerprint}
 * ```
 * 
 * ## Import
 * SSH Keys can be imported using the `ssh key id`, e.g.
 * ```sh
 * $ pulumi import digitalocean:index/sshKey:SshKey mykey 263654
 * ```
 * @property name The name of the SSH key for identification
 * @property publicKey The public key. If this is a file, it
 * can be read using the file interpolation function
 */
public data class SshKeyArgs(
    public val name: Output? = null,
    public val publicKey: Output? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.digitalocean.SshKeyArgs =
        com.pulumi.digitalocean.SshKeyArgs.builder()
            .name(name?.applyValue({ args0 -> args0 }))
            .publicKey(publicKey?.applyValue({ args0 -> args0 })).build()
}

/**
 * Builder for [SshKeyArgs].
 */
@PulumiTagMarker
public class SshKeyArgsBuilder internal constructor() {
    private var name: Output? = null

    private var publicKey: Output? = null

    /**
     * @param value The name of the SSH key for identification
     */
    @JvmName("gstsydaigrhdmvuu")
    public suspend fun name(`value`: Output) {
        this.name = value
    }

    /**
     * @param value The public key. If this is a file, it
     * can be read using the file interpolation function
     */
    @JvmName("avghdmbvjpdnutpv")
    public suspend fun publicKey(`value`: Output) {
        this.publicKey = value
    }

    /**
     * @param value The name of the SSH key for identification
     */
    @JvmName("nmkmxnlhljhvvnff")
    public suspend fun name(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.name = mapped
    }

    /**
     * @param value The public key. If this is a file, it
     * can be read using the file interpolation function
     */
    @JvmName("lioxbgidfinmymox")
    public suspend fun publicKey(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.publicKey = mapped
    }

    internal fun build(): SshKeyArgs = SshKeyArgs(
        name = name,
        publicKey = publicKey,
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy