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.
Files changed (89) hide show
  1. data/.gitignore +35 -0
  2. data/.travis.yml +20 -0
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +78 -0
  5. data/LICENSE +204 -0
  6. data/README.md +17 -0
  7. data/Rakefile +26 -0
  8. data/bin/zaws +20 -0
  9. data/feature/compute/assoc_security_group.feature +55 -0
  10. data/feature/compute/compute.feature +138 -0
  11. data/feature/compute/secondary_ip.feature +107 -0
  12. data/feature/compute/view.feature +23 -0
  13. data/feature/compute/view_images.feature +24 -0
  14. data/feature/elasticip/elasticip.feature +138 -0
  15. data/feature/elasticip/view.feature +18 -0
  16. data/feature/hosted_zone/view.feature +17 -0
  17. data/feature/hosted_zone/view_record.feature +29 -0
  18. data/feature/load_balancer/instance_registration.feature +120 -0
  19. data/feature/load_balancer/listener.feature +86 -0
  20. data/feature/load_balancer/load_balancer.feature +101 -0
  21. data/feature/load_balancer/view.feature +18 -0
  22. data/feature/route_table/assoc_subnet.feature +128 -0
  23. data/feature/route_table/route_propagation.feature +93 -0
  24. data/feature/route_table/route_table.feature +91 -0
  25. data/feature/route_table/route_to_gateway.feature +69 -0
  26. data/feature/route_table/route_to_instance.feature +115 -0
  27. data/feature/route_table/view.feature +25 -0
  28. data/feature/security_group/ingress.feature +184 -0
  29. data/feature/security_group/security_group.feature +107 -0
  30. data/feature/security_group/view.feature +23 -0
  31. data/feature/subnet/subnet.feature +92 -0
  32. data/feature/subnet/view.feature +24 -0
  33. data/feature/support/env.rb +14 -0
  34. data/feature/version.feature +6 -0
  35. data/lib/zaws/aws.rb +26 -0
  36. data/lib/zaws/command/compute.rb +100 -0
  37. data/lib/zaws/command/elasticip.rb +47 -0
  38. data/lib/zaws/command/hosted_zone.rb +26 -0
  39. data/lib/zaws/command/load_balancer.rb +113 -0
  40. data/lib/zaws/command/route_table.rb +134 -0
  41. data/lib/zaws/command/security_group.rb +69 -0
  42. data/lib/zaws/command/subnet.rb +65 -0
  43. data/lib/zaws/ec2/compute.rb +247 -0
  44. data/lib/zaws/ec2/elasticip.rb +85 -0
  45. data/lib/zaws/ec2/route_table.rb +202 -0
  46. data/lib/zaws/ec2/security_group.rb +116 -0
  47. data/lib/zaws/ec2/subnet.rb +108 -0
  48. data/lib/zaws/ec2.rb +40 -0
  49. data/lib/zaws/elb/load_balancer.rb +157 -0
  50. data/lib/zaws/elb.rb +20 -0
  51. data/lib/zaws/helper/file.rb +23 -0
  52. data/lib/zaws/helper/option.rb +24 -0
  53. data/lib/zaws/helper/output.rb +46 -0
  54. data/lib/zaws/helper/shell.rb +25 -0
  55. data/lib/zaws/route53/hosted_zone.rb +36 -0
  56. data/lib/zaws/route53.rb +20 -0
  57. data/lib/zaws/version.rb +3 -0
  58. data/lib/zaws.rb +57 -0
  59. data/spec/spec_helper.rb +4 -0
  60. data/spec/zaws/ec2/compute/add_volume_spec.rb +39 -0
  61. data/spec/zaws/ec2/compute/block_device_mapping_spec.rb +31 -0
  62. data/spec/zaws/ec2/compute/instance_id_by_external_id_spec.rb +23 -0
  63. data/spec/zaws/ec2/compute/instance_ping_spec.rb +34 -0
  64. data/spec/zaws/ec2/compute/instance_running_spec.rb +47 -0
  65. data/spec/zaws/ec2/compute/network_interface_json_spec.rb +57 -0
  66. data/spec/zaws/ec2/compute/nosdcheck_spec.rb +17 -0
  67. data/spec/zaws/ec2/compute/tag_instance_spec.rb +21 -0
  68. data/spec/zaws/ec2/security_group/id_by_name_spec.rb +32 -0
  69. data/spec/zaws/ec2/subnet/available_spec.rb +22 -0
  70. data/spec/zaws/ec2/subnet/declare_spec.rb +31 -0
  71. data/spec/zaws/ec2/subnet/exists_spec.rb +33 -0
  72. data/spec/zaws/ec2/subnet/id_array_by_cidrblock_array_spec.rb +48 -0
  73. data/spec/zaws/ec2/subnet/id_by_cidrblock_spec.rb +35 -0
  74. data/spec/zaws/ec2/subnet/id_by_ip_spec.rb +42 -0
  75. data/spec/zaws/ec2/subnet/view_spec.rb +34 -0
  76. data/spec/zaws/elb/load_balancer/calculated_listener_spec.rb +18 -0
  77. data/spec/zaws/helper/option/absent_spec.rb +14 -0
  78. data/spec/zaws/helper/option/exclusive_spec.rb +14 -0
  79. data/spec/zaws/helper/option/exists_spec.rb +18 -0
  80. data/spec/zaws/helper/option/minimum_spec.rb +14 -0
  81. data/spec/zaws/helper/output/binary_nagios_check_spec.rb +19 -0
  82. data/spec/zaws/helper/output/colorize_spec.rb +30 -0
  83. data/spec/zaws/helper/output/opt_exclusive_spec.rb +14 -0
  84. data/spec/zaws/helper/output/opt_minimum_spec.rb +15 -0
  85. data/spec/zaws/helper/output/opt_required_spec.rb +12 -0
  86. data/spec/zaws/helper/shell/cli_spec.rb +33 -0
  87. data/spec/zaws/helper/shell/if_then_spec.rb +24 -0
  88. data/zaws.gemspec +34 -0
  89. metadata +350 -0
@@ -0,0 +1,107 @@
1
+ Feature: Compute
2
+
3
+ Scenario: Determine secondary ip exists on instance by external ip
4
+ 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:
5
+ """
6
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX",
7
+ "NetworkInterfaces" : [ { "PrivateIpAddresses" : [ { "PrivateIpAddress" : "0.0.0.0" } ] } ],
8
+ "Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
9
+ """
10
+ When I run `bundle exec zaws compute exists_secondary_ip my_instance 0.0.0.0 --region us-west-1 --vpcid my_vpc_id`
11
+ Then the output should contain "true\n"
12
+
13
+ Scenario: Determine secondary ip does not exist on instance by external ip
14
+ 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:
15
+ """
16
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX",
17
+ "NetworkInterfaces" : [ { "PrivateIpAddresses" : [ { "PrivateIpAddress" : "0.0.0.1" } ] } ],
18
+ "Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
19
+ """
20
+ When I run `bundle exec zaws compute exists_secondary_ip my_instance 0.0.0.0 --region us-west-1 --vpcid my_vpc_id`
21
+ Then the output should contain "false\n"
22
+
23
+ Scenario: Declare secondary ip for instance by external ip
24
+ 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:
25
+ """
26
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX",
27
+ "NetworkInterfaces" : [ { "NetworkInterfaceId": "net-123", "PrivateIpAddresses" : [ { "PrivateIpAddress" : "0.0.0.1" } ] } ],
28
+ "Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
29
+ """
30
+ Given I double `aws --output json --region us-west-1 ec2 assign-private-ip-addresses --network-interface-id 'net-123' --private-ip-addresses '0.0.0.0'` with stdout:
31
+ """
32
+ { "return" : "true" }
33
+ """
34
+ When I run `bundle exec zaws compute declare_secondary_ip my_instance 0.0.0.0 --region us-west-1 --vpcid my_vpc_id`
35
+ Then the output should contain "Secondary ip assigned.\n"
36
+
37
+ Scenario: Skip declaring secondary ip for instance by external ip because it exists already.
38
+ 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:
39
+ """
40
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX",
41
+ "NetworkInterfaces" : [ { "PrivateIpAddresses" : [ { "PrivateIpAddress" : "0.0.0.0" } ] } ],
42
+ "Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
43
+ """
44
+ When I run `bundle exec zaws compute declare_secondary_ip my_instance 0.0.0.0 --region us-west-1 --vpcid my_vpc_id`
45
+ Then the output should contain "Secondary ip already exists. Skipping assignment.\n"
46
+
47
+ Scenario: Delete
48
+ 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:
49
+ """
50
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX",
51
+ "NetworkInterfaces" : [ { "NetworkInterfaceId": "net-123", "PrivateIpAddresses" : [ { "PrivateIpAddress" : "0.0.0.0" } ] } ],
52
+ "Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
53
+ """
54
+ Given I double `aws --output json --region us-west-1 ec2 unassign-private-ip-addresses --network-interface-id 'net-123' --private-ip-addresses '0.0.0.0'` with stdout:
55
+ """
56
+ { "return" : "true" }
57
+ """
58
+ When I run `bundle exec zaws compute delete_secondary_ip my_instance 0.0.0.0 --region us-west-1 --vpcid my_vpc_id`
59
+ Then the output should contain "Secondary ip deleted.\n"
60
+
61
+ Scenario: Delete, skip
62
+ 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:
63
+ """
64
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX",
65
+ "NetworkInterfaces" : [ { "PrivateIpAddresses" : [ { "PrivateIpAddress" : "0.0.0.1" } ] } ],
66
+ "Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
67
+ """
68
+ When I run `bundle exec zaws compute delete_secondary_ip my_instance 0.0.0.0 --region us-west-1 --vpcid my_vpc_id`
69
+ Then the output should contain "Secondary IP does not exists, skipping deletion.\n"
70
+
71
+ Scenario: Nagios OK
72
+ 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:
73
+ """
74
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX",
75
+ "NetworkInterfaces" : [ { "NetworkInterfaceId": "net-123", "PrivateIpAddresses" : [ { "PrivateIpAddress" : "0.0.0.0" } ] } ],
76
+ "Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
77
+ """
78
+ When I run `bundle exec zaws compute declare_secondary_ip my_instance 0.0.0.0 --region us-west-1 --vpcid my_vpc_id --nagios`
79
+ Then the output should contain "OK: Secondary ip exists.\n"
80
+
81
+ Scenario: Nagios CRITICAL
82
+ 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:
83
+ """
84
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX",
85
+ "NetworkInterfaces" : [ { "NetworkInterfaceId": "net-123", "PrivateIpAddresses" : [ { "PrivateIpAddress" : "0.0.0.1" } ] } ],
86
+ "Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
87
+ """
88
+ When I run `bundle exec zaws compute declare_secondary_ip my_instance 0.0.0.0 --region us-west-1 --vpcid my_vpc_id --nagios`
89
+ Then the output should contain "CRITICAL: Secondary ip does not exist.\n"
90
+
91
+ Scenario: Undo file
92
+ 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:
93
+ """
94
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-XXXXXXX",
95
+ "NetworkInterfaces" : [ { "NetworkInterfaceId": "net-123", "PrivateIpAddresses" : [ { "PrivateIpAddress" : "0.0.0.1" } ] } ],
96
+ "Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
97
+ """
98
+ Given I double `aws --output json --region us-west-1 ec2 assign-private-ip-addresses --network-interface-id 'net-123' --private-ip-addresses '0.0.0.0'` with stdout:
99
+ """
100
+ { "return" : "true" }
101
+ """
102
+ Given an empty file named "undo.sh.1"
103
+ When I run `bundle exec zaws compute declare_secondary_ip my_instance 0.0.0.0 --region us-west-1 --vpcid my_vpc_id --undofile undo.sh.1`
104
+ Then the output should contain "Secondary ip assigned.\n"
105
+ And the file "undo.sh.1" should contain "zaws compute delete_secondary_ip my_instance 0.0.0.0 --region us-west-1 --vpcid my_vpc_id $XTRA_OPTS"
106
+
107
+
@@ -0,0 +1,23 @@
1
+ Feature: Compute
2
+
3
+ Scenario: Get compute instances in a human readable table.
4
+ Given I double `aws --output table --region us-west-1 ec2 describe-instances` with "AWS Compute Output"
5
+ When I run `bundle exec zaws compute view --region us-west-1 --viewtype table`
6
+ Then the stdout should contain "AWS Compute Output\n"
7
+
8
+ Scenario: Get compute instances in a human readable table form by default
9
+ Given I double `aws --output table --region us-west-1 ec2 describe-instances` with "AWS Compute Output"
10
+ When I run `bundle exec zaws compute view --region us-west-1`
11
+ Then the stdout should contain "AWS Compute Output\n"
12
+
13
+ Scenario: Get compute instances in JSON form
14
+ Given I double `aws --output json --region us-west-1 ec2 describe-instances` with "AWS Compute JSON Output"
15
+ When I run `bundle exec zaws compute view --region us-west-1 --viewtype json`
16
+ Then the stdout should contain "AWS Compute JSON Output\n"
17
+
18
+ Scenario: Get compute instances from specified vpcid
19
+ Given I double `aws --output table --region us-west-1 ec2 describe-instances --filter 'Name=vpc-id,Values=my_vpc_id'` with "AWS Compute Output"
20
+ When I run `bundle exec zaws compute view --region us-west-1 --vpcid my_vpc_id`
21
+ Then the stdout should contain "AWS Compute Output\n"
22
+
23
+
@@ -0,0 +1,24 @@
1
+ Feature: View images
2
+
3
+ Scenario: Get compute images in a human readable table.
4
+ Given I double `aws --output table --region us-west-1 ec2 describe-images --owner self` with "AWS Compute Output"
5
+ When I run `bundle exec zaws compute view_images --region us-west-1 --viewtype table`
6
+ Then the stdout should contain "AWS Compute Output\n"
7
+
8
+ Scenario: Get compute images in a human readable table form by default
9
+ Given I double `aws --output table --region us-west-1 ec2 describe-images --owner self` with "AWS Compute Output"
10
+ When I run `bundle exec zaws compute view_images --region us-west-1`
11
+ Then the stdout should contain "AWS Compute Output\n"
12
+
13
+ Scenario: Get compute images in JSON form
14
+ Given I double `aws --output json --region us-west-1 ec2 describe-images --owner self` with "AWS Compute JSON Output"
15
+ When I run `bundle exec zaws compute view_images --region us-west-1 --viewtype json`
16
+ Then the stdout should contain "AWS Compute JSON Output\n"
17
+
18
+ Scenario: Get compute images for a specific owner in JSON form
19
+ Given I double `aws --output json --region us-west-1 ec2 describe-images --owner me` with "AWS Compute JSON Output"
20
+ When I run `bundle exec zaws compute view_images --region us-west-1 --viewtype json --owner me`
21
+ Then the stdout should contain "AWS Compute JSON Output\n"
22
+
23
+
24
+
@@ -0,0 +1,138 @@
1
+ Feature: Elasticip
2
+
3
+ Scenario: Determine elasticip exists for instance
4
+ 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:
5
+ """
6
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-abc1234","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
7
+ """
8
+ And I double `aws --output json --region us-west-1 ec2 describe-addresses --filter 'Name=domain,Values=vpc' 'Name=instance-id,Values=i-abc1234'` with stdout:
9
+ """
10
+ { "Addresses": [ { "InstanceId" : "i-abc1234", "PublicIp": "198.51.100.0", "Domain": "vpc", "AssociationId":"eipassoc-abcd1234", "AllocationId":"eipalloc-abcd1234"} ] }
11
+ """
12
+ When I run `bundle exec zaws elasticip assoc_exists my_instance --region us-west-1 --vpcid my_vpc_id`
13
+ Then the output should contain "true\n"
14
+
15
+ Scenario: Determine elasticip DOES NOT exist for instance
16
+ 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:
17
+ """
18
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-abc1234","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
19
+ """
20
+ And I double `aws --output json --region us-west-1 ec2 describe-addresses --filter 'Name=domain,Values=vpc' 'Name=instance-id,Values=i-abc1234'` with stdout:
21
+ """
22
+ { "Addresses": [ ] }
23
+ """
24
+ When I run `bundle exec zaws elasticip assoc_exists my_instance --region us-west-1 --vpcid my_vpc_id`
25
+ Then the output should contain "false\n"
26
+
27
+ Scenario: Declare elasticip for an instance by external id
28
+ 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:
29
+ """
30
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-abc1234","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
31
+ """
32
+ And I double `aws --output json --region us-west-1 ec2 describe-addresses --filter 'Name=domain,Values=vpc' 'Name=instance-id,Values=i-abc1234'` with stdout:
33
+ """
34
+ { "Addresses": [ ] }
35
+ """
36
+ And I double `aws --region us-west-1 ec2 allocate-address --domain vpc` with stdout:
37
+ """
38
+ { "PublicIp": "198.51.100.0", "Domain": "vpc", "AllocationId": "eipalloc-abcd1234", "AllocationId":"eipalloc-abcd1234" }
39
+ """
40
+ And I double `aws --region us-west-1 ec2 associate-address --instance-id i-abc1234 --public-ip 198.51.100.0 --allocation-id eipalloc-abcd1234` with stdout:
41
+ """
42
+ { "return": "true" }
43
+ """
44
+ When I run `bundle exec zaws elasticip declare my_instance --region us-west-1 --vpcid my_vpc_id`
45
+ Then the output should contain "New elastic ip associated to instance.\n"
46
+
47
+ Scenario: Declare elasticip for an instance by external id, Skip creation
48
+ 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:
49
+ """
50
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-abc1234","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
51
+ """
52
+ And I double `aws --output json --region us-west-1 ec2 describe-addresses --filter 'Name=domain,Values=vpc' 'Name=instance-id,Values=i-abc1234'` with stdout:
53
+ """
54
+ { "Addresses": [ { "InstanceId" : "i-abc1234", "PublicIp": "198.51.100.0", "Domain": "vpc", "AssociationId":"eipassoc-abcd1234", "AllocationId":"eipalloc-abcd1234"} ] }
55
+ """
56
+ When I run `bundle exec zaws elasticip declare my_instance --region us-west-1 --vpcid my_vpc_id`
57
+ Then the output should contain "instance already has an elastic ip. Skipping creation.\n"
58
+
59
+ Scenario: Delete
60
+ 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:
61
+ """
62
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-abc1234","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
63
+ """
64
+ And I double `aws --output json --region us-west-1 ec2 describe-addresses --filter 'Name=domain,Values=vpc' 'Name=instance-id,Values=i-abc1234'` with stdout:
65
+ """
66
+ { "Addresses": [ { "InstanceId" : "i-abc1234", "PublicIp": "198.51.100.0", "Domain": "vpc", "AssociationId":"eipassoc-abcd1234", "AllocationId":"eipalloc-abcd1234"} ] }
67
+ """
68
+ And I double `aws --region us-west-1 ec2 disassociate-address --public-ip 198.51.100.0 --association-id eipassoc-abcd1234` with stdout:
69
+ """
70
+ { "return": "true" }
71
+ """
72
+ And I double `aws --region us-west-1 ec2 release-address --public-ip 198.51.100.0 --allocation-id eipalloc-abcd1234` with stdout:
73
+ """
74
+ { "return": "true" }
75
+ """
76
+ When I run `bundle exec zaws elasticip release my_instance --region us-west-1 --vpcid my_vpc_id`
77
+ Then the output should contain "Deleted elasticip.\n"
78
+
79
+ Scenario: Delete, skip
80
+ 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:
81
+ """
82
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-abc1234","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
83
+ """
84
+ And I double `aws --output json --region us-west-1 ec2 describe-addresses --filter 'Name=domain,Values=vpc' 'Name=instance-id,Values=i-abc1234'` with stdout:
85
+ """
86
+ { "Addresses": [ ] }
87
+ """
88
+ When I run `bundle exec zaws elasticip release my_instance --region us-west-1 --vpcid my_vpc_id`
89
+ Then the output should contain "Elasticip does not exist. Skipping deletion.\n"
90
+
91
+ Scenario: Nagios OK
92
+ 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:
93
+ """
94
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-abc1234","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
95
+ """
96
+ And I double `aws --output json --region us-west-1 ec2 describe-addresses --filter 'Name=domain,Values=vpc' 'Name=instance-id,Values=i-abc1234'` with stdout:
97
+ """
98
+ { "Addresses": [ { "InstanceId" : "i-abc1234", "PublicIp": "198.51.100.0", "Domain": "vpc", "AssociationId":"eipassoc-abcd1234", "AllocationId":"eipalloc-abcd1234"} ] }
99
+ """
100
+ When I run `bundle exec zaws elasticip declare my_instance --region us-west-1 --vpcid my_vpc_id --nagios`
101
+ Then the output should contain "OK: Elastic Ip exists.\n"
102
+
103
+ Scenario: Nagios CRITICAL
104
+ 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:
105
+ """
106
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-abc1234","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
107
+ """
108
+ And I double `aws --output json --region us-west-1 ec2 describe-addresses --filter 'Name=domain,Values=vpc' 'Name=instance-id,Values=i-abc1234'` with stdout:
109
+ """
110
+ { "Addresses": [ ] }
111
+ """
112
+ When I run `bundle exec zaws elasticip declare my_instance --region us-west-1 --vpcid my_vpc_id --nagios`
113
+ Then the output should contain "CRITICAL: Elastic Ip DOES NOT EXIST.\n"
114
+
115
+ Scenario: Undo file
116
+ 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:
117
+ """
118
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-abc1234","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
119
+ """
120
+ And I double `aws --output json --region us-west-1 ec2 describe-addresses --filter 'Name=domain,Values=vpc' 'Name=instance-id,Values=i-abc1234'` with stdout:
121
+ """
122
+ { "Addresses": [ ] }
123
+ """
124
+ And I double `aws --region us-west-1 ec2 allocate-address --domain vpc` with stdout:
125
+ """
126
+ { "PublicIp": "198.51.100.0", "Domain": "vpc", "AllocationId": "eipalloc-abcd1234", "AllocationId":"eipalloc-abcd1234" }
127
+ """
128
+ And I double `aws --region us-west-1 ec2 associate-address --instance-id i-abc1234 --public-ip 198.51.100.0 --allocation-id eipalloc-abcd1234` with stdout:
129
+ """
130
+ { "return": "true" }
131
+ """
132
+ Given an empty file named "undo.sh.1"
133
+ When I run `bundle exec zaws elasticip declare my_instance --region us-west-1 --vpcid my_vpc_id --undofile undo.sh.1`
134
+ Then the output should contain "New elastic ip associated to instance.\n"
135
+ And the file "undo.sh.1" should contain "zaws elasticip release my_instance --region us-west-1 --vpcid my_vpc_id $XTRA_OPTS"
136
+
137
+
138
+
@@ -0,0 +1,18 @@
1
+ Feature: Elasticip
2
+
3
+ Scenario: Get elasticip in a human readable table.
4
+ Given I double `aws --output table --region us-west-1 ec2 describe-addresses` with "AWS Elasticip Output"
5
+ When I run `bundle exec zaws elasticip view --region us-west-1 --viewtype table`
6
+ Then the stdout should contain "AWS Elasticip Output\n"
7
+
8
+ Scenario: Get elasticip in a human readable table form by default
9
+ Given I double `aws --output table --region us-west-1 ec2 describe-addresses` with "AWS Elasticip Output"
10
+ When I run `bundle exec zaws elasticip view --region us-west-1`
11
+ Then the stdout should contain "AWS Elasticip Output\n"
12
+
13
+ Scenario: Get elasticip in JSON form
14
+ Given I double `aws --output json --region us-west-1 ec2 describe-addresses` with "AWS Elasticip JSON Output"
15
+ When I run `bundle exec zaws elasticip view --region us-west-1 --viewtype json`
16
+ Then the stdout should contain "AWS Elasticip JSON Output\n"
17
+
18
+
@@ -0,0 +1,17 @@
1
+ Feature: Hosted Zone
2
+
3
+ Scenario: Get hosted zone in a human readable table.
4
+ Given I double `aws --output table route53 list-hosted-zones` with "AWS Hosted Zone Output"
5
+ When I run `bundle exec zaws hosted_zone view --viewtype table`
6
+ Then the stdout should contain "AWS Hosted Zone Output\n"
7
+
8
+ Scenario: Get hosted zone in a human readable table form by default
9
+ Given I double `aws --output table route53 list-hosted-zones` with "AWS Hosted Zone Output"
10
+ When I run `bundle exec zaws hosted_zone view`
11
+ Then the stdout should contain "AWS Hosted Zone Output\n"
12
+
13
+ Scenario: Get hosted zone in JSON form
14
+ Given I double `aws --output json route53 list-hosted-zones` with "AWS Hosted Zone JSON Output"
15
+ When I run `bundle exec zaws hosted_zone view --viewtype json`
16
+ Then the stdout should contain "AWS Hosted Zone JSON Output\n"
17
+
@@ -0,0 +1,29 @@
1
+ Feature: View Record
2
+
3
+ Scenario: Get records for hosted zone in a human readable table.
4
+ Given I double `aws --output json route53 list-hosted-zones` with stdout:
5
+ """
6
+ { "HostedZones": [ { "Id": "id-???", "Name": "abc.com." } ] }
7
+ """
8
+ And I double `aws --output table route53 list-resource-record-sets --hosted-zone-id id-???` with "AWS Resource Record Sets Output"
9
+ When I run `bundle exec zaws hosted_zone view_records abc.com. --viewtype table`
10
+ Then the stdout should contain "AWS Resource Record Sets Output\n"
11
+
12
+ Scenario: Get records for hosted zone in a human readable table form by default
13
+ Given I double `aws --output json route53 list-hosted-zones` with stdout:
14
+ """
15
+ { "HostedZones": [ { "Id": "id-???", "Name": "abc.com." } ] }
16
+ """
17
+ And I double `aws --output table route53 list-resource-record-sets --hosted-zone-id id-???` with "AWS Resource Record Sets Output"
18
+ When I run `bundle exec zaws hosted_zone view_records abc.com.`
19
+ Then the stdout should contain "AWS Resource Record Sets Output\n"
20
+
21
+ Scenario: Get records for hosted zone in a JSON form.
22
+ Given I double `aws --output json route53 list-hosted-zones` with stdout:
23
+ """
24
+ { "HostedZones": [ { "Id": "id-???", "Name": "abc.com." } ] }
25
+ """
26
+ And I double `aws --output json route53 list-resource-record-sets --hosted-zone-id id-???` with "AWS Resource Record Sets Output"
27
+ When I run `bundle exec zaws hosted_zone view_records abc.com. --viewtype json`
28
+ Then the stdout should contain "AWS Resource Record Sets Output\n"
29
+
@@ -0,0 +1,120 @@
1
+ Feature: Instance Registration
2
+
3
+ Scenario: Determine instance is registered
4
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
5
+ """
6
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "Instances": [ { "InstanceId": "i-X" } ]} ] }
7
+ """
8
+ And 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:
9
+ """
10
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-X","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
11
+ """
12
+ When I run `bundle exec zaws load_balancer exists_instance lbname my_instance --region us-west-1 --vpcid my_vpc_id`
13
+ Then the stdout should contain "true\n"
14
+
15
+ Scenario: Determine instance is NOT registered
16
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
17
+ """
18
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "Instances": [ { "InstanceId": "i-Y" } ]} ] }
19
+ """
20
+ And 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:
21
+ """
22
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-X","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
23
+ """
24
+ When I run `bundle exec zaws load_balancer exists_instance lbname my_instance --region us-west-1 --vpcid my_vpc_id`
25
+ Then the stdout should contain "false\n"
26
+
27
+ Scenario: Declare instance registration
28
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
29
+ """
30
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "Instances": [ ] } ] }
31
+ """
32
+ And 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:
33
+ """
34
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-X","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
35
+ """
36
+ And I double `aws --region us-west-1 elb register-instances-with-load-balancer --load-balancer-name lbname --instances i-X` with stdout:
37
+ """
38
+ { "return" : "true" }
39
+ """
40
+ When I run `bundle exec zaws load_balancer register_instance lbname my_instance --region us-west-1 --vpcid my_vpc_id`
41
+ Then the stdout should contain "New instance registered.\n"
42
+
43
+ Scenario: Declare instance registration, Skip creation
44
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
45
+ """
46
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "Instances": [ { "InstanceId": "i-X" } ]} ] }
47
+ """
48
+ And 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:
49
+ """
50
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-X","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
51
+ """
52
+ When I run `bundle exec zaws load_balancer register_instance lbname my_instance --region us-west-1 --vpcid my_vpc_id`
53
+ Then the stdout should contain "Instance already registered. Skipping registration.\n"
54
+
55
+ Scenario: Delete
56
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
57
+ """
58
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "Instances": [ { "InstanceId": "i-X" } ]} ] }
59
+ """
60
+ And 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:
61
+ """
62
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-X","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
63
+ """
64
+ And I double `aws --region us-west-1 elb deregister-instances-with-load-balancer --load-balancer-name lbname --instances i-X` with stdout:
65
+ """
66
+ { "return" : "true" }
67
+ """
68
+ When I run `bundle exec zaws load_balancer deregister_instance lbname my_instance --region us-west-1 --vpcid my_vpc_id`
69
+ Then the stdout should contain "Instance deregistered.\n"
70
+
71
+ Scenario: Delete, skip
72
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
73
+ """
74
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "Instances": [ ] } ] }
75
+ """
76
+ And 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:
77
+ """
78
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-X","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
79
+ """
80
+ When I run `bundle exec zaws load_balancer deregister_instance lbname my_instance --region us-west-1 --vpcid my_vpc_id`
81
+ Then the stdout should contain "Instance not registered. Skipping deregistration.\n"
82
+
83
+ Scenario: Nagios OK
84
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
85
+ """
86
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "Instances": [ { "InstanceId": "i-X" } ]} ] }
87
+ """
88
+ And 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:
89
+ """
90
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-X","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
91
+ """
92
+ When I run `bundle exec zaws load_balancer register_instance lbname my_instance --region us-west-1 --vpcid my_vpc_id --nagios`
93
+ Then the stdout should contain "OK: Instance registerd.\n"
94
+
95
+ Scenario: Nagios CRITICAL
96
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
97
+ """
98
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "Instances": [ ] } ] }
99
+ """
100
+ And 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:
101
+ """
102
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-X","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
103
+ """
104
+ When I run `bundle exec zaws load_balancer register_instance lbname my_instance --region us-west-1 --vpcid my_vpc_id --nagios`
105
+ Then the stdout should contain "CRITICAL: Instance not registered.\n"
106
+
107
+ Scenario: Undo file
108
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
109
+ """
110
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "Instances": [ { "InstanceId": "i-X" } ]} ] }
111
+ """
112
+ And 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:
113
+ """
114
+ { "Reservations": [ { "Instances" : [ {"InstanceId": "i-X","Tags": [ { "Value": "my_instance","Key": "externalid" } ] } ] } ] }
115
+ """
116
+ Given an empty file named "undo.sh.1"
117
+ When I run `bundle exec zaws load_balancer register_instance lbname my_instance --region us-west-1 --vpcid my_vpc_id --undofile undo.sh.1`
118
+ Then the stdout should contain "Instance already registered. Skipping registration.\n"
119
+ And the file "undo.sh.1" should contain "zaws load_balancer deregister_instance lbname my_instance --region us-west-1 --vpcid my_vpc_id $XTRA_OPTS"
120
+
@@ -0,0 +1,86 @@
1
+ Feature: Listner
2
+
3
+ Scenario: Determine listner exists
4
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
5
+ """
6
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "ListenerDescriptions": [ { "Listener": { "InstancePort": 80, "LoadBalancerPort": 80, "Protocol": "HTTP", "InstanceProtocol": "HTTP" }, "PolicyNames": [] } ] } ] }
7
+ """
8
+ When I run `bundle exec zaws load_balancer exists_listener lbname HTTP 80 HTTP 80 --region us-west-1`
9
+ Then the stdout should contain "true\n"
10
+
11
+ Scenario: Determine listner does not exist
12
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
13
+ """
14
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "ListenerDescriptions": [ { "Listener": { "InstancePort": 17080, "LoadBalancerPort": 80, "Protocol": "HTTP", "InstanceProtocol": "HTTP" }, "PolicyNames": [] } ] } ] }
15
+ """
16
+ When I run `bundle exec zaws load_balancer exists_listener lbname tcp 80 tcp 80 --region us-west-1`
17
+ Then the stdout should contain "false\n"
18
+
19
+ Scenario: Declare listner
20
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
21
+ """
22
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "ListenerDescriptions": [] } ] }
23
+ """
24
+ And I double `aws --region us-west-1 elb create-load-balancer-listeners --load-balancer-name lbname --listeners '[{"Protocol":"HTTP","LoadBalancerPort":80,"InstanceProtocol":"HTTP","InstancePort":80}]'` with stdout:
25
+ """
26
+ { "return": "true" }
27
+ """
28
+ When I run `bundle exec zaws load_balancer declare_listener lbname HTTP 80 HTTP 80 --region us-west-1`
29
+ Then the stdout should contain "Listener created.\n"
30
+
31
+ Scenario: Declare listner, Skip creation
32
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
33
+ """
34
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "ListenerDescriptions": [ { "Listener": { "InstancePort": 80, "LoadBalancerPort": 80, "Protocol": "HTTP", "InstanceProtocol": "HTTP" }, "PolicyNames": [] } ] } ] }
35
+ """
36
+ When I run `bundle exec zaws load_balancer declare_listener lbname HTTP 80 HTTP 80 --region us-west-1`
37
+ Then the stdout should contain "Listerner exists. Skipping creation.\n"
38
+
39
+ Scenario: Delete
40
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
41
+ """
42
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "ListenerDescriptions": [ { "Listener": { "InstancePort": 80, "LoadBalancerPort": 80, "Protocol": "HTTP", "InstanceProtocol": "HTTP" }, "PolicyNames": [] } ] } ] }
43
+ """
44
+ And I double `aws --region us-west-1 elb delete-load-balancer-listeners --load-balancer-name lbname --load-balancer-ports 80` with stdout:
45
+ """
46
+ { "return": "true" }
47
+ """
48
+ When I run `bundle exec zaws load_balancer delete_listener lbname HTTP 80 HTTP 80 --region us-west-1`
49
+ Then the stdout should contain "Listerner deleted.\n"
50
+
51
+ Scenario: Delete, skip
52
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
53
+ """
54
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "ListenerDescriptions": [] } ] }
55
+ """
56
+ When I run `bundle exec zaws load_balancer delete_listener lbname HTTP 80 HTTP 80 --region us-west-1`
57
+ Then the stdout should contain "Listener does not exist. Skipping deletion.\n"
58
+
59
+ Scenario: Nagios OK
60
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
61
+ """
62
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "ListenerDescriptions": [ { "Listener": { "InstancePort": 80, "LoadBalancerPort": 80, "Protocol": "HTTP", "InstanceProtocol": "HTTP" }, "PolicyNames": [] } ] } ] }
63
+ """
64
+ When I run `bundle exec zaws load_balancer declare_listener lbname HTTP 80 HTTP 80 --region us-west-1 --nagios`
65
+ Then the stdout should contain "OK: Listerner exists.\n"
66
+
67
+ Scenario: Nagios CRITICAL
68
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
69
+ """
70
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "ListenerDescriptions": [] } ] }
71
+ """
72
+ When I run `bundle exec zaws load_balancer declare_listener lbname HTTP 80 HTTP 80 --region us-west-1 --nagios`
73
+ Then the stdout should contain "CRITICAL: Listener does not exist.\n"
74
+
75
+ Scenario: Undo file
76
+ Given I double `aws --output json --region us-west-1 elb describe-load-balancers` with stdout:
77
+ """
78
+ { "LoadBalancerDescriptions": [ { "LoadBalancerName": "lbname", "ListenerDescriptions": [ { "Listener": { "InstancePort": 80, "LoadBalancerPort": 80, "Protocol": "HTTP", "InstanceProtocol": "HTTP" }, "PolicyNames": [] } ] } ] }
79
+ """
80
+ Given an empty file named "undo.sh.1"
81
+ When I run `bundle exec zaws load_balancer declare_listener lbname HTTP 80 HTTP 80 --region us-west-1 --undofile undo.sh.1`
82
+ Then the stdout should contain "Listerner exists. Skipping creation.\n"
83
+ And the file "undo.sh.1" should contain "zaws load_balancer delete_listener lbname HTTP 80 HTTP 80 --region us-west-1 $XTRA_OPTS"
84
+
85
+
86
+