Skip to content

Commit 9b20e6f

Browse files
authored
Merge pull request #21 from unifio/wc-peer-support
Peering connection support
2 parents fa2d1be + f1ba6cb commit 9b20e6f

20 files changed

+369
-65
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
## Unreleased
22

3+
## 0.2.5 (October 7, 2016)
4+
5+
#### BACKWARDS INCOMPATIBILITIES / NOTES:
6+
* Unattached VPN gateways created by previous versions of this module will be destroyed and recreated on update due to changes in resource naming.
7+
* This module has been verified for compatiblity with Terraform 0.7.5.
8+
9+
#### FEATURES:
10+
* Added support for establishing VPC peering connections.
11+
12+
#### BUG FIXES:
13+
* Resolved issue where changing the attached status of a VPN gateway would result in the resource being destroyed and recreated.
14+
315
## 0.2.4 (June 24, 2016)
416

517
#### IMPROVEMENTS:

README.md

Lines changed: 84 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,68 +18,69 @@ The Base module provisions the VPC, attaches an Internet Gateway, and creates NA
1818

1919
### Input Variables ###
2020

21-
- `stack_item_label` - Short form identifier for this stack. This value is used to create the "Name" resource tag for resources created by this stack item, and also serves as a unique key for re-use.
22-
- `stack_item_fullname` - Long form descriptive name for this stack item. This value is used to create the "application" resource tag for resources created by this stack item.
23-
- `vpc_cidr` - The CIDR block you want the VPC to cover. For example: 10.0.0.0/16.
24-
- `instance_tenacy` - The allowed tenancy of instances launched into the VPC. Defaults to 'default'. Only other option at this time is 'dedicated', which will force any instance launched into the VPC to be dedicated, regardless of the tenancy option specified when the instance is launched.
21+
- `enable_classiclink` - (Optional) Specifies whether ClassicLink is enabled for the VPC. Defaults to false.
2522
- `enable_dns` - (Optional) Specifies whether DNS resolution is supported for the VPC. Defaults to true.
2623
- `enable_hostnames` - (Optional) Specifies whether the instances launched in the VPC get DNS hostnames. Defaults to true.
27-
- `enable_classiclink` - (Optional) Specifies whether ClassicLink is enabled for the VPC. Defaults to false.
2824
- `flow_log_traffic_type` - (Optional) The type of traffic to capture. Valid values: ACCEPT,REJECT,ALL.
25+
- `instance_tenacy` - The allowed tenancy of instances launched into the VPC. Defaults to 'default'. Only other option at this time is 'dedicated', which will force any instance launched into the VPC to be dedicated, regardless of the tenancy option specified when the instance is launched.
2926
- `rt_vgw_prop` - (Optional) Specifies whether virtual gateway route propagation should be enabled on the routing table(s). Valid values: 0 or 1. Defaults to 0 (disabled).
27+
- `stack_item_label` - Short form identifier for this stack. This value is used to create the "Name" resource tag for resources created by this stack item, and also serves as a unique key for re-use.
28+
- `stack_item_fullname` - Long form descriptive name for this stack item. This value is used to create the "application" resource tag for resources created by this stack item.
29+
- `vpc_cidr` - The CIDR block you want the VPC to cover. For example: 10.0.0.0/16.
3030
- `vgw_ids` - (Optional) A list of virtual gateways to associate with the routing tables for route propagation.
3131

32-
3332
### Usage ###
3433

3534
```js
3635
module "vpc_base" {
37-
source = "github.com/unifio/terraform-aws-vpc//base"
38-
stack_item_label = "mystack1"
39-
stack_item_fullname = "Stack Item Description"
40-
vpc_cidr = "10.10.0.0/22"
36+
source = "github.com/unifio/terraform-aws-vpc?ref=master//base"
37+
4138
enable_dns = true
4239
enable_hostnames = false
40+
stack_item_fullname = "Stack Item Description"
41+
stack_item_label = "mystack1"
42+
vpc_cidr = "10.10.0.0/22"
4343
}
4444
```
4545

4646
### Outputs ###
4747

48-
- `vpc_id` - ID of the VPC.
48+
- `flow_log_id` - ID of the AWS flow log.
4949
- `igw_id` - ID of the Internet gateway.
5050
- `rt_dmz_id` - ID of the DMZ routing table.
51-
- `flow_log_id` - ID of the AWS flow log.
51+
- `vpc_id` - ID of the VPC.
5252

5353
## DHCP module ##
5454

5555
The DHCP module provisions a DHCP options resource and associates it with the specified VPC resource.
5656

5757
### Input Variables ###
5858

59-
- `stack_item_label` - Short form identifier for this stack. This value is used to create the "Name" resource tag for resources created by this stack item, and also serves as a unique key for re-use.
60-
- `stack_item_fullname` - Long form descriptive name for this stack item. This value is used to create the "application" resource tag for resources created by this stack item.
61-
- `vpc_id` - ID of the VPC to associate the DHCP Options Set with.
6259
- `domain_name` - (Optional) The suffix domain name to use by default when resolving non Fully Qualified Domain Names. In other words, this is what ends up being the search value in the /etc/resolv.conf file.
6360
- `name_servers` - (Optional) List of name servers to configure in /etc/resolv.conf.
64-
- `ntp_servers` - (Optional) List of NTP servers to configure.
6561
- `netbios_name_servers` - (Optional) List of NETBIOS name servers.
6662
- `netbios_node_type` - (Optional) The NetBIOS node type (1, 2, 4, or 8). AWS recommends to specify 2 since broadcast and multicast are not supported in their network. For more information about these node types, see RFC 2132. Defaults to 2.
63+
- `ntp_servers` - (Optional) List of NTP servers to configure.
64+
- `stack_item_fullname` - Long form descriptive name for this stack item. This value is used to create the "application" resource tag for resources created by this stack item.
65+
- `stack_item_label` - Short form identifier for this stack. This value is used to create the "Name" resource tag for resources created by this stack item, and also serves as a unique key for re-use.
66+
- `vpc_id` - ID of the VPC to associate the DHCP Options Set with.
6767

6868
### Usage ###
6969

7070
The usage examples may assume that previous modules in this stack have already been declared, such as the base module, instantiated as "vpc_base". This declaration is not necessary, but does promote a consistent and maintainable standard.
7171

7272
```js
7373
module "dhcp" {
74-
source = "github.com/terraform-aws-vpc//dhcp"
75-
vpc_id = "${module.vpc_base.vpc_id}"
76-
stack_item_label = "mystack1"
77-
stack_item_fullname = "myname"
74+
source = "github.com/terraform-aws-vpc?ref=master//dhcp"
75+
7876
domain_name = "mydomain.com"
7977
name_servers = "10.128.8.10"
80-
ntp_servers = "10.128.8.10"
8178
netbios_name_servers = "10.128.8.10"
8279
netbios_node_type = 2
80+
ntp_servers = "10.128.8.10"
81+
stack_item_fullname = "myname"
82+
stack_item_label = "mystack1"
83+
vpc_id = "${module.vpc_base.vpc_id}"
8384
}
8485
```
8586

@@ -93,8 +94,8 @@ Creates a VPC VPN Gateway
9394

9495
### Input Variables
9596

96-
- `stack_item_label` - Short form identifier for this stack. This value is used to create the "Name" resource tag for resources created by this stack item, and also serves as a unique key for re-use.
9797
- `stack_item_fullname` - Long form descriptive name for this stack item. This value is used to create the "application" resource tag for resources created by this stack item.
98+
- `stack_item_label` - Short form identifier for this stack. This value is used to create the "Name" resource tag for resources created by this stack item, and also serves as a unique key for re-use.
9899
- `vpc_attach` - Specifies whether the VPG should be associated with a VPC. Valid value: 0 or 1. Defaults to 0 (unattached).
99100
- `vpc_id` - The VPC to associate the VPG with.
100101

@@ -104,11 +105,12 @@ The usage examples may assume that previous modules in this stack have already b
104105

105106
```js
106107
module "vpg" {
107-
source = "github.com/terraform-aws-vpc//vpg"
108-
vpc_attach = 1
109-
vpc_id = "${module.vpc_base.vpc_id}"
108+
source = "github.com/terraform-aws-vpc?ref=master//vpg"
109+
110110
stack_item_fullname = "Stack Item Description"
111111
stack_item_label = "mystack1"
112+
vpc_attach = 1
113+
vpc_id = "${module.vpc_base.vpc_id}"
112114
}
113115
```
114116

@@ -122,38 +124,39 @@ In each Availability Zone provided, this module provisions subnets and routing t
122124

123125
### Input Variables ###
124126

125-
- `stack_item_label` - Short form identifier for this stack. This value is used to create the "Name" resource tag for resources created by this stack item, and also serves as a unique key for re-use.
126-
- `stack_item_fullname` - Long form descriptive name for this stack item. This value is used to create the "application" resource tag for resources created by this stack item.
127-
- `vpc_id` - ID of the VPC.
128-
- `region` - The AWS region.
129127
- `az` - Availability zone(s). Will accept a comma delimited string.
130128
- `dmz_cidr` - The CIDR block(s) you want the DMZ subnet(s) to cover. Will accept a comma delimited string. This list should correspond 1:1 to each AZ.
129+
- `enable_dmz_public_ips` - (Optional) Specify true to indicate that instances launched into the DMZ subnet should be assigned a public IP address. Defaults to true.
131130
- `lan_cidr` - The CIDR block(s) you want the LAN subnet(s) to cover. Will accept a comma delimited string. This list should correspond 1:1 to each AZ.
132131
- `lans_per_az` - (Optional) The number of private LAN subnets to be provisioned per AZ. You will need to double the CIDR blocks specified in the `lan_cidr` variable for each increase in this value. Defaults to 1.
133-
- `enable_dmz_public_ips` - (Optional) Specify true to indicate that instances launched into the DMZ subnet should be assigned a public IP address. Defaults to true.
132+
- `region` - The AWS region.
134133
- `rt_dmz_id` - The ID of the DMZ routing table.
135134
- `rt_vgw_prop` - (Optional) Specifies whether virtual gateway route propagation should be enabled on the routing table(s). Valid values: 0 or 1. Defaults to 0 (disabled).
135+
- `stack_item_fullname` - Long form descriptive name for this stack item. This value is used to create the "application" resource tag for resources created by this stack item.
136+
- `stack_item_label` - Short form identifier for this stack. This value is used to create the "Name" resource tag for resources created by this stack item, and also serves as a unique key for re-use.
136137
- `vgw_ids` - (Optional) A list of virtual gateways to associate with the routing tables for route propagation.
138+
- `vpc_id` - ID of the VPC.
137139

138140
### Usage ###
139141

140142
The usage examples may assume that previous modules in this stack have already been declared, such as the base module, instantiated as "vpc_base". This declaration is not necessary, but does promote a consistent and maintainable standard.
141143

142144
```js
143-
module "AZs" {
144-
source = "github.com/unifio/terraform-aws-vpc//az"
145-
stack_item_label = "mystack1"
146-
stack_item_fullname = "Stack Item Description"
147-
vpc_id = "${module.vpc_base.vpc_id}"
148-
region = "us-west-2"
149-
az = "a,b"
150-
dmz_cidr = "10.10.0.0/25,10.10.0.128/25,10.10.1.0/25"
151-
lan_cidr = "10.10.2.0/25,10.10.2.128/25,10.10.3.0/25"
152-
lans_per_az = "1"
153-
enable_dmz_public_ips = true
154-
rt_dmz_id = "${module.vpc_base.rt_dmz_id}"
155-
rt_vgw_prop = 1
156-
vgw_ids = "${aws_vpn_gateway.vpg.id}"
145+
module "az" {
146+
source = "github.com/unifio/terraform-aws-vpc?ref=master//az"
147+
148+
az = "a,b"
149+
dmz_cidr = "10.10.0.0/25,10.10.0.128/25,10.10.1.0/25"
150+
enable_dmz_public_ips = true
151+
lan_cidr = "10.10.2.0/25,10.10.2.128/25,10.10.3.0/25"
152+
lans_per_az = "1"
153+
region = "us-west-2"
154+
rt_dmz_id = "${module.vpc_base.rt_dmz_id}"
155+
rt_vgw_prop = 1
156+
stack_item_fullname = "Stack Item Description"
157+
stack_item_label = "mystack1"
158+
vgw_ids = "${aws_vpn_gateway.vpg.id}"
159+
vpc_id = "${module.vpc_base.vpc_id}"
157160
}
158161
```
159162

@@ -170,6 +173,43 @@ module "AZs" {
170173
- `eip_nat_ip` - List of NAT gateway public IPs.
171174
- `rt_lan_id` - List of routing table IDs for the LAN subnets.
172175

176+
## Peer Module ##
177+
178+
Creates a VPC peering connection
179+
180+
### Input Variables
181+
182+
- `accepter_allow_remote_dns` - Allow accepter VPC to resolve public DNS hostnames to private IP addresses when queried from instances in the requester VPC.
183+
- `multi_acct` - Flag indicating whether the peering connection spans multiple AWS accounts.
184+
- `peer_owner_id` - The AWS account ID of the owner of the peer VPC.
185+
- `peer_vpc_id` - The ID of the VPC with which you are creating the VPC Peering Connection.
186+
- `requester_allow_remote_dns` - Allow requester VPC to resolve public DNS hostnames to private IP addresses when queried from instances in the accepter VPC.
187+
- `stack_item_fullname` - Long form descriptive name for this stack item. This value is used to create the "application" resource tag for resources created by this stack item.
188+
- `stack_item_label` - Short form identifier for this stack. This value is used to create the "Name" resource tag for resources created by this stack item, and also serves as a unique key for re-use.
189+
- `vpc_id` - The ID of the requester VPC.
190+
191+
### Usage
192+
193+
The usage examples may assume that previous modules in this stack have already been declared, such as the base module, instantiated as "vpc_base". This declaration is not necessary, but does promote a consistent and maintainable standard.
194+
195+
```js
196+
module "vpc_peer" {
197+
source = "github.com/terraform-aws-vpc?ref=master//peer"
198+
199+
accepter_allow_remote_dns = false
200+
peer_owner_id = "${var.peer_owner_id}"
201+
peer_vpc_id = "${var.peer_vpc_id}"
202+
requester_allow_remote_dns = true
203+
stack_item_fullname = "${var.stack_item_fullname}"
204+
stack_item_label = "${var.stack_item_label}"
205+
vpc_id = "${var.owner_vpc_id}"
206+
}
207+
```
208+
209+
### Outputs ###
210+
211+
- `peer_connection_id` - ID of the newly created peering connection.
212+
173213
## Examples ##
174214

175215
See the [examples](examples) directory for a complete set of example source files.

Rakefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ task :default => :verify
88
desc "Verify the stack"
99
task :verify do
1010

11-
['basic', 'full_stack'].each do |stack|
11+
%w(basic full_stack).each do |stack|
1212
task_args = {:stack => stack, :tf_img => ENV['TF_IMG'], :tf_cmd => ENV['TF_CMD']}
1313
Rake::Task['clean'].execute(Rake::TaskArguments.new(task_args.keys, task_args.values))
1414
Rake::Task['check_style'].execute(Rake::TaskArguments.new(task_args.keys, task_args.values))
@@ -37,6 +37,11 @@ task :get, [:stack, :tf_img, :tf_cmd] do |t, args|
3737
sh "#{args['tf_cmd']} -v `pwd`:/data -w /data/examples/#{args['stack']} #{args['tf_img']} get"
3838
end
3939

40+
desc "Get output"
41+
task :output, [:stack, :tf_img, :tf_cmd, :output] do |t, args|
42+
sh "#{args['tf_cmd']} -v `pwd`:/data -w /data/examples/#{args['stack']} #{args['tf_img']} output #{args['output']}"
43+
end
44+
4045
desc "Apply stack"
4146
task :apply, [:stack, :tf_img, :tf_cmd, :var_file] do |t, args|
4247
sh "#{args['tf_cmd']} -v `pwd`:/data -w /data/examples/#{args['stack']} #{args['tf_img']} apply -var-file /data/examples/#{args['var_file']}"

circle.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,35 @@ machine:
22
services:
33
- docker
44
environment:
5-
TF_IMG: unifio/terraform:0.7.4
6-
TF_CMD: docker run -v /home/ubuntu/.aws:/home/user/.aws -e AWS_DEFAULT_REGION=us-east-1 -e LOCAL_USER_ID=1000 --rm
5+
TF_IMG: unifio/terraform:0.7.5
6+
TF_CMD: docker run -v /home/ubuntu/.aws:/home/user/.aws -e AWS_DEFAULT_REGION=us-east-1 -e LOCAL_USER_ID=1000
77
test:
88
pre:
99
- docker pull $TF_IMG
1010
override:
11+
# Verify stacks
1112
- bundle exec rake
13+
# Test basic VPC deployment
1214
- "bundle exec rake apply['basic',${TF_IMG},\"${TF_CMD}\",'basic.tfvars']"
15+
# Test VPG attachment
16+
- 'echo -e "vpg_vpc_attach = \"1\"\n" | tee -a examples/basic.tfvars'
17+
- "bundle exec rake apply['basic',${TF_IMG},\"${TF_CMD}\",'basic.tfvars']"
18+
# Test full stack VPC deployment
19+
- "bundle exec rake apply['full_stack',${TF_IMG},\"${TF_CMD}\",'full_stack.tfvars']"
20+
# Test VPG attachment and route propagation
21+
- 'echo -e "vpg_vpc_attach = \"1\"\n" | tee -a examples/full_stack.tfvars'
22+
- 'echo -e "rt_vgw_prop = \"1\"\n" | tee -a examples/full_stack.tfvars'
23+
- "bundle exec rake apply['full_stack',${TF_IMG},\"${TF_CMD}\",'full_stack.tfvars']"
24+
# Testing peering connection
25+
- 'export LAN_RT_IDS=`bundle exec rake output["basic",${TF_IMG},"${TF_CMD}","lan_rt_ids"]` && echo -e "owner_rt_lan_id = \"${LAN_RT_IDS}\"" | tee -a examples/peering.tfvars'
26+
- 'export VPC_ID=`bundle exec rake output["basic",${TF_IMG},"${TF_CMD}","vpc_id"]` && echo -e "owner_vpc_id = \"${VPC_ID}\"" | tee -a examples/peering.tfvars'
27+
- 'export LAN_RT_IDS=`bundle exec rake output["full_stack",${TF_IMG},"${TF_CMD}","lan_rt_ids"]` && echo -e "peer_rt_lan_id = \"${LAN_RT_IDS}\"" | tee -a examples/peering.tfvars'
28+
- 'export VPC_ID=`bundle exec rake output["full_stack",${TF_IMG},"${TF_CMD}","vpc_id"]` && echo -e "peer_vpc_id = \"${VPC_ID}\"" | tee -a examples/peering.tfvars'
29+
- 'echo -e "peer_owner_id = \"${PEER_OWNER_ID}\"\n" | tee -a examples/peering.tfvars'
30+
- "bundle exec rake get['peering',${TF_IMG},\"${TF_CMD}\"]"
31+
- "bundle exec rake apply['peering',${TF_IMG},\"${TF_CMD}\",'peering.tfvars']"
32+
# Test stack clean-up
33+
- "bundle exec rake destroy['peering',${TF_IMG},\"${TF_CMD}\",'peering.tfvars']"
34+
- "bundle exec rake destroy['full_stack',${TF_IMG},\"${TF_CMD}\",'full_stack.tfvars']"
1335
- "bundle exec rake destroy['basic',${TF_IMG},\"${TF_CMD}\",'basic.tfvars']"
36+

examples/basic.tfvars

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
enable_dns = "true"
2+
enable_hostnames = "true"
13
stack_item_fullname = "Basic AWS VPC deployment example"
24
stack_item_label = "exmpl-bsc"

examples/basic/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ module "vpc_vpg" {
4242
#source = "github.com/unifio/terraform-aws-vpc?ref=master//vpg"
4343
source = "../../vpg"
4444

45-
vpc_attach = 0
4645
stack_item_label = "${var.stack_item_label}"
4746
stack_item_fullname = "${var.stack_item_fullname}"
47+
vpc_attach = "${var.vpg_vpc_attach}"
48+
vpc_id = "${module.vpc_base.vpc_id}"
4849
}
4950

5051
## Configures routing

examples/basic/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ output "dmz_subnet_ids" {
1111
output "lan_subnet_ids" {
1212
value = "${module.vpc_az.lan_id}"
1313
}
14+
15+
output "lan_rt_ids" {
16+
value = "${module.vpc_az.rt_lan_id}"
17+
}

examples/basic/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,9 @@ variable "enable_hostnames" {
5656
description = "Specifies whether the instances launched in the VPC get DNS hostnames"
5757
default = false
5858
}
59+
60+
variable "vpg_vpc_attach" {
61+
type = "string"
62+
description = "Flag for selecting whether the VPG should be attached to a VPC."
63+
default = "0"
64+
}

0 commit comments

Comments
 (0)