-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dave Barnum
authored and
Dave Barnum
committed
Jan 12, 2024
1 parent
3cdb99e
commit e8185df
Showing
5 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# aws/cloudflare-sg - Cloudflare Security Group | ||
This module is used to create a security group to allow HTTPS/443 traffic from | ||
Cloudflare IP addresses only. | ||
|
||
## What this does | ||
|
||
- Create security group allowing HTTPS traffic on port 443 from Cloudflare IPs | ||
|
||
## Required Inputs | ||
|
||
- `vpc_id` - ID of VPC to place security group | ||
|
||
## Outputs | ||
|
||
- `id` - ID of security group created | ||
- `name` - Name of security group created | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
module "cloudflare-sg" { | ||
source = "github.com/wycliffe-usa/terraform-modules//aws/cloudflare-sg" | ||
vpc_id = "${var.vpc_id}" | ||
} | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module "cf_ips" { | ||
source = "github.com/wycliffe-usa/terraform-modules//cloudflare/ips?ref=1.7.1" | ||
} | ||
|
||
resource "aws_security_group" "cloudflare_https" { | ||
name = "cloudflare-https" | ||
description = "Allow HTTPS traffic from Cloudflare" | ||
vpc_id = var.vpc_id | ||
} | ||
|
||
resource "aws_security_group_rule" "cloudflare_ipv4" { | ||
type = "ingress" | ||
from_port = 443 | ||
to_port = 443 | ||
protocol = "tcp" | ||
security_group_id = aws_security_group.cloudflare_https.id | ||
cidr_blocks = module.cf_ips.ipv4_cidrs | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
output "id" { | ||
value = aws_security_group.cloudflare_https.id | ||
} | ||
|
||
output "name" { | ||
value = aws_security_group.cloudflare_https.name | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
variable "vpc_id" { | ||
type = string | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 5.0.0, < 6.0.0" | ||
} | ||
} | ||
} |