Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/release01 for AWS Multi Account VPC Peering #22

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
5842dca
Add files via upload
rachit89 Mar 13, 2024
243d7a5
Add files via upload
rachit89 Mar 14, 2024
ddb9dc2
Add files via upload
rachit89 Mar 14, 2024
203e8c5
Add files via upload
rachit89 Mar 14, 2024
51e3271
Add files via upload
rachit89 Mar 14, 2024
bac5267
Add files via upload
rachit89 Mar 15, 2024
ef9535f
Update main.tf
rachit89 Mar 18, 2024
4db8ba6
Update variables.tf
rachit89 Mar 18, 2024
478b87d
Update main.tf
rachit89 Mar 18, 2024
543faae
Modified Example
rachit89 Mar 18, 2024
3f51851
Changes for subnet & security rules
rachit89 Mar 18, 2024
d41708f
Update main.tf
rachit89 Mar 18, 2024
1c9109d
Added example of AWS multi account vpc peering
rachit89 Mar 21, 2024
0c9bc0d
Modified Variables & upgraded version of vpn modules and vpn security…
rachit89 Mar 29, 2024
053ba95
Changes made in variables.
rachit89 Apr 2, 2024
df2f828
Merge branch 'main' into feature/release01
rachit89 Apr 5, 2024
7945a3f
Merge pull request #3 from rachit89/feature/release01
rachit89 Apr 5, 2024
7f5d87e
Update variables.tf
rachit89 Apr 5, 2024
0db6178
Update variables.tf
rachit89 Apr 5, 2024
dcc438d
Update main.tf
rachit89 Apr 11, 2024
e68791b
Update main.tf for security group for ecr api endpoint
rachit89 Apr 18, 2024
95a1872
Update main.tf
rachit89 Apr 18, 2024
286e84c
Update variables.tf
rachit89 Apr 18, 2024
740128a
Update main.tf
rachit89 Apr 18, 2024
99eff27
Update main.tf
rachit89 Apr 18, 2024
78cbb12
Update main.tf
rachit89 Apr 18, 2024
42d1cb0
Update main.tf
rachit89 Apr 18, 2024
5d60b41
Update main.tf
rachit89 Apr 18, 2024
5717f70
Update main.tf
rachit89 Apr 18, 2024
fa17483
Update main.tf
rachit89 Apr 18, 2024
7334ddb
Merge branch 'main' into main
rachit89 Apr 19, 2024
74a1c5c
Updated
rachit89 Apr 22, 2024
520760b
Updated provider.tf for variable.
rachit89 Apr 22, 2024
b053a17
Merge branch 'main' into feature/release01
rachit89 Apr 22, 2024
34602e0
updated
rachit89 Apr 22, 2024
20a6df8
updated
rachit89 Apr 22, 2024
62f63ca
Merge pull request #4 from rachit89/feature/release01
rachit89 Apr 22, 2024
19d358e
Update main.tf
rachit89 Apr 22, 2024
4fa599f
Merge pull request #26 from rachit89/main
nitin-yadav-sq Apr 22, 2024
81143e9
Update main.tf
rachit89 Apr 23, 2024
1199280
Merge branch 'release-3.4.0' into feature/release01
rachit89 Apr 23, 2024
0e7446a
Update README.md
rachit89 Apr 23, 2024
0aa1f05
Update README.md
rachit89 Apr 23, 2024
06000f2
Update README.md
rachit89 Apr 23, 2024
77ea3b9
Update README.md
rachit89 Apr 23, 2024
95eb23c
Update README.md
rachit89 Apr 23, 2024
2799dca
Update README.md
rachit89 Apr 23, 2024
08d505b
Update README.md
rachit89 Apr 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .pre-commit-config.yaml
100644 → 100755
Empty file.
Empty file modified .tflint.hcl
100644 → 100755
Empty file.
Empty file modified IAM.md
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
119 changes: 72 additions & 47 deletions README.md
100644 → 100755

Large diffs are not rendered by default.

Empty file modified compliance.md
100644 → 100755
Empty file.
7 changes: 3 additions & 4 deletions examples/complete-vpc-with-vpn/README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ No inputs.
| Name | Description |
|------|-------------|
| <a name="output_database_subnets"></a> [database\_subnets](#output\_database\_subnets) | List of IDs of database subnets |
| <a name="output_intra_subnets"></a> [intra\_subnets](#output\_intra\_subnets) | List of IDs of Intra subnets |
| <a name="output_private_subnets"></a> [private\_subnets](#output\_private\_subnets) | List of IDs of private subnets |
| <a name="output_public_subnets"></a> [public\_subnets](#output\_public\_subnets) | List of IDs of public subnets |
| <a name="output_region"></a> [region](#output\_region) | AWS Region |
| <a name="output_vpc_cidr_block"></a> [vpc\_cidr\_block](#output\_vpc\_cidr\_block) | AWS Region |
| <a name="output_vpc_id"></a> [vpc\_id](#output\_vpc\_id) | The ID of the VPC |
| <a name="output_vpc_intra_subnets"></a> [vpc\_intra\_subnets](#output\_vpc\_intra\_subnets) | List of IDs of Intra subnets |
| <a name="output_vpc_private_subnets"></a> [vpc\_private\_subnets](#output\_vpc\_private\_subnets) | List of IDs of private subnets |
| <a name="output_vpc_public_subnets"></a> [vpc\_public\_subnets](#output\_vpc\_public\_subnets) | List of IDs of public subnets |
| <a name="output_vpn_host_public_ip"></a> [vpn\_host\_public\_ip](#output\_vpn\_host\_public\_ip) | IP Adress of VPN Server |
| <a name="output_vpn_security_group"></a> [vpn\_security\_group](#output\_vpn\_security\_group) | Security Group ID of VPN Server |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
109 changes: 69 additions & 40 deletions examples/complete-vpc-with-vpn/main.tf
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,42 +1,64 @@
locals {
name = "vpc"
region = "ap-south-1"
environment = "prod"
vpc_name = "vpc-test"
aws_region = "ap-northeast-1"
aws_account_id = "767398031518"
environment = "prod"
kms_user = null
vpc_cidr = "10.10.0.0/16"
vpc_availability_zones = ["ap-northeast-1a", "ap-northeast-1c"]
kms_deletion_window_in_days = 7
enable_key_rotation = false
is_enabled = true
vpc_flow_log_enabled = false
vpn_server_enabled = true
vpc_intra_subnet_enabled = true
vpc_public_subnet_enabled = true
auto_assign_public_ip = true
vpc_private_subnet_enabled = true
vpc_one_nat_gateway_per_az = true
vpc_database_subnet_enabled = true
vpc_s3_endpoint_enabled = true
vpc_ecr_endpoint_enabled = true
vpn_server_instance_type = "t3a.small"
vpc_flow_log_cloudwatch_log_group_skip_destroy = false
current_identity = data.aws_caller_identity.current.arn
multi_region = false
vpc_public_subnets_counts = 2
vpc_private_subnets_counts = 2
vpc_database_subnets_counts = 2
vpc_intra_subnets_counts = 2
additional_aws_tags = {
Owner = "Organization_Name"
Expires = "Never"
Department = "Engineering"
}
kms_user = null
vpc_cidr = "10.10.0.0/16"
current_identity = data.aws_caller_identity.current.arn
}

data "aws_caller_identity" "current" {}

module "key_pair_vpn" {
source = "squareops/keypair/aws"
key_name = format("%s-%s-vpn", local.environment, local.name)
key_name = format("%s-%s-vpn", local.environment, local.vpc_name)
environment = local.environment
ssm_parameter_path = format("%s-%s-vpn", local.environment, local.name)
ssm_parameter_path = format("%s-%s-vpn", local.environment, local.vpc_name)
}

module "kms" {
source = "terraform-aws-modules/kms/aws"

deletion_window_in_days = 7
deletion_window_in_days = local.kms_deletion_window_in_days
description = "Symetric Key to Enable Encryption at rest using KMS services."
enable_key_rotation = false
is_enabled = true
enable_key_rotation = local.enable_key_rotation
is_enabled = local.is_enabled
key_usage = "ENCRYPT_DECRYPT"
multi_region = false
multi_region = local.multi_region

# Policy
enable_default_policy = true
key_owners = [local.current_identity]
key_administrators = local.kms_user == null ? ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling", "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/aws-service-role/eks.amazonaws.com/AWSServiceRoleForAmazonEKS", local.current_identity] : local.kms_user
key_users = local.kms_user == null ? ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling", "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/aws-service-role/eks.amazonaws.com/AWSServiceRoleForAmazonEKS", local.current_identity] : local.kms_user
key_service_users = local.kms_user == null ? ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling", "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/aws-service-role/eks.amazonaws.com/AWSServiceRoleForAmazonEKS", local.current_identity] : local.kms_user
key_administrators = local.kms_user == null ? ["arn:aws:iam::${local.aws_account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling", "arn:aws:iam::${local.aws_account_id}:role/aws-service-role/eks.amazonaws.com/AWSServiceRoleForAmazonEKS", local.current_identity] : local.kms_user
key_users = local.kms_user == null ? ["arn:aws:iam::${local.aws_account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling", "arn:aws:iam::${local.aws_account_id}:role/aws-service-role/eks.amazonaws.com/AWSServiceRoleForAmazonEKS", local.current_identity] : local.kms_user
key_service_users = local.kms_user == null ? ["arn:aws:iam::${local.aws_account_id}:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling", "arn:aws:iam::${local.aws_account_id}:role/aws-service-role/eks.amazonaws.com/AWSServiceRoleForAmazonEKS", local.current_identity] : local.kms_user
key_symmetric_encryption_users = [local.current_identity]
key_hmac_users = [local.current_identity]
key_asymmetric_public_encryption_users = [local.current_identity]
Expand All @@ -57,38 +79,45 @@ module "kms" {
principals = [
{
type = "Service"
identifiers = ["logs.${local.region}.amazonaws.com"]
identifiers = ["logs.${local.aws_region}.amazonaws.com"]
}
]
}
]
# Aliases
aliases = ["${local.name}-KMS"]
aliases = ["${local.vpc_name}-KMS"]
aliases_use_name_prefix = true
}


module "vpc" {
source = "squareops/vpc/aws"
name = local.name
region = local.region
vpc_cidr = local.vpc_cidr
environment = local.environment
flow_log_enabled = true
vpn_key_pair_name = module.key_pair_vpn.key_pair_name
availability_zones = ["ap-south-1a", "ap-south-1b"]
vpn_server_enabled = true
intra_subnet_enabled = true
public_subnet_enabled = true
auto_assign_public_ip = true
private_subnet_enabled = true
one_nat_gateway_per_az = true
database_subnet_enabled = true
vpn_server_instance_type = "t3a.small"
vpc_s3_endpoint_enabled = true
vpc_ecr_endpoint_enabled = true
flow_log_max_aggregation_interval = 60 # In seconds
flow_log_cloudwatch_log_group_skip_destroy = true
flow_log_cloudwatch_log_group_retention_in_days = 90
flow_log_cloudwatch_log_group_kms_key_arn = module.kms.key_arn #Enter your kms key arn
}
source = "../../"
name = local.vpc_name
aws_region = local.aws_region
vpc_cidr = local.vpc_cidr
environment = local.environment
vpc_flow_log_enabled = local.vpc_flow_log_enabled
vpn_server_key_pair_name = module.key_pair_vpn.key_pair_name
vpc_availability_zones = local.vpc_availability_zones
vpn_server_enabled = local.vpn_server_enabled
vpc_intra_subnet_enabled = local.vpc_intra_subnet_enabled
vpc_public_subnet_enabled = local.vpc_public_subnet_enabled
auto_assign_public_ip = local.auto_assign_public_ip
vpc_private_subnet_enabled = local.vpc_private_subnet_enabled
vpc_one_nat_gateway_per_az = local.vpc_one_nat_gateway_per_az
vpc_database_subnet_enabled = local.vpc_database_subnet_enabled
vpn_server_instance_type = local.vpn_server_instance_type
vpc_s3_endpoint_enabled = local.vpc_s3_endpoint_enabled
vpc_ecr_endpoint_enabled = local.vpc_ecr_endpoint_enabled
vpc_flow_log_max_aggregation_interval = 60 # In seconds
vpc_flow_log_cloudwatch_log_group_skip_destroy = local.vpc_flow_log_cloudwatch_log_group_skip_destroy
vpc_flow_log_cloudwatch_log_group_retention_in_days = 90
vpc_flow_log_cloudwatch_log_group_kms_key_arn = module.kms.key_arn #Enter your kms key arn
vpc_public_subnets_counts = local.vpc_public_subnets_counts
vpc_private_subnets_counts = local.vpc_private_subnets_counts
vpc_database_subnets_counts = local.vpc_database_subnets_counts
vpc_intra_subnets_counts = local.vpc_intra_subnets_counts
vpc_endpoint_type_private_s3 = "Gateway"
vpc_endpoint_type_ecr_dkr = "Interface"
vpc_endpoint_type_ecr_api = "Interface"
}
19 changes: 7 additions & 12 deletions examples/complete-vpc-with-vpn/outputs.tf
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
output "region" {
description = "AWS Region"
value = local.region
}

output "vpc_id" {
description = "The ID of the VPC"
value = module.vpc.vpc_id
Expand All @@ -13,24 +8,24 @@ output "vpc_cidr_block" {
value = module.vpc.vpc_cidr_block
}

output "public_subnets" {
output "vpc_public_subnets" {
description = "List of IDs of public subnets"
value = module.vpc.public_subnets
value = module.vpc.vpc_public_subnets
}

output "private_subnets" {
output "vpc_private_subnets" {
description = "List of IDs of private subnets"
value = module.vpc.private_subnets
value = module.vpc.vpc_private_subnets
}

output "database_subnets" {
description = "List of IDs of database subnets"
value = module.vpc.database_subnets
}

output "intra_subnets" {
output "vpc_intra_subnets" {
description = "List of IDs of Intra subnets"
value = module.vpc.intra_subnets
value = module.vpc.vpc_intra_subnets
}

output "vpn_host_public_ip" {
Expand All @@ -41,4 +36,4 @@ output "vpn_host_public_ip" {
output "vpn_security_group" {
description = "Security Group ID of VPN Server"
value = module.vpc.vpn_security_group
}
}
2 changes: 1 addition & 1 deletion examples/complete-vpc-with-vpn/providers.tf
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
provider "aws" {
region = local.region
region = local.aws_region
default_tags {
tags = local.additional_aws_tags
}
Expand Down
Empty file modified examples/ipam-managed-vpc/README.md
100644 → 100755
Empty file.
Empty file modified examples/ipam-managed-vpc/main.tf
100644 → 100755
Empty file.
Empty file modified examples/ipam-managed-vpc/output.tf
100644 → 100755
Empty file.
Empty file modified examples/ipam-managed-vpc/providers.tf
100644 → 100755
Empty file.
25 changes: 25 additions & 0 deletions examples/multi-account-vpc-peering/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
locals {
accepter_name = "tenent-peering"
accepter_region = "us-east-1"
accepter_vpc_id = "vpc-07a2c1d0328341493"
requester_name = "management-peering"
requester_region = "ap-northeast-1"
requester_vpc_id = "vpc-0ce36808b9b133608"
additional_tags = {
Owner = "tenent"
Tenancy = "dedicated"
}
}

module "vpc_peering" {
source = "../../modules/vpc_peering"
accepter_name = local.accepter_name
vpc_peering_accepter_vpc_id = local.accepter_vpc_id
vpc_peering_accepter_vpc_region = local.accepter_region
requester_name = local.requester_name
vpc_peering_requester_vpc_id = local.requester_vpc_id
vpc_peering_requester_vpc_region = local.requester_region
vpc_peering_multi_account_enabled = true
vpc_peering_requester_aws_profile = "peer"
vpc_peering_accepter_aws_profile = "accepter"
}
9 changes: 9 additions & 0 deletions examples/multi-account-vpc-peering/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "vpc_peering_connection_id" {
description = "Peering connection ID"
value = module.vpc_peering.vpc_peering_connection_id
}

output "vpc_peering_accept_status" {
description = "Accept status for the connection"
value = module.vpc_peering.vpc_peering_accept_status
}
17 changes: 17 additions & 0 deletions examples/multi-account-vpc-peering/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
provider "aws" {
alias = "peer"
region = "ap-northeast-1"
aws_account_id = ""
default_tags {
tags = local.additional_tags
}
}

provider "aws" {
alias = "accepter"
region = "ap-northeast-1"
aws_account_id = ""
default_tags {
tags = local.additional_tags
}
}
Empty file modified examples/simple-vpc/README.md
100644 → 100755
Empty file.
Empty file modified examples/simple-vpc/main.tf
100644 → 100755
Empty file.
Empty file modified examples/simple-vpc/output.tf
100644 → 100755
Empty file.
Empty file modified examples/simple-vpc/providers.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-dualstack/README.md
100644 → 100755
Empty file.
Empty file modified examples/vpc-dualstack/main.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-dualstack/outputs.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-dualstack/providers.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-native-ipv6/README.md
100644 → 100755
Empty file.
Empty file modified examples/vpc-native-ipv6/main.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-native-ipv6/outputs.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-native-ipv6/providers.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-with-peering/README.md
100644 → 100755
Empty file.
Empty file modified examples/vpc-with-peering/main.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-with-peering/output.tf
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion examples/vpc-with-peering/provider.tf
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
provider "aws" {
region = local.region
region = local.accepter_region
default_tags {
tags = local.additional_tags
}
Expand Down
Empty file modified examples/vpc-with-peering/vpc-requester-accepter/main.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-with-peering/vpc-requester-accepter/providers.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-with-private-subnet/README.md
100644 → 100755
Empty file.
Empty file modified examples/vpc-with-private-subnet/main.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-with-private-subnet/outputs.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-with-private-subnet/providers.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-with-secondary-cidr/README.md
100644 → 100755
Empty file.
Empty file modified examples/vpc-with-secondary-cidr/main.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-with-secondary-cidr/outputs.tf
100644 → 100755
Empty file.
Empty file modified examples/vpc-with-secondary-cidr/providers.tf
100644 → 100755
Empty file.
Loading