Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
tf_mod_aws_vpc
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
steamhaus
tf_mod_aws_vpc
Commits
5add0b77
Commit
5add0b77
authored
Oct 28, 2020
by
Felix Edelsten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
terraform version 0.12.29
parent
b5570009
Pipeline
#8332
failed with stage
in 15 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
62 deletions
+67
-62
main.tf
main.tf
+67
-62
No files found.
main.tf
View file @
5add0b77
variable
"name"
{
variable
"name"
{
description
=
"Name of the VPC"
}
variable
"cidr"
{
variable
"cidr"
{
description
=
"The CIDR block for the VPC"
}
variable
"availability_zones"
{
variable
"availability_zones"
{
description
=
"List of availability zones"
type
=
"list"
type
=
list
(
string
)
}
variable
"public_subnets"
{
description
=
"List of public subnets to availability zones"
type
=
"list"
variable
"public_subnets"
{
description
=
"List of public subnets to availability zones"
type
=
list
(
string
)
}
variable
"private_subnets"
{
description
=
"List of private subnets to availability zones"
type
=
"list"
description
=
"List of private subnets to availability zones"
type
=
list
(
string
)
}
variable
"enable_dns_hostnames"
{
variable
"enable_dns_hostnames"
{
description
=
"When set to true, instances in the VPC get DNS hostname"
default
=
true
}
variable
"enable_dns_support"
{
variable
"enable_dns_support"
{
description
=
"When set to true, the Amazon DNS server is enabled within the VPC"
default
=
true
}
resource
"aws_vpc"
"mod"
{
cidr_block
=
"
${
var
.
cidr
}
"
enable_dns_hostnames
=
"
${
var
.
enable_dns_hostnames
}
"
enable_dns_support
=
"
${
var
.
enable_dns_support
}
"
cidr_block
=
var
.
cidr
enable_dns_hostnames
=
var
.
enable_dns_hostnames
enable_dns_support
=
var
.
enable_dns_support
tags
{
Name
=
"
${
var
.
name
}
"
tags
=
{
Name
=
var
.
name
}
}
resource
"aws_subnet"
"public"
{
lifecycle
{
create_before_destroy
=
true
}
lifecycle
{
create_before_destroy
=
true
}
vpc_id
=
"
${
aws_vpc
.
mod
.
id
}
"
cidr_block
=
"
${
element
(
var
.
public_subnets
,
count
.
index
)
}
"
availability_zone
=
"
${
element
(
var
.
availability_zones
,
count
.
index
)
}
"
count
=
"
${
length
(
var
.
public_subnets
)
}
"
vpc_id
=
aws_vpc
.
mod
.
id
cidr_block
=
element
(
var
.
public_subnets
,
count
.
index
)
availability_zone
=
element
(
var
.
availability_zones
,
count
.
index
)
count
=
length
(
var
.
public_subnets
)
map_public_ip_on_launch
=
true
tags
{
tags
=
{
Name
=
"
${
var
.
name
}
.public.
${
element
(
var
.
availability_zones
,
count
.
index
)
}
"
}
}
resource
"aws_subnet"
"private"
{
lifecycle
{
create_before_destroy
=
true
}
vpc_id
=
"
${
aws_vpc
.
mod
.
id
}
"
cidr_block
=
"
${
element
(
var
.
private_subnets
,
count
.
index
)
}
"
availability_zone
=
"
${
element
(
var
.
availability_zones
,
count
.
index
)
}
"
count
=
"
${
length
(
var
.
private_subnets
)
}
"
tags
{
lifecycle
{
create_before_destroy
=
true
}
vpc_id
=
aws_vpc
.
mod
.
id
cidr_block
=
element
(
var
.
private_subnets
,
count
.
index
)
availability_zone
=
element
(
var
.
availability_zones
,
count
.
index
)
count
=
length
(
var
.
private_subnets
)
tags
=
{
Name
=
"
${
var
.
name
}
.private.
${
element
(
var
.
availability_zones
,
count
.
index
)
}
"
}
}
resource
"aws_internet_gateway"
"mod"
{
vpc_id
=
"
${
aws_vpc
.
mod
.
id
}
"
vpc_id
=
aws_vpc
.
mod
.
id
tags
{
Name
=
"
${
var
.
name
}
"
tags
=
{
Name
=
var
.
name
}
}
resource
"aws_eip"
"nat"
{
vpc
=
true
count
=
"
${
length
(
var
.
public_subnets
)
}
"
count
=
length
(
var
.
public_subnets
)
}
resource
"aws_nat_gateway"
"nat"
{
subnet_id
=
"
${
element
(
aws_subnet
.
public
.
*
.
id
,
count
.
index
)
}
"
allocation_id
=
"
${
element
(
aws_eip
.
nat
.
*
.
id
,
count
.
index
)
}
"
count
=
"
${
length
(
var
.
public_subnets
)
}
"
depends_on
=
[
"aws_internet_gateway.mod"
]
subnet_id
=
element
(
aws_subnet
.
public
.*.
id
,
count
.
index
)
allocation_id
=
element
(
aws_eip
.
nat
.*.
id
,
count
.
index
)
count
=
length
(
var
.
public_subnets
)
depends_on
=
[
aws_internet_gateway
.
mod
]
}
resource
"aws_route_table"
"public"
{
vpc_id
=
"
${
aws_vpc
.
mod
.
id
}
"
vpc_id
=
aws_vpc
.
mod
.
id
tags
{
Name
=
"
${
var
.
name
}
.public"
tags
=
{
Name
=
"
${
var
.
name
}
.public"
}
}
resource
"aws_route_table"
"private"
{
vpc_id
=
"
${
aws_vpc
.
mod
.
id
}
"
count
=
"
${
length
(
var
.
private_subnets
)
}
"
vpc_id
=
aws_vpc
.
mod
.
id
count
=
length
(
var
.
private_subnets
)
tags
{
tags
=
{
Name
=
"
${
var
.
name
}
.private.
${
element
(
var
.
availability_zones
,
count
.
index
)
}
"
}
}
resource
"aws_route"
"public_internet_gateway"
{
route_table_id
=
"
${
aws_route_table
.
public
.
id
}
"
route_table_id
=
aws_route_table
.
public
.
id
destination_cidr_block
=
"0.0.0.0/0"
gateway_id
=
"
${
aws_internet_gateway
.
mod
.
id
}
"
gateway_id
=
aws_internet_gateway
.
mod
.
id
}
resource
"aws_route"
"nat_gateway"
{
route_table_id
=
"
${
element
(
aws_route_table
.
private
.
*
.
id
,
count
.
index
)
}
"
route_table_id
=
element
(
aws_route_table
.
private
.*.
id
,
count
.
index
)
destination_cidr_block
=
"0.0.0.0/0"
nat_gateway_id
=
"
${
element
(
aws_nat_gateway
.
nat
.
*
.
id
,
count
.
index
)
}
"
count
=
"
${
length
(
var
.
public_subnets
)
}
"
nat_gateway_id
=
element
(
aws_nat_gateway
.
nat
.*.
id
,
count
.
index
)
count
=
length
(
var
.
public_subnets
)
depends_on
=
[
"aws_route_table.private"
]
depends_on
=
[
aws_route_table
.
private
]
}
resource
"aws_route_table_association"
"public"
{
subnet_id
=
"
${
element
(
aws_subnet
.
public
.
*
.
id
,
count
.
index
)
}
"
route_table_id
=
"
${
aws_route_table
.
public
.
id
}
"
count
=
"
${
length
(
var
.
public_subnets
)
}
"
subnet_id
=
element
(
aws_subnet
.
public
.*.
id
,
count
.
index
)
route_table_id
=
aws_route_table
.
public
.
id
count
=
length
(
var
.
public_subnets
)
}
resource
"aws_route_table_association"
"private"
{
subnet_id
=
"
${
element
(
aws_subnet
.
private
.
*
.
id
,
count
.
index
)
}
"
route_table_id
=
"
${
element
(
aws_route_table
.
private
.
*
.
id
,
count
.
index
)
}
"
count
=
"
${
length
(
var
.
private_subnets
)
}
"
subnet_id
=
element
(
aws_subnet
.
private
.*.
id
,
count
.
index
)
route_table_id
=
element
(
aws_route_table
.
private
.*.
id
,
count
.
index
)
count
=
length
(
var
.
private_subnets
)
}
output
"private_subnets"
{
value
=
[
"
${
aws_subnet
.
private
.
*
.
id
}
"
]
value
=
aws_subnet
.
private
.*.
id
}
output
"public_subnets"
{
value
=
[
"
${
aws_subnet
.
public
.
*
.
id
}
"
]
value
=
aws_subnet
.
public
.*.
id
}
output
"vpc_id"
{
value
=
"
${
aws_vpc
.
mod
.
id
}
"
value
=
aws_vpc
.
mod
.
id
}
output
"public_route_table_id"
{
value
=
"
${
aws_route_table
.
public
.
id
}
"
value
=
aws_route_table
.
public
.
id
}
output
"private_route_table_ids"
{
value
=
[
"
${
aws_route_table
.
private
.
*
.
id
}
"
]
value
=
aws_route_table
.
private
.*.
id
}
output
"nat_gateway_public_ips"
{
value
=
[
"
${
aws_eip
.
nat
.
*
.
public_ip
}
"
]
value
=
aws_eip
.
nat
.*.
public_ip
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment