swa 0.7.7 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/swa/cli/lake_formation_command.rb +69 -0
- data/lib/swa/cli/main_command.rb +2 -0
- data/lib/swa/lake_formation/permission.rb +32 -0
- data/lib/swa/lake_formation/resource_info.rb +21 -0
- data/lib/swa/version.rb +1 -1
- data/swa.gemspec +1 -0
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc012c238e6f8addd7891b70044fa5958d8ce541b0a8f835a5dc565199532c9f
|
4
|
+
data.tar.gz: 89190ad304d311425e0daa21509b3821e057ca2b411f9599740f152ec0fbd079
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 489ad35514b0bbfbdb6b82693c351610fced3582cb5f2b93c559298d3bac19abf73d7ae3240ee50daf26dd9e432a8671d37bed10828218aeaa399c339554f879
|
7
|
+
data.tar.gz: a4334e5402813b7cbe3baa7bbfccb88d2f4588578b6ec1f316282a6eb62d2d4d732692a3cdddb8d9066df73656bf563c0d893d1b536bd121309a51532f00bcfc
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require "aws-sdk-lakeformation"
|
2
|
+
require "swa/cli/base_command"
|
3
|
+
require "swa/cli/collection_behaviour"
|
4
|
+
require "swa/cli/item_behaviour"
|
5
|
+
require "swa/lake_formation/permission"
|
6
|
+
require "swa/lake_formation/resource_info"
|
7
|
+
|
8
|
+
module Swa
|
9
|
+
module CLI
|
10
|
+
|
11
|
+
class LakeFormationCommand < BaseCommand
|
12
|
+
|
13
|
+
subcommand ["permissions"], "Show permissions" do
|
14
|
+
|
15
|
+
self.description = <<-EOF
|
16
|
+
List permissions.
|
17
|
+
EOF
|
18
|
+
|
19
|
+
ALLOWED_RESOURCE_TYPES = %w(CATALOG DATABASE TABLE DATA_LOCATION LF_TAG LF_TAG_POLICY LF_TAG_POLICY_DATABASE LF_TAG_POLICY_TABLE)
|
20
|
+
|
21
|
+
option ["--type", "-T"], "TYPE", "Resource type" do |value|
|
22
|
+
value = value.upcase
|
23
|
+
raise ArgumentError, "Invalid resource type: #{value}" unless ALLOWED_RESOURCE_TYPES.include?(value)
|
24
|
+
value
|
25
|
+
end
|
26
|
+
|
27
|
+
include CollectionBehaviour
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def collection
|
32
|
+
query_args = {}
|
33
|
+
query_args[:resource_type] = type if type
|
34
|
+
query_for(:list_permissions, :principal_resource_permissions, Swa::LakeFormation::Permission, **query_args)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
subcommand ["resources"], "Show resources" do
|
40
|
+
|
41
|
+
self.description = <<-EOF
|
42
|
+
List resources.
|
43
|
+
EOF
|
44
|
+
|
45
|
+
include CollectionBehaviour
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def collection
|
50
|
+
query_for(:list_resources, :resource_info_list, Swa::LakeFormation::ResourceInfo)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
def lf_client
|
58
|
+
::Aws::LakeFormation::Client.new(aws_config)
|
59
|
+
end
|
60
|
+
|
61
|
+
def query_for(query_method, response_key, model, **query_args)
|
62
|
+
records = lf_client.public_send(query_method, **query_args).public_send(response_key)
|
63
|
+
model.list(records)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
data/lib/swa/cli/main_command.rb
CHANGED
@@ -6,6 +6,7 @@ require "swa/cli/elb_command"
|
|
6
6
|
require "swa/cli/glue_command"
|
7
7
|
require "swa/cli/iam_command"
|
8
8
|
require "swa/cli/kms_command"
|
9
|
+
require "swa/cli/lake_formation_command"
|
9
10
|
require "swa/cli/s3_command"
|
10
11
|
|
11
12
|
module Swa
|
@@ -20,6 +21,7 @@ module Swa
|
|
20
21
|
subcommand "glue", "Glue stuff", GlueCommand
|
21
22
|
subcommand "iam", "IAM stuff", IamCommand
|
22
23
|
subcommand "kms", "KMS stuff", KmsCommand
|
24
|
+
subcommand ["lf", "lakeformation"], "LakeFormation stuff", LakeFormationCommand
|
23
25
|
subcommand "s3", "S3 stuff", S3Command
|
24
26
|
|
25
27
|
protected
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "swa/record"
|
2
|
+
|
3
|
+
module Swa
|
4
|
+
module LakeFormation
|
5
|
+
|
6
|
+
class Permission < Record
|
7
|
+
|
8
|
+
def summary
|
9
|
+
[
|
10
|
+
principal_id,
|
11
|
+
permissions.join(","),
|
12
|
+
resource_summary
|
13
|
+
].join(" ")
|
14
|
+
end
|
15
|
+
|
16
|
+
delegate :permissions
|
17
|
+
delegate :principal
|
18
|
+
|
19
|
+
def principal_id
|
20
|
+
aws_record.principal.data_lake_principal_identifier
|
21
|
+
end
|
22
|
+
|
23
|
+
def resource_summary
|
24
|
+
h = aws_record.resource.to_hash.compact
|
25
|
+
type, details = h.first
|
26
|
+
"#{type}:#{details.values.join("/")}"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "swa/record"
|
2
|
+
|
3
|
+
module Swa
|
4
|
+
module LakeFormation
|
5
|
+
|
6
|
+
class ResourceInfo < Record
|
7
|
+
|
8
|
+
def summary
|
9
|
+
[
|
10
|
+
resource_arn,
|
11
|
+
role_arn
|
12
|
+
].join(" ")
|
13
|
+
end
|
14
|
+
|
15
|
+
delegate :resource_arn
|
16
|
+
delegate :role_arn
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/swa/version.rb
CHANGED
data/swa.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_runtime_dependency "aws-sdk-glue", "~> 1"
|
31
31
|
spec.add_runtime_dependency "aws-sdk-iam", "~> 1"
|
32
32
|
spec.add_runtime_dependency "aws-sdk-kms", "~> 1"
|
33
|
+
spec.add_runtime_dependency "aws-sdk-lakeformation", "~> 1"
|
33
34
|
spec.add_runtime_dependency "aws-sdk-s3", "~> 1"
|
34
35
|
spec.add_runtime_dependency "pry"
|
35
36
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '1'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: aws-sdk-lakeformation
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '1'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '1'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: aws-sdk-s3
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -282,6 +296,7 @@ files:
|
|
282
296
|
- lib/swa/cli/iam_command.rb
|
283
297
|
- lib/swa/cli/item_behaviour.rb
|
284
298
|
- lib/swa/cli/kms_command.rb
|
299
|
+
- lib/swa/cli/lake_formation_command.rb
|
285
300
|
- lib/swa/cli/main_command.rb
|
286
301
|
- lib/swa/cli/s3_command.rb
|
287
302
|
- lib/swa/cli/selector.rb
|
@@ -315,6 +330,8 @@ files:
|
|
315
330
|
- lib/swa/iam/user.rb
|
316
331
|
- lib/swa/kms/alias.rb
|
317
332
|
- lib/swa/kms/key.rb
|
333
|
+
- lib/swa/lake_formation/permission.rb
|
334
|
+
- lib/swa/lake_formation/resource_info.rb
|
318
335
|
- lib/swa/polyfill.rb
|
319
336
|
- lib/swa/record.rb
|
320
337
|
- lib/swa/resource.rb
|
@@ -343,7 +360,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
343
360
|
- !ruby/object:Gem::Version
|
344
361
|
version: '0'
|
345
362
|
requirements: []
|
346
|
-
rubygems_version: 3.
|
363
|
+
rubygems_version: 3.5.3
|
347
364
|
signing_key:
|
348
365
|
specification_version: 4
|
349
366
|
summary: AWS, backwards
|