awspec 0.18.2 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -1
- data/awspec.gemspec +1 -0
- data/lib/awspec/command/generate.rb +6 -16
- data/lib/awspec/helper.rb +1 -0
- data/lib/awspec/helper/credentials_loader.rb +27 -0
- data/lib/awspec/setup.rb +1 -9
- data/lib/awspec/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88afd19a09bdcdf08ab582088100317268ae0862
|
4
|
+
data.tar.gz: 725e4006d459deed7e815b1b5cdbf3537c631ec7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 877f327dd10941729185d7f936d5e0196baa02367a70e4d510d7c6dc835d6b2da0f24225b14fd7103867d3013864c7870dfa7dd2862a208f1748359602fd24a4
|
7
|
+
data.tar.gz: 9b4487deaee273642d839cb76a7938327cb9386c6fb204fe296ab90cec1cb44a130c4862c3345d984479efe0e494264b0fa1e808fcf60173caa22f16a3212f9c
|
data/README.md
CHANGED
@@ -68,7 +68,7 @@ end
|
|
68
68
|
|
69
69
|
$ bundle exec rake spec
|
70
70
|
|
71
|
-
### Advanced
|
71
|
+
### Advanced Tips: Spec generate command
|
72
72
|
|
73
73
|
Generate spec from AWS resources already exists.
|
74
74
|
|
@@ -76,6 +76,16 @@ Generate spec from AWS resources already exists.
|
|
76
76
|
$ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
|
77
77
|
```
|
78
78
|
|
79
|
+
### Advanced Tips: Use Shared credentials (~/.aws/config ~/.aws/credentials)
|
80
|
+
|
81
|
+
```sh
|
82
|
+
$ awspec generate ec2 vpc-ab123cde --profile mycreds
|
83
|
+
```
|
84
|
+
|
85
|
+
```sh
|
86
|
+
$ export AWS_PROFILE=mycreds; bundle exec rake spec
|
87
|
+
```
|
88
|
+
|
79
89
|
## Support AWS Resources
|
80
90
|
|
81
91
|
- [x] EC2 (`ec2`)
|
data/awspec.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_runtime_dependency 'rspec', '~> 3.0'
|
24
24
|
spec.add_runtime_dependency 'rspec-its'
|
25
25
|
spec.add_runtime_dependency 'aws-sdk', '~> 2.1.20'
|
26
|
+
spec.add_runtime_dependency 'aws_config'
|
26
27
|
spec.add_runtime_dependency 'thor'
|
27
28
|
spec.add_runtime_dependency 'activesupport'
|
28
29
|
spec.add_development_dependency 'bundler', '~> 1.9'
|
@@ -1,8 +1,11 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'awspec/setup'
|
3
|
+
require 'awspec/helper/credentials_loader'
|
3
4
|
|
4
5
|
module Awspec
|
5
6
|
class Generate < Thor
|
7
|
+
class_option :profile
|
8
|
+
|
6
9
|
types = %w(
|
7
10
|
vpc ec2 rds security_group elb
|
8
11
|
)
|
@@ -10,7 +13,7 @@ module Awspec
|
|
10
13
|
types.each do |type|
|
11
14
|
desc type + ' [vpc_id]', "Generate #{type} spec from VPC ID (or VPC \"Name\" tag)"
|
12
15
|
define_method type do |*args|
|
13
|
-
|
16
|
+
Awspec::Helper::CredentialsLoader.load(options[:profile])
|
14
17
|
vpc_id = args.first
|
15
18
|
eval "puts Awspec::Generator::Spec::#{type.camelize}.new.generate_by_vpc_id(vpc_id)"
|
16
19
|
end
|
@@ -22,7 +25,7 @@ module Awspec
|
|
22
25
|
|
23
26
|
desc 'route53_hosted_zone [example.com.]', 'Generate route53_hosted_zone spec from Domain name'
|
24
27
|
def route53_hosted_zone(hosted_zone)
|
25
|
-
|
28
|
+
Awspec::Helper::CredentialsLoader.load(options[:profile])
|
26
29
|
puts Awspec::Generator::Spec::Route53HostedZone.new.generate_by_domain_name(hosted_zone)
|
27
30
|
end
|
28
31
|
|
@@ -37,22 +40,9 @@ module Awspec
|
|
37
40
|
desc type, "Generate #{type} spec"
|
38
41
|
end
|
39
42
|
define_method type do
|
40
|
-
|
43
|
+
Awspec::Helper::CredentialsLoader.load(options[:profile])
|
41
44
|
eval "puts Awspec::Generator::Spec::#{type.camelize}.new.generate_all"
|
42
45
|
end
|
43
46
|
end
|
44
|
-
|
45
|
-
no_commands do
|
46
|
-
def load_secrets
|
47
|
-
creds = YAML.load_file('spec/secrets.yml') if File.exist?('spec/secrets.yml')
|
48
|
-
creds = YAML.load_file('secrets.yml') if File.exist?('secrets.yml')
|
49
|
-
Aws.config.update({
|
50
|
-
region: creds['region'],
|
51
|
-
credentials: Aws::Credentials.new(
|
52
|
-
creds['aws_access_key_id'],
|
53
|
-
creds['aws_secret_access_key'])
|
54
|
-
}) if creds
|
55
|
-
end
|
56
|
-
end
|
57
47
|
end
|
58
48
|
end
|
data/lib/awspec/helper.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'aws-sdk'
|
2
|
+
require 'aws_config'
|
3
|
+
|
4
|
+
module Awspec::Helper
|
5
|
+
module CredentialsLoader
|
6
|
+
def self.load(profile = nil)
|
7
|
+
profile = ENV['AWS_PROFILE'] if profile.nil? && ENV.key?('AWS_PROFILE')
|
8
|
+
if profile
|
9
|
+
# SharedCredentials
|
10
|
+
aws_config = AWSConfig.profiles[profile]
|
11
|
+
aws_config = AWSConfig.profiles['default'] unless aws_config
|
12
|
+
Aws.config[:region] = aws_config.config_hash[:region] if aws_config
|
13
|
+
Aws.config[:credentials] = Aws::SharedCredentials.new(profile_name: profile)
|
14
|
+
else
|
15
|
+
# secrets.yml
|
16
|
+
creds = YAML.load_file('spec/secrets.yml') if File.exist?('spec/secrets.yml')
|
17
|
+
creds = YAML.load_file('secrets.yml') if File.exist?('secrets.yml')
|
18
|
+
Aws.config.update({
|
19
|
+
region: creds['region'],
|
20
|
+
credentials: Aws::Credentials.new(
|
21
|
+
creds['aws_access_key_id'],
|
22
|
+
creds['aws_secret_access_key'])
|
23
|
+
}) if creds
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/awspec/setup.rb
CHANGED
@@ -13,15 +13,7 @@ module Awspec
|
|
13
13
|
def self.generate_spec_helper
|
14
14
|
content = <<-'EOF'
|
15
15
|
require 'awspec'
|
16
|
-
|
17
|
-
creds = YAML.load_file('spec/secrets.yml')
|
18
|
-
Aws.config.update({
|
19
|
-
region: creds['region'],
|
20
|
-
credentials: Aws::Credentials.new(
|
21
|
-
creds['aws_access_key_id'],
|
22
|
-
creds['aws_secret_access_key'])
|
23
|
-
})
|
24
|
-
end
|
16
|
+
Awspec::Helper::CredentialsLoader.load
|
25
17
|
EOF
|
26
18
|
dir = 'spec'
|
27
19
|
if File.exist? dir
|
data/lib/awspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 2.1.20
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aws_config
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: thor
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,6 +220,7 @@ files:
|
|
206
220
|
- lib/awspec/generator/spec/vpc.rb
|
207
221
|
- lib/awspec/generator/template.rb
|
208
222
|
- lib/awspec/helper.rb
|
223
|
+
- lib/awspec/helper/credentials_loader.rb
|
209
224
|
- lib/awspec/helper/finder.rb
|
210
225
|
- lib/awspec/helper/finder/auto_scaling.rb
|
211
226
|
- lib/awspec/helper/finder/cloudwatch.rb
|