mist_aws 0.1.9 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/mist_aws/iam.rb +8 -8
- data/lib/mist_aws/version.rb +1 -1
- data/mist_aws.gemspec +2 -1
- data/spec/iam/mocked_spec.rb +3 -1
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27462753daf44858bc4b364373962b3ae694c7a2
|
4
|
+
data.tar.gz: cb5a6de74bee828ebc96885851a3bcf0aee2dd81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0989864073bd2a6dd98f17fba167bd681ddd5549412644522d944ad12d509eec4dfcede9e1462490aa2e89b20503f3b008368fa977baf07c9334564737cb73d1
|
7
|
+
data.tar.gz: 804f1dfa2f8983fd0eb56091ebc751691d4c2a5ad60ea25e5fc3cdb5acfc6acb60d9ac8933aec76d10afb20332f20af5da2094a02820e23fe7d9139011076ced
|
data/README.md
CHANGED
@@ -4,6 +4,7 @@ Uses the [ruby aws-sdk v2](https://github.com/aws/aws-sdk-core-ruby) [Resource I
|
|
4
4
|
|
5
5
|
> NOTE: Currently the only object implemented is Iam for creating / deleting instance roles and an Ec2 for working with Security Groups
|
6
6
|
|
7
|
+
[![mist_aws API Documentation](https://www.omniref.com/ruby/gems/mist_aws.png)](https://www.omniref.com/ruby/gems/mist_aws)
|
7
8
|
|
8
9
|
## Installation
|
9
10
|
|
data/lib/mist_aws/iam.rb
CHANGED
@@ -46,15 +46,15 @@ module MistAws
|
|
46
46
|
# profile_name and various Environment Variables
|
47
47
|
@credentials = get_creds(profile_name)
|
48
48
|
|
49
|
-
@iam_client = Aws::IAM::Client.new(credentials: @credentials, region: @region)
|
50
|
-
@iam = Aws::IAM::Resource.new(client: @iam_client)
|
49
|
+
@iam_client = ::Aws::IAM::Client.new(credentials: @credentials, region: @region)
|
50
|
+
@iam = ::Aws::IAM::Resource.new(client: @iam_client)
|
51
51
|
end
|
52
52
|
|
53
53
|
|
54
54
|
# Returns the proper Aws credential object.
|
55
55
|
#
|
56
56
|
# @param profile_name [String] (nil) Name of profile
|
57
|
-
# @return [Aws::SharedCredentials | Aws::Credentials]
|
57
|
+
# @return [::Aws::SharedCredentials | ::Aws::Credentials]
|
58
58
|
#
|
59
59
|
def get_creds(profile_name=nil)
|
60
60
|
unless profile_name
|
@@ -62,7 +62,7 @@ module MistAws
|
|
62
62
|
@profile_name = ENV['AWS_PROFILE']
|
63
63
|
else
|
64
64
|
if ENV['AWS_ACCESS_KEY_ID'] && ENV['AWS_SECRET_ACCESS_KEY']
|
65
|
-
return Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'])
|
65
|
+
return ::Aws::Credentials.new(ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'])
|
66
66
|
else
|
67
67
|
@profile_name = 'default'
|
68
68
|
end
|
@@ -72,7 +72,7 @@ module MistAws
|
|
72
72
|
end
|
73
73
|
|
74
74
|
begin
|
75
|
-
Aws::SharedCredentials.new(profile_name: @profile_name)
|
75
|
+
::Aws::SharedCredentials.new(profile_name: @profile_name)
|
76
76
|
rescue StandardError => e
|
77
77
|
@logger.error e.inspect
|
78
78
|
raise e
|
@@ -105,7 +105,7 @@ module MistAws
|
|
105
105
|
begin
|
106
106
|
iam_client.get_role_policy(role_name: role_name, policy_name: policy_name)
|
107
107
|
exists = true
|
108
|
-
rescue Aws::IAM::Errors::NoSuchEntityException
|
108
|
+
rescue ::Aws::IAM::Errors::NoSuchEntityException
|
109
109
|
logger.warn "No role_polcy: #{policy_name.inspect} for role: #{role_name.inspect}"
|
110
110
|
exists = false
|
111
111
|
end
|
@@ -174,11 +174,11 @@ module MistAws
|
|
174
174
|
role = iam.create_role(role_name: role_name, assume_role_policy_document: assume_role_policy)
|
175
175
|
|
176
176
|
# Create a policy object associated to the role and stuff the policy document into it
|
177
|
-
policy = Aws::IAM::RolePolicy.new(role_name: role_name, name: policy_name, client: iam_client)
|
177
|
+
policy = ::Aws::IAM::RolePolicy.new(role_name: role_name, name: policy_name, client: iam_client)
|
178
178
|
policy.put(policy_document: policy_document)
|
179
179
|
|
180
180
|
# Create an instance_profile
|
181
|
-
instance_profile = iam.create_instance_profile(instance_profile_name: instance_profile_name)
|
181
|
+
instance_profile = iam.create_instance_profile(instance_profile_name: instance_profile_name) unless instance_profile_exists?(instance_profile_name)
|
182
182
|
instance_profile.add_role(role_name: role_name)
|
183
183
|
role
|
184
184
|
end
|
data/lib/mist_aws/version.rb
CHANGED
data/mist_aws.gemspec
CHANGED
@@ -23,7 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.1.0"
|
24
24
|
spec.add_development_dependency "pry"
|
25
25
|
spec.add_development_dependency "yard"
|
26
|
-
spec.add_dependency "aws-sdk"
|
26
|
+
spec.add_dependency "aws-sdk-core"
|
27
|
+
spec.add_dependency "aws-sdk-resources"
|
27
28
|
spec.add_dependency "json"
|
28
29
|
spec.add_dependency "inifile"
|
29
30
|
end
|
data/spec/iam/mocked_spec.rb
CHANGED
@@ -186,8 +186,10 @@ describe "Fully Mocked Tests" do
|
|
186
186
|
expect(::Aws::IAM::RolePolicy).to receive(:new).with(role_name: role_name, name: role_policy_name, client: iam_client).and_return(role_policy)
|
187
187
|
expect(role_policy).to receive(:put).with(policy_document: role_policy_document)
|
188
188
|
|
189
|
-
expect(iam).to receive(:
|
189
|
+
expect(iam).to receive(:instance_profile).with(instance_profile_name).and_return(instance_profile)
|
190
190
|
expect(instance_profile).to receive(:add_role).with(role_name: role_name)
|
191
|
+
expect(instance_profile).to receive(:data_loaded?).and_return(false)
|
192
|
+
expect(iam).to receive(:create_instance_profile).with(instance_profile_name: instance_profile_name).and_return(instance_profile)
|
191
193
|
|
192
194
|
|
193
195
|
mist_aws.create_iam_role(role_name, role_policy_name, role_policy_document, instance_profile_name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mist_aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert J. Berger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,19 +81,33 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name: aws-sdk
|
84
|
+
name: aws-sdk-core
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: aws-sdk-resources
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: json
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
181
|
version: '0'
|
168
182
|
requirements: []
|
169
183
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.4.
|
184
|
+
rubygems_version: 2.4.8
|
171
185
|
signing_key:
|
172
186
|
specification_version: 4
|
173
187
|
summary: Wrapper around aws-sdk V2 for higher level use
|