Skip to content

azurermBastionHost

Manages a Bastion Host.

Example Usage

This example deploys an Azure Bastion Host Instance to a target virtual network.

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
const azurermResourceGroupExample = new azurerm.resourceGroup.ResourceGroup(
  this,
  "example",
  {
    location: "West Europe",
    name: "example-resources",
  }
);
const azurermVirtualNetworkExample = new azurerm.virtualNetwork.VirtualNetwork(
  this,
  "example_1",
  {
    address_space: ["192.168.1.0/24"],
    location: azurermResourceGroupExample.location,
    name: "examplevnet",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermVirtualNetworkExample.overrideLogicalId("example");
const azurermPublicIpExample = new azurerm.publicIp.PublicIp(
  this,
  "example_2",
  {
    allocation_method: "Static",
    location: azurermResourceGroupExample.location,
    name: "examplepip",
    resource_group_name: azurermResourceGroupExample.name,
    sku: "Standard",
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermPublicIpExample.overrideLogicalId("example");
const azurermSubnetExample = new azurerm.subnet.Subnet(this, "example_3", {
  address_prefixes: ["192.168.1.224/27"],
  name: "AzureBastionSubnet",
  resource_group_name: azurermResourceGroupExample.name,
  virtual_network_name: azurermVirtualNetworkExample.name,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermSubnetExample.overrideLogicalId("example");
const azurermBastionHostExample = new azurerm.bastionHost.BastionHost(
  this,
  "example_4",
  {
    ip_configuration: [
      {
        name: "configuration",
        public_ip_address_id: azurermPublicIpExample.id,
        subnet_id: azurermSubnetExample.id,
      },
    ],
    location: azurermResourceGroupExample.location,
    name: "examplebastion",
    resource_group_name: azurermResourceGroupExample.name,
  }
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
azurermBastionHostExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • name - (Required) Specifies the name of the Bastion Host. Changing this forces a new resource to be created.

  • resourceGroupName - (Required) The name of the resource group in which to create the Bastion Host. Changing this forces a new resource to be created.

  • location - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. Review Azure Bastion Host FAQ for supported locations.

  • copyPasteEnabled - (Optional) Is Copy/Paste feature enabled for the Bastion Host. Defaults to true.

  • fileCopyEnabled - (Optional) Is File Copy feature enabled for the Bastion Host. Defaults to false.

\~> Note: fileCopyEnabled is only supported when sku is standard.

  • sku - (Optional) The SKU of the Bastion Host. Accepted values are basic and standard. Defaults to basic.

  • ipConfiguration - (Optional) A ipConfiguration block as defined below. Changing this forces a new resource to be created.

  • ipConnectEnabled - (Optional) Is IP Connect feature enabled for the Bastion Host. Defaults to false.

\~> Note: ipConnectEnabled is only supported when sku is standard.

  • scaleUnits - (Optional) The number of scale units with which to provision the Bastion Host. Possible values are between 2 and 50. Defaults to 2.

\~> Note: scaleUnits only can be changed when sku is standard. scaleUnits is always 2 when sku is basic.

  • shareableLinkEnabled - (Optional) Is Shareable Link feature enabled for the Bastion Host. Defaults to false.

\~> Note: shareableLinkEnabled is only supported when sku is standard.

  • tunnelingEnabled - (Optional) Is Tunneling feature enabled for the Bastion Host. Defaults to false.

\~> Note: tunnelingEnabled is only supported when sku is standard.

  • tags - (Optional) A mapping of tags to assign to the resource.

A ipConfiguration block supports the following:

  • name - (Required) The name of the IP configuration. Changing this forces a new resource to be created.

  • subnetId - (Required) Reference to a subnet in which this Bastion Host has been created. Changing this forces a new resource to be created.

\~> Note: The Subnet used for the Bastion Host must have the name azureBastionSubnet and the subnet mask must be at least a /26.

  • publicIpAddressId - (Required) Reference to a Public IP Address to associate with this Bastion Host. Changing this forces a new resource to be created.

Attributes Reference

The following attributes are exported:

  • id - The ID of the Bastion Host.

  • dnsName - The FQDN for the Bastion Host.

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 minutes) Used when creating the Bastion Host.
  • update - (Defaults to 30 minutes) Used when updating the Bastion Host.
  • read - (Defaults to 5 minutes) Used when retrieving the Bastion Host.
  • delete - (Defaults to 30 minutes) Used when deleting the Bastion Host.

Import

Bastion Hosts can be imported using the resourceId, e.g.

terraform import azurerm_bastion_host.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/bastionHosts/instance1