putpaws 0.1.4 → 0.1.5
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 +29 -5
- data/lib/putpaws/provision/config_writer.rb +26 -9
- data/lib/putpaws/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6b0c08e32fd66d0f401c637c162bb7d2e408beb0110e433fec09d2a5853e0372
|
|
4
|
+
data.tar.gz: faeacb4b1476fd8247f627e32640ddaaac55e906754bba8e0155adc35a624225
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f43a0329c4b6705b72c235687f0ba9f3a038a1314c32dca0dcfb83f26f28326b0e7ae7d2d1cb13267674626ccd47786100b574b17fa95119606ebcf960b1193
|
|
7
|
+
data.tar.gz: 3488ea35bc10ce0ed4449ed0ca1ec97836f22535d246662f3d3f729779fc12d1e67b5a231cc28acc7fa9c816c369a59a37e6f5a9d5bda45c97fa9e9e70fc0291
|
data/README.md
CHANGED
|
@@ -55,6 +55,14 @@ or a new one is created for the service when left empty on `ready`.
|
|
|
55
55
|
When the service step completes, the new service is reflected into
|
|
56
56
|
`.putpaws/application.json` and `.putpaws/infra.json` (diff is shown and confirmed),
|
|
57
57
|
so `ecs:attach`, `ecs:shell`, `ecs:run` and `log:*` work immediately.
|
|
58
|
+
One entry is written per task definition of the preset, keyed by the task definition
|
|
59
|
+
family `{service_name}-{suffix}` (Ex: `awesome-api-staging-app` / `awesome-api-staging-web`),
|
|
60
|
+
each pointing at the `infra.target` of the same name. Only the entry of the preset's
|
|
61
|
+
`service_task_definition` carries `service` (for `ecs:deploy` / `ecs:attach`); the others have
|
|
62
|
+
`service: null` and are meant for one-off tasks (`ecs:run` / `ecs:shell` / scheduler),
|
|
63
|
+
so `db:migrate` keeps running on the plain `app` task definition even when the service
|
|
64
|
+
runs `web` (nginx + app). `infra.network` is written once as `{service_name}`.
|
|
65
|
+
Existing keys are never deleted; remove stale ones by hand.
|
|
58
66
|
Secrets are handled by reference only: task definitions point to existing
|
|
59
67
|
SSM parameters (Ex: `/{service_name}/RAILS_MASTER_KEY`) and putpaws never touches the values.
|
|
60
68
|
|
|
@@ -225,19 +233,35 @@ gem 'putpaws'
|
|
|
225
233
|
|
|
226
234
|
`.putpaws/application.json`
|
|
227
235
|
|
|
236
|
+
Keys are free-form names you pass to the CLI. The ones written by `putpaws up` follow
|
|
237
|
+
`{service_name}-{suffix}`: `-app` for one-off tasks (`service: null`), `-web` for the
|
|
238
|
+
long-running service.
|
|
239
|
+
|
|
228
240
|
```
|
|
229
241
|
{
|
|
230
|
-
"awesome-api-staging": {
|
|
242
|
+
"awesome-api-staging-app": {
|
|
231
243
|
"region": "ap-northeast-1",
|
|
232
244
|
"cluster": "cluster-staging",
|
|
233
245
|
"service": null,
|
|
234
|
-
"task_name_prefix": "awesome-api",
|
|
235
|
-
"log_group_prefix": "/ecs/awesome
|
|
246
|
+
"task_name_prefix": "awesome-api-staging-app",
|
|
247
|
+
"log_group_prefix": "/ecs/awesome-api-staging",
|
|
248
|
+
"log_region": null,
|
|
249
|
+
"build_log_group_prefix": "/aws/codebuild/awesome-api-staging",
|
|
250
|
+
"build_project_name_prefix": "awesome-api-staging",
|
|
251
|
+
"network": "awesome-api-staging",
|
|
252
|
+
"target": "awesome-api-staging-app"
|
|
253
|
+
},
|
|
254
|
+
"awesome-api-staging-web": {
|
|
255
|
+
"region": "ap-northeast-1",
|
|
256
|
+
"cluster": "cluster-staging",
|
|
257
|
+
"service": "awesome-api-staging",
|
|
258
|
+
"task_name_prefix": "awesome-api-staging-web",
|
|
259
|
+
"log_group_prefix": "/ecs/awesome-api-staging",
|
|
236
260
|
"log_region": null,
|
|
237
261
|
"build_log_group_prefix": "/aws/codebuild/awesome-api-staging",
|
|
238
262
|
"build_project_name_prefix": "awesome-api-staging",
|
|
239
|
-
"network": "awesome-
|
|
240
|
-
"target": "awesome-staging"
|
|
263
|
+
"network": "awesome-api-staging",
|
|
264
|
+
"target": "awesome-api-staging-web"
|
|
241
265
|
},
|
|
242
266
|
"awesome-api-production": {
|
|
243
267
|
"region": "ap-northeast-1",
|
|
@@ -8,6 +8,15 @@ module Putpaws
|
|
|
8
8
|
# Reflects provisioned resources into .putpaws/application.json and
|
|
9
9
|
# .putpaws/infra.json. Only the keys of the target service are touched.
|
|
10
10
|
# Shows a diff and asks for confirmation before writing.
|
|
11
|
+
#
|
|
12
|
+
# One application entry and one infra.target entry are written per task
|
|
13
|
+
# definition of the preset, keyed by the task definition family
|
|
14
|
+
# (`<service_name>-<suffix>`). The entry whose suffix is the preset's
|
|
15
|
+
# `service_task_definition` carries `service` so that ecs:deploy /
|
|
16
|
+
# ecs:attach address the long-running service; the others are for
|
|
17
|
+
# one-off tasks (ecs:run / ecs:shell / scheduler) and have `service: null`.
|
|
18
|
+
# infra.network is written once per service as it does not depend on the
|
|
19
|
+
# task definition.
|
|
11
20
|
class ConfigWriter
|
|
12
21
|
attr_reader :config, :state, :prompt, :io
|
|
13
22
|
def initialize(config:, state:, prompt:, io: $stdout)
|
|
@@ -17,17 +26,18 @@ module Putpaws
|
|
|
17
26
|
@io = io
|
|
18
27
|
end
|
|
19
28
|
|
|
20
|
-
def application_entry
|
|
29
|
+
def application_entry(entry)
|
|
30
|
+
family = config.task_definition_family(entry[:suffix])
|
|
21
31
|
{
|
|
22
32
|
region: config.region,
|
|
23
33
|
cluster: config.cluster_name,
|
|
24
|
-
service: config.service_name,
|
|
25
|
-
task_name_prefix:
|
|
34
|
+
service: service_entry?(entry) ? config.service_name : nil,
|
|
35
|
+
task_name_prefix: family,
|
|
26
36
|
log_group_prefix: config.log_group,
|
|
27
37
|
build_log_group_prefix: config.build_log_group,
|
|
28
38
|
build_project_name_prefix: config.build_project_name,
|
|
29
39
|
network: config.service_name,
|
|
30
|
-
target:
|
|
40
|
+
target: family,
|
|
31
41
|
}
|
|
32
42
|
end
|
|
33
43
|
|
|
@@ -39,25 +49,32 @@ module Putpaws
|
|
|
39
49
|
}
|
|
40
50
|
end
|
|
41
51
|
|
|
42
|
-
def target_entry
|
|
52
|
+
def target_entry(entry)
|
|
43
53
|
{
|
|
44
54
|
# Used by EventBridge Scheduler (scheduler:deploy).
|
|
45
55
|
scheduler_role: config.roles[:scheduler_role_arn],
|
|
46
56
|
cluster: state.resources[:cluster_arn],
|
|
47
57
|
# Revision-less on purpose: always run the latest ACTIVE revision.
|
|
48
|
-
task_definition: config.
|
|
49
|
-
container_name:
|
|
58
|
+
task_definition: config.task_definition_family(entry[:suffix]),
|
|
59
|
+
container_name: entry[:container_name] || 'app',
|
|
50
60
|
}
|
|
51
61
|
end
|
|
52
62
|
|
|
53
63
|
def apply!
|
|
54
|
-
write_key(path('application.json'), [config.service_name.to_sym], application_entry)
|
|
55
64
|
write_key(path('infra.json'), [:network, config.service_name.to_sym], network_entry)
|
|
56
|
-
|
|
65
|
+
config.preset.task_definitions.each do |entry|
|
|
66
|
+
key = config.task_definition_family(entry[:suffix]).to_sym
|
|
67
|
+
write_key(path('application.json'), [key], application_entry(entry))
|
|
68
|
+
write_key(path('infra.json'), [:target, key], target_entry(entry))
|
|
69
|
+
end
|
|
57
70
|
end
|
|
58
71
|
|
|
59
72
|
private
|
|
60
73
|
|
|
74
|
+
def service_entry?(entry)
|
|
75
|
+
entry[:suffix] == config.preset.service_task_definition
|
|
76
|
+
end
|
|
77
|
+
|
|
61
78
|
def path(basename)
|
|
62
79
|
Pathname.new(config.path_prefix).join(basename)
|
|
63
80
|
end
|
data/lib/putpaws/version.rb
CHANGED