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

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

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 4.38.0.0
Show newest version
@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.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit

/**
 * Builder for [ReservedIpAssignment].
 */
@PulumiTagMarker
public class ReservedIpAssignmentResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: ReservedIpAssignmentArgs = ReservedIpAssignmentArgs()

    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 ReservedIpAssignmentArgsBuilder.() -> Unit) {
        val builder = ReservedIpAssignmentArgsBuilder()
        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(): ReservedIpAssignment {
        val builtJavaResource = com.pulumi.digitalocean.ReservedIpAssignment(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return ReservedIpAssignment(builtJavaResource)
    }
}

/**
 * Provides a resource for assigning an existing DigitalOcean reserved IP to a Droplet. This
 * makes it easy to provision reserved IP addresses that are not tied to the lifecycle of your
 * Droplet.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as digitalocean from "@pulumi/digitalocean";
 * const example = new digitalocean.ReservedIp("example", {region: "nyc3"});
 * const exampleDroplet = new digitalocean.Droplet("example", {
 *     name: "baz",
 *     size: digitalocean.DropletSlug.DropletS1VCPU1GB,
 *     image: "ubuntu-22-04-x64",
 *     region: digitalocean.Region.NYC3,
 *     ipv6: true,
 *     privateNetworking: true,
 * });
 * const exampleReservedIpAssignment = new digitalocean.ReservedIpAssignment("example", {
 *     ipAddress: example.ipAddress,
 *     dropletId: exampleDroplet.id,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_digitalocean as digitalocean
 * example = digitalocean.ReservedIp("example", region="nyc3")
 * example_droplet = digitalocean.Droplet("example",
 *     name="baz",
 *     size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB,
 *     image="ubuntu-22-04-x64",
 *     region=digitalocean.Region.NYC3,
 *     ipv6=True,
 *     private_networking=True)
 * example_reserved_ip_assignment = digitalocean.ReservedIpAssignment("example",
 *     ip_address=example.ip_address,
 *     droplet_id=example_droplet.id)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using DigitalOcean = Pulumi.DigitalOcean;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new DigitalOcean.ReservedIp("example", new()
 *     {
 *         Region = "nyc3",
 *     });
 *     var exampleDroplet = new DigitalOcean.Droplet("example", new()
 *     {
 *         Name = "baz",
 *         Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
 *         Image = "ubuntu-22-04-x64",
 *         Region = DigitalOcean.Region.NYC3,
 *         Ipv6 = true,
 *         PrivateNetworking = true,
 *     });
 *     var exampleReservedIpAssignment = new DigitalOcean.ReservedIpAssignment("example", new()
 *     {
 *         IpAddress = example.IpAddress,
 *         DropletId = exampleDroplet.Id,
 *     });
 * });
 * ```
 * ```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 {
 * 		example, err := digitalocean.NewReservedIp(ctx, "example", &digitalocean.ReservedIpArgs{
 * 			Region: pulumi.String("nyc3"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleDroplet, err := digitalocean.NewDroplet(ctx, "example", &digitalocean.DropletArgs{
 * 			Name:              pulumi.String("baz"),
 * 			Size:              pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
 * 			Image:             pulumi.String("ubuntu-22-04-x64"),
 * 			Region:            pulumi.String(digitalocean.RegionNYC3),
 * 			Ipv6:              pulumi.Bool(true),
 * 			PrivateNetworking: pulumi.Bool(true),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = digitalocean.NewReservedIpAssignment(ctx, "example", &digitalocean.ReservedIpAssignmentArgs{
 * 			IpAddress: example.IpAddress,
 * 			DropletId: exampleDroplet.ID(),
 * 		})
 * 		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.ReservedIp;
 * import com.pulumi.digitalocean.ReservedIpArgs;
 * import com.pulumi.digitalocean.Droplet;
 * import com.pulumi.digitalocean.DropletArgs;
 * import com.pulumi.digitalocean.ReservedIpAssignment;
 * import com.pulumi.digitalocean.ReservedIpAssignmentArgs;
 * 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 example = new ReservedIp("example", ReservedIpArgs.builder()
 *             .region("nyc3")
 *             .build());
 *         var exampleDroplet = new Droplet("exampleDroplet", DropletArgs.builder()
 *             .name("baz")
 *             .size("s-1vcpu-1gb")
 *             .image("ubuntu-22-04-x64")
 *             .region("nyc3")
 *             .ipv6(true)
 *             .privateNetworking(true)
 *             .build());
 *         var exampleReservedIpAssignment = new ReservedIpAssignment("exampleReservedIpAssignment", ReservedIpAssignmentArgs.builder()
 *             .ipAddress(example.ipAddress())
 *             .dropletId(exampleDroplet.id())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: digitalocean:ReservedIp
 *     properties:
 *       region: nyc3
 *   exampleDroplet:
 *     type: digitalocean:Droplet
 *     name: example
 *     properties:
 *       name: baz
 *       size: s-1vcpu-1gb
 *       image: ubuntu-22-04-x64
 *       region: nyc3
 *       ipv6: true
 *       privateNetworking: true
 *   exampleReservedIpAssignment:
 *     type: digitalocean:ReservedIpAssignment
 *     name: example
 *     properties:
 *       ipAddress: ${example.ipAddress}
 *       dropletId: ${exampleDroplet.id}
 * ```
 * 
 * ## Import
 * Reserved IP assignments can be imported using the reserved IP itself and the `id` of
 * the Droplet joined with a comma. For example:
 * ```sh
 * $ pulumi import digitalocean:index/reservedIpAssignment:ReservedIpAssignment foobar 192.0.2.1,123456
 * ```
 */
public class ReservedIpAssignment internal constructor(
    override val javaResource: com.pulumi.digitalocean.ReservedIpAssignment,
) : KotlinCustomResource(javaResource, ReservedIpAssignmentMapper) {
    /**
     * The ID of Droplet that the reserved IP will be assigned to.
     */
    public val dropletId: Output
        get() = javaResource.dropletId().applyValue({ args0 -> args0 })

    /**
     * The reserved IP to assign to the Droplet.
     */
    public val ipAddress: Output
        get() = javaResource.ipAddress().applyValue({ args0 -> args0 })
}

public object ReservedIpAssignmentMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.digitalocean.ReservedIpAssignment::class == javaResource::class

    override fun map(javaResource: Resource): ReservedIpAssignment = ReservedIpAssignment(
        javaResource
            as com.pulumi.digitalocean.ReservedIpAssignment,
    )
}

/**
 * @see [ReservedIpAssignment].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [ReservedIpAssignment].
 */
public suspend fun reservedIpAssignment(
    name: String,
    block: suspend ReservedIpAssignmentResourceBuilder.() -> Unit,
): ReservedIpAssignment {
    val builder = ReservedIpAssignmentResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [ReservedIpAssignment].
 * @param name The _unique_ name of the resulting resource.
 */
public fun reservedIpAssignment(name: String): ReservedIpAssignment {
    val builder = ReservedIpAssignmentResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy