Skip to content

Instantly share code, notes, and snippets.

@iurisilvio
Created August 16, 2021 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iurisilvio/79062183c503666bdbc7c0cdb9e4fd69 to your computer and use it in GitHub Desktop.
Save iurisilvio/79062183c503666bdbc7c0cdb9e4fd69 to your computer and use it in GitHub Desktop.
Gocache prefix list sync
data "http" "gocache_response" {
url = "https://gocache.com.br/ips"
}
resource "aws_ec2_managed_prefix_list" "gocache" {
name = "gocache ips"
address_family = "IPv4"
max_entries = 30
dynamic "entry" {
# compact remove empty lines
for_each = compact(split("\n", data.http.gocache_response.body))
content {
cidr = entry.value
description = "https://gocache.com.br/ips"
}
}
}
resource "aws_security_group_rule" "prod_rule" {
type = "ingress"
from_port = 80
to_port = 80
protocol = "tcp"
description = "gocache ip (terraform managed)"
prefix_list_ids = [aws_ec2_managed_prefix_list.gocache.id]
security_group_id = "sg-000000" # your sg group
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment