Skip to content

Commit 053ba95

Browse files
committed
Changes made in variables.
1 parent 0c9bc0d commit 053ba95

File tree

8 files changed

+50
-46
lines changed

8 files changed

+50
-46
lines changed

README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,30 @@ module "vpc" {
2929
ipv6_enabled = true
3030
create_ipam_pool = false
3131
ipam_enabled = false
32-
flow_log_enabled = true
33-
vpn_key_pair_name = module.key_pair_vpn.key_pair_name
34-
availability_zones = ["us-east-1a", "us-east-1b"]
32+
vpc_flow_log_enabled = true
33+
vpn_server_key_pair_name = module.key_pair_vpn.key_pair_name
34+
vpc_availability_zones = ["us-east-1a", "us-east-1b"]
3535
vpn_server_enabled = false
36-
intra_subnet_enabled = true
36+
vpc_intra_subnet_enabled = true
3737
auto_assign_public_ip = true
38-
public_subnet_enabled = true
39-
private_subnet_enabled = true
40-
one_nat_gateway_per_az = true
41-
database_subnet_enabled = true
38+
vpc_public_subnet_enabled = true
39+
vpc_private_subnet_enable = true
40+
vpc_one_nat_gateway_per_az = true
41+
vpc_database_subnet_enabled = true
4242
vpn_server_instance_type = "t3a.small"
43+
vpc_public_subnets_counts = 2
44+
vpc_private_subnets_counts = 2
45+
vpc_database_subnets_counts = 2
46+
vpc_intra_subnets_counts = 2
47+
vpc_endpoint_type_private_s3 = "Gateway"
48+
vpc_endpoint_type_ecr_dkr = "Interface"
49+
vpc_endpoint_type_ecr_api = "Interface"
4350
vpc_s3_endpoint_enabled = true
4451
vpc_ecr_endpoint_enabled = true
45-
flow_log_max_aggregation_interval = 60
46-
flow_log_cloudwatch_log_group_skip_destroy = true
47-
flow_log_cloudwatch_log_group_retention_in_days = 90
48-
flow_log_cloudwatch_log_group_kms_key_arn = "arn:aws:kms:us-east-2:222222222222:key/kms_key_arn" #Enter your kms key arn
52+
vpc_flow_log_max_aggregation_interval = 60
53+
vpc_flow_log_cloudwatch_log_group_skip_destroy = true
54+
vpc_flow_log_cloudwatch_log_group_retention_in_days = 90
55+
vpc_flow_log_cloudwatch_log_group_kms_key_arn = "arn:aws:kms:us-east-2:222222222222:key/kms_key_arn" #Enter your kms key arn
4956
}
5057
```
5158
Refer [this](https://github.com/squareops/terraform-aws-vpc/tree/main/examples) for more examples.

modules/vpc_peering/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ No modules.
5858
| Name | Description | Type | Default | Required |
5959
|------|-------------|------|---------|:--------:|
6060
| <a name="input_vpc_peering_accepter_aws_profile"></a> [vpc\_peering\_accepter\_aws\_profile](#input\_vpc\_peering\_accepter\_aws\_profile) | Provide the AWS profile where the accepter VPC is located. | `string` | `""` | no |
61+
| <a name="input_vpc_peering_accepter_id"></a> [vpc\_peering\_accepter\_id](#input\_vpc\_peering\_accepter\_id) | Specify the unique identifier of the VPC that will act as the Acceptor in the VPC peering connection. | `string` | `""` | no |
6162
| <a name="input_vpc_peering_accepter_name"></a> [vpc\_peering\_accepter\_name](#input\_vpc\_peering\_accepter\_name) | Assign a meaningful name or label to the VPC Accepter. This aids in distinguishing the Accepter VPC within the VPC peering connection. | `string` | `""` | no |
62-
| <a name="input_vpc_peering_accepter_vpc_id"></a> [vpc\_peering\_accepter\_vpc\_id](#input\_vpc\_peering\_accepter\_vpc\_id) | Specify the unique identifier of the VPC that will act as the Acceptor in the VPC peering connection. | `string` | `""` | no |
63-
| <a name="input_vpc_peering_accepter_vpc_region"></a> [vpc\_peering\_accepter\_vpc\_region](#input\_vpc\_peering\_accepter\_vpc\_region) | Provide the AWS region where the Acceptor VPC is located. This helps in identifying the correct region for establishing the VPC peering connection. | `string` | `""` | no |
63+
| <a name="input_vpc_peering_accepter_region"></a> [vpc\_peering\_accepter\_region](#input\_vpc\_peering\_accepter\_region) | Provide the AWS region where the Acceptor VPC is located. This helps in identifying the correct region for establishing the VPC peering connection. | `string` | `""` | no |
6464
| <a name="input_vpc_peering_enabled"></a> [vpc\_peering\_enabled](#input\_vpc\_peering\_enabled) | Set this variable to true if you want to create the VPC peering connection. Set it to false if you want to skip the creation process. | `bool` | `true` | no |
6565
| <a name="input_vpc_peering_multi_account_enabled"></a> [vpc\_peering\_multi\_account\_enabled](#input\_vpc\_peering\_multi\_account\_enabled) | Set this variable to true if you want to create the VPC peering connection between reagions. Set it to false if you want to skip the creation process. | `bool` | `true` | no |
6666
| <a name="input_vpc_peering_requester_aws_profile"></a> [vpc\_peering\_requester\_aws\_profile](#input\_vpc\_peering\_requester\_aws\_profile) | Provide the AWS profile where the requester VPC is located. | `string` | `""` | no |
67+
| <a name="input_vpc_peering_requester_id"></a> [vpc\_peering\_requester\_id](#input\_vpc\_peering\_requester\_id) | Specify the unique identifier of the VPC that will act as the Reqester in the VPC peering connection. | `string` | `""` | no |
6768
| <a name="input_vpc_peering_requester_name"></a> [vpc\_peering\_requester\_name](#input\_vpc\_peering\_requester\_name) | Provide a descriptive name or label for the VPC Requester. This helps identify and differentiate the Requester VPC in the peering connection. | `string` | `""` | no |
68-
| <a name="input_vpc_peering_requester_vpc_id"></a> [vpc\_peering\_requester\_vpc\_id](#input\_vpc\_peering\_requester\_vpc\_id) | Specify the unique identifier of the VPC that will act as the Reqester in the VPC peering connection. | `string` | `""` | no |
69-
| <a name="input_vpc_peering_requester_vpc_region"></a> [vpc\_peering\_requester\_vpc\_region](#input\_vpc\_peering\_requester\_vpc\_region) | Specify the AWS region where the Requester VPC resides. It ensures the correct region is used for setting up the VPC peering. | `string` | `""` | no |
69+
| <a name="input_vpc_peering_requester_region"></a> [vpc\_peering\_requester\_region](#input\_vpc\_peering\_requester\_region) | Specify the AWS region where the Requester VPC resides. It ensures the correct region is used for setting up the VPC peering. | `string` | `""` | no |
7070

7171
## Outputs
7272

modules/vpc_peering/main.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,33 @@ locals {
55

66
provider "aws" {
77
alias = "peer"
8-
region = var.vpc_peering_requester_vpc_region
8+
region = var.vpc_peering_requester_region
99
profile = var.vpc_peering_multi_account_enabled ? var.vpc_peering_requester_aws_profile : "default"
1010
}
1111

1212
provider "aws" {
1313
alias = "accepter"
14-
region = var.vpc_peering_accepter_vpc_region
14+
region = var.vpc_peering_accepter_region
1515
profile = var.vpc_peering_multi_account_enabled ? var.vpc_peering_accepter_aws_profile : "default"
1616
}
1717

1818
data "aws_vpc" "accepter" {
19-
id = var.vpc_peering_accepter_vpc_id
19+
id = var.vpc_peering_accepter_id
2020
provider = aws.accepter
2121
}
2222

2323
data "aws_route_tables" "accepter" {
24-
vpc_id = var.vpc_peering_accepter_vpc_id
24+
vpc_id = var.vpc_peering_accepter_id
2525
provider = aws.accepter
2626
}
2727

2828
data "aws_vpc" "requester" {
29-
id = var.vpc_peering_requester_vpc_id
29+
id = var.vpc_peering_requester_id
3030
provider = aws.peer
3131
}
3232

3333
data "aws_route_tables" "requester" {
34-
vpc_id = var.vpc_peering_requester_vpc_id
34+
vpc_id = var.vpc_peering_requester_id
3535
provider = aws.peer
3636
}
3737

@@ -41,9 +41,9 @@ data "aws_caller_identity" "accepter" {
4141

4242
resource "aws_vpc_peering_connection" "this" {
4343
count = var.vpc_peering_enabled ? 1 : 0
44-
vpc_id = var.vpc_peering_requester_vpc_id
45-
peer_vpc_id = var.vpc_peering_accepter_vpc_id
46-
peer_region = var.vpc_peering_multi_account_enabled ? var.vpc_peering_accepter_vpc_region : null
44+
vpc_id = var.vpc_peering_requester_id
45+
peer_vpc_id = var.vpc_peering_accepter_id
46+
peer_region = var.vpc_peering_multi_account_enabled ? var.vpc_peering_accepter_region : null
4747
auto_accept = false
4848
peer_owner_id = var.vpc_peering_multi_account_enabled ? data.aws_caller_identity.accepter.id : null
4949
provider = aws.peer

modules/vpc_peering/variables.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
variable "vpc_peering_accepter_vpc_id" {
1+
variable "vpc_peering_accepter_id" {
22
type = string
33
description = "Specify the unique identifier of the VPC that will act as the Acceptor in the VPC peering connection."
44
default = ""
55
}
66

7-
variable "vpc_peering_accepter_vpc_region" {
7+
variable "vpc_peering_accepter_region" {
88
type = string
99
description = "Provide the AWS region where the Acceptor VPC is located. This helps in identifying the correct region for establishing the VPC peering connection."
1010
default = ""
1111
}
1212

13-
variable "vpc_peering_requester_vpc_id" {
13+
variable "vpc_peering_requester_id" {
1414
type = string
1515
description = "Specify the unique identifier of the VPC that will act as the Reqester in the VPC peering connection."
1616
default = ""
1717
}
1818

19-
variable "vpc_peering_requester_vpc_region" {
19+
variable "vpc_peering_requester_region" {
2020
type = string
2121
description = "Specify the AWS region where the Requester VPC resides. It ensures the correct region is used for setting up the VPC peering."
2222
default = ""

modules/vpn/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ Refer [this](https://pritunl.com/) for more information.
5252
| [aws_ami.ubuntu_20_ami](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami) | data source |
5353
| [aws_iam_policy.SSMManagedInstanceCore](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source |
5454
| [aws_iam_policy.SecretsManagerReadWrite](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source |
55-
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
5655
| [template_file.pritunl](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |
5756

5857
## Inputs
5958

6059
| Name | Description | Type | Default | Required |
6160
|------|-------------|------|---------|:--------:|
61+
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | Name of the AWS region where S3 bucket is to be created. | `string` | `""` | no |
6262
| <a name="input_environment"></a> [environment](#input\_environment) | Specify the environment indentifier for the VPC | `string` | `""` | no |
6363
| <a name="input_name"></a> [name](#input\_name) | Specify the name of the VPC | `string` | `""` | no |
64-
| <a name="input_public_subnet"></a> [public\_subnet](#input\_public\_subnet) | The VPC Subnet ID to launch in | `string` | `""` | no |
64+
| <a name="input_public_subnet_ids"></a> [public\_subnet\_ids](#input\_public\_subnet\_ids) | The VPC Subnet ID to launch in | `string` | `""` | no |
6565
| <a name="input_vpc_cidr"></a> [vpc\_cidr](#input\_vpc\_cidr) | The CIDR block of the Default VPC | `string` | `"10.0.0.0/16"` | no |
6666
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The ID of the VPC | `string` | `""` | no |
67-
| <a name="input_vpn_key_pair"></a> [vpn\_key\_pair](#input\_vpn\_key\_pair) | Specify the name of AWS Keypair to be used for VPN Server | `string` | `""` | no |
67+
| <a name="input_vpn_key_pair_name"></a> [vpn\_key\_pair\_name](#input\_vpn\_key\_pair\_name) | Specify the name of AWS Keypair to be used for VPN Server | `string` | `""` | no |
6868
| <a name="input_vpn_server_instance_type"></a> [vpn\_server\_instance\_type](#input\_vpn\_server\_instance\_type) | EC2 instance Type for VPN Server, Only amd64 based instance type are supported eg. t2.medium, t3.micro, c5a.large etc. | `string` | `"t3a.small"` | no |
6969

7070
## Outputs

modules/vpn/main.tf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,14 @@ data "template_file" "pritunl" {
7979
template = file("${path.module}/scripts/pritunl-vpn.sh")
8080
}
8181

82-
data "aws_region" "current" {}
83-
8482
module "vpn_server" {
8583
source = "terraform-aws-modules/ec2-instance/aws"
8684
version = "5.6.0"
8785
name = format("%s-%s-%s", var.environment, var.name, "vpn-ec2-instance")
8886
ami = data.aws_ami.ubuntu_20_ami.image_id
8987
instance_type = var.vpn_server_instance_type
90-
subnet_id = var.public_subnet
91-
key_name = var.vpn_key_pair
88+
subnet_id = var.public_subnet_ids
89+
key_name = var.vpn_key_pair_name
9290
associate_public_ip_address = true
9391
vpc_security_group_ids = [module.security_group_vpn.security_group_id]
9492
user_data = join("", data.template_file.pritunl[*].rendered)
@@ -195,7 +193,7 @@ resource "aws_ssm_document" "vpn_ssm_document" {
195193
"PASSWORD=$(sudo pritunl default-password | grep password | awk '{ print $2 }' | tail -n1)",
196194
"sleep 60",
197195
"VPN_HOST=${aws_eip.vpn.public_ip}",
198-
"aws secretsmanager create-secret --region ${data.aws_region.current.name} --name ${var.environment}-${var.name}-vpnp --secret-string \"{\\\"user\\\": \\\"pritunl\\\", \\\"password\\\": $PASSWORD, \\\"setup-key\\\": \\\"$SETUPKEY\\\", \\\"vpn_host\\\": \\\"$VPN_HOST\\\"}\""
196+
"aws secretsmanager create-secret --region ${var.aws_region} --name ${var.environment}-${var.name}-vpnp --secret-string \"{\\\"user\\\": \\\"pritunl\\\", \\\"password\\\": $PASSWORD, \\\"setup-key\\\": \\\"$SETUPKEY\\\", \\\"vpn_host\\\": \\\"$VPN_HOST\\\"}\""
199197
]
200198
}
201199
}
@@ -208,7 +206,7 @@ resource "null_resource" "vpn_delete_secret" {
208206
triggers = {
209207
environment = var.environment
210208
name = var.name
211-
region = data.aws_region.current.name
209+
region = var.aws_region
212210
}
213211
provisioner "local-exec" {
214212
when = destroy

modules/vpn/variables.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
variable "aws_region" {
2+
description = "Name of the AWS region where S3 bucket is to be created."
3+
default = ""
4+
type = string
5+
}
16

27
variable "vpn_server_instance_type" {
38
description = "EC2 instance Type for VPN Server, Only amd64 based instance type are supported eg. t2.medium, t3.micro, c5a.large etc. "
@@ -17,7 +22,7 @@ variable "name" {
1722
type = string
1823
}
1924

20-
variable "public_subnet" {
25+
variable "public_subnet_ids" {
2126
description = "The VPC Subnet ID to launch in"
2227
default = ""
2328
type = string
@@ -35,7 +40,7 @@ variable "vpc_id" {
3540
type = string
3641
}
3742

38-
variable "vpn_key_pair" {
43+
variable "vpn_key_pair_name" {
3944
description = "Specify the name of AWS Keypair to be used for VPN Server"
4045
default = ""
4146
type = string

providers.tf

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)