zaws 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +35 -0
- data/.travis.yml +20 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +78 -0
- data/LICENSE +204 -0
- data/README.md +17 -0
- data/Rakefile +26 -0
- data/bin/zaws +20 -0
- data/feature/compute/assoc_security_group.feature +55 -0
- data/feature/compute/compute.feature +138 -0
- data/feature/compute/secondary_ip.feature +107 -0
- data/feature/compute/view.feature +23 -0
- data/feature/compute/view_images.feature +24 -0
- data/feature/elasticip/elasticip.feature +138 -0
- data/feature/elasticip/view.feature +18 -0
- data/feature/hosted_zone/view.feature +17 -0
- data/feature/hosted_zone/view_record.feature +29 -0
- data/feature/load_balancer/instance_registration.feature +120 -0
- data/feature/load_balancer/listener.feature +86 -0
- data/feature/load_balancer/load_balancer.feature +101 -0
- data/feature/load_balancer/view.feature +18 -0
- data/feature/route_table/assoc_subnet.feature +128 -0
- data/feature/route_table/route_propagation.feature +93 -0
- data/feature/route_table/route_table.feature +91 -0
- data/feature/route_table/route_to_gateway.feature +69 -0
- data/feature/route_table/route_to_instance.feature +115 -0
- data/feature/route_table/view.feature +25 -0
- data/feature/security_group/ingress.feature +184 -0
- data/feature/security_group/security_group.feature +107 -0
- data/feature/security_group/view.feature +23 -0
- data/feature/subnet/subnet.feature +92 -0
- data/feature/subnet/view.feature +24 -0
- data/feature/support/env.rb +14 -0
- data/feature/version.feature +6 -0
- data/lib/zaws/aws.rb +26 -0
- data/lib/zaws/command/compute.rb +100 -0
- data/lib/zaws/command/elasticip.rb +47 -0
- data/lib/zaws/command/hosted_zone.rb +26 -0
- data/lib/zaws/command/load_balancer.rb +113 -0
- data/lib/zaws/command/route_table.rb +134 -0
- data/lib/zaws/command/security_group.rb +69 -0
- data/lib/zaws/command/subnet.rb +65 -0
- data/lib/zaws/ec2/compute.rb +247 -0
- data/lib/zaws/ec2/elasticip.rb +85 -0
- data/lib/zaws/ec2/route_table.rb +202 -0
- data/lib/zaws/ec2/security_group.rb +116 -0
- data/lib/zaws/ec2/subnet.rb +108 -0
- data/lib/zaws/ec2.rb +40 -0
- data/lib/zaws/elb/load_balancer.rb +157 -0
- data/lib/zaws/elb.rb +20 -0
- data/lib/zaws/helper/file.rb +23 -0
- data/lib/zaws/helper/option.rb +24 -0
- data/lib/zaws/helper/output.rb +46 -0
- data/lib/zaws/helper/shell.rb +25 -0
- data/lib/zaws/route53/hosted_zone.rb +36 -0
- data/lib/zaws/route53.rb +20 -0
- data/lib/zaws/version.rb +3 -0
- data/lib/zaws.rb +57 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/zaws/ec2/compute/add_volume_spec.rb +39 -0
- data/spec/zaws/ec2/compute/block_device_mapping_spec.rb +31 -0
- data/spec/zaws/ec2/compute/instance_id_by_external_id_spec.rb +23 -0
- data/spec/zaws/ec2/compute/instance_ping_spec.rb +34 -0
- data/spec/zaws/ec2/compute/instance_running_spec.rb +47 -0
- data/spec/zaws/ec2/compute/network_interface_json_spec.rb +57 -0
- data/spec/zaws/ec2/compute/nosdcheck_spec.rb +17 -0
- data/spec/zaws/ec2/compute/tag_instance_spec.rb +21 -0
- data/spec/zaws/ec2/security_group/id_by_name_spec.rb +32 -0
- data/spec/zaws/ec2/subnet/available_spec.rb +22 -0
- data/spec/zaws/ec2/subnet/declare_spec.rb +31 -0
- data/spec/zaws/ec2/subnet/exists_spec.rb +33 -0
- data/spec/zaws/ec2/subnet/id_array_by_cidrblock_array_spec.rb +48 -0
- data/spec/zaws/ec2/subnet/id_by_cidrblock_spec.rb +35 -0
- data/spec/zaws/ec2/subnet/id_by_ip_spec.rb +42 -0
- data/spec/zaws/ec2/subnet/view_spec.rb +34 -0
- data/spec/zaws/elb/load_balancer/calculated_listener_spec.rb +18 -0
- data/spec/zaws/helper/option/absent_spec.rb +14 -0
- data/spec/zaws/helper/option/exclusive_spec.rb +14 -0
- data/spec/zaws/helper/option/exists_spec.rb +18 -0
- data/spec/zaws/helper/option/minimum_spec.rb +14 -0
- data/spec/zaws/helper/output/binary_nagios_check_spec.rb +19 -0
- data/spec/zaws/helper/output/colorize_spec.rb +30 -0
- data/spec/zaws/helper/output/opt_exclusive_spec.rb +14 -0
- data/spec/zaws/helper/output/opt_minimum_spec.rb +15 -0
- data/spec/zaws/helper/output/opt_required_spec.rb +12 -0
- data/spec/zaws/helper/shell/cli_spec.rb +33 -0
- data/spec/zaws/helper/shell/if_then_spec.rb +24 -0
- data/zaws.gemspec +34 -0
- metadata +350 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
Feature: Load Balancer
|
2
|
+
|
3
|
+
Scenario: Determine a load balancer exists in a vpc
|
4
|
+
Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
|
5
|
+
"""
|
6
|
+
{ "LoadBalancerDescriptions": [ { "LoadBalancerName": "name-???" } ] }
|
7
|
+
"""
|
8
|
+
When I run `bundle exec zaws load_balancer exists name-??? --region us-west-1`
|
9
|
+
Then the stdout should contain "true\n"
|
10
|
+
|
11
|
+
Scenario: Determine a load balancer does not exist in a vpc
|
12
|
+
Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
|
13
|
+
"""
|
14
|
+
{ "LoadBalancerDescriptions": [ ] }
|
15
|
+
"""
|
16
|
+
When I run `bundle exec zaws load_balancer exists name-??? --region us-west-1`
|
17
|
+
Then the stdout should contain "false\n"
|
18
|
+
|
19
|
+
Scenario: Declare load balancer in vpc
|
20
|
+
Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
|
21
|
+
"""
|
22
|
+
{ "LoadBalancerDescriptions": [ ] }
|
23
|
+
"""
|
24
|
+
And I double `aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=cidr,Values=10.0.0.0/28'` with stdout:
|
25
|
+
"""
|
26
|
+
{ "Subnets": [ { "SubnetId" : "subnet-A???","CidrBlock":"10.0.0.0/28" }] }
|
27
|
+
"""
|
28
|
+
And I double `aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=cidr,Values=10.0.1.0/28'` with stdout:
|
29
|
+
"""
|
30
|
+
{ "Subnets": [ { "SubnetId" : "subnet-B???" ,"CidrBlock":"10.0.1.0/28"}] }
|
31
|
+
"""
|
32
|
+
And I double `aws --output json --region us-west-1 ec2 describe-security-groups --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=group-name,Values=my_security_group_name'` with stdout:
|
33
|
+
"""
|
34
|
+
{ "SecurityGroups": [ { "GroupName": "my_security_group_name","GroupId": "sg-???" } ] }
|
35
|
+
"""
|
36
|
+
And I double `aws --region us-west-1 elb create-load-balancer --load-balancer-name newlb --listeners '[{"Protocol":"tcp","LoadBalancerPort":80,"InstanceProtocol":"tcp","InstancePort":80}]' --subnets subnet-A??? subnet-B??? --security-groups sg-???` with stdout:
|
37
|
+
"""
|
38
|
+
{ "DNSName": "???.us-west-1.elb.amazonaws.com" }
|
39
|
+
"""
|
40
|
+
When I run `bundle exec zaws load_balancer create_in_subnet newlb tcp 80 tcp 80 my_security_group_name --cidrblocks="10.0.0.0/28" "10.0.1.0/28" --vpcid my_vpc_id --region us-west-1`
|
41
|
+
Then the stdout should contain "Load balancer created.\n"
|
42
|
+
|
43
|
+
Scenario: Declare load balancer in vpc, Skip creation
|
44
|
+
Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
|
45
|
+
"""
|
46
|
+
{ "LoadBalancerDescriptions": [ { "LoadBalancerName": "name-???" } ] }
|
47
|
+
"""
|
48
|
+
When I run `bundle exec zaws load_balancer create_in_subnet name-??? tcp 80 tcp 80 my_security_group_name --cidrblocks="10.0.0.0/28" "10.0.1.0/28" --vpcid my_vpc_id --region us-west-1`
|
49
|
+
Then the stdout should contain "Load balancer already exists. Skipping creation.\n"
|
50
|
+
|
51
|
+
Scenario: Delete
|
52
|
+
Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
|
53
|
+
"""
|
54
|
+
{ "LoadBalancerDescriptions": [ { "LoadBalancerName": "name-???" }] }
|
55
|
+
"""
|
56
|
+
And I double `aws --region us-west-1 elb delete-load-balancer --load-balancer-name name-???` with stdout:
|
57
|
+
"""
|
58
|
+
{ "return": "true" }
|
59
|
+
"""
|
60
|
+
When I run `bundle exec zaws load_balancer delete "name-???" --region us-west-1`
|
61
|
+
Then the stdout should contain "Load balancer deleted.\n"
|
62
|
+
|
63
|
+
Scenario: Delete, skip
|
64
|
+
Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
|
65
|
+
"""
|
66
|
+
{ "LoadBalancerDescriptions": [ ] }
|
67
|
+
"""
|
68
|
+
When I run `bundle exec zaws load_balancer delete name-??? --region us-west-1`
|
69
|
+
Then the stdout should contain "Load balancer does not exist. Skipping deletion.\n"
|
70
|
+
|
71
|
+
Scenario: Nagios OK
|
72
|
+
Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
|
73
|
+
"""
|
74
|
+
{ "LoadBalancerDescriptions": [ { "LoadBalancerName": "name-???" } ] }
|
75
|
+
"""
|
76
|
+
When I run `bundle exec zaws load_balancer create_in_subnet name-??? tcp 80 tcp 80 my_security_group_name --cidrblocks="10.0.0.0/28" "10.0.1.0/28" --vpcid my_vpc_id --region us-west-1 --nagios`
|
77
|
+
Then the output should contain "OK: Load Balancer Exists.\n"
|
78
|
+
And the exit status should be 0
|
79
|
+
|
80
|
+
Scenario: Nagios CRITICAL
|
81
|
+
Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
|
82
|
+
"""
|
83
|
+
{ "LoadBalancerDescriptions": [ ] }
|
84
|
+
"""
|
85
|
+
When I run `bundle exec zaws load_balancer create_in_subnet name-??? tcp 80 tcp 80 my_security_group_name --cidrblocks="10.0.0.0/28" "10.0.1.0/28" --vpcid my_vpc_id --region us-west-1 --nagios`
|
86
|
+
Then the output should contain "CRITICAL: Load Balancer does not exist.\n"
|
87
|
+
And the exit status should be 2
|
88
|
+
|
89
|
+
Scenario: Undo file
|
90
|
+
Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
|
91
|
+
"""
|
92
|
+
{ "LoadBalancerDescriptions": [ { "LoadBalancerName": "name-???" } ] }
|
93
|
+
"""
|
94
|
+
Given an empty file named "undo.sh.1"
|
95
|
+
When I run `bundle exec zaws load_balancer create_in_subnet name-??? tcp 80 tcp 80 my_security_group_name --cidrblocks="10.0.0.0/28" "10.0.1.0/28" --vpcid my_vpc_id --region us-west-1 --undofile undo.sh.1`
|
96
|
+
Then the stdout should contain "Load balancer already exists. Skipping creation.\n"
|
97
|
+
And the file "undo.sh.1" should contain "zaws load_balancer delete name-??? --region us-west-1 $XTRA_OPTS"
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Feature: Load Balancer
|
2
|
+
|
3
|
+
Scenario: Get load balancer in a human readable table.
|
4
|
+
Given I double `aws --output table --region us-west-1 elb describe-load-balancers` with "AWS Load Balancer Output"
|
5
|
+
When I run `bundle exec zaws load_balancer view --region us-west-1 --viewtype table`
|
6
|
+
Then the stdout should contain "AWS Load Balancer Output\n"
|
7
|
+
|
8
|
+
Scenario: Get load balancer in a human readable table form by default
|
9
|
+
Given I double `aws --output table --region us-west-1 elb describe-load-balancers` with "AWS Load Balancer Output"
|
10
|
+
When I run `bundle exec zaws load_balancer view --region us-west-1`
|
11
|
+
Then the stdout should contain "AWS Load Balancer Output\n"
|
12
|
+
|
13
|
+
Scenario: Get load balancer in JSON form
|
14
|
+
Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with "AWS Load Balancer JSON Output"
|
15
|
+
When I run `bundle exec zaws load_balancer view --region us-west-1 --viewtype json`
|
16
|
+
Then the stdout should contain "AWS Load Balancer JSON Output\n"
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,128 @@
|
|
1
|
+
Feature: Route Table
|
2
|
+
|
3
|
+
Scenario: Determine that a subnet is associated to a route table
|
4
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=cidr,Values=my_cidr_block'` with stdout:
|
5
|
+
"""
|
6
|
+
{ "Subnets": [ { "SubnetId" : "X" } ] }
|
7
|
+
"""
|
8
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
9
|
+
"""
|
10
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX","Associations": [ { "SubnetId":"X" } ] } ] }
|
11
|
+
"""
|
12
|
+
When I run `bundle exec zaws route_table subnet_assoc_exists my_route_table my_cidr_block --region us-west-1 --vpcid my_vpc_id`
|
13
|
+
Then the output should contain "true\n"
|
14
|
+
|
15
|
+
Scenario: Determine that a subnet is NOT associated to a route table
|
16
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=cidr,Values=my_cidr_block'` with stdout:
|
17
|
+
"""
|
18
|
+
{ "Subnets": [ { "SubnetId" : "X" } ] }
|
19
|
+
"""
|
20
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
21
|
+
"""
|
22
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX","Associations": [ ] } ] }
|
23
|
+
"""
|
24
|
+
When I run `bundle exec zaws route_table subnet_assoc_exists my_route_table my_cidr_block --region us-west-1 --vpcid my_vpc_id`
|
25
|
+
Then the output should contain "false\n"
|
26
|
+
|
27
|
+
Scenario: Associate a subnet to a route table
|
28
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=cidr,Values=my_cidr_block'` with stdout:
|
29
|
+
"""
|
30
|
+
{ "Subnets": [ { "SubnetId" : "X" } ] }
|
31
|
+
"""
|
32
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
33
|
+
"""
|
34
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX","Associations": [ ] } ] }
|
35
|
+
"""
|
36
|
+
And I double `aws --region us-west-1 ec2 associate-route-table --subnet-id X --route-table-id rtb-XXXXXXX` with stdout:
|
37
|
+
"""
|
38
|
+
{ "AssociationId": "rtbassoc-???????" }
|
39
|
+
"""
|
40
|
+
When I run `bundle exec zaws route_table assoc_subnet my_route_table my_cidr_block --region us-west-1 --vpcid my_vpc_id`
|
41
|
+
Then the output should contain "Route table associated to subnet.\n"
|
42
|
+
|
43
|
+
Scenario: Associate a subnet to a route table, skip because it exists already
|
44
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=cidr,Values=my_cidr_block'` with stdout:
|
45
|
+
"""
|
46
|
+
{ "Subnets": [ { "SubnetId" : "X" } ] }
|
47
|
+
"""
|
48
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
49
|
+
"""
|
50
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX","Associations": [ { "SubnetId":"X" } ] } ] }
|
51
|
+
"""
|
52
|
+
When I run `bundle exec zaws route_table assoc_subnet my_route_table my_cidr_block --region us-west-1 --vpcid my_vpc_id`
|
53
|
+
Then the output should contain "Route table already associated to subnet. Skipping association.\n"
|
54
|
+
|
55
|
+
Scenario: Delete subnet association to route table
|
56
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=cidr,Values=my_cidr_block'` with stdout:
|
57
|
+
"""
|
58
|
+
{ "Subnets": [ { "SubnetId" : "X" } ] }
|
59
|
+
"""
|
60
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
61
|
+
"""
|
62
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX","Associations": [ { "SubnetId":"X","RouteTableAssociationId":"rtbassoc-????????" } ] } ] }
|
63
|
+
"""
|
64
|
+
And I double `aws --region us-west-1 ec2 disassociate-route-table --association-id rtbassoc-????????` with stdout:
|
65
|
+
"""
|
66
|
+
{ "return" : "true" }
|
67
|
+
"""
|
68
|
+
When I run `bundle exec zaws route_table delete_assoc_subnet my_route_table my_cidr_block --region us-west-1 --vpcid my_vpc_id`
|
69
|
+
Then the output should contain "Route table association to subnet deleted.\n"
|
70
|
+
|
71
|
+
Scenario: Delete subnet association to route table that does not exists, skip it.
|
72
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=cidr,Values=my_cidr_block'` with stdout:
|
73
|
+
"""
|
74
|
+
{ "Subnets": [ { "SubnetId" : "X" } ] }
|
75
|
+
"""
|
76
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
77
|
+
"""
|
78
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX","Associations": [ ] } ] }
|
79
|
+
"""
|
80
|
+
When I run `bundle exec zaws route_table delete_assoc_subnet my_route_table my_cidr_block --region us-west-1 --vpcid my_vpc_id`
|
81
|
+
Then the output should contain "Route table association to subnet not deleted because it does not exist.\n"
|
82
|
+
|
83
|
+
Scenario: Nagios OK
|
84
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=cidr,Values=my_cidr_block'` with stdout:
|
85
|
+
"""
|
86
|
+
{ "Subnets": [ { "SubnetId" : "X" } ] }
|
87
|
+
"""
|
88
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
89
|
+
"""
|
90
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX","Associations": [ { "SubnetId":"X" } ] } ] }
|
91
|
+
"""
|
92
|
+
When I run `bundle exec zaws route_table assoc_subnet my_route_table my_cidr_block --region us-west-1 --vpcid my_vpc_id --nagios`
|
93
|
+
Then the output should contain "OK: Route table association to subnet exists.\n"
|
94
|
+
And the exit status should be 0
|
95
|
+
|
96
|
+
Scenario: Nagios CRITICAL
|
97
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=cidr,Values=my_cidr_block'` with stdout:
|
98
|
+
"""
|
99
|
+
{ "Subnets": [ { "SubnetId" : "X" } ] }
|
100
|
+
"""
|
101
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
102
|
+
"""
|
103
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX","Associations": [ ] } ] }
|
104
|
+
"""
|
105
|
+
When I run `bundle exec zaws route_table assoc_subnet my_route_table my_cidr_block --region us-west-1 --vpcid my_vpc_id --nagios`
|
106
|
+
Then the output should contain "CRITICAL: Route table association to subnet does not exist.\n"
|
107
|
+
And the exit status should be 2
|
108
|
+
|
109
|
+
Scenario: Undo file
|
110
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-subnets --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=cidr,Values=my_cidr_block'` with stdout:
|
111
|
+
"""
|
112
|
+
{ "Subnets": [ { "SubnetId" : "X" } ] }
|
113
|
+
"""
|
114
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
115
|
+
"""
|
116
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX","Associations": [ ] } ] }
|
117
|
+
"""
|
118
|
+
And I double `aws --region us-west-1 ec2 associate-route-table --subnet-id X --route-table-id rtb-XXXXXXX` with stdout:
|
119
|
+
"""
|
120
|
+
{ "AssociationId": "rtbassoc-???????" }
|
121
|
+
"""
|
122
|
+
Given an empty file named "undo.sh.1"
|
123
|
+
When I run `bundle exec zaws route_table assoc_subnet my_route_table my_cidr_block --region us-west-1 --vpcid my_vpc_id --undofile undo.sh.1`
|
124
|
+
Then the output should contain "Route table associated to subnet.\n"
|
125
|
+
And the file "undo.sh.1" should contain "zaws route_table delete_assoc_subnet my_route_table my_cidr_block --region us-west-1 --vpcid my_vpc_id"
|
126
|
+
|
127
|
+
|
128
|
+
|
@@ -0,0 +1,93 @@
|
|
1
|
+
Feature: Route to Gateway
|
2
|
+
|
3
|
+
Scenario: Determine a route propagation exsits by virtual gateway and route table
|
4
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
5
|
+
"""
|
6
|
+
{ "RouteTables": [ { "PropagatingVgws" : [ { "GatewayId":"vgw-????????" } ] } ] }
|
7
|
+
"""
|
8
|
+
When I run `bundle exec zaws route_table propagation_exists_from_gateway my_route_table vgw-???????? --region us-west-1 --vpcid my_vpc_id`
|
9
|
+
Then the output should contain "true\n"
|
10
|
+
|
11
|
+
Scenario: Determine a route propagation does not exsits by gateway id and route table
|
12
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
13
|
+
"""
|
14
|
+
{ "RouteTables": [ { "PropagatingVgws" : [] } ] }
|
15
|
+
"""
|
16
|
+
When I run `bundle exec zaws route_table propagation_exists_from_gateway my_route_table vgw-???????? --region us-west-1 --vpcid my_vpc_id`
|
17
|
+
Then the output should contain "false\n"
|
18
|
+
|
19
|
+
Scenario: Declare route propagation by gateway id and route table
|
20
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
21
|
+
"""
|
22
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-????????","PropagatingVgws" : [] } ] }
|
23
|
+
"""
|
24
|
+
And I double `aws --region us-west-1 ec2 enable-vgw-route-propagation --route-table-id rtb-???????? --gateway-id vgw-????????` with stdout:
|
25
|
+
"""
|
26
|
+
{ "return": "true" }
|
27
|
+
"""
|
28
|
+
When I run `bundle exec zaws route_table declare_propagation_from_gateway my_route_table vgw-???????? --region us-west-1 --vpcid my_vpc_id`
|
29
|
+
Then the output should contain "Route propagation from gateway enabled.\n"
|
30
|
+
|
31
|
+
Scenario: Declare route propagation by gateway id and route table, but skip
|
32
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
33
|
+
"""
|
34
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-????????","PropagatingVgws" : [ { "GatewayId":"vgw-????????" } ] } ] }
|
35
|
+
"""
|
36
|
+
When I run `bundle exec zaws route_table declare_propagation_from_gateway my_route_table vgw-???????? --region us-west-1 --vpcid my_vpc_id`
|
37
|
+
Then the output should contain "Route propagation from gateway already enabled. Skipping propagation.\n"
|
38
|
+
|
39
|
+
Scenario: Delete route propagation from gateway.
|
40
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
41
|
+
"""
|
42
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-????????","PropagatingVgws" : [ { "GatewayId":"vgw-????????" } ] } ] }
|
43
|
+
"""
|
44
|
+
And I double `aws --region us-west-1 ec2 disable-vgw-route-propagation --route-table-id rtb-???????? --gateway-id vgw-????????` with stdout:
|
45
|
+
"""
|
46
|
+
{ "return": "true" }
|
47
|
+
"""
|
48
|
+
When I run `bundle exec zaws route_table delete_propagation_from_gateway my_route_table vgw-???????? --region us-west-1 --vpcid my_vpc_id`
|
49
|
+
Then the output should contain "Deleted route propagation from gateway.\n"
|
50
|
+
|
51
|
+
Scenario: Delete route propagation from gateway, but skip it because it doesn't exist.
|
52
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
53
|
+
"""
|
54
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-????????","PropagatingVgws" : [ ] } ] }
|
55
|
+
"""
|
56
|
+
When I run `bundle exec zaws route_table delete_propagation_from_gateway my_route_table vgw-???????? --region us-west-1 --vpcid my_vpc_id`
|
57
|
+
Then the output should contain "Route propagation from gateway does not exist, skipping deletion.\n"
|
58
|
+
|
59
|
+
Scenario: Nagios OK
|
60
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
61
|
+
"""
|
62
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-????????","PropagatingVgws" : [ { "GatewayId":"vgw-????????" } ] } ] }
|
63
|
+
"""
|
64
|
+
When I run `bundle exec zaws route_table declare_propagation_from_gateway my_route_table vgw-???????? --region us-west-1 --vpcid my_vpc_id --nagios`
|
65
|
+
Then the output should contain "OK: Route propagation from gateway enabled.\n"
|
66
|
+
And the exit status should be 0
|
67
|
+
|
68
|
+
Scenario: Nagios CRITICAL
|
69
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
70
|
+
"""
|
71
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-????????","PropagatingVgws" : [] } ] }
|
72
|
+
"""
|
73
|
+
When I run `bundle exec zaws route_table declare_propagation_from_gateway my_route_table vgw-???????? --region us-west-1 --vpcid my_vpc_id --nagios`
|
74
|
+
Then the output should contain "CRITICAL: Route propagation from gateway not enabled.\n"
|
75
|
+
And the exit status should be 2
|
76
|
+
|
77
|
+
Scenario: Undo file
|
78
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
79
|
+
"""
|
80
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-????????","PropagatingVgws" : [] } ] }
|
81
|
+
"""
|
82
|
+
And I double `aws --region us-west-1 ec2 enable-vgw-route-propagation --route-table-id rtb-???????? --gateway-id vgw-????????` with stdout:
|
83
|
+
"""
|
84
|
+
{ "return": "true" }
|
85
|
+
"""
|
86
|
+
Given an empty file named "undo.sh.1"
|
87
|
+
When I run `bundle exec zaws route_table declare_propagation_from_gateway my_route_table vgw-???????? --region us-west-1 --vpcid my_vpc_id --undofile undo.sh.1`
|
88
|
+
Then the output should contain "Route propagation from gateway enabled.\n"
|
89
|
+
And the file "undo.sh.1" should contain "zaws route_table delete_propagation_from_gateway my_route_table vgw-???????? --region us-west-1 --vpcid my_vpc_id $XTRA_OPTS"
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
@@ -0,0 +1,91 @@
|
|
1
|
+
Feature: Route Table
|
2
|
+
Route Tables control network traffic in AWS between subnets and gateways.
|
3
|
+
|
4
|
+
Scenario: Determine a route table DOES NOT exists by external id
|
5
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
6
|
+
"""
|
7
|
+
{ "RouteTables": [] }
|
8
|
+
"""
|
9
|
+
When I run `bundle exec zaws route_table exists_by_external_id my_route_table --region us-west-1 --vpcid my_vpc_id`
|
10
|
+
Then the output should contain "false\n"
|
11
|
+
|
12
|
+
Scenario: Determine a route table exists by external id
|
13
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
14
|
+
"""
|
15
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX" } ] }
|
16
|
+
"""
|
17
|
+
When I run `bundle exec zaws route_table exists_by_external_id my_route_table --region us-west-1 --vpcid my_vpc_id`
|
18
|
+
Then the output should contain "true\n"
|
19
|
+
|
20
|
+
Scenario: Declare route table by external id
|
21
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
22
|
+
"""
|
23
|
+
{ "RouteTables": [] }
|
24
|
+
"""
|
25
|
+
And I double `aws --region us-west-1 ec2 create-route-table --vpc-id my_vpc_id` with stdout:
|
26
|
+
"""
|
27
|
+
{ "RouteTable": { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX" } }
|
28
|
+
"""
|
29
|
+
And I double `aws --region us-west-1 ec2 create-tags --resources rtb-XXXXXXX --tags Key=externalid,Value=my_route_table` with stdout:
|
30
|
+
"""
|
31
|
+
{ "return": "true" }
|
32
|
+
"""
|
33
|
+
When I run `bundle exec zaws route_table declare my_route_table --region us-west-1 --vpcid my_vpc_id`
|
34
|
+
Then the output should contain "Route table created with external id: my_route_table.\n"
|
35
|
+
|
36
|
+
Scenario: Declare route table by external id, but DO NOT create it because it exists
|
37
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
38
|
+
"""
|
39
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX" } ] }
|
40
|
+
"""
|
41
|
+
When I run `bundle exec zaws route_table declare my_route_table --region us-west-1 --vpcid my_vpc_id`
|
42
|
+
Then the output should contain "Route table exists already. Skipping Creation.\n"
|
43
|
+
|
44
|
+
Scenario: Delete a route table in a vpc, but skip it cause it does not exist
|
45
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
46
|
+
"""
|
47
|
+
{ "RouteTables": [] }
|
48
|
+
"""
|
49
|
+
When I run `bundle exec zaws route_table delete my_route_table --region us-west-1 --vpcid my_vpc_id`
|
50
|
+
Then the output should contain "Route table does not exist. Skipping deletion.\n"
|
51
|
+
|
52
|
+
Scenario: Delete a route table in a vpc
|
53
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
54
|
+
"""
|
55
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX" } ] }
|
56
|
+
"""
|
57
|
+
And I double `aws --region us-west-1 ec2 delete-route-table --route-table-id rtb-XXXXXXX` with stdout:
|
58
|
+
"""
|
59
|
+
{ "return": "true" }
|
60
|
+
"""
|
61
|
+
When I run `bundle exec zaws route_table delete my_route_table --region us-west-1 --vpcid my_vpc_id`
|
62
|
+
Then the output should contain "Route table deleted.\n"
|
63
|
+
|
64
|
+
Scenario: Perform a nagios check, with the result indicatin OK (exit 0), indicating declaring a route table requires no action because it exists.
|
65
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
66
|
+
"""
|
67
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX" } ] }
|
68
|
+
"""
|
69
|
+
When I run `bundle exec zaws route_table declare my_route_table --region us-west-1 --vpcid my_vpc_id --nagios`
|
70
|
+
Then the output should contain "OK: Route table exists.\n"
|
71
|
+
And the exit status should be 0
|
72
|
+
|
73
|
+
Scenario: Perform a nagios check, with the result indicatin CRITICAL (exit 2), indicating declaring a security group requires action because it does not exist.
|
74
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
75
|
+
"""
|
76
|
+
{ "RouteTables": [ ] }
|
77
|
+
"""
|
78
|
+
When I run `bundle exec zaws route_table declare my_route_table --region us-west-1 --vpcid my_vpc_id --nagios`
|
79
|
+
Then the output should contain "CRITICAL: Route table does not exist.\n"
|
80
|
+
And the exit status should be 2
|
81
|
+
|
82
|
+
Scenario: Declaring a route to an instance, should append the command to remove the security group to file.
|
83
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
84
|
+
"""
|
85
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX" } ] }
|
86
|
+
"""
|
87
|
+
Given an empty file named "undo.sh.1"
|
88
|
+
When I run `bundle exec zaws route_table declare my_route_table --region us-west-1 --vpcid my_vpc_id --undofile undo.sh.1`
|
89
|
+
Then the output should contain "Route table exists already. Skipping Creation.\n"
|
90
|
+
And the file "undo.sh.1" should contain "zaws route_table delete my_route_table --region us-west-1 --vpcid my_vpc_id $XTRA_OPTS"
|
91
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
Feature: Route to Gateway
|
2
|
+
|
3
|
+
Scenario: Determine a route DOES NOT exist to a gateway by a gateway id
|
4
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
5
|
+
"""
|
6
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ { "GatewayId": "igw-XXXXXXX", "DestinationCidrBlock": "0.0.0.0/0" } ] } ] }
|
7
|
+
"""
|
8
|
+
When I run `bundle exec zaws route_table route_exists_by_gatewayid my_route_table 0.0.0.0/0 igw-XXXXXXX --region us-west-1 --vpcid my_vpc_id`
|
9
|
+
Then the output should contain "true\n"
|
10
|
+
|
11
|
+
Scenario: Determine a route to a gateway by a gateway id does not exist
|
12
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
13
|
+
"""
|
14
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ { "GatewayId": "igw-YYYYYYY", "DestinationCidrBlock": "0.0.0.0/0" } ] } ] }
|
15
|
+
"""
|
16
|
+
When I run `bundle exec zaws route_table route_exists_by_gatewayid my_route_table 0.0.0.0/0 igw-XXXXXXX --region us-west-1 --vpcid my_vpc_id`
|
17
|
+
Then the output should contain "false\n"
|
18
|
+
|
19
|
+
Scenario: Declare route to gateway id
|
20
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
21
|
+
"""
|
22
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "0.0.0.0/0", "GatewayId": "igw-YYYYYYY"} ] } ] }
|
23
|
+
"""
|
24
|
+
And I double `aws --region us-west-1 ec2 create-route --route-table-id rtb-XXXXXXX --destination-cidr-block 0.0.0.0/0 --gateway-id igw-XXXXXXX` with stdout:
|
25
|
+
"""
|
26
|
+
{ "return" : "true" }
|
27
|
+
"""
|
28
|
+
When I run `bundle exec zaws route_table declare_route_to_gateway my_route_table 0.0.0.0/0 igw-XXXXXXX --region us-west-1 --vpcid my_vpc_id`
|
29
|
+
Then the output should contain "Route created to gateway.\n"
|
30
|
+
|
31
|
+
Scenario: Declare route to gateway id, but skip it because it exists
|
32
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
33
|
+
"""
|
34
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "0.0.0.0/0", "GatewayId": "igw-XXXXXXX"} ] } ] }
|
35
|
+
"""
|
36
|
+
When I run `bundle exec zaws route_table declare_route_to_gateway my_route_table 0.0.0.0/0 igw-XXXXXXX --region us-west-1 --vpcid my_vpc_id`
|
37
|
+
Then the output should contain "Route to gateway exists. Skipping creation.\n"
|
38
|
+
|
39
|
+
Scenario: Nagios OK
|
40
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
41
|
+
"""
|
42
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "0.0.0.0/0", "GatewayId": "igw-XXXXXXX"} ] } ] }
|
43
|
+
"""
|
44
|
+
When I run `bundle exec zaws route_table declare_route_to_gateway my_route_table 0.0.0.0/0 igw-XXXXXXX --region us-west-1 --vpcid my_vpc_id --nagios`
|
45
|
+
Then the output should contain "OK: Route to gateway exists.\n"
|
46
|
+
|
47
|
+
|
48
|
+
Scenario: Nagios CRITICAL
|
49
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
50
|
+
"""
|
51
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "0.0.0.0/0", "GatewayId": "igw-YYYYYYY"} ] } ] }
|
52
|
+
"""
|
53
|
+
When I run `bundle exec zaws route_table declare_route_to_gateway my_route_table 0.0.0.0/0 igw-XXXXXXX --region us-west-1 --vpcid my_vpc_id --nagios`
|
54
|
+
Then the output should contain "CRITICAL: Route to gateway does not exist.\n"
|
55
|
+
|
56
|
+
|
57
|
+
Scenario: Undo file
|
58
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
59
|
+
"""
|
60
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "0.0.0.0/0", "GatewayId": "igw-XXXXXXX"} ] } ] }
|
61
|
+
"""
|
62
|
+
Given an empty file named "undo.sh.1"
|
63
|
+
When I run `bundle exec zaws route_table declare_route_to_gateway my_route_table 0.0.0.0/0 igw-XXXXXXX --region us-west-1 --vpcid my_vpc_id --undofile undo.sh.1`
|
64
|
+
Then the output should contain "Route to gateway exists. Skipping creation.\n"
|
65
|
+
And the file "undo.sh.1" should contain "zaws route_table delete_route my_route_table 0.0.0.0/0 --region us-west-1 --vpcid my_vpc_id $XTRA_OPTS"
|
66
|
+
|
67
|
+
|
68
|
+
#Deletion and Undo file covered by route_to_instance.feature because deletion requires route table and cidrblock only.
|
69
|
+
|
@@ -0,0 +1,115 @@
|
|
1
|
+
Feature: Route Table
|
2
|
+
Route Tables control network traffic in AWS between subnets and gateways.
|
3
|
+
|
4
|
+
Scenario: Determine a route DOES NOT exist to an instance by instance external id
|
5
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-instances --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_instance'` with stdout:
|
6
|
+
"""
|
7
|
+
{ "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
|
8
|
+
"""
|
9
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
10
|
+
"""
|
11
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "0.0.0.0/0", "InstanceId": "i-YYYYYYY"} ] } ] }
|
12
|
+
"""
|
13
|
+
When I run `bundle exec zaws route_table route_exists_by_instance my_route_table 0.0.0.0/0 my_instance --region us-west-1 --vpcid my_vpc_id`
|
14
|
+
Then the output should contain "false\n"
|
15
|
+
|
16
|
+
Scenario: Determine a route exists to an instance by instance external id
|
17
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-instances --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_instance'` with stdout:
|
18
|
+
"""
|
19
|
+
{ "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
|
20
|
+
"""
|
21
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
22
|
+
"""
|
23
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "0.0.0.0/0", "InstanceId": "i-XXXXXXX"} ] } ] }
|
24
|
+
"""
|
25
|
+
When I run `bundle exec zaws route_table route_exists_by_instance my_route_table 0.0.0.0/0 my_instance --region us-west-1 --vpcid my_vpc_id`
|
26
|
+
Then the output should contain "true\n"
|
27
|
+
|
28
|
+
Scenario: Declare route to an instance by instance external id
|
29
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-instances --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_instance'` with stdout:
|
30
|
+
"""
|
31
|
+
{ "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
|
32
|
+
"""
|
33
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
34
|
+
"""
|
35
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "0.0.0.0/0", "InstanceId": "i-YYYYYYY"} ] } ] }
|
36
|
+
"""
|
37
|
+
And I double `aws --region us-west-1 ec2 create-route --route-table-id rtb-XXXXXXX --destination-cidr-block 0.0.0.0/0 --instance-id i-XXXXXXX` with stdout:
|
38
|
+
"""
|
39
|
+
{ "return" : "true" }
|
40
|
+
"""
|
41
|
+
When I run `bundle exec zaws route_table declare_route my_route_table 0.0.0.0/0 my_instance --region us-west-1 --vpcid my_vpc_id`
|
42
|
+
Then the output should contain "Route created to instance.\n"
|
43
|
+
|
44
|
+
Scenario: Declare route to an instance by instance external id, but skip createion because it exists.
|
45
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-instances --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_instance'` with stdout:
|
46
|
+
"""
|
47
|
+
{ "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
|
48
|
+
"""
|
49
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
50
|
+
"""
|
51
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "0.0.0.0/0", "InstanceId": "i-XXXXXXX"} ] } ] }
|
52
|
+
"""
|
53
|
+
When I run `bundle exec zaws route_table declare_route my_route_table 0.0.0.0/0 my_instance --region us-west-1 --vpcid my_vpc_id`
|
54
|
+
Then the output should contain "Route not created to instance. Skip creation.\n"
|
55
|
+
|
56
|
+
Scenario: Delete route
|
57
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
58
|
+
"""
|
59
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "0.0.0.0/0", "InstanceId": "i-XXXXXXX"} ] } ] }
|
60
|
+
"""
|
61
|
+
And I double `aws --region us-west-1 ec2 delete-route --route-table-id rtb-XXXXXXX --destination-cidr-block 0.0.0.0/0` with stdout:
|
62
|
+
"""
|
63
|
+
{ "return" : "true" }
|
64
|
+
"""
|
65
|
+
When I run `bundle exec zaws route_table delete_route my_route_table 0.0.0.0/0 --region us-west-1 --vpcid my_vpc_id`
|
66
|
+
Then the output should contain "Route deleted.\n"
|
67
|
+
|
68
|
+
Scenario: Delete route skipped because it doesn't exist
|
69
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
70
|
+
"""
|
71
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "1.1.1.1/0", "InstanceId": "i-XXXXXXX"} ] } ] }
|
72
|
+
"""
|
73
|
+
When I run `bundle exec zaws route_table delete_route my_route_table 0.0.0.0/0 --region us-west-1 --vpcid my_vpc_id`
|
74
|
+
Then the output should contain "Route does not exist. Skipping deletion.\n"
|
75
|
+
|
76
|
+
Scenario: Perform a nagios check, with the result indicatin OK (exit 0), indicating declaring a route requires no action because it exists.
|
77
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-instances --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_instance'` with stdout:
|
78
|
+
"""
|
79
|
+
{ "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
|
80
|
+
"""
|
81
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
82
|
+
"""
|
83
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "0.0.0.0/0", "InstanceId": "i-XXXXXXX"} ] } ] }
|
84
|
+
"""
|
85
|
+
When I run `bundle exec zaws route_table declare_route my_route_table 0.0.0.0/0 my_instance --region us-west-1 --vpcid my_vpc_id --nagios`
|
86
|
+
Then the output should contain "OK: Route to instance exists.\n"
|
87
|
+
And the exit status should be 0
|
88
|
+
|
89
|
+
Scenario: Perform a nagios check, with the result indicatin CRITICAL (exit 2), indicating declaring a security group requires action because it does not exist.
|
90
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-instances --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_instance'` with stdout:
|
91
|
+
"""
|
92
|
+
{ "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
|
93
|
+
"""
|
94
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
95
|
+
"""
|
96
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "0.0.0.0/0", "InstanceId": "i-YYYYYYY"} ] } ] }
|
97
|
+
"""
|
98
|
+
When I run `bundle exec zaws route_table declare_route my_route_table 0.0.0.0/0 my_instance --region us-west-1 --vpcid my_vpc_id --nagios`
|
99
|
+
Then the output should contain "CRITICAL: Route to instance does not exist.\n"
|
100
|
+
And the exit status should be 2
|
101
|
+
|
102
|
+
Scenario: Declaring a route to an instance, should append the command to remove the security group to file.
|
103
|
+
Given I double `aws --output json --region us-west-1 ec2 describe-instances --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_instance'` with stdout:
|
104
|
+
"""
|
105
|
+
{ "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
|
106
|
+
"""
|
107
|
+
And I double `aws --output json --region us-west-1 ec2 describe-route-tables --filter 'Name=vpc-id,Values=my_vpc_id' 'Name=tag:externalid,Values=my_route_table'` with stdout:
|
108
|
+
"""
|
109
|
+
{ "RouteTables": [ { "VpcId":"my_vpc_id","RouteTableId":"rtb-XXXXXXX", "Routes":[ {"DestinationCidrBlock": "0.0.0.0/0", "InstanceId": "i-XXXXXXX"} ] } ] }
|
110
|
+
"""
|
111
|
+
Given an empty file named "undo.sh.1"
|
112
|
+
When I run `bundle exec zaws route_table declare_route my_route_table 0.0.0.0/0 my_instance --region us-west-1 --vpcid my_vpc_id --undofile undo.sh.1`
|
113
|
+
Then the output should contain "Route not created to instance. Skip creation.\n"
|
114
|
+
And the file "undo.sh.1" should contain "zaws route_table delete_route my_route_table 0.0.0.0/0 --region us-west-1 --vpcid my_vpc_id $XTRA_OPTS"
|
115
|
+
|