awspec 0.7.0 → 0.8.0
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.
- checksums.yaml +4 -4
- data/.tachikoma.yml +1 -0
- data/README.md +5 -2
- data/doc/resource_types.md +10 -0
- data/lib/awspec/generator/doc/type/iam_user.rb +17 -0
- data/lib/awspec/helper/finder.rb +3 -0
- data/lib/awspec/helper/finder/iam.rb +36 -0
- data/lib/awspec/helper/type.rb +1 -1
- data/lib/awspec/matcher.rb +3 -0
- data/lib/awspec/matcher/belong_to_iam_group.rb +8 -0
- data/lib/awspec/stub/iam_user.rb +34 -0
- data/lib/awspec/type/iam_user.rb +27 -0
- data/lib/awspec/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b82928f9ac3ba086bd8057f29a2d29d924b6173
|
4
|
+
data.tar.gz: 46a33e636b743394115ecc99d5b3db3418716041
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 898a43391065b7f8f4cae1bec98f4b68e8c4328db0acf23e4356e40bbed8782930f7d371ca037396a6c48bb5a1f8918d90515a25921b7305e4474a0c96d55495
|
7
|
+
data.tar.gz: d4490f55c1e4f4ebf2f85a081ca7235f1c3d6236c598145bf30f62e04cae818da4dfc9d210be8e1a40849511ca6393f3d4833e183210c93305bca9d3ad7fae05
|
data/.tachikoma.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
strategy: 'bundler'
|
data/README.md
CHANGED
@@ -92,13 +92,16 @@ $ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
|
|
92
92
|
- [x] EBS Volume (`ebs`)
|
93
93
|
- [x] ELB (`elb`)
|
94
94
|
- [x] Lambda (`lambda`)
|
95
|
+
- IAM
|
96
|
+
- [x] IAM User (`iam_user`)
|
97
|
+
- [ ] IAM Group
|
98
|
+
- [ ] IAM Role
|
99
|
+
- [ ] IAM Policy
|
95
100
|
|
96
101
|
[Resource Types more infomation here](doc/resource_types.md)
|
97
102
|
|
98
103
|
### Next..
|
99
104
|
|
100
|
-
- IAM
|
101
|
-
- [ ] IAM User
|
102
105
|
- ...
|
103
106
|
|
104
107
|
## Contributing
|
data/doc/resource_types.md
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
| [ebs](#ebs)
|
14
14
|
| [elb](#elb)
|
15
15
|
| [lambda](#lambda)
|
16
|
+
| [iam_user](#iam_user)
|
16
17
|
|
17
18
|
## <a name="ec2">ec2</a>
|
18
19
|
|
@@ -268,3 +269,12 @@ Lambda resource type.
|
|
268
269
|
This matcher does not support Amazon S3 event sources. ( [See SDK doc](http://docs.aws.amazon.com/sdkforruby/api/Aws/Lambda/Client.html#list_event_source_mappings-instance_method) )
|
269
270
|
|
270
271
|
#### its(:function_name), its(:function_arn), its(:runtime), its(:role), its(:handler), its(:code_size), its(:description), its(:timeout), its(:memory_size), its(:last_modified)
|
272
|
+
## <a name="iam_user">iam_user</a>
|
273
|
+
|
274
|
+
IamUser resource type.
|
275
|
+
|
276
|
+
### exist
|
277
|
+
|
278
|
+
### have_iam_policy
|
279
|
+
|
280
|
+
#### its(:path), its(:user_name), its(:user_id), its(:arn), its(:create_date), its(:password_last_used)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class IamUser < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type_name = 'IamUser'
|
8
|
+
@type = Awspec::Type::IamUser.new('my-iam-user')
|
9
|
+
@ret = @type.user
|
10
|
+
@matchers = []
|
11
|
+
@ignore_matchers = []
|
12
|
+
@describes = []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/awspec/helper/finder.rb
CHANGED
@@ -9,6 +9,7 @@ require 'awspec/helper/finder/auto_scaling'
|
|
9
9
|
require 'awspec/helper/finder/ebs'
|
10
10
|
require 'awspec/helper/finder/elb'
|
11
11
|
require 'awspec/helper/finder/lambda'
|
12
|
+
require 'awspec/helper/finder/iam'
|
12
13
|
|
13
14
|
module Awspec::Helper
|
14
15
|
module Finder
|
@@ -23,6 +24,7 @@ module Awspec::Helper
|
|
23
24
|
include Awspec::Helper::Finder::Ebs
|
24
25
|
include Awspec::Helper::Finder::Elb
|
25
26
|
include Awspec::Helper::Finder::Lambda
|
27
|
+
include Awspec::Helper::Finder::Iam
|
26
28
|
|
27
29
|
# rubocop:disable all
|
28
30
|
def initialize(id = nil)
|
@@ -33,6 +35,7 @@ module Awspec::Helper
|
|
33
35
|
@auto_scaling_client = Aws::AutoScaling::Client.new
|
34
36
|
@elb_client = Aws::ElasticLoadBalancing::Client.new
|
35
37
|
@lambda_client = Aws::Lambda::Client.new
|
38
|
+
@iam_client = Aws::IAM::Client.new
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Awspec::Helper
|
2
|
+
module Finder
|
3
|
+
module Iam
|
4
|
+
def find_iam_user(id)
|
5
|
+
users = []
|
6
|
+
marker = nil
|
7
|
+
loop do
|
8
|
+
res = @iam_client.list_users(
|
9
|
+
marker: marker
|
10
|
+
)
|
11
|
+
marker = res.marker
|
12
|
+
break if res.users.empty?
|
13
|
+
res.users.each do |user|
|
14
|
+
users.push(user) if user.user_name == id || user.user_id == id
|
15
|
+
end
|
16
|
+
break unless marker
|
17
|
+
end
|
18
|
+
return users[0] if users.count == 1
|
19
|
+
end
|
20
|
+
|
21
|
+
def select_iam_group_by_user_name(user_name)
|
22
|
+
res = @iam_client.list_groups_for_user({
|
23
|
+
user_name: user_name
|
24
|
+
})
|
25
|
+
res.groups
|
26
|
+
end
|
27
|
+
|
28
|
+
def select_iam_policy_by_user_name(user_name)
|
29
|
+
res = @iam_client.list_attached_user_policies({
|
30
|
+
user_name: user_name
|
31
|
+
})
|
32
|
+
res.attached_policies
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/awspec/helper/type.rb
CHANGED
data/lib/awspec/matcher.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
Aws.config[:iam] = {
|
2
|
+
stub_responses: {
|
3
|
+
list_users: {
|
4
|
+
users: [
|
5
|
+
path: '/',
|
6
|
+
user_name: 'my-iam-user',
|
7
|
+
user_id: 'ABCDEFGHI1234556890',
|
8
|
+
arn: 'arn:aws:iam::123456789012:user/my-iam-user',
|
9
|
+
create_date: Time.local(2015)
|
10
|
+
]
|
11
|
+
},
|
12
|
+
list_groups_for_user: {
|
13
|
+
groups: [
|
14
|
+
{
|
15
|
+
path: '/',
|
16
|
+
group_name: 'my-iam-group',
|
17
|
+
group_id: 'GABCDEFGHI123455689',
|
18
|
+
arn: 'arn:aws:iam::123456789012:group/my-iam-group',
|
19
|
+
create_date: Time.local(2015)
|
20
|
+
}
|
21
|
+
]
|
22
|
+
},
|
23
|
+
list_attached_user_policies: {
|
24
|
+
attached_policies: [
|
25
|
+
{
|
26
|
+
policy_arn: 'arn:aws:iam::aws:policy/ReadOnlyAccess',
|
27
|
+
policy_name: 'ReadOnlyAccess'
|
28
|
+
}
|
29
|
+
],
|
30
|
+
is_truncated: false,
|
31
|
+
maker: nil
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class IamUser < Base
|
3
|
+
attr_reader :user
|
4
|
+
|
5
|
+
def initialize(id)
|
6
|
+
super
|
7
|
+
@user = find_iam_user(id)
|
8
|
+
@id = @user[:user_id] if @user
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(name)
|
12
|
+
describe = name.to_sym
|
13
|
+
if @user.members.include?(describe)
|
14
|
+
@user[describe]
|
15
|
+
else
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def has_iam_policy?(policy_id)
|
21
|
+
policies = select_iam_policy_by_user_name(@user[:user_name])
|
22
|
+
policies.find do |policy|
|
23
|
+
policy.policy_arn == policy_id || policy.policy_name == policy_id
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
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.8.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-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- ".editorconfig"
|
134
134
|
- ".gitignore"
|
135
135
|
- ".rubocop.yml"
|
136
|
+
- ".tachikoma.yml"
|
136
137
|
- ".travis.yml"
|
137
138
|
- Gemfile
|
138
139
|
- LICENSE.txt
|
@@ -160,6 +161,7 @@ files:
|
|
160
161
|
- lib/awspec/generator/doc/type/ebs.rb
|
161
162
|
- lib/awspec/generator/doc/type/ec2.rb
|
162
163
|
- lib/awspec/generator/doc/type/elb.rb
|
164
|
+
- lib/awspec/generator/doc/type/iam_user.rb
|
163
165
|
- lib/awspec/generator/doc/type/lambda.rb
|
164
166
|
- lib/awspec/generator/doc/type/rds.rb
|
165
167
|
- lib/awspec/generator/doc/type/rds_db_parameter_group.rb
|
@@ -182,6 +184,7 @@ files:
|
|
182
184
|
- lib/awspec/helper/finder/ebs.rb
|
183
185
|
- lib/awspec/helper/finder/ec2.rb
|
184
186
|
- lib/awspec/helper/finder/elb.rb
|
187
|
+
- lib/awspec/helper/finder/iam.rb
|
185
188
|
- lib/awspec/helper/finder/lambda.rb
|
186
189
|
- lib/awspec/helper/finder/rds.rb
|
187
190
|
- lib/awspec/helper/finder/route53.rb
|
@@ -192,6 +195,7 @@ files:
|
|
192
195
|
- lib/awspec/matcher.rb
|
193
196
|
- lib/awspec/matcher/be_opened.rb
|
194
197
|
- lib/awspec/matcher/belong_to_db_subnet_group.rb
|
198
|
+
- lib/awspec/matcher/belong_to_iam_group.rb
|
195
199
|
- lib/awspec/matcher/belong_to_subnet.rb
|
196
200
|
- lib/awspec/matcher/belong_to_vpc.rb
|
197
201
|
- lib/awspec/matcher/have_record_set.rb
|
@@ -202,6 +206,7 @@ files:
|
|
202
206
|
- lib/awspec/stub/ebs.rb
|
203
207
|
- lib/awspec/stub/ec2.rb
|
204
208
|
- lib/awspec/stub/elb.rb
|
209
|
+
- lib/awspec/stub/iam_user.rb
|
205
210
|
- lib/awspec/stub/lambda.rb
|
206
211
|
- lib/awspec/stub/rds.rb
|
207
212
|
- lib/awspec/stub/rds_db_parameter_group.rb
|
@@ -217,6 +222,7 @@ files:
|
|
217
222
|
- lib/awspec/type/ebs.rb
|
218
223
|
- lib/awspec/type/ec2.rb
|
219
224
|
- lib/awspec/type/elb.rb
|
225
|
+
- lib/awspec/type/iam_user.rb
|
220
226
|
- lib/awspec/type/lambda.rb
|
221
227
|
- lib/awspec/type/rds.rb
|
222
228
|
- lib/awspec/type/rds_db_parameter_group.rb
|