Skip to main content

dtcloud_my_ip (Data Source)

Reports the address the API sees the caller coming from.

Its purpose is scoping a rule to your own address: let me in, and nobody else. It is not necessarily your public address. It is your address on whatever network you reached the API over, so behind a corporate VPN it is the VPN address, which is usually the useful answer, since that is also the address a machine sees.

Example Usage​

data "dtcloud_my_ip" "here" {}

# Scope an administrative rule to whoever is running Terraform. Read the note on
# the data source page before using this for anything a service depends on.
resource "dtcloud_security_group_rule" "ssh_from_me" {
security_group_id = dtcloud_security_group.web.id
direction = "ingress"
protocol = "tcp"
port_range_min = 22
port_range_max = 22
remote_ip_prefix = data.dtcloud_my_ip.here.cidr
}

Schema​

Read-Only​

  • cidr (String) The same address as a single-host CIDR — /32 for IPv4, /128 for IPv6 — which is the form remote_ip_prefix takes.
  • id (String) The ID of this resource.
  • ip (String) The address the API saw the request come from.

Behaviour worth knowing​

warning

Read this before using it in a rule. The value changes when you change network, and a connection can renumber on its own. A security group rule forces replacement, so a changed address means the next plan deletes the rule and creates a new one. That is right for an administrative allow-rule and a poor idea for anything a service depends on. It also means whoever ran the last apply decides who has access, which is rarely right from CI; use an explicit CIDR there.

  • An IPv4-mapped address is unwrapped. An address the API reports as ::ffff:192.0.2.10 comes back as 192.0.2.10, with a /32 CIDR.