Skip to content

Commit 3a52aa2

Browse files
standardization for v1.0
1 parent c6f7099 commit 3a52aa2

File tree

11 files changed

+114
-128
lines changed

11 files changed

+114
-128
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright 2023 SquareOps Technologies Pvt. Ltd.
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 58 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,76 @@
11

22
# AWS Network Terraform module
33

4+
![squareops_avatar]
5+
6+
[squareops_avatar]: https://squareops.com/img/home1/Squareops_logo.jpg
7+
8+
### [SquareOps Technologies](https://squareops.com/) Provide end to end solution for all your DevOps needs
9+
10+
<br>
11+
12+
413
Terraform module to create Networking resources for workload deployment on AWS Cloud.
514

15+
<br>
16+
617
## Usage Example
718

819
```hcl
20+
21+
module "key_pair_vpn" {
22+
source = "squareops/terraform-aws-ec2-keypair"
23+
region = us-east-1
24+
environment = production
25+
key_name = format("%s-%s-vpn", production, skaf)
26+
ssm_parameter_path = format("%s-%s-vpn", production, skaf)
27+
}
28+
29+
930
module "vpc" {
10-
source = "git@gitlab.com:squareops/sal/terraform/aws/network.git?ref=qa"
11-
12-
environment = "dev"
13-
name = "skaf"
14-
region = "us-east-1"
15-
vpc_cidr = "10.0.0.0/16"
16-
azs = ["us-east-1a", "us-east-1b"]
17-
enable_public_subnet = true
31+
source = "squareops/terraform-aws-network"
32+
33+
environment = "production"
34+
name = "skaf"
35+
region = "us-east-1"
36+
vpc_cidr = "10.0.0.0/16"
37+
azs = ["us-east-1a", "us-east-1b"]
38+
enable_public_subnet = true
39+
enable_private_subnet = true
40+
enable_database_subnet = true
41+
enable_intra_subnet = true
42+
one_nat_gateway_per_az = true
43+
vpn_server_enabled = true
44+
vpn_server_instance_type = "t3a.small"
45+
vpn_key_pair = module.key_pair_vpn.key_pair_name
46+
enable_flow_log = true
47+
flow_log_max_aggregation_interval = 60
48+
flow_log_cloudwatch_log_group_retention_in_days = 90
49+
1850
}
1951
52+
2053
```
21-
Refer [examples](https://gitlab.com/squareops/sal/terraform/aws/network/-/tree/qa/examples) directory for more references.
54+
Refer [examples](examples) for all examples.
55+
2256
## Important Note
23-
To prevent destruction interruptions, any extra LBs or resources that have been created outside of Terraform and attached to the Terraform resources must be deleted before the module is destroyed.
57+
To prevent destruction interruptions, any resources that have been created outside of Terraform and attached to the resources provisioned by Terraform must be deleted before the module is destroyed.
2458

2559
## Network Scenarios
2660

27-
Users need to provide `vpc_cidr` and subnets are calculated with the help of [in-built functions](https://gitlab.com/squareops/sal/terraform/aws/network/-/blob/qa/main.tf#L2).
61+
Users need to declare `vpc_cidr` and subnets are calculated with the help of in-built functions.
2862

29-
This module supports three scenarios for creating Network resource on AWS. Each will be explained in detail in the corresponding sections.
63+
This module supports three scenarios to create Network resource on AWS. Each will be explained in brief in the corresponding sections.
3064

31-
- **simple-vpc (default behavior):** For creating a VPC with only public subnets and IGW.
65+
- **simple-vpc (default behavior):** To create a VPC with public subnets and IGW.
3266
- `vpc_cidr = ""`
3367
- `enable_public_subnet = true`
34-
- **vpc-with-private-sub:** For creating a VPC with both public and private subnets and IGW and NAT gateway.
68+
- **vpc-with-private-sub:** To create a VPC with public subnets, private subnets, IGW gateway and NAT gateway.
3569
- `vpc_cidr = local.vpc_cidr`
3670
- `enable_public_subnet = true`
3771
- `enable_private_subnet = true`
3872

39-
- **complete-vpc-with-vpn:** For creating a VPC with public, private, database and intra subnets along with an IGW and NAT gateway. Jump server/Bastion Host is also configured.
73+
- **complete-vpc-with-vpn:** To create a VPC with public, private, database and intra subnets along with an IGW and NAT gateway. Jump server/Bastion Host is also configured.
4074
- `vpc_cidr = local.vpc_cidr`
4175
- `enable_public_subnet = true`
4276
- `enable_private_subnet = true`
@@ -50,6 +84,12 @@ This module supports three scenarios for creating Network resource on AWS. Each
5084
- `flow_log_max_aggregation_interval = 60`
5185
- `flow_log_cloudwatch_log_group_retention_in_days = 90`
5286

87+
88+
# IAM Permissions
89+
The required IAM permissions to create resources from this module can be found [here](https://github.com/squareops/terraform-aws-network/blob/main/IAM.md)
90+
91+
92+
5393
# VPN setup-
5494

5595
To configure Pritunl VPN:
@@ -83,73 +123,6 @@ server administration ports (Automated)
83123
(Automated)
84124

85125

86-
<!-- BEGIN_TF_DOCS -->
87-
## Requirements
88-
89-
| Name | Version |
90-
|------|---------|
91-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
92-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.23 |
93-
94-
## Providers
95-
96-
| Name | Version |
97-
|------|---------|
98-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.31.0 |
99-
100-
## Modules
101-
102-
| Name | Source | Version |
103-
|------|--------|---------|
104-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | 3.14.4 |
105-
| <a name="module_vpn_server"></a> [vpn\_server](#module\_vpn\_server) | ./modules/vpn | n/a |
106-
107-
## Resources
108-
109-
| Name | Type |
110-
|------|------|
111-
| [aws_ec2_instance_type.arch](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ec2_instance_type) | data source |
112-
113-
## Inputs
114-
115-
| Name | Description | Type | Default | Required |
116-
|------|-------------|------|---------|:--------:|
117-
| <a name="input_azs"></a> [azs](#input\_azs) | List of Availability Zone to be used by VPC | `list(any)` | n/a | yes |
118-
| <a name="input_database_subnet_cidrs"></a> [database\_subnet\_cidrs](#input\_database\_subnet\_cidrs) | Database Tier subnet CIDRs to be created | `list(any)` | `[]` | no |
119-
| <a name="input_default_network_acl_ingress"></a> [default\_network\_acl\_ingress](#input\_default\_network\_acl\_ingress) | List of maps of ingress rules to set on the Default Network ACL | `list(map(string))` | <pre>[<br> {<br> "action": "deny",<br> "cidr_block": "0.0.0.0/0",<br> "from_port": 22,<br> "protocol": "tcp",<br> "rule_no": 98,<br> "to_port": 22<br> },<br> {<br> "action": "deny",<br> "cidr_block": "0.0.0.0/0",<br> "from_port": 3389,<br> "protocol": "tcp",<br> "rule_no": 99,<br> "to_port": 3389<br> },<br> {<br> "action": "allow",<br> "cidr_block": "0.0.0.0/0",<br> "from_port": 0,<br> "protocol": "-1",<br> "rule_no": 100,<br> "to_port": 0<br> },<br> {<br> "action": "allow",<br> "from_port": 0,<br> "ipv6_cidr_block": "::/0",<br> "protocol": "-1",<br> "rule_no": 101,<br> "to_port": 0<br> }<br>]</pre> | no |
120-
| <a name="input_enable_database_subnet"></a> [enable\_database\_subnet](#input\_enable\_database\_subnet) | Set true to enable database subnets | `bool` | `false` | no |
121-
| <a name="input_enable_flow_log"></a> [enable\_flow\_log](#input\_enable\_flow\_log) | Whether or not to enable VPC Flow Logs | `bool` | `false` | no |
122-
| <a name="input_enable_intra_subnet"></a> [enable\_intra\_subnet](#input\_enable\_intra\_subnet) | Set true to enable intra subnets | `bool` | `false` | no |
123-
| <a name="input_enable_private_subnet"></a> [enable\_private\_subnet](#input\_enable\_private\_subnet) | Set true to enable private subnets | `bool` | `false` | no |
124-
| <a name="input_enable_public_subnet"></a> [enable\_public\_subnet](#input\_enable\_public\_subnet) | Set true to enable public subnets | `bool` | `false` | no |
125-
| <a name="input_environment"></a> [environment](#input\_environment) | Specify the environment indentifier for the VPC | `string` | n/a | yes |
126-
| <a name="input_flow_log_cloudwatch_log_group_retention_in_days"></a> [flow\_log\_cloudwatch\_log\_group\_retention\_in\_days](#input\_flow\_log\_cloudwatch\_log\_group\_retention\_in\_days) | Specifies the number of days you want to retain log events in the specified log group for VPC flow logs. | `number` | `null` | no |
127-
| <a name="input_flow_log_max_aggregation_interval"></a> [flow\_log\_max\_aggregation\_interval](#input\_flow\_log\_max\_aggregation\_interval) | The maximum interval of time during which a flow of packets is captured and aggregated into a flow log record. Valid Values: `60` seconds or `600` seconds. | `number` | `60` | no |
128-
| <a name="input_intra_subnet_cidrs"></a> [intra\_subnet\_cidrs](#input\_intra\_subnet\_cidrs) | A list of intra subnets CIDR to be created | `list(any)` | `[]` | no |
129-
| <a name="input_name"></a> [name](#input\_name) | Specify the name of the VPC | `string` | n/a | yes |
130-
| <a name="input_one_nat_gateway_per_az"></a> [one\_nat\_gateway\_per\_az](#input\_one\_nat\_gateway\_per\_az) | Set to true if a NAT Gateway is required per availability zone for Private Subnet Tier | `bool` | `false` | no |
131-
| <a name="input_private_subnet_cidrs"></a> [private\_subnet\_cidrs](#input\_private\_subnet\_cidrs) | A list of private subnets CIDR to be created inside the VPC | `list(any)` | `[]` | no |
132-
| <a name="input_public_subnet_cidrs"></a> [public\_subnet\_cidrs](#input\_public\_subnet\_cidrs) | A list of public subnets CIDR to be created inside the VPC | `list(any)` | `[]` | no |
133-
| <a name="input_region"></a> [region](#input\_region) | Specify the region in which VPC will be created | `string` | `"us-east-1"` | no |
134-
| <a name="input_vpc_cidr"></a> [vpc\_cidr](#input\_vpc\_cidr) | The CIDR block of the VPC | `string` | `"10.0.0.0/16"` | no |
135-
| <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 |
136-
| <a name="input_vpn_server_enabled"></a> [vpn\_server\_enabled](#input\_vpn\_server\_enabled) | Set to true if you want to deploy VPN Gateway resource and attach it to the VPC | `bool` | `false` | no |
137-
| <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 |
138-
139-
## Outputs
140-
141-
| Name | Description |
142-
|------|-------------|
143-
| <a name="output_database_subnets"></a> [database\_subnets](#output\_database\_subnets) | List of IDs of database subnets |
144-
| <a name="output_intra_subnets"></a> [intra\_subnets](#output\_intra\_subnets) | Intra Subnet IDs |
145-
| <a name="output_private_subnets"></a> [private\_subnets](#output\_private\_subnets) | List of IDs of private subnets |
146-
| <a name="output_public_subnets"></a> [public\_subnets](#output\_public\_subnets) | List of IDs of public subnets |
147-
| <a name="output_region"></a> [region](#output\_region) | AWS Region for the VPC |
148-
| <a name="output_vpc_cidr_block"></a> [vpc\_cidr\_block](#output\_vpc\_cidr\_block) | IPV4 CIDR Block for this VPC |
149-
| <a name="output_vpc_id"></a> [vpc\_id](#output\_vpc\_id) | The ID of the VPC |
150-
| <a name="output_vpn_host_public_ip"></a> [vpn\_host\_public\_ip](#output\_vpn\_host\_public\_ip) | IP Address of VPN Server |
151-
| <a name="output_vpn_security_group"></a> [vpn\_security\_group](#output\_vpn\_security\_group) | Security Group ID of VPN Server |
152-
<!-- END_TF_DOCS -->
153126
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
154127
## Requirements
155128

@@ -217,3 +190,6 @@ server administration ports (Automated)
217190
| <a name="output_vpn_host_public_ip"></a> [vpn\_host\_public\_ip](#output\_vpn\_host\_public\_ip) | IP Address of VPN Server |
218191
| <a name="output_vpn_security_group"></a> [vpn\_security\_group](#output\_vpn\_security\_group) | Security Group ID of VPN Server |
219192
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
193+
194+
195+

examples/complete-vpc-with-vpn/README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
# complete-vpc-with-vpn
1+
# Complete VPC with VPN
2+
3+
This configuration is suitable for production environments
4+
5+
A NAT Gateway, Public and Private subnet will be created per availability zone.
6+
7+
8+
## Usage
9+
10+
To run this example you need to execute:
11+
12+
```bash
13+
$ terraform init
14+
$ terraform plan
15+
$ terraform apply
16+
```
17+
18+
Note that this example may create resources which can cost money (AWS Elastic IP, for example). Run `terraform destroy` when you don't need these resources.
19+
220

321
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
422
## Requirements
@@ -43,3 +61,5 @@ No inputs.
4361
| <a name="output_vpn_host_public_ip"></a> [vpn\_host\_public\_ip](#output\_vpn\_host\_public\_ip) | IP Adress of VPN Server |
4462
| <a name="output_vpn_security_group"></a> [vpn\_security\_group](#output\_vpn\_security\_group) | Security Group ID of VPN Server |
4563
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
64+
65+

examples/complete-vpc-with-vpn/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ data "aws_region" "current" {}
1414
data "aws_availability_zones" "available" {}
1515

1616
module "key_pair_vpn" {
17-
source = "git@gitlab.com:squareops/sal/terraform/aws/ec2-keypair.git?ref=qa"
17+
source = "squareops/terraform-aws-ec2-keypair"
1818
region = local.region
1919
environment = local.environment
2020
key_name = format("%s-%s-vpn", local.environment, local.name)
2121
ssm_parameter_path = format("%s-%s-vpn", local.environment, local.name)
2222
}
2323

2424
module "vpc" {
25-
source = "git@gitlab.com:squareops/sal/terraform/aws/network.git?ref=qa"
25+
source = "squareops/terraform-aws-network"
2626

2727
environment = local.environment
2828
name = local.name
@@ -33,7 +33,7 @@ module "vpc" {
3333
enable_private_subnet = true
3434
enable_database_subnet = true
3535
enable_intra_subnet = true
36-
one_nat_gateway_per_az = false
36+
one_nat_gateway_per_az = true
3737
vpn_server_enabled = true
3838
vpn_server_instance_type = "t3a.small"
3939
vpn_key_pair = module.key_pair_vpn.key_pair_name

examples/simple-vpc/README.md

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,6 @@ $ terraform apply
1818

1919
Note that this example may create resources which can cost money (AWS Elastic IP, for example). Run `terraform destroy` when you don't need these resources.
2020

21-
<!-- BEGIN_TF_DOCS -->
22-
## Requirements
23-
24-
| Name | Version |
25-
|------|---------|
26-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
27-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.63 |
28-
29-
## Providers
30-
31-
No providers.
32-
33-
## Modules
34-
35-
| Name | Source | Version |
36-
|------|--------|---------|
37-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | ../../ | n/a |
38-
39-
## Resources
40-
41-
No resources.
42-
43-
## Inputs
44-
45-
No inputs.
46-
47-
## Outputs
48-
49-
| Name | Description |
50-
|------|-------------|
51-
| <a name="output_private_subnets"></a> [private\_subnets](#output\_private\_subnets) | List of IDs of private subnets |
52-
| <a name="output_public_subnets"></a> [public\_subnets](#output\_public\_subnets) | List of IDs of public subnets |
53-
| <a name="output_region"></a> [region](#output\_region) | AWS Region |
54-
| <a name="output_vpc_cidr_block"></a> [vpc\_cidr\_block](#output\_vpc\_cidr\_block) | AWS Region |
55-
| <a name="output_vpc_id"></a> [vpc\_id](#output\_vpc\_id) | The ID of the VPC |
56-
<!-- END_TF_DOCS -->
5721
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
5822
## Requirements
5923

examples/simple-vpc/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ data "aws_availability_zones" "available" {}
1818
################################################################################
1919

2020
module "vpc" {
21-
source = "../../"
21+
source = "squareops/terraform-aws-network"
2222

2323
environment = local.environment
2424
name = local.name

examples/vpc-with-private-sub/README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
# vpc-with-private-sub
1+
# VPC with Private Subnets
2+
3+
4+
A public and private subnet will be created per availability zone in addition to single NAT Gateway shared between all availability zones.
5+
6+
## Usage
7+
8+
To run this example you need to execute:
9+
10+
```bash
11+
$ terraform init
12+
$ terraform plan
13+
$ terraform apply
14+
```
15+
16+
Note that this example may create resources which can cost money (AWS Elastic IP, for example). Run `terraform destroy` when you don't need these resources.
17+
218

319
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
420
## Requirements

examples/vpc-with-private-sub/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ data "aws_region" "current" {}
1414
data "aws_availability_zones" "available" {}
1515

1616
module "vpc" {
17-
source = "git@gitlab.com:squareops/sal/terraform/aws/network.git?ref=qa"
17+
source = "squareops/terraform-aws-network"
1818

1919
environment = local.environment
2020
name = local.name

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ data "aws_ec2_instance_type" "arch" {
1515

1616
module "vpc" {
1717
source = "terraform-aws-modules/vpc/aws"
18-
version = "3.14.4"
18+
version = "1.0.0"
1919
name = format("%s-%s-vpc", var.environment, var.name)
2020
cidr = var.vpc_cidr # CIDR FOR VPC
2121
azs = var.azs

modules/vpn/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# VPN
22

3+
Terraform module to create Pritunl VPN server on AWS.
4+
5+
Pritunl is an VPN software with features including but not limited to:
6+
- Open Source
7+
- Supports multiple protocols
8+
- Supports Single Sign-On
9+
- Highly secure
10+
11+
Refer [this](https://pritunl.com/) for more information.
12+
313
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
414
## Requirements
515

0 commit comments

Comments
 (0)