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
8c5f1320
Commit
8c5f1320
authored
Aug 21, 2016
by
Rob Greenwood
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial commit
parents
Pipeline
#58
passed with stage
in 5 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
165 additions
and
0 deletions
+165
-0
.gitlab-ci.yml
.gitlab-ci.yml
+12
-0
main.tf
main.tf
+153
-0
No files found.
.gitlab-ci.yml
0 → 100644
View file @
8c5f1320
image
:
alpine:latest
variables
:
TERRAFORM_URL
:
"
https://releases.hashicorp.com/terraform/0.7.1/terraform_0.7.1_linux_amd64.zip"
before_script
:
-
apk update && apk add ca-certificates && update-ca-certificates && apk add openssl
-
wget -O /tmp/terraform.zip $TERRAFORM_URL
-
unzip /tmp/terraform.zip -d /usr/local/bin
test
:
script
:
terraform validate
main.tf
0 → 100644
View file @
8c5f1320
variable
"name"
{
description
=
"Name of the VPC"
}
variable
"cidr"
{
description
=
"The CIDR block for the VPC"
}
variable
"availability_zones"
{
description
=
"List of availability zones"
type
=
"list"
}
variable
"public_subnets"
{
description
=
"List of public subnets to availability zones"
type
=
"list"
}
variable
"private_subnets"
{
description
=
"List of private subnets to availability zones"
type
=
"list"
}
variable
"enable_dns_hostnames"
{
description
=
"When set to true, instances in the VPC get DNS hostname"
default
=
true
}
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
}
"
tags
{
Name
=
"
${
var
.
name
}
"
}
}
resource
"aws_subnet"
"public"
{
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
)
}
"
map_public_ip_on_launch
=
true
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
{
Name
=
"
${
var
.
name
}
.private.
${
element
(
var
.
availability_zones
,
count
.
index
)
}
"
}
}
resource
"aws_internet_gateway"
"mod"
{
vpc_id
=
"
${
aws_vpc
.
mod
.
id
}
"
tags
{
Name
=
"
${
var
.
name
}
"
}
}
resource
"aws_eip"
"nat"
{
vpc
=
true
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"
]
}
resource
"aws_route_table"
"public"
{
vpc_id
=
"
${
aws_vpc
.
mod
.
id
}
"
tags
{
Name
=
"
${
var
.
name
}
.public"
}
}
resource
"aws_route_table"
"private"
{
vpc_id
=
"
${
aws_vpc
.
mod
.
id
}
"
count
=
"
${
length
(
var
.
private_subnets
)
}
"
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
}
"
destination_cidr_block
=
"0.0.0.0/0"
gateway_id
=
"
${
aws_internet_gateway
.
mod
.
id
}
"
}
resource
"aws_route"
"nat_gateway"
{
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
)
}
"
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
)
}
"
}
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
)
}
"
}
output
"private_subnets"
{
value
=
[
"
${
aws_subnet
.
private
.
*
.
id
}
"
]
}
output
"public_subnets"
{
value
=
[
"
${
aws_subnet
.
public
.
*
.
id
}
"
]
}
output
"vpc_id"
{
value
=
"
${
aws_vpc
.
mod
.
id
}
"
}
output
"public_route_table_id"
{
value
=
"
${
aws_route_table
.
public
.
id
}
"
}
output
"private_route_table_ids"
{
value
=
[
"
${
aws_route_table
.
private
.
*
.
id
}
"
]
}
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