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

com.pulumi.azure.compute.kotlin.BastionHost.kt Maven / Gradle / Ivy

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

package com.pulumi.azure.compute.kotlin

import com.pulumi.azure.compute.kotlin.outputs.BastionHostIpConfiguration
import com.pulumi.azure.compute.kotlin.outputs.BastionHostIpConfiguration.Companion.toKotlin
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
import kotlin.collections.Map

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

    public var args: BastionHostArgs = BastionHostArgs()

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

/**
 * Manages a Bastion Host.
 * ## Example Usage
 * This example deploys an Azure Bastion Host Instance to a target virtual network.
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", {
 *     name: "examplevnet",
 *     addressSpaces: ["192.168.1.0/24"],
 *     location: example.location,
 *     resourceGroupName: example.name,
 * });
 * const exampleSubnet = new azure.network.Subnet("example", {
 *     name: "AzureBastionSubnet",
 *     resourceGroupName: example.name,
 *     virtualNetworkName: exampleVirtualNetwork.name,
 *     addressPrefixes: ["192.168.1.224/27"],
 * });
 * const examplePublicIp = new azure.network.PublicIp("example", {
 *     name: "examplepip",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     allocationMethod: "Static",
 *     sku: "Standard",
 * });
 * const exampleBastionHost = new azure.compute.BastionHost("example", {
 *     name: "examplebastion",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     ipConfiguration: {
 *         name: "configuration",
 *         subnetId: exampleSubnet.id,
 *         publicIpAddressId: examplePublicIp.id,
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_virtual_network = azure.network.VirtualNetwork("example",
 *     name="examplevnet",
 *     address_spaces=["192.168.1.0/24"],
 *     location=example.location,
 *     resource_group_name=example.name)
 * example_subnet = azure.network.Subnet("example",
 *     name="AzureBastionSubnet",
 *     resource_group_name=example.name,
 *     virtual_network_name=example_virtual_network.name,
 *     address_prefixes=["192.168.1.224/27"])
 * example_public_ip = azure.network.PublicIp("example",
 *     name="examplepip",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     allocation_method="Static",
 *     sku="Standard")
 * example_bastion_host = azure.compute.BastionHost("example",
 *     name="examplebastion",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     ip_configuration=azure.compute.BastionHostIpConfigurationArgs(
 *         name="configuration",
 *         subnet_id=example_subnet.id,
 *         public_ip_address_id=example_public_ip.id,
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example-resources",
 *         Location = "West Europe",
 *     });
 *     var exampleVirtualNetwork = new Azure.Network.VirtualNetwork("example", new()
 *     {
 *         Name = "examplevnet",
 *         AddressSpaces = new[]
 *         {
 *             "192.168.1.0/24",
 *         },
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *     });
 *     var exampleSubnet = new Azure.Network.Subnet("example", new()
 *     {
 *         Name = "AzureBastionSubnet",
 *         ResourceGroupName = example.Name,
 *         VirtualNetworkName = exampleVirtualNetwork.Name,
 *         AddressPrefixes = new[]
 *         {
 *             "192.168.1.224/27",
 *         },
 *     });
 *     var examplePublicIp = new Azure.Network.PublicIp("example", new()
 *     {
 *         Name = "examplepip",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         AllocationMethod = "Static",
 *         Sku = "Standard",
 *     });
 *     var exampleBastionHost = new Azure.Compute.BastionHost("example", new()
 *     {
 *         Name = "examplebastion",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         IpConfiguration = new Azure.Compute.Inputs.BastionHostIpConfigurationArgs
 *         {
 *             Name = "configuration",
 *             SubnetId = exampleSubnet.Id,
 *             PublicIpAddressId = examplePublicIp.Id,
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/compute"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/network"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleVirtualNetwork, err := network.NewVirtualNetwork(ctx, "example", &network.VirtualNetworkArgs{
 * 			Name: pulumi.String("examplevnet"),
 * 			AddressSpaces: pulumi.StringArray{
 * 				pulumi.String("192.168.1.0/24"),
 * 			},
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleSubnet, err := network.NewSubnet(ctx, "example", &network.SubnetArgs{
 * 			Name:               pulumi.String("AzureBastionSubnet"),
 * 			ResourceGroupName:  example.Name,
 * 			VirtualNetworkName: exampleVirtualNetwork.Name,
 * 			AddressPrefixes: pulumi.StringArray{
 * 				pulumi.String("192.168.1.224/27"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		examplePublicIp, err := network.NewPublicIp(ctx, "example", &network.PublicIpArgs{
 * 			Name:              pulumi.String("examplepip"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			AllocationMethod:  pulumi.String("Static"),
 * 			Sku:               pulumi.String("Standard"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = compute.NewBastionHost(ctx, "example", &compute.BastionHostArgs{
 * 			Name:              pulumi.String("examplebastion"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			IpConfiguration: &compute.BastionHostIpConfigurationArgs{
 * 				Name:              pulumi.String("configuration"),
 * 				SubnetId:          exampleSubnet.ID(),
 * 				PublicIpAddressId: examplePublicIp.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.azure.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.network.VirtualNetwork;
 * import com.pulumi.azure.network.VirtualNetworkArgs;
 * import com.pulumi.azure.network.Subnet;
 * import com.pulumi.azure.network.SubnetArgs;
 * import com.pulumi.azure.network.PublicIp;
 * import com.pulumi.azure.network.PublicIpArgs;
 * import com.pulumi.azure.compute.BastionHost;
 * import com.pulumi.azure.compute.BastionHostArgs;
 * import com.pulumi.azure.compute.inputs.BastionHostIpConfigurationArgs;
 * 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 ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("example-resources")
 *             .location("West Europe")
 *             .build());
 *         var exampleVirtualNetwork = new VirtualNetwork("exampleVirtualNetwork", VirtualNetworkArgs.builder()
 *             .name("examplevnet")
 *             .addressSpaces("192.168.1.0/24")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .build());
 *         var exampleSubnet = new Subnet("exampleSubnet", SubnetArgs.builder()
 *             .name("AzureBastionSubnet")
 *             .resourceGroupName(example.name())
 *             .virtualNetworkName(exampleVirtualNetwork.name())
 *             .addressPrefixes("192.168.1.224/27")
 *             .build());
 *         var examplePublicIp = new PublicIp("examplePublicIp", PublicIpArgs.builder()
 *             .name("examplepip")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .allocationMethod("Static")
 *             .sku("Standard")
 *             .build());
 *         var exampleBastionHost = new BastionHost("exampleBastionHost", BastionHostArgs.builder()
 *             .name("examplebastion")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .ipConfiguration(BastionHostIpConfigurationArgs.builder()
 *                 .name("configuration")
 *                 .subnetId(exampleSubnet.id())
 *                 .publicIpAddressId(examplePublicIp.id())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleVirtualNetwork:
 *     type: azure:network:VirtualNetwork
 *     name: example
 *     properties:
 *       name: examplevnet
 *       addressSpaces:
 *         - 192.168.1.0/24
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *   exampleSubnet:
 *     type: azure:network:Subnet
 *     name: example
 *     properties:
 *       name: AzureBastionSubnet
 *       resourceGroupName: ${example.name}
 *       virtualNetworkName: ${exampleVirtualNetwork.name}
 *       addressPrefixes:
 *         - 192.168.1.224/27
 *   examplePublicIp:
 *     type: azure:network:PublicIp
 *     name: example
 *     properties:
 *       name: examplepip
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       allocationMethod: Static
 *       sku: Standard
 *   exampleBastionHost:
 *     type: azure:compute:BastionHost
 *     name: example
 *     properties:
 *       name: examplebastion
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       ipConfiguration:
 *         name: configuration
 *         subnetId: ${exampleSubnet.id}
 *         publicIpAddressId: ${examplePublicIp.id}
 * ```
 * 
 * ## Import
 * Bastion Hosts can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:compute/bastionHost:BastionHost example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/bastionHosts/instance1
 * ```
 */
public class BastionHost internal constructor(
    override val javaResource: com.pulumi.azure.compute.BastionHost,
) : KotlinCustomResource(javaResource, BastionHostMapper) {
    /**
     * Is Copy/Paste feature enabled for the Bastion Host. Defaults to `true`.
     */
    public val copyPasteEnabled: Output?
        get() = javaResource.copyPasteEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The FQDN for the Bastion Host.
     */
    public val dnsName: Output
        get() = javaResource.dnsName().applyValue({ args0 -> args0 })

    /**
     * Is File Copy feature enabled for the Bastion Host. Defaults to `false`.
     * > **Note:** `file_copy_enabled` is only supported when `sku` is `Standard`.
     */
    public val fileCopyEnabled: Output?
        get() = javaResource.fileCopyEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * A `ip_configuration` block as defined below. Changing this forces a new resource to be created.
     */
    public val ipConfiguration: Output
        get() = javaResource.ipConfiguration().applyValue({ args0 ->
            args0.let({ args0 ->
                toKotlin(args0)
            })
        })

    /**
     * Is IP Connect feature enabled for the Bastion Host. Defaults to `false`.
     * > **Note:** `ip_connect_enabled` is only supported when `sku` is `Standard`.
     */
    public val ipConnectEnabled: Output?
        get() = javaResource.ipConnectEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Is Kerberos authentication feature enabled for the Bastion Host. Defaults to `false`.
     * > **Note:** `kerberos_enabled` is only supported when `sku` is `Standard`.
     */
    public val kerberosEnabled: Output?
        get() = javaResource.kerberosEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. Review [Azure Bastion Host FAQ](https://docs.microsoft.com/azure/bastion/bastion-faq) for supported locations.
     */
    public val location: Output
        get() = javaResource.location().applyValue({ args0 -> args0 })

    /**
     * Specifies the name of the Bastion Host. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The name of the resource group in which to create the Bastion Host. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * The number of scale units with which to provision the Bastion Host. Possible values are between `2` and `50`. Defaults to `2`.
     * > **Note:** `scale_units` only can be changed when `sku` is `Standard`. `scale_units` is always `2` when `sku` is `Basic`.
     */
    public val scaleUnits: Output?
        get() = javaResource.scaleUnits().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Is Shareable Link feature enabled for the Bastion Host. Defaults to `false`.
     * > **Note:** `shareable_link_enabled` is only supported when `sku` is `Standard`.
     */
    public val shareableLinkEnabled: Output?
        get() = javaResource.shareableLinkEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The SKU of the Bastion Host. Accepted values are `Basic` and `Standard`. Defaults to `Basic`.
     * > **Note** Downgrading the SKU will force a new resource to be created.
     */
    public val sku: Output?
        get() = javaResource.sku().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * A mapping of tags to assign to the resource.
     */
    public val tags: Output>?
        get() = javaResource.tags().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * Is Tunneling feature enabled for the Bastion Host. Defaults to `false`.
     * > **Note:** `tunneling_enabled` is only supported when `sku` is `Standard`.
     */
    public val tunnelingEnabled: Output?
        get() = javaResource.tunnelingEnabled().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })
}

public object BastionHostMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.compute.BastionHost::class == javaResource::class

    override fun map(javaResource: Resource): BastionHost = BastionHost(
        javaResource as
            com.pulumi.azure.compute.BastionHost,
    )
}

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy