UPD: replaced null_resource with http data source
This commit is contained in:
parent
69a2790123
commit
60be67bc64
@ -11,7 +11,7 @@
|
|||||||
| Name | Version |
|
| Name | Version |
|
||||||
|------|---------|
|
|------|---------|
|
||||||
| aws | 5.51.1 |
|
| aws | 5.51.1 |
|
||||||
| null | 3.2.2 |
|
| http | 3.4.2 |
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
@ -26,10 +26,10 @@
|
|||||||
| Name | Type |
|
| Name | Type |
|
||||||
|------|------|
|
|------|------|
|
||||||
| [aws_ec2_managed_prefix_list.pl1](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_managed_prefix_list) | resource |
|
| [aws_ec2_managed_prefix_list.pl1](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ec2_managed_prefix_list) | resource |
|
||||||
| [null_resource.CloudflareIps](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource |
|
|
||||||
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
|
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
|
||||||
| [aws_iam_policy_document.dynamodb_endpoint_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
| [aws_iam_policy_document.dynamodb_endpoint_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
||||||
| [aws_iam_policy_document.s3_endpoint_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
| [aws_iam_policy_document.s3_endpoint_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
|
||||||
|
| [http_http.CloudflareIps](https://registry.terraform.io/providers/hashicorp/http/latest/docs/data-sources/http) | data source |
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
|
@ -89,14 +89,12 @@ data "aws_iam_policy_document" "dynamodb_endpoint_policy" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "null_resource" "CloudflareIps" {
|
|
||||||
provisioner "local-exec" {
|
|
||||||
command = "wget -qO CfIps.json https://api.cloudflare.com/client/v4/ips"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
locals {
|
data "http" "CloudflareIps" {
|
||||||
CfIpJson = jsondecode(file("${path.module}/CfIps.json"))
|
url = "https://api.cloudflare.com/client/v4/ips"
|
||||||
|
request_headers = {
|
||||||
|
Accept = "application/json"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ec2_managed_prefix_list" "pl1" {
|
resource "aws_ec2_managed_prefix_list" "pl1" {
|
||||||
@ -104,7 +102,7 @@ resource "aws_ec2_managed_prefix_list" "pl1" {
|
|||||||
address_family = "IPv4"
|
address_family = "IPv4"
|
||||||
max_entries = 20
|
max_entries = 20
|
||||||
dynamic "entry" {
|
dynamic "entry" {
|
||||||
for_each = local.CfIpJson.result.ipv4_cidrs
|
for_each = jsondecode(data.http.CloudflareIps.response_body)["result"]["ipv4_cidrs"]
|
||||||
content {
|
content {
|
||||||
cidr = entry.value
|
cidr = entry.value
|
||||||
description = "Cloudflare IP"
|
description = "Cloudflare IP"
|
||||||
|
Loading…
Reference in New Issue
Block a user