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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d38b16d5a4fc24915b8bde117f9fda98d0fb6418989eebf98385e86ad724dd32
4
- data.tar.gz: c3ee3c20989376d82da51e970aa23ab2995af32c39b0e37524c7fa915cf9a8f9
3
+ metadata.gz: 6b0c08e32fd66d0f401c637c162bb7d2e408beb0110e433fec09d2a5853e0372
4
+ data.tar.gz: faeacb4b1476fd8247f627e32640ddaaac55e906754bba8e0155adc35a624225
5
5
  SHA512:
6
- metadata.gz: e2d00b74e706f5c9192a455bd7919845c4afeb06d2c3db9cd17c2030689cdc2858cc439efb6dd360cc8b9d4eb3fe6fceb6e9a62fb361de1ff0b8d30be4be10c2
7
- data.tar.gz: 49fbf55b6659a02a563792d4ab406bbe1f583e84abf82eee10c5c52b12bbcb3da42d539fb1346dc10dd4a4a6ba70df427b8ddc5f1b5edf7c07e775c4b314fb72
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/awesome-api-staging",
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-private-staging",
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: config.service_name,
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: config.service_name,
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.service_task_definition_family,
49
- container_name: config.service_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
- write_key(path('infra.json'), [:target, config.service_name.to_sym], target_entry)
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
@@ -1,3 +1,3 @@
1
1
  module Putpaws
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: putpaws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - metheglin