awful 0.0.93 → 0.0.94
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awful/route53.rb +44 -61
- data/lib/awful/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9932dbe8c2c2317a74d5eef41bb3ccf472833910
|
4
|
+
data.tar.gz: d67153dad78acac983e8375364964be7503e8701
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea8acf559c5e07a562428aee94fb3cb15e8bbe44c5113c3384c29a3f412e9593ac864fa381146fb682549914e081f0e1812e1deb1d3fe8c405f45d86732065a5
|
7
|
+
data.tar.gz: eac45d06cfc36d50cd12069ea58782e1048cc9348c79073e50b1faead012da8db4f35bb2cb8245356a5e8b24361eb2a04033f1fe072e454783ad658e3ba0761c
|
data/lib/awful/route53.rb
CHANGED
@@ -11,6 +11,12 @@ module Awful
|
|
11
11
|
@route53 ||= Aws::Route53::Client.new
|
12
12
|
end
|
13
13
|
|
14
|
+
## extract domain part of dns name
|
15
|
+
def get_domain(name)
|
16
|
+
name.split('.').last(2).join('.')
|
17
|
+
end
|
18
|
+
|
19
|
+
## get hosted zone id from domain name
|
14
20
|
def get_zone_by_name(name)
|
15
21
|
if name.match(/^Z[A-Z0-9]{13}$/) # id is 14 char upcase string starting with Z
|
16
22
|
name
|
@@ -30,6 +36,12 @@ module Awful
|
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
39
|
+
|
40
|
+
## return dns name and hosted zone id
|
41
|
+
def get_elb_dns(name)
|
42
|
+
desc = elb.describe_load_balancers(load_balancer_names: [name]).load_balancer_descriptions[0]
|
43
|
+
['dualstack.' + desc.dns_name, desc.canonical_hosted_zone_name_id]
|
44
|
+
end
|
33
45
|
end
|
34
46
|
|
35
47
|
desc 'ls [NAME]', 'list hosted zones'
|
@@ -96,68 +108,39 @@ module Awful
|
|
96
108
|
end
|
97
109
|
|
98
110
|
# desc 'update NAME', 'change a record set'
|
99
|
-
# method_option :type, aliases: '-t', type: :string, default: 'A', desc: 'Type of record: SOA, A, TXT, NS, CNAME, MX, PTR, SRV, SPF, AAAA'
|
100
|
-
# method_option :alias, aliases: '-a', type: :boolean, default: false, desc: 'Create an ALIAS record'
|
111
|
+
# # method_option :type, aliases: '-t', type: :string, default: 'A', desc: 'Type of record: SOA, A, TXT, NS, CNAME, MX, PTR, SRV, SPF, AAAA'
|
112
|
+
# # method_option :alias, aliases: '-a', type: :boolean, default: false, desc: 'Create an ALIAS record'
|
101
113
|
# def update(name, target)
|
102
|
-
# zone = name.split('.').last(2).join('.')
|
103
|
-
# hosted_zone_id = get_zone_by_name(zone)
|
104
|
-
# rrset = {
|
105
|
-
# name: name,
|
106
|
-
# type: options[:type].upcase
|
107
|
-
# }
|
108
|
-
# if options[:alias]
|
109
|
-
# rrset.merge!(
|
110
|
-
# alias_target: {
|
111
|
-
# hosted_zone_id: 'Z35SXDOTRQ7X7K',
|
112
|
-
# # dns_name: 'dualstack.release-1-elbadmin-uhcp4ix1utqo-918434006.us-east-1.elb.amazonaws.com.',
|
113
|
-
# dns_name: target,
|
114
|
-
# evaluate_target_health: false
|
115
|
-
# }
|
116
|
-
# )
|
117
|
-
# else
|
118
|
-
# rrset.merge!(
|
119
|
-
# ttl: 180, # required for non-alias, not allowed for alias
|
120
|
-
# resource_records: [{value: target}]
|
121
|
-
# )
|
122
|
-
# end
|
123
|
-
|
124
|
-
# params = {
|
125
|
-
# hosted_zone_id: hosted_zone_id,
|
126
|
-
# change_batch: {
|
127
|
-
# changes: [
|
128
|
-
# {
|
129
|
-
# action: 'UPSERT',
|
130
|
-
# resource_record_set: rrset
|
131
|
-
# # {
|
132
|
-
# # name: name,
|
133
|
-
# # type: options[:type].upcase,
|
134
|
-
# # ttl: 180, # required for non-alias, not allowed for alias
|
135
|
-
# # # resource_records: [
|
136
|
-
# # # {value: target}
|
137
|
-
# # # ]
|
138
|
-
# # alias_target: {
|
139
|
-
# # hosted_zone_id: 'Z35SXDOTRQ7X7K',
|
140
|
-
# # dns_name: 'dualstack.release-1-elbadmin-uhcp4ix1utqo-918434006.us-east-1.elb.amazonaws.com.',
|
141
|
-
# # evaluate_target_health: false
|
142
|
-
# # }
|
143
|
-
# # }
|
144
|
-
# }
|
145
|
-
# ]
|
146
|
-
# }
|
147
|
-
# }
|
148
|
-
# # if options[:alias]
|
149
|
-
# # params[:change_batch][:changes][0][:alias_target] = {
|
150
|
-
# # # hosted_zone_id: '/hostedzone/Z3DZXE0Q79N41H',
|
151
|
-
# # hosted_zone_id: 'Z35SXDOTRQ7X7K',
|
152
|
-
# # # dns_name: target,
|
153
|
-
# # dns_name: 'dualstack.release-1-elbadmin-uhcp4ix1utqo-918434006.us-east-1.elb.amazonaws.com.',
|
154
|
-
# # evaluate_target_health: false
|
155
|
-
# # }
|
156
|
-
# # end
|
157
|
-
# p params
|
158
|
-
# route53.change_resource_record_sets(params).tap do |response|
|
159
|
-
# puts YAML.dump(stringify_keys(response.change_info.to_hash))
|
160
|
-
# end
|
161
114
|
# end
|
115
|
+
|
116
|
+
## create/update alias to ELB record; later add S3, CF, Beanstalk, rrsets
|
117
|
+
desc 'alias NAME', 'upsert an alias to an AWS resource given by name'
|
118
|
+
method_option :resource, aliases: '-r', type: :string, default: 'elb', desc: 'Type of target resource, for now just `elb`'
|
119
|
+
method_option :type, aliases: '-t', type: :string, default: 'A', desc: 'Type of record: A, SOA, TXT, NS, CNAME, MX, PTR, SRV, SPF, AAAA'
|
120
|
+
def alias(name, target)
|
121
|
+
dns_name, hosted_zone_id = send("get_#{options[:resource]}_dns", target)
|
122
|
+
params = {
|
123
|
+
hosted_zone_id: get_zone_by_name(get_domain(name)),
|
124
|
+
change_batch: {
|
125
|
+
changes: [
|
126
|
+
{
|
127
|
+
action: 'UPSERT',
|
128
|
+
resource_record_set: {
|
129
|
+
name: name,
|
130
|
+
type: options[:type],
|
131
|
+
alias_target: {
|
132
|
+
hosted_zone_id: hosted_zone_id,
|
133
|
+
dns_name: dns_name,
|
134
|
+
evaluate_target_health: false
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
]
|
139
|
+
}
|
140
|
+
}
|
141
|
+
route53.change_resource_record_sets(params).tap do |response|
|
142
|
+
puts YAML.dump(stringify_keys(response.change_info.to_hash))
|
143
|
+
end
|
144
|
+
end
|
162
145
|
end
|
163
146
|
end
|
data/lib/awful/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.94
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ric Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|