-
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.
feat: Added seperate example for slave and master account
- Loading branch information
Showing
12 changed files
with
254 additions
and
72 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
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 |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
*.tfstate | ||
*.tfstate.backup | ||
.terraform | ||
.terraform.* | ||
.idea | ||
*.iml |
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 |
---|---|---|
@@ -0,0 +1,111 @@ | ||
provider "aws" { | ||
region = "eu-west-2" | ||
} | ||
|
||
locals { | ||
name = "app" | ||
environment = "test" | ||
other_name = "app_1" | ||
other_environment = "test_1" | ||
} | ||
|
||
##------------------------------------------------------------------------------ | ||
# VPC module call. | ||
##------------------------------------------------------------------------------ | ||
module "vpc" { | ||
source = "clouddrove/vpc/aws" | ||
version = "2.0.0" | ||
name = local.name | ||
environment = local.environment | ||
cidr_block = "10.10.0.0/16" | ||
} | ||
|
||
##------------------------------------------------------------------------------ | ||
# Subnet module call. | ||
##------------------------------------------------------------------------------ | ||
#tfsec:ignore:aws-ec2-no-excessive-port-access # Ingnored because these are basic examples, it can be changed via varibales as per requirement. | ||
#tfsec:ignore:aws-ec2-no-public-ingress-acl # Ingnored because these are basic examples, it can be changed via varibales as per requirement. | ||
module "subnets" { | ||
source = "clouddrove/subnet/aws" | ||
version = "2.0.0" | ||
name = local.name | ||
environment = local.environment | ||
availability_zones = ["eu-west-2a", "eu-west-2b"] | ||
vpc_id = module.vpc.vpc_id | ||
type = "public" | ||
igw_id = module.vpc.igw_id | ||
nat_gateway_enabled = false | ||
cidr_block = module.vpc.vpc_cidr_block | ||
ipv6_cidr_block = module.vpc.ipv6_cidr_block | ||
} | ||
|
||
##------------------------------------------------------------------------------ | ||
## Other-vpc module call. | ||
##------------------------------------------------------------------------------ | ||
module "vpc_other" { | ||
source = "clouddrove/vpc/aws" | ||
version = "2.0.0" | ||
name = local.other_name | ||
environment = local.other_environment | ||
cidr_block = "192.168.0.0/16" | ||
} | ||
|
||
##------------------------------------------------------------------------------ | ||
# Other-subnet module call. | ||
##------------------------------------------------------------------------------ | ||
#tfsec:ignore:aws-ec2-no-excessive-port-access # Ingnored because these are basic examples, it can be changed via varibales as per requirement. | ||
#tfsec:ignore:aws-ec2-no-public-ingress-acl # Ingnored because these are basic examples, it can be changed via varibales as per requirement. | ||
module "subnets_other" { | ||
source = "clouddrove/subnet/aws" | ||
version = "2.0.0" | ||
name = local.other_name | ||
environment = local.other_environment | ||
availability_zones = ["eu-west-2a", "eu-west-2b"] | ||
vpc_id = module.vpc_other.vpc_id | ||
type = "public" | ||
igw_id = module.vpc_other.igw_id | ||
nat_gateway_enabled = false | ||
cidr_block = module.vpc_other.vpc_cidr_block | ||
|
||
} | ||
|
||
##------------------------------------------------------------------------------ | ||
## Transit-gateway module call. | ||
## Transit gateway configuration for main account where a central transit gateway will be hosted and shared with slave(other accounts) | ||
##------------------------------------------------------------------------------ | ||
module "transit_gateway" { | ||
depends_on = [module.vpc, module.subnets] | ||
source = "./../../../" | ||
name = local.name | ||
environment = local.environment | ||
tgw_create = true | ||
amazon_side_asn = 64512 | ||
auto_accept_shared_attachments = "enable" | ||
default_route_table_propagation = "enable" | ||
description = "This transit Gateway create for testing purpose" | ||
#TGW Share | ||
resource_share_enable = true | ||
resource_share_allow_external_principals = true | ||
resource_share_account_ids = ["xxxxxxxxxxxx"] | ||
# VPC Attachements | ||
vpc_attachments = { | ||
vpc1 = { | ||
vpc_id = module.vpc.vpc_id | ||
subnet_ids = module.subnets.public_subnet_id | ||
transit_gateway_default_route_table_association = true | ||
transit_gateway_default_route_table_propagation = true | ||
# Below should be uncommented only when vpc and subnet are already deployed. | ||
# vpc_route_table_ids = module.subnets.public_route_tables_id | ||
# destination_cidr = ["10.11.0.0/16"] | ||
}, | ||
vpc2 = { | ||
vpc_id = module.vpc_other.vpc_id | ||
subnet_ids = module.subnets_other.public_subnet_id | ||
transit_gateway_default_route_table_association = false | ||
transit_gateway_default_route_table_propagation = false | ||
# Below should be uncommented only when vpc and subnet are already deployed. | ||
#vpc_route_table_ids = module.subnets_other.public_route_tables_id | ||
#destination_cidr = ["31.0.0.0/16", "53.0.0.0/16"] | ||
} | ||
} | ||
} |
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,44 @@ | ||
output "transit_gateway_id" { | ||
value = module.transit_gateway[*].transit_gateway_id | ||
description = "The ID of the transit-gateway." | ||
} | ||
|
||
output "tags" { | ||
value = module.transit_gateway.tags | ||
description = "A mapping of tags to assign to the transit-gateway." | ||
} | ||
|
||
output "ec2_transit_gateway_arn" { | ||
value = module.transit_gateway.ec2_transit_gateway_arn | ||
description = "EC2 Transit Gateway Amazon Resource Name (ARN)" | ||
} | ||
|
||
output "ec2_transit_gateway_route_table_id" { | ||
value = module.transit_gateway.ec2_transit_gateway_route_table_id | ||
description = "EC2 Transit Gateway Route Table identifier" | ||
} | ||
|
||
output "ec2_transit_gateway_owner_id" { | ||
value = module.transit_gateway.ec2_transit_gateway_owner_id | ||
description = "Identifier of the AWS account that owns the EC2 Transit Gateway" | ||
} | ||
|
||
output "ec2_transit_gateway_association_default_route_table_id" { | ||
value = module.transit_gateway.ec2_transit_gateway_association_default_route_table_id | ||
description = "Identifier of the default association route table" | ||
} | ||
|
||
output "ec2_transit_gateway_vpc_attachment_ids" { | ||
value = module.transit_gateway.ec2_transit_gateway_vpc_attachment_ids | ||
description = "List of EC2 Transit Gateway VPC Attachment identifiers" | ||
} | ||
|
||
output "ram_resource_share_id" { | ||
value = module.transit_gateway.ram_resource_share_id | ||
description = "The Amazon Resource Name (ARN) of the resource share" | ||
} | ||
|
||
output "resource_share_arn" { | ||
value = module.transit_gateway.resource_share_arn | ||
description = "The ARN of the RAM." | ||
} |
File renamed without changes.
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
8 changes: 4 additions & 4 deletions
8
_example/multi_account/outputs.tf → ...le/multi_account/slave_account/outputs.tf
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,19 +1,19 @@ | ||
output "tags" { | ||
value = module.transit_gateway.tags | ||
value = module.transit_gateway_peer.tags | ||
description = "A mapping of tags to assign to the transit-gateway." | ||
} | ||
|
||
output "ram_resource_share_id" { | ||
value = module.transit_gateway.ram_resource_share_id | ||
value = module.transit_gateway_peer.ram_resource_share_id | ||
description = "The Amazon Resource Name (ARN) of the resource share" | ||
} | ||
|
||
output "ec2_transit_gateway_association_default_route_table_id" { | ||
value = module.transit_gateway.ec2_transit_gateway_association_default_route_table_id | ||
value = module.transit_gateway_peer.ec2_transit_gateway_association_default_route_table_id | ||
description = "Identifier of the default association route table" | ||
} | ||
|
||
output "ec2_transit_gateway_vpc_attachment_ids" { | ||
value = module.transit_gateway.ec2_transit_gateway_vpc_attachment_ids | ||
value = module.transit_gateway_peer.ec2_transit_gateway_vpc_attachment_ids | ||
description = "List of EC2 Transit Gateway VPC Attachment identifiers" | ||
} |
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 version | ||
terraform { | ||
required_version = ">= 1.5.4" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 5.10" | ||
} | ||
} | ||
} |
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
Oops, something went wrong.