Data Source: azurermPublicIp
Use this data source to access information about an existing Public IP Address.
Example Usage (reference an existing)
import * as cdktf from "cdktf";
/*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 dataAzurermPublicIpExample =
new azurerm.dataAzurermPublicIp.DataAzurermPublicIp(this, "example", {
name: "name_of_public_ip",
resource_group_name: "name_of_resource_group",
});
new cdktf.TerraformOutput(this, "domain_name_label", {
value: dataAzurermPublicIpExample.domainNameLabel,
});
new cdktf.TerraformOutput(this, "public_ip_address", {
value: dataAzurermPublicIpExample.ipAddress,
});
Example Usage (Retrieve the Dynamic Public IP of a new VM)
import * as cdktf from "cdktf";
/*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: "test-resources",
}
);
const azurermVirtualNetworkExample = new azurerm.virtualNetwork.VirtualNetwork(
this,
"example_1",
{
address_space: ["10.0.0.0/16"],
location: azurermResourceGroupExample.location,
name: "test-network",
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: "Dynamic",
idle_timeout_in_minutes: 30,
location: azurermResourceGroupExample.location,
name: "test-pip",
resource_group_name: azurermResourceGroupExample.name,
tags: {
environment: "test",
},
}
);
/*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: ["10.0.2.0/24"],
name: "acctsub",
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 azurermNetworkInterfaceExample =
new azurerm.networkInterface.NetworkInterface(this, "example_4", {
ip_configuration: [
{
name: "testconfiguration1",
private_ip_address: "10.0.2.5",
private_ip_address_allocation: "Static",
public_ip_address_id: azurermPublicIpExample.id,
subnet_id: azurermSubnetExample.id,
},
],
location: azurermResourceGroupExample.location,
name: "test-nic",
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.*/
azurermNetworkInterfaceExample.overrideLogicalId("example");
const azurermVirtualMachineExample = new azurerm.virtualMachine.VirtualMachine(
this,
"example_5",
{
location: azurermResourceGroupExample.location,
name: "test-vm",
network_interface_ids: [azurermNetworkInterfaceExample.id],
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.*/
azurermVirtualMachineExample.overrideLogicalId("example");
const dataAzurermPublicIpExample =
new azurerm.dataAzurermPublicIp.DataAzurermPublicIp(this, "example_6", {
name: azurermPublicIpExample.name,
resource_group_name: azurermVirtualMachineExample.resourceGroupName,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
dataAzurermPublicIpExample.overrideLogicalId("example");
new cdktf.TerraformOutput(this, "public_ip_address", {
value: dataAzurermPublicIpExample.ipAddress,
});
Argument Reference
name
- Specifies the name of the public IP address.resourceGroupName
- Specifies the name of the resource group.
Attributes Reference
id
- The ID of the Public IP address.domainNameLabel
- The label for the Domain Name.idleTimeoutInMinutes
- Specifies the timeout for the TCP idle connection.ddosProtectionMode
- The DDoS protection mode of the public IP.ddosProtectionPlanId
- The ID of DDoS protection plan associated with the public IP.fqdn
- Fully qualified domain name of the A DNS record associated with the public IP. This is the concatenation of the domainNameLabel and the regionalized DNS zone.ipAddress
- The IP address value that was allocated.ipVersion
- The IP version being used, for exampleiPv4
oriPv6
.sku
- The SKU of the Public IP.ipTags
- A mapping of tags to assigned to the resource.tags
- A mapping of tags to assigned to the resource.zones
- A list of Availability Zones in which this Public IP is located.
Timeouts
The timeouts
block allows you to specify timeouts for certain actions:
read
- (Defaults to 5 minutes) Used when retrieving the Public IP Address.