Initial commit

This commit is contained in:
Nemo 2019-01-11 18:18:13 +05:30
commit 9c09ede23c
5 changed files with 103 additions and 0 deletions

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Abhay Rana
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

40
README.md Normal file
View File

@ -0,0 +1,40 @@
# terraform-http-setcronjob-whitelist
This module scrapes the SetCronJob IPs from their website and makes them available as a list. If you are using this module, I highly recommend subscribing to the SetCronJob Notification emails regarding changes to this list at http://eepurl.com/cxEQcL. Since this module dynamically generates the list, it won't be updated alongside updates to the SetCronJob list updates.
[The SetCronjob service documentation](https://support.setcronjob.com/hc/en-us/articles/219802207-SetCronJob-IP-addresses-list) points to the following text files for IPs that they use:
- https://www.setcronjob.com/ip.txt
- https://www.setcronjob.com/ipv4.txt
- https://www.setcronjob.com/ipv6.txt
# Usage
```hcl
module "scj" {
source = "github.com/captn3m0/terraform-http-setcronjob-whitelist"
}
resource "aws_security_group_rule" "allow_all_from_scj" {
type = "ingress"
from_port = 0
to_port = 443
protocol = "tcp"
cidr_blocks = ["${module.scj.ipv4_cidr}"]
security_group_id = "sg-123456"
}
```
# Outputs
| Name | Description |
| --------- | ------------------------------------------------------------------------------------------------------ |
| ips | List of all SetCronjob egress IPs, scraped from https://www.setcronjob.com/ip.txt |
| ipv4 | List of all SetCronjob egress IPv4 IPs, scraped from https://www.setcronjob.com/ipv4.txt |
| ipv4_cidr | List of all SetCronjob egress IPv4 IPs as /32 CIDRs, scraped from https://www.setcronjob.com/ipv4.txt |
| ipv6 | List of all SetCronjob egress IPv6 IPs, scraped from https://www.setcronjob.com/ipv6.txt |
| ipv6_cidr | List of all SetCronjob egress IPv6 IPs as /128 CIDRs, scraped from https://www.setcronjob.com/ipv6.txt |
# LICENSE
Licensed under MIT. See [nemo.mit-license.org](https://nemo.mit-license.org/) for complete text.

11
main.tf Normal file
View File

@ -0,0 +1,11 @@
data "http" "list-txt" {
url = "https://www.setcronjob.com/ip.txt"
}
data "http" "list-ipv4" {
url = "https://www.setcronjob.com/ipv4.txt"
}
data "http" "list-ipv6" {
url = "https://www.setcronjob.com/ipv6.txt"
}

30
outputs.tf Normal file
View File

@ -0,0 +1,30 @@
locals {
ips = ["${split("\n", chomp(data.http.list-txt.body))}"]
ipv4 = ["${split("\n", chomp(data.http.list-ipv4.body))}"]
ipv6 = ["${split("\n", chomp(data.http.list-ipv6.body))}"]
}
output "ips" {
description = "List of all SetCronjob egress IPs."
value = "${local.ips}"
}
output "ipv4" {
description = "List of all SetCronjob egress IPv4 IPs."
value = "${local.ipv4}"
}
output "ipv6" {
description = "List of all SetCronjob egress IPv6 IPs."
value = "${local.ipv6}"
}
output "ipv4_cidr" {
description = "List of all SetCronjob egress IPv4 IPs, formatted as /32 CIDRs"
value = ["${formatlist("%s/32", local.ipv4)}"]
}
output "ipv6_cidr" {
description = "List of all SetCronjob egress IPv6 IPs, formatted as /128 CIDRs"
value = ["${formatlist("%s/128", local.ipv6)}"]
}

1
variables.tf Normal file
View File

@ -0,0 +1 @@