Created
August 16, 2021 17:08
-
-
Save iurisilvio/79062183c503666bdbc7c0cdb9e4fd69 to your computer and use it in GitHub Desktop.
Gocache prefix list sync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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