Skip to content

Instantly share code, notes, and snippets.

@amaudy
Last active September 4, 2022 04:05
Show Gist options
  • Save amaudy/53dd6bddd9af6c37e2dfab2c94d42801 to your computer and use it in GitHub Desktop.
Save amaudy/53dd6bddd9af6c37e2dfab2c94d42801 to your computer and use it in GitHub Desktop.
Firewall rule
data "http" "myip" {
url = "http://ipv4.icanhazip.com"
}
resource "digitalocean_firewall" "devbox" {
name = "demo-devbox-firewall"
droplet_ids = [digitalocean_droplet.devbox.id]
inbound_rule {
protocol = "tcp"
port_range = "1-65535"
source_addresses = ["${chomp(data.http.myip.body)}/32"]
}
outbound_rule {
protocol = "icmp"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
outbound_rule {
protocol = "tcp"
port_range = "1-65535"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
outbound_rule {
protocol = "udp"
port_range = "1-65535"
destination_addresses = ["0.0.0.0/0", "::/0"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment