aws-sdk-utils 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/id_util.rb +68 -0
  3. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4acd964ce1e3aa7e6158791b3caaf54e359f88f5
4
- data.tar.gz: f12cfc991139653eae9bf4d105053bab7e3444c9
3
+ metadata.gz: bf0e2d8968beac87bf54fde28c050e01571bd83a
4
+ data.tar.gz: 97b74d87594352024825482be9b1a8912ed09f83
5
5
  SHA512:
6
- metadata.gz: b7b6d6c04776683cf429ffc1249ccc0d9ab5c2bc8395ebb5dbe2649e3367eab759b59428cbe301e51dd9844b04d9532e5075da0ac28368e84a8bded992995076
7
- data.tar.gz: 4f4ab72847b11035cf5f99f70eb206e839144d89140293747737248f7286edc182f33168d7a3d2bff9c1234525fbfbf55f4cbd73b4533e57b2d01e874ac0bb32
6
+ metadata.gz: d361dc7f4864848d056ed204e1ee92b52911f8e4df7c042bfe11b974939cd6957cb08cd29d19f23f410bf4f0166bed3dbc15f9783999ce23237eb88feab17615
7
+ data.tar.gz: 29fe26d38a353ad7e512991edb342260f15a43f2c995772ba6137e2c8fed597fcbd5279aeea2892afbea07e33e1c9f2ba2d66d6e645d69a3e31c99fa9eb56117
@@ -0,0 +1,68 @@
1
+ require 'aws-sdk'
2
+
3
+ module IdUtil
4
+
5
+ def vpc_id_by_name(vpc_name)
6
+ client = Aws::EC2::Client.new
7
+ describe_vpcs_response = client.describe_vpcs filters: [
8
+ {
9
+ name: 'tag:Name',
10
+ values: [vpc_name],
11
+ }
12
+ ]
13
+
14
+ if describe_vpcs_response.vpcs.length != 1
15
+ raise "unique vpc not found: #{vpc_name} has #{describe_vpcs_response.vpcs.length} hits"
16
+ else
17
+ describe_vpcs_response.vpcs.first.vpc_id
18
+ end
19
+ end
20
+
21
+ def subnet_id_by_name(subnet_name)
22
+ client = Aws::EC2::Client.new
23
+ describe_subnets_response = client.describe_subnets filters: [
24
+ {
25
+ name: 'tag:Name',
26
+ values: [subnet_name],
27
+ }
28
+ ]
29
+
30
+ if describe_subnets_response.subnets.length != 1
31
+ raise "unique subnet not found: #{subnet_name} has #{describe_subnets_response.subnets.length} hits"
32
+ else
33
+ describe_subnets_response.subnets.first.subnet_id
34
+ end
35
+ end
36
+
37
+ def igw_id_by_name(igw_name)
38
+ client = Aws::EC2::Client.new
39
+ describe_internet_gateways_response = client.describe_internet_gateways filters: [
40
+ {
41
+ name: 'tag:Name',
42
+ values: [igw_name],
43
+ }
44
+ ]
45
+
46
+ if describe_internet_gateways_response.internet_gateways.length != 1
47
+ raise "unique igw not found: #{igw_name} has #{describe_internet_gateways_response.internet_gateways.length} hits"
48
+ else
49
+ describe_internet_gateways_response.internet_gateways.first.internet_gateway_id
50
+ end
51
+ end
52
+
53
+ def route_table_id_by_name(route_table_name)
54
+ client = Aws::EC2::Client.new
55
+ describe_route_tables_response = client.describe_route_tables filters: [
56
+ {
57
+ name: 'tag:Name',
58
+ values: [route_table_name],
59
+ }
60
+ ]
61
+
62
+ if describe_route_tables_response.route_tables.length != 1
63
+ raise "unique route table not found: #{route_table_name} has #{describe_route_tables_response.route_tables.length} hits"
64
+ else
65
+ describe_route_tables_response.route_tables.first.route_table_id
66
+ end
67
+ end
68
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - someguy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-01 00:00:00.000000000 Z
11
+ date: 2016-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -67,6 +67,7 @@ files:
67
67
  - lib/changeset_util.rb
68
68
  - lib/cloudformation_converger.rb
69
69
  - lib/cloudformation_tag_parser.rb
70
+ - lib/id_util.rb
70
71
  - lib/lambda_alias_switcher.rb
71
72
  - lib/waf_util.rb
72
73
  homepage: https://github.com/stelligent/aws-sdk-utils