-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use efs instead of ebs to store mongodb datas
- Loading branch information
Showing
10 changed files
with
163 additions
and
193 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 |
---|---|---|
@@ -1,20 +1,27 @@ | ||
module "pritunl" { | ||
source = "../modules/pritunl" | ||
|
||
environment = local.env | ||
vpc_id = module.vpc.vpc_id | ||
public_subnets = module.vpc.public_subnets | ||
pritunl_sg_rules = [ | ||
ingress_with_cidr_blocks = [ | ||
{ | ||
protocol = "6" | ||
from_port = 443 | ||
to_port = 443 | ||
cidr_blocks = ["8.8.8.8/32"] # the list of IPs that will have access to the web console | ||
cidr_blocks = "127.0.0.1/32" # IP address that will have access to the web console | ||
}, | ||
{ | ||
protocol = "17" | ||
from_port = 19739 #this is a port that we will set in pritunl server configuration (after installation) | ||
from_port = 19739 # this is a port that we will set in pritunl server configuration (after installation) | ||
to_port = 19739 | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
cidr_blocks = "0.0.0.0/0" | ||
}, | ||
{ | ||
protocol = "6" | ||
from_port = 80 | ||
to_port = 80 | ||
cidr_blocks = "127.0.0.1/32" # IP address that will have access to the web console | ||
}, | ||
] | ||
} |
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 @@ | ||
resource "aws_backup_vault" "this" { | ||
name = var.name | ||
} | ||
|
||
resource "aws_backup_plan" "this" { | ||
name = "${var.name}_backup_plan" | ||
rule { | ||
rule_name = "${var.name}_backup_plan_efs" | ||
target_vault_name = aws_backup_vault.this.name | ||
schedule = "cron(0 1 * * ? *)" | ||
lifecycle { | ||
delete_after = 30 | ||
} | ||
} | ||
} | ||
|
||
resource "aws_backup_selection" "efs" { | ||
iam_role_arn = module.backup_role.this_iam_role_arn | ||
name = "${var.name}_backup_selection_efs" | ||
plan_id = aws_backup_plan.this.id | ||
|
||
resources = [ | ||
aws_efs_file_system.this.arn | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
#------------------------------------------------------------------------------ | ||
# Create EFS | ||
#------------------------------------------------------------------------------ | ||
resource "aws_efs_file_system" "this" { | ||
creation_token = var.name | ||
encrypted = var.encrypted | ||
kms_key_id = var.kms_key_id | ||
|
||
tags = { | ||
"Name" = var.name | ||
} | ||
lifecycle { | ||
ignore_changes = [ | ||
tags, | ||
] | ||
} | ||
} | ||
|
||
resource "aws_efs_mount_target" "this" { | ||
count = length(var.public_subnets) | ||
file_system_id = aws_efs_file_system.this.id | ||
subnet_id = var.public_subnets[count.index] | ||
security_groups = [ | ||
module.efs_sg.this_security_group_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
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
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
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 |
---|---|---|
@@ -1,34 +1,37 @@ | ||
resource "aws_security_group" "this" { | ||
module "ec2_sg" { | ||
source = "terraform-aws-modules/security-group/aws" | ||
|
||
name = var.name | ||
description = "${var.name} security group" | ||
vpc_id = var.vpc_id | ||
|
||
ingress { | ||
protocol = "6" | ||
from_port = 80 | ||
to_port = 80 | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
ingress_with_source_security_group_id = var.ingress_with_source_security_group_id | ||
|
||
dynamic "ingress" { | ||
for_each = var.pritunl_sg_rules | ||
ingress_with_cidr_blocks = var.ingress_with_cidr_blocks | ||
|
||
content { | ||
protocol = ingress.value["protocol"] | ||
from_port = ingress.value["from_port"] | ||
to_port = ingress.value["to_port"] | ||
cidr_blocks = ingress.value["cidr_blocks"] | ||
egress_with_cidr_blocks = [ | ||
{ | ||
protocol = "-1" | ||
from_port = 0 | ||
to_port = 0 | ||
cidr_blocks = "0.0.0.0/0" | ||
} | ||
} | ||
] | ||
} | ||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
module "efs_sg" { | ||
source = "terraform-aws-modules/security-group/aws" | ||
|
||
tags = { | ||
Name = "${var.name} security group" | ||
} | ||
name = "${var.name}-efs" | ||
description = "${var.name} efs security group" | ||
vpc_id = var.vpc_id | ||
|
||
ingress_with_source_security_group_id = [ | ||
{ | ||
protocol = "6" | ||
from_port = 2049 | ||
to_port = 2049 | ||
source_security_group_id = module.ec2_sg.this_security_group_id | ||
} | ||
] | ||
} |
Oops, something went wrong.