terrafying-components 2.3.7 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/terrafying/components/dynamicset.rb +1 -1
- data/lib/terrafying/components/instance.rb +1 -0
- data/lib/terrafying/components/prometheus.rb +1 -1
- data/lib/terrafying/components/security/trail.rb +75 -11
- data/lib/terrafying/components/service.rb +1 -1
- data/lib/terrafying/components/staticset.rb +1 -1
- data/lib/terrafying/components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 958f5cf0e55c8fb3ee50530de70424c144000a3ec34c263c66216fb89b234bca
|
4
|
+
data.tar.gz: 2b53beccd6f67c5069f3f1971c9d33e11830c1e047fae99a26197dc59e7696a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c0e3a2933af5c003222be6e5d957cd9d1763b0c6c241b794beb15e45b0e116f1bd3b7f2ac0b7a81c184f76d2a156be36fc6b079f4ce491cb19704695c7730cb
|
7
|
+
data.tar.gz: c9732ff0ecdc0be2ed2351f6a7b3405b2225d13e57d4a7b5c9b782cfae09064f2e1796a4ee314456b90104f8e2784b01a4877e85bc367c4753e72c0cbee37e40
|
@@ -33,7 +33,7 @@ module Terrafying
|
|
33
33
|
options = {
|
34
34
|
public: false,
|
35
35
|
eip: false,
|
36
|
-
ami: aws.ami('base-image-fc-
|
36
|
+
ami: aws.ami('base-image-fc-f50b677a', owners = ['477284023816']),
|
37
37
|
instance_type: 't3a.micro',
|
38
38
|
instances: { min: 1, max: 1, desired: 1, tags: {} },
|
39
39
|
ports: [],
|
@@ -7,7 +7,7 @@ require 'terrafying/components'
|
|
7
7
|
module Terrafying
|
8
8
|
module Components
|
9
9
|
class Prometheus < Terrafying::Context
|
10
|
-
attr_reader :prometheus, :security_group
|
10
|
+
attr_reader :prometheus, :security_group, :thanos
|
11
11
|
|
12
12
|
def self.create_in(options)
|
13
13
|
new(**options).tap(&:create)
|
@@ -81,7 +81,8 @@ module Terrafying
|
|
81
81
|
store:,
|
82
82
|
topic:,
|
83
83
|
include_all_regions: true,
|
84
|
-
include_all_organisation: true
|
84
|
+
include_all_organisation: true,
|
85
|
+
ignore_buckets: []
|
85
86
|
)
|
86
87
|
|
87
88
|
@name = name
|
@@ -142,6 +143,8 @@ module Terrafying
|
|
142
143
|
policy_arn: log_role_policy["arn"],
|
143
144
|
}
|
144
145
|
|
146
|
+
s3_data_selectors = bucket_selector(ignore_buckets)
|
147
|
+
|
145
148
|
resource :aws_cloudtrail, "#{name}", {
|
146
149
|
name: "#{name}",
|
147
150
|
s3_bucket_name: store.name,
|
@@ -165,20 +168,81 @@ module Terrafying
|
|
165
168
|
values: ["arn:aws:lambda"],
|
166
169
|
},
|
167
170
|
},
|
168
|
-
{
|
169
|
-
read_write_type: "All",
|
170
|
-
include_management_events: true,
|
171
|
-
|
172
|
-
data_resource: {
|
173
|
-
type: "AWS::S3::Object",
|
174
|
-
values: ["arn:aws:s3:::"],
|
175
|
-
},
|
176
|
-
},
|
177
171
|
],
|
178
|
-
|
172
|
+
|
173
|
+
}.deep_merge(s3_data_selectors)
|
179
174
|
self
|
180
175
|
end
|
181
176
|
|
177
|
+
def bucket_selector(buckets)
|
178
|
+
buckets = Array(buckets)
|
179
|
+
|
180
|
+
return all_buckets if buckets.empty?
|
181
|
+
|
182
|
+
{
|
183
|
+
advanced_event_selector: [
|
184
|
+
ignore_buckets_selectors(buckets),
|
185
|
+
management_events_selector,
|
186
|
+
]
|
187
|
+
}
|
188
|
+
end
|
189
|
+
|
190
|
+
def all_buckets
|
191
|
+
{
|
192
|
+
event_selector: [
|
193
|
+
{
|
194
|
+
read_write_type: "All",
|
195
|
+
include_management_events: true,
|
196
|
+
|
197
|
+
data_resource: {
|
198
|
+
type: "AWS::S3::Object",
|
199
|
+
values: ["arn:aws:s3:::"],
|
200
|
+
}
|
201
|
+
}
|
202
|
+
]
|
203
|
+
}
|
204
|
+
end
|
205
|
+
|
206
|
+
def ignore_buckets_selectors(buckets)
|
207
|
+
ignore_bucket_arns = Array(buckets).map { |bucket|
|
208
|
+
data_name = Digest::SHA256.hexdigest("#{@name}-#{bucket}")[0..16]
|
209
|
+
arn = data(:aws_s3_bucket, "ct-ignore-#{data_name}", bucket: bucket)['arn']
|
210
|
+
"#{arn}/"
|
211
|
+
}
|
212
|
+
|
213
|
+
{
|
214
|
+
name: "Log all S3 buckets objects events except these",
|
215
|
+
|
216
|
+
field_selector: [
|
217
|
+
{
|
218
|
+
field: 'eventCategory',
|
219
|
+
equals: ['Data']
|
220
|
+
},
|
221
|
+
{
|
222
|
+
field: 'resources.type',
|
223
|
+
equals: ['AWS::S3::Object']
|
224
|
+
},
|
225
|
+
{
|
226
|
+
field: 'resources.ARN',
|
227
|
+
not_equals: ignore_bucket_arns
|
228
|
+
}
|
229
|
+
],
|
230
|
+
}
|
231
|
+
end
|
232
|
+
|
233
|
+
def management_events_selector
|
234
|
+
{
|
235
|
+
name: "Log readOnly and writeOnly management events",
|
236
|
+
|
237
|
+
field_selector: [
|
238
|
+
{
|
239
|
+
field: "eventCategory",
|
240
|
+
equals: ["Management"]
|
241
|
+
}
|
242
|
+
]
|
243
|
+
}
|
244
|
+
end
|
245
|
+
|
182
246
|
def alert!(name:, pattern:, threshold: 1, topic: @topic)
|
183
247
|
|
184
248
|
ident = "cloudwatch-#{@name}-#{name}"
|
@@ -41,7 +41,7 @@ module Terrafying
|
|
41
41
|
|
42
42
|
def create_in(vpc, name, options = {})
|
43
43
|
options = {
|
44
|
-
ami: aws.ami('base-image-fc-
|
44
|
+
ami: aws.ami('base-image-fc-f50b677a', owners = ['477284023816']),
|
45
45
|
instance_type: 't3a.micro',
|
46
46
|
ports: [],
|
47
47
|
instances: [{}],
|
@@ -38,7 +38,7 @@ module Terrafying
|
|
38
38
|
options = {
|
39
39
|
public: false,
|
40
40
|
eip: false,
|
41
|
-
ami: aws.ami('base-image-fc-
|
41
|
+
ami: aws.ami('base-image-fc-f50b677a', owners = ['477284023816']),
|
42
42
|
instance_type: 't3a.micro',
|
43
43
|
subnets: vpc.subnets.fetch(:private, []),
|
44
44
|
ports: [],
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terrafying-components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- uSwitch Limited
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|