awspec 0.8.1 → 0.9.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/README.md +1 -1
- data/doc/resource_types.md +12 -0
- data/lib/awspec/generator/doc/type/iam_group.rb +17 -0
- data/lib/awspec/generator/template.rb +1 -1
- data/lib/awspec/helper/finder/iam.rb +24 -0
- data/lib/awspec/helper/type.rb +1 -1
- data/lib/awspec/stub/iam_group.rb +43 -0
- data/lib/awspec/type/iam_group.rb +26 -0
- data/lib/awspec/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 327a5cd2ed17af3f58122c6d2d2edf1fab622bfa
|
4
|
+
data.tar.gz: 66f4220079021aaf43365b7bb013e69b78df44d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37722811763e42a9728d7e1fc8d6f22c3e6403f910c16c84411114c73f191361f807adf2afaa6c43cc5aa5133606efd4e6ad8b3e807268364464ca2231f1dc98
|
7
|
+
data.tar.gz: fc0d09164bdbf8825bac61b2cf514d19d21929bde7a61b79ba20212cbfd82d77fcf438350dd6322af19b98d76aa12233c27e0458f4fd1a9f808804db64046f40
|
data/README.md
CHANGED
data/doc/resource_types.md
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
| [elb](#elb)
|
15
15
|
| [lambda](#lambda)
|
16
16
|
| [iam_user](#iam_user)
|
17
|
+
| [iam_group](#iam_group)
|
17
18
|
|
18
19
|
## <a name="ec2">ec2</a>
|
19
20
|
|
@@ -280,3 +281,14 @@ IamUser resource type.
|
|
280
281
|
### belong_to_iam_group
|
281
282
|
|
282
283
|
#### its(:path), its(:user_name), its(:user_id), its(:arn), its(:create_date), its(:password_last_used)
|
284
|
+
## <a name="iam_group">iam_group</a>
|
285
|
+
|
286
|
+
IamGroup resource type.
|
287
|
+
|
288
|
+
### exist
|
289
|
+
|
290
|
+
### have_iam_policy
|
291
|
+
|
292
|
+
### have_iam_user
|
293
|
+
|
294
|
+
#### its(:path), its(:group_name), its(:group_id), its(:arn), its(:create_date)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class IamGroup < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type_name = 'IamGroup'
|
8
|
+
@type = Awspec::Type::IamGroup.new('my-iam-group')
|
9
|
+
@ret = @type.resource
|
10
|
+
@matchers = []
|
11
|
+
@ignore_matchers = []
|
12
|
+
@describes = []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -18,6 +18,23 @@ module Awspec::Helper
|
|
18
18
|
return users[0] if users.count == 1
|
19
19
|
end
|
20
20
|
|
21
|
+
def find_iam_group(id)
|
22
|
+
groups = []
|
23
|
+
marker = nil
|
24
|
+
loop do
|
25
|
+
res = @iam_client.list_groups(
|
26
|
+
marker: marker
|
27
|
+
)
|
28
|
+
marker = res.marker
|
29
|
+
break if res.groups.empty?
|
30
|
+
res.groups.each do |group|
|
31
|
+
groups.push(group) if group.group_name == id || group.group_id == id
|
32
|
+
end
|
33
|
+
break unless marker
|
34
|
+
end
|
35
|
+
return groups[0] if groups.count == 1
|
36
|
+
end
|
37
|
+
|
21
38
|
def select_iam_group_by_user_name(user_name)
|
22
39
|
res = @iam_client.list_groups_for_user({
|
23
40
|
user_name: user_name
|
@@ -31,6 +48,13 @@ module Awspec::Helper
|
|
31
48
|
})
|
32
49
|
res.attached_policies
|
33
50
|
end
|
51
|
+
|
52
|
+
def select_iam_policy_by_group_name(group_name)
|
53
|
+
res = @iam_client.list_attached_group_policies({
|
54
|
+
group_name: group_name
|
55
|
+
})
|
56
|
+
res.attached_policies
|
57
|
+
end
|
34
58
|
end
|
35
59
|
end
|
36
60
|
end
|
data/lib/awspec/helper/type.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
Aws.config[:iam] = {
|
2
|
+
stub_responses: {
|
3
|
+
list_groups: {
|
4
|
+
groups: [
|
5
|
+
path: '/',
|
6
|
+
group_name: 'my-iam-group',
|
7
|
+
group_id: 'GABCDEFGHI123455689',
|
8
|
+
arn: 'arn:aws:iam::123456789012:group/my-iam-group',
|
9
|
+
create_date: Time.local(2015)
|
10
|
+
]
|
11
|
+
},
|
12
|
+
list_users: {
|
13
|
+
users: [
|
14
|
+
path: '/',
|
15
|
+
user_name: 'my-iam-user',
|
16
|
+
user_id: 'ABCDEFGHI1234556890',
|
17
|
+
arn: 'arn:aws:iam::123456789012:user/my-iam-user',
|
18
|
+
create_date: Time.local(2015)
|
19
|
+
]
|
20
|
+
},
|
21
|
+
list_groups_for_user: {
|
22
|
+
groups: [
|
23
|
+
{
|
24
|
+
path: '/',
|
25
|
+
group_name: 'my-iam-group',
|
26
|
+
group_id: 'GABCDEFGHI123455689',
|
27
|
+
arn: 'arn:aws:iam::123456789012:group/my-iam-group',
|
28
|
+
create_date: Time.local(2015)
|
29
|
+
}
|
30
|
+
]
|
31
|
+
},
|
32
|
+
list_attached_group_policies: {
|
33
|
+
attached_policies: [
|
34
|
+
{
|
35
|
+
policy_arn: 'arn:aws:iam::aws:policy/ReadOnlyAccess',
|
36
|
+
policy_name: 'ReadOnlyAccess'
|
37
|
+
}
|
38
|
+
],
|
39
|
+
is_truncated: false,
|
40
|
+
maker: nil
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class IamGroup < Base
|
3
|
+
def initialize(id)
|
4
|
+
super
|
5
|
+
@resource = find_iam_group(id)
|
6
|
+
@id = @resource[:group_id] if @resource
|
7
|
+
end
|
8
|
+
|
9
|
+
def has_iam_user?(user_id)
|
10
|
+
user = find_iam_user(user_id)
|
11
|
+
return false unless user
|
12
|
+
user_name = user[:user_name]
|
13
|
+
groups = select_iam_group_by_user_name(user_name)
|
14
|
+
groups.find do |group|
|
15
|
+
group.group_id == @id
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def has_iam_policy?(policy_id)
|
20
|
+
policies = select_iam_policy_by_group_name(@resource[:group_name])
|
21
|
+
policies.find do |policy|
|
22
|
+
policy.policy_arn == policy_id || policy.policy_name == policy_id
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
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.9.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-09-
|
11
|
+
date: 2015-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- lib/awspec/generator/doc/type/ebs.rb
|
162
162
|
- lib/awspec/generator/doc/type/ec2.rb
|
163
163
|
- lib/awspec/generator/doc/type/elb.rb
|
164
|
+
- lib/awspec/generator/doc/type/iam_group.rb
|
164
165
|
- lib/awspec/generator/doc/type/iam_user.rb
|
165
166
|
- lib/awspec/generator/doc/type/lambda.rb
|
166
167
|
- lib/awspec/generator/doc/type/rds.rb
|
@@ -206,6 +207,7 @@ files:
|
|
206
207
|
- lib/awspec/stub/ebs.rb
|
207
208
|
- lib/awspec/stub/ec2.rb
|
208
209
|
- lib/awspec/stub/elb.rb
|
210
|
+
- lib/awspec/stub/iam_group.rb
|
209
211
|
- lib/awspec/stub/iam_user.rb
|
210
212
|
- lib/awspec/stub/lambda.rb
|
211
213
|
- lib/awspec/stub/rds.rb
|
@@ -222,6 +224,7 @@ files:
|
|
222
224
|
- lib/awspec/type/ebs.rb
|
223
225
|
- lib/awspec/type/ec2.rb
|
224
226
|
- lib/awspec/type/elb.rb
|
227
|
+
- lib/awspec/type/iam_group.rb
|
225
228
|
- lib/awspec/type/iam_user.rb
|
226
229
|
- lib/awspec/type/lambda.rb
|
227
230
|
- lib/awspec/type/rds.rb
|