alchemy-effect 0.2.0 → 0.4.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.
- package/bin/alchemy-effect.js +55354 -8
- package/bin/alchemy-effect.js.map +1 -1
- package/bin/alchemy-effect.ts +266 -10
- package/lib/$.d.ts +5 -0
- package/lib/$.d.ts.map +1 -0
- package/lib/$.js +9 -0
- package/lib/$.js.map +1 -0
- package/lib/app.d.ts +4 -17
- package/lib/app.d.ts.map +1 -1
- package/lib/app.js +0 -20
- package/lib/app.js.map +1 -1
- package/lib/apply.d.ts +15 -75
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +439 -154
- package/lib/apply.js.map +1 -1
- package/lib/assert-never.d.ts +12 -0
- package/lib/assert-never.d.ts.map +1 -0
- package/lib/assert-never.js +11 -0
- package/lib/assert-never.js.map +1 -0
- package/lib/aws/account.d.ts +10 -1
- package/lib/aws/account.d.ts.map +1 -1
- package/lib/aws/account.js +18 -3
- package/lib/aws/account.js.map +1 -1
- package/lib/aws/client.d.ts.map +1 -1
- package/lib/aws/client.js +0 -1
- package/lib/aws/client.js.map +1 -1
- package/lib/aws/config.d.ts +15 -0
- package/lib/aws/config.d.ts.map +1 -0
- package/lib/aws/config.js +1 -0
- package/lib/aws/config.js.map +1 -0
- package/lib/aws/credentials.d.ts +10 -0
- package/lib/aws/credentials.d.ts.map +1 -1
- package/lib/aws/credentials.js +73 -47
- package/lib/aws/credentials.js.map +1 -1
- package/lib/aws/dynamodb/client.d.ts +1 -1
- package/lib/aws/dynamodb/client.d.ts.map +1 -1
- package/lib/aws/dynamodb/index.d.ts +2 -1
- package/lib/aws/dynamodb/index.d.ts.map +1 -1
- package/lib/aws/dynamodb/index.js +1 -2
- package/lib/aws/dynamodb/index.js.map +1 -1
- package/lib/aws/dynamodb/secondary-index.d.ts +5 -4
- package/lib/aws/dynamodb/secondary-index.d.ts.map +1 -1
- package/lib/aws/dynamodb/table.d.ts +23 -20
- package/lib/aws/dynamodb/table.d.ts.map +1 -1
- package/lib/aws/dynamodb/table.get-item.d.ts +8 -6
- package/lib/aws/dynamodb/table.get-item.d.ts.map +1 -1
- package/lib/aws/dynamodb/table.get-item.js +4 -2
- package/lib/aws/dynamodb/table.get-item.js.map +1 -1
- package/lib/aws/dynamodb/table.js.map +1 -1
- package/lib/aws/dynamodb/table.provider.d.ts +3 -4
- package/lib/aws/dynamodb/table.provider.d.ts.map +1 -1
- package/lib/aws/dynamodb/table.provider.js +18 -29
- package/lib/aws/dynamodb/table.provider.js.map +1 -1
- package/lib/aws/ec2/client.d.ts +1 -1
- package/lib/aws/ec2/client.d.ts.map +1 -1
- package/lib/aws/ec2/index.d.ts +11 -0
- package/lib/aws/ec2/index.d.ts.map +1 -1
- package/lib/aws/ec2/index.js +11 -0
- package/lib/aws/ec2/index.js.map +1 -1
- package/lib/aws/ec2/internet-gateway.d.ts +65 -0
- package/lib/aws/ec2/internet-gateway.d.ts.map +1 -0
- package/lib/aws/ec2/internet-gateway.js +4 -0
- package/lib/aws/ec2/internet-gateway.js.map +1 -0
- package/lib/aws/ec2/internet-gateway.provider.d.ts +6 -0
- package/lib/aws/ec2/internet-gateway.provider.d.ts.map +1 -0
- package/lib/aws/ec2/internet-gateway.provider.js +193 -0
- package/lib/aws/ec2/internet-gateway.provider.js.map +1 -0
- package/lib/aws/ec2/route-table-association.d.ts +63 -0
- package/lib/aws/ec2/route-table-association.d.ts.map +1 -0
- package/lib/aws/ec2/route-table-association.js +4 -0
- package/lib/aws/ec2/route-table-association.js.map +1 -0
- package/lib/aws/ec2/route-table-association.provider.d.ts +4 -0
- package/lib/aws/ec2/route-table-association.provider.d.ts.map +1 -0
- package/lib/aws/ec2/route-table-association.provider.js +121 -0
- package/lib/aws/ec2/route-table-association.provider.js.map +1 -0
- package/lib/aws/ec2/route-table.d.ts +159 -0
- package/lib/aws/ec2/route-table.d.ts.map +1 -0
- package/lib/aws/ec2/route-table.js +4 -0
- package/lib/aws/ec2/route-table.js.map +1 -0
- package/lib/aws/ec2/route-table.provider.d.ts +6 -0
- package/lib/aws/ec2/route-table.provider.d.ts.map +1 -0
- package/lib/aws/ec2/route-table.provider.js +213 -0
- package/lib/aws/ec2/route-table.provider.js.map +1 -0
- package/lib/aws/ec2/route.d.ts +155 -0
- package/lib/aws/ec2/route.d.ts.map +1 -0
- package/lib/aws/ec2/route.js +3 -0
- package/lib/aws/ec2/route.js.map +1 -0
- package/lib/aws/ec2/route.provider.d.ts +4 -0
- package/lib/aws/ec2/route.provider.d.ts.map +1 -0
- package/lib/aws/ec2/route.provider.js +166 -0
- package/lib/aws/ec2/route.provider.js.map +1 -0
- package/lib/aws/ec2/subnet.d.ts +175 -0
- package/lib/aws/ec2/subnet.d.ts.map +1 -0
- package/lib/aws/ec2/subnet.js +4 -0
- package/lib/aws/ec2/subnet.js.map +1 -0
- package/lib/aws/ec2/subnet.provider.d.ts +4 -0
- package/lib/aws/ec2/subnet.provider.d.ts.map +1 -0
- package/lib/aws/ec2/subnet.provider.js +250 -0
- package/lib/aws/ec2/subnet.provider.js.map +1 -0
- package/lib/aws/ec2/vpc.d.ts +13 -8
- package/lib/aws/ec2/vpc.d.ts.map +1 -1
- package/lib/aws/ec2/vpc.js +1 -0
- package/lib/aws/ec2/vpc.js.map +1 -1
- package/lib/aws/ec2/vpc.provider.d.ts +1 -2
- package/lib/aws/ec2/vpc.provider.d.ts.map +1 -1
- package/lib/aws/ec2/vpc.provider.js +45 -37
- package/lib/aws/ec2/vpc.provider.js.map +1 -1
- package/lib/aws/index.d.ts +15 -19
- package/lib/aws/index.d.ts.map +1 -1
- package/lib/aws/index.js +8 -10
- package/lib/aws/index.js.map +1 -1
- package/lib/aws/lambda/consume.d.ts +10 -11
- package/lib/aws/lambda/consume.d.ts.map +1 -1
- package/lib/aws/lambda/consume.js +3 -3
- package/lib/aws/lambda/consume.js.map +1 -1
- package/lib/aws/lambda/function.d.ts +7 -7
- package/lib/aws/lambda/function.d.ts.map +1 -1
- package/lib/aws/lambda/function.handler.d.ts +1 -1
- package/lib/aws/lambda/function.handler.d.ts.map +1 -1
- package/lib/aws/lambda/function.handler.js.map +1 -1
- package/lib/aws/lambda/function.invoke.d.ts +6 -4
- package/lib/aws/lambda/function.invoke.d.ts.map +1 -1
- package/lib/aws/lambda/function.invoke.js +3 -1
- package/lib/aws/lambda/function.invoke.js.map +1 -1
- package/lib/aws/lambda/function.js +1 -1
- package/lib/aws/lambda/function.js.map +1 -1
- package/lib/aws/lambda/function.provider.d.ts +3 -2
- package/lib/aws/lambda/function.provider.d.ts.map +1 -1
- package/lib/aws/lambda/function.provider.js +28 -25
- package/lib/aws/lambda/function.provider.js.map +1 -1
- package/lib/aws/lambda/index.d.ts +1 -0
- package/lib/aws/lambda/index.d.ts.map +1 -1
- package/lib/aws/lambda/index.js +1 -0
- package/lib/aws/lambda/index.js.map +1 -1
- package/lib/aws/lambda/serve.d.ts +2 -4
- package/lib/aws/lambda/serve.d.ts.map +1 -1
- package/lib/aws/profile.d.ts +2 -2
- package/lib/aws/profile.d.ts.map +1 -1
- package/lib/aws/profile.js +1 -1
- package/lib/aws/profile.js.map +1 -1
- package/lib/aws/region.d.ts +14 -2
- package/lib/aws/region.d.ts.map +1 -1
- package/lib/aws/region.js +26 -1
- package/lib/aws/region.js.map +1 -1
- package/lib/aws/sqs/client.d.ts +1 -1
- package/lib/aws/sqs/client.d.ts.map +1 -1
- package/lib/aws/sqs/index.d.ts +1 -0
- package/lib/aws/sqs/index.d.ts.map +1 -1
- package/lib/aws/sqs/index.js +1 -0
- package/lib/aws/sqs/index.js.map +1 -1
- package/lib/aws/sqs/queue.consume.d.ts +1 -1
- package/lib/aws/sqs/queue.consume.d.ts.map +1 -1
- package/lib/aws/sqs/queue.consume.js +0 -1
- package/lib/aws/sqs/queue.consume.js.map +1 -1
- package/lib/aws/sqs/queue.d.ts +6 -4
- package/lib/aws/sqs/queue.d.ts.map +1 -1
- package/lib/aws/sqs/queue.event-source.d.ts +8 -6
- package/lib/aws/sqs/queue.event-source.d.ts.map +1 -1
- package/lib/aws/sqs/queue.event-source.js +26 -44
- package/lib/aws/sqs/queue.event-source.js.map +1 -1
- package/lib/aws/sqs/queue.js +1 -1
- package/lib/aws/sqs/queue.js.map +1 -1
- package/lib/aws/sqs/queue.provider.d.ts +2 -2
- package/lib/aws/sqs/queue.provider.d.ts.map +1 -1
- package/lib/aws/sqs/queue.provider.js +2 -1
- package/lib/aws/sqs/queue.provider.js.map +1 -1
- package/lib/aws/sqs/queue.send-message.d.ts +7 -5
- package/lib/aws/sqs/queue.send-message.d.ts.map +1 -1
- package/lib/aws/sqs/queue.send-message.js +4 -2
- package/lib/aws/sqs/queue.send-message.js.map +1 -1
- package/lib/binding.d.ts +12 -12
- package/lib/binding.d.ts.map +1 -1
- package/lib/binding.js.map +1 -1
- package/lib/cli/components/ApprovePlan.d.ts +2 -2
- package/lib/cli/components/ApprovePlan.d.ts.map +1 -1
- package/lib/cli/components/ApprovePlan.js.map +1 -1
- package/lib/cli/components/Plan.d.ts +2 -2
- package/lib/cli/components/Plan.d.ts.map +1 -1
- package/lib/cli/components/Plan.js.map +1 -1
- package/lib/cli/components/PlanProgress.d.ts +8 -4
- package/lib/cli/components/PlanProgress.d.ts.map +1 -1
- package/lib/cli/components/PlanProgress.js +11 -1
- package/lib/cli/components/PlanProgress.js.map +1 -1
- package/lib/cli/index.d.ts +384 -264
- package/lib/cli/index.d.ts.map +1 -1
- package/lib/cli/index.js +57 -65
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/ink-service.d.ts +4 -0
- package/lib/cli/ink-service.d.ts.map +1 -0
- package/lib/cli/ink-service.js +43 -0
- package/lib/cli/ink-service.js.map +1 -0
- package/lib/cli/service.d.ts +21 -0
- package/lib/cli/service.d.ts.map +1 -0
- package/lib/cli/service.js +5 -0
- package/lib/cli/service.js.map +1 -0
- package/lib/cloudflare/account.d.ts +10 -0
- package/lib/cloudflare/account.d.ts.map +1 -0
- package/lib/cloudflare/account.js +24 -0
- package/lib/cloudflare/account.js.map +1 -0
- package/lib/cloudflare/api.d.ts +7 -7
- package/lib/cloudflare/api.d.ts.map +1 -1
- package/lib/cloudflare/api.js +18 -17
- package/lib/cloudflare/api.js.map +1 -1
- package/lib/cloudflare/config.d.ts +9 -0
- package/lib/cloudflare/config.d.ts.map +1 -0
- package/lib/cloudflare/config.js +1 -0
- package/lib/cloudflare/config.js.map +1 -0
- package/lib/cloudflare/index.d.ts +3 -1
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +3 -0
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/kv/namespace.binding.d.ts +5 -3
- package/lib/cloudflare/kv/namespace.binding.d.ts.map +1 -1
- package/lib/cloudflare/kv/namespace.binding.js +1 -1
- package/lib/cloudflare/kv/namespace.binding.js.map +1 -1
- package/lib/cloudflare/kv/namespace.client.d.ts +1 -1
- package/lib/cloudflare/kv/namespace.d.ts +3 -2
- package/lib/cloudflare/kv/namespace.d.ts.map +1 -1
- package/lib/cloudflare/kv/namespace.js.map +1 -1
- package/lib/cloudflare/kv/namespace.provider.d.ts +3 -2
- package/lib/cloudflare/kv/namespace.provider.d.ts.map +1 -1
- package/lib/cloudflare/kv/namespace.provider.js +9 -7
- package/lib/cloudflare/kv/namespace.provider.js.map +1 -1
- package/lib/cloudflare/live.d.ts +5 -5
- package/lib/cloudflare/live.d.ts.map +1 -1
- package/lib/cloudflare/live.js +5 -8
- package/lib/cloudflare/live.js.map +1 -1
- package/lib/cloudflare/r2/bucket.binding.d.ts +5 -3
- package/lib/cloudflare/r2/bucket.binding.d.ts.map +1 -1
- package/lib/cloudflare/r2/bucket.binding.js +1 -1
- package/lib/cloudflare/r2/bucket.binding.js.map +1 -1
- package/lib/cloudflare/r2/bucket.d.ts +3 -2
- package/lib/cloudflare/r2/bucket.d.ts.map +1 -1
- package/lib/cloudflare/r2/bucket.js.map +1 -1
- package/lib/cloudflare/r2/bucket.provider.d.ts +3 -2
- package/lib/cloudflare/r2/bucket.provider.d.ts.map +1 -1
- package/lib/cloudflare/r2/bucket.provider.js +14 -8
- package/lib/cloudflare/r2/bucket.provider.js.map +1 -1
- package/lib/cloudflare/worker/assets.fetch.d.ts +3 -2
- package/lib/cloudflare/worker/assets.fetch.d.ts.map +1 -1
- package/lib/cloudflare/worker/assets.fetch.js +2 -1
- package/lib/cloudflare/worker/assets.fetch.js.map +1 -1
- package/lib/cloudflare/worker/assets.provider.d.ts +1 -1
- package/lib/cloudflare/worker/assets.provider.d.ts.map +1 -1
- package/lib/cloudflare/worker/index.d.ts +0 -1
- package/lib/cloudflare/worker/index.d.ts.map +1 -1
- package/lib/cloudflare/worker/worker.d.ts +5 -6
- package/lib/cloudflare/worker/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker/worker.handler.d.ts +1 -1
- package/lib/cloudflare/worker/worker.handler.d.ts.map +1 -1
- package/lib/cloudflare/worker/worker.handler.js.map +1 -1
- package/lib/cloudflare/worker/worker.js.map +1 -1
- package/lib/cloudflare/worker/worker.provider.d.ts +3 -2
- package/lib/cloudflare/worker/worker.provider.d.ts.map +1 -1
- package/lib/cloudflare/worker/worker.provider.js +12 -7
- package/lib/cloudflare/worker/worker.provider.js.map +1 -1
- package/lib/cloudflare/worker/worker.serve.d.ts +7 -7
- package/lib/cloudflare/worker/worker.serve.d.ts.map +1 -1
- package/lib/cloudflare/worker/worker.serve.js.map +1 -1
- package/lib/data.d.ts +3 -0
- package/lib/data.d.ts.map +1 -0
- package/lib/data.js +8 -0
- package/lib/data.js.map +1 -0
- package/lib/destroy.d.ts +1 -1
- package/lib/destroy.d.ts.map +1 -1
- package/lib/destroy.js +1 -4
- package/lib/destroy.js.map +1 -1
- package/lib/diff.d.ts +18 -0
- package/lib/diff.d.ts.map +1 -0
- package/lib/diff.js +22 -0
- package/lib/diff.js.map +1 -0
- package/lib/env.d.ts +5 -0
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +15 -29
- package/lib/env.js.map +1 -1
- package/lib/event.d.ts +1 -1
- package/lib/event.d.ts.map +1 -1
- package/lib/exports.d.ts +9 -0
- package/lib/exports.d.ts.map +1 -0
- package/lib/exports.js +13 -0
- package/lib/exports.js.map +1 -0
- package/lib/index.d.ts +10 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -5
- package/lib/index.js.map +1 -1
- package/lib/input.d.ts +32 -0
- package/lib/input.d.ts.map +1 -0
- package/lib/input.js +1 -0
- package/lib/input.js.map +1 -0
- package/lib/instance-id.d.ts +8 -0
- package/lib/instance-id.d.ts.map +1 -0
- package/lib/instance-id.js +12 -0
- package/lib/instance-id.js.map +1 -0
- package/lib/output.d.ts +145 -0
- package/lib/output.d.ts.map +1 -0
- package/lib/output.js +283 -0
- package/lib/output.js.map +1 -0
- package/lib/physical-name.d.ts +14 -1
- package/lib/physical-name.d.ts.map +1 -1
- package/lib/physical-name.js +41 -2
- package/lib/physical-name.js.map +1 -1
- package/lib/plan.d.ts +84 -58
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +504 -166
- package/lib/plan.js.map +1 -1
- package/lib/policy.d.ts +3 -4
- package/lib/policy.d.ts.map +1 -1
- package/lib/policy.js +0 -1
- package/lib/policy.js.map +1 -1
- package/lib/provider.d.ts +39 -24
- package/lib/provider.d.ts.map +1 -1
- package/lib/provider.js +9 -0
- package/lib/provider.js.map +1 -1
- package/lib/ref.d.ts +14 -0
- package/lib/ref.d.ts.map +1 -0
- package/lib/ref.js +21 -0
- package/lib/ref.js.map +1 -0
- package/lib/resource.d.ts +13 -8
- package/lib/resource.d.ts.map +1 -1
- package/lib/resource.js.map +1 -1
- package/lib/runtime.d.ts +7 -6
- package/lib/runtime.d.ts.map +1 -1
- package/lib/runtime.js.map +1 -1
- package/lib/service.d.ts +9 -6
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js.map +1 -1
- package/lib/stack.d.ts +60 -0
- package/lib/stack.d.ts.map +1 -0
- package/lib/stack.js +11 -0
- package/lib/stack.js.map +1 -0
- package/lib/stage.d.ts +39 -0
- package/lib/stage.d.ts.map +1 -0
- package/lib/stage.js +32 -0
- package/lib/stage.js.map +1 -0
- package/lib/state.d.ts +135 -17
- package/lib/state.d.ts.map +1 -1
- package/lib/state.js +34 -30
- package/lib/state.js.map +1 -1
- package/lib/tags.d.ts +15 -0
- package/lib/tags.d.ts.map +1 -1
- package/lib/tags.js +27 -0
- package/lib/tags.js.map +1 -1
- package/lib/test.d.ts +25 -4
- package/lib/test.d.ts.map +1 -1
- package/lib/test.js +54 -14
- package/lib/test.js.map +1 -1
- package/lib/todo.d.ts +3 -0
- package/lib/todo.d.ts.map +1 -0
- package/lib/todo.js +3 -0
- package/lib/todo.js.map +1 -0
- package/lib/tsconfig.test.tsbuildinfo +1 -1
- package/lib/type.d.ts +3 -0
- package/lib/type.d.ts.map +1 -1
- package/lib/unknown.d.ts +4 -0
- package/lib/unknown.d.ts.map +1 -0
- package/lib/unknown.js +4 -0
- package/lib/unknown.js.map +1 -0
- package/lib/user.d.ts +3 -0
- package/lib/user.d.ts.map +1 -0
- package/lib/user.js +3 -0
- package/lib/user.js.map +1 -0
- package/lib/util.d.ts +6 -0
- package/lib/util.d.ts.map +1 -0
- package/lib/util.js +9 -0
- package/lib/util.js.map +1 -0
- package/package.json +18 -12
- package/src/$.ts +17 -0
- package/src/app.ts +3 -32
- package/src/apply.ts +824 -452
- package/src/assert-never.ts +18 -0
- package/src/aws/account.ts +23 -3
- package/src/aws/client.ts +0 -1
- package/src/aws/config.ts +16 -0
- package/src/aws/credentials.ts +212 -177
- package/src/aws/dynamodb/index.ts +3 -3
- package/src/aws/dynamodb/table.get-item.ts +5 -9
- package/src/aws/dynamodb/table.provider.ts +36 -39
- package/src/aws/dynamodb/table.ts +29 -84
- package/src/aws/ec2/index.ts +12 -0
- package/src/aws/ec2/internet-gateway.provider.ts +316 -0
- package/src/aws/ec2/internet-gateway.ts +79 -0
- package/src/aws/ec2/route-table-association.provider.ts +214 -0
- package/src/aws/ec2/route-table-association.ts +82 -0
- package/src/aws/ec2/route-table.provider.ts +306 -0
- package/src/aws/ec2/route-table.ts +175 -0
- package/src/aws/ec2/route.provider.ts +213 -0
- package/src/aws/ec2/route.ts +192 -0
- package/src/aws/ec2/subnet.provider.ts +358 -0
- package/src/aws/ec2/subnet.ts +213 -0
- package/src/aws/ec2/vpc.provider.ts +58 -50
- package/src/aws/ec2/vpc.ts +21 -8
- package/src/aws/index.ts +49 -40
- package/src/aws/lambda/consume.ts +8 -7
- package/src/aws/lambda/function.handler.ts +1 -1
- package/src/aws/lambda/function.invoke.ts +6 -2
- package/src/aws/lambda/function.provider.ts +41 -32
- package/src/aws/lambda/function.ts +7 -4
- package/src/aws/lambda/index.ts +2 -0
- package/src/aws/profile.ts +1 -4
- package/src/aws/region.ts +42 -3
- package/src/aws/sqs/index.ts +2 -0
- package/src/aws/sqs/queue.consume.ts +1 -1
- package/src/aws/sqs/queue.event-source.ts +29 -55
- package/src/aws/sqs/queue.provider.ts +10 -2
- package/src/aws/sqs/queue.send-message.ts +5 -8
- package/src/aws/sqs/queue.ts +9 -4
- package/src/binding.ts +19 -19
- package/src/cli/components/ApprovePlan.tsx +2 -2
- package/src/cli/components/Plan.tsx +3 -2
- package/src/cli/components/PlanProgress.tsx +32 -14
- package/src/cli/index.ts +2 -6
- package/src/cli/ink-service.tsx +61 -0
- package/src/cli/service.ts +23 -0
- package/src/cloudflare/account.ts +37 -0
- package/src/cloudflare/api.ts +33 -29
- package/src/cloudflare/config.ts +7 -0
- package/src/cloudflare/index.ts +3 -1
- package/src/cloudflare/kv/namespace.binding.ts +3 -1
- package/src/cloudflare/kv/namespace.provider.ts +10 -8
- package/src/cloudflare/kv/namespace.ts +3 -2
- package/src/cloudflare/live.ts +11 -17
- package/src/cloudflare/r2/bucket.binding.ts +3 -1
- package/src/cloudflare/r2/bucket.provider.ts +16 -9
- package/src/cloudflare/r2/bucket.ts +8 -2
- package/src/cloudflare/worker/assets.fetch.ts +3 -1
- package/src/cloudflare/worker/assets.provider.ts +1 -1
- package/src/cloudflare/worker/index.ts +0 -2
- package/src/cloudflare/worker/worker.handler.ts +1 -1
- package/src/cloudflare/worker/worker.provider.ts +21 -14
- package/src/cloudflare/worker/worker.serve.ts +5 -2
- package/src/cloudflare/worker/worker.ts +4 -3
- package/src/data.ts +18 -0
- package/src/destroy.ts +1 -5
- package/src/diff.ts +48 -0
- package/src/env.ts +20 -32
- package/src/event.ts +6 -0
- package/src/exports.ts +21 -0
- package/src/index.ts +10 -5
- package/src/input.ts +81 -0
- package/src/instance-id.ts +16 -0
- package/src/output.ts +542 -0
- package/src/physical-name.ts +57 -2
- package/src/plan.ts +757 -278
- package/src/policy.ts +3 -5
- package/src/provider.ts +70 -31
- package/src/ref.ts +48 -0
- package/src/resource.ts +70 -10
- package/src/runtime.ts +15 -8
- package/src/service.ts +11 -7
- package/src/stack.ts +116 -0
- package/src/stage.ts +85 -0
- package/src/state.ts +269 -76
- package/src/tags.ts +31 -0
- package/src/test.ts +118 -17
- package/src/todo.ts +4 -0
- package/src/type.ts +4 -0
- package/src/unknown.ts +6 -0
- package/src/user.ts +4 -0
- package/src/util.ts +21 -0
- package/lib/approve.d.ts +0 -15
- package/lib/approve.d.ts.map +0 -1
- package/lib/approve.js +0 -7
- package/lib/approve.js.map +0 -1
- package/lib/cli/approve.d.ts +0 -4
- package/lib/cli/approve.d.ts.map +0 -1
- package/lib/cli/approve.js +0 -18
- package/lib/cli/approve.js.map +0 -1
- package/lib/cli/clack.d.ts +0 -14
- package/lib/cli/clack.d.ts.map +0 -1
- package/lib/cli/clack.js +0 -12
- package/lib/cli/clack.js.map +0 -1
- package/lib/cli/main.d.ts +0 -2
- package/lib/cli/main.d.ts.map +0 -1
- package/lib/cli/main.js +0 -1
- package/lib/cli/main.js.map +0 -1
- package/lib/cli/plan.d.ts +0 -13
- package/lib/cli/plan.d.ts.map +0 -1
- package/lib/cli/plan.js +0 -1
- package/lib/cli/plan.js.map +0 -1
- package/lib/cli/progress.d.ts +0 -7
- package/lib/cli/progress.d.ts.map +0 -1
- package/lib/cli/progress.js +0 -30
- package/lib/cli/progress.js.map +0 -1
- package/lib/cli/spinner.d.ts +0 -2
- package/lib/cli/spinner.d.ts.map +0 -1
- package/lib/cli/spinner.js +0 -13
- package/lib/cli/spinner.js.map +0 -1
- package/src/approve.ts +0 -13
- package/src/cli/approve.tsx +0 -30
- package/src/cli/clack.ts +0 -22
- package/src/cli/main.ts +0 -0
- package/src/cli/plan.ts +0 -16
- package/src/cli/progress.tsx +0 -46
- package/src/cli/spinner.ts +0 -14
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import * as Data from "effect/Data";
|
|
2
1
|
import * as Effect from "effect/Effect";
|
|
3
2
|
import * as Layer from "effect/Layer";
|
|
4
3
|
import * as Schedule from "effect/Schedule";
|
|
5
4
|
|
|
6
|
-
import { App, type Provider, type ProviderService } from "alchemy-effect";
|
|
7
5
|
import type { TimeToLiveSpecification } from "itty-aws/dynamodb";
|
|
6
|
+
import { App } from "../../app.ts";
|
|
7
|
+
import type { Input } from "../../input.ts";
|
|
8
|
+
import type { Provider, ProviderService } from "../../provider.ts";
|
|
8
9
|
import { createTagger, hasTags } from "../../tags.ts";
|
|
9
|
-
import { Account } from "../account.ts";
|
|
10
|
-
import { Region } from "../region.ts";
|
|
11
10
|
import { isScalarAttributeType, toAttributeType } from "./attribute-value.ts";
|
|
12
11
|
import { DynamoDBClient } from "./client.ts";
|
|
13
12
|
import {
|
|
14
13
|
Table,
|
|
15
14
|
type AnyTable,
|
|
15
|
+
type AttributesSchema,
|
|
16
16
|
type TableAttrs,
|
|
17
17
|
type TableProps,
|
|
18
18
|
} from "./table.ts";
|
|
@@ -20,23 +20,22 @@ import {
|
|
|
20
20
|
// we add an explict type to simplify the Layer type errors because the Table interface has a lot of type args
|
|
21
21
|
export const tableProvider = (): Layer.Layer<
|
|
22
22
|
Provider<AnyTable>,
|
|
23
|
-
|
|
24
|
-
App | DynamoDBClient
|
|
23
|
+
never,
|
|
24
|
+
App | DynamoDBClient
|
|
25
25
|
> =>
|
|
26
26
|
Table.provider.effect(
|
|
27
|
-
// @ts-expect-error
|
|
28
27
|
Effect.gen(function* () {
|
|
29
28
|
const dynamodb = yield* DynamoDBClient;
|
|
30
29
|
const app = yield* App;
|
|
31
|
-
const region = yield* Region;
|
|
32
|
-
const accountId = yield* Account;
|
|
33
30
|
|
|
34
|
-
const createTableName = (
|
|
35
|
-
|
|
31
|
+
const createTableName = (
|
|
32
|
+
id: string,
|
|
33
|
+
props: Input.ResolveProps<TableProps>,
|
|
34
|
+
) => props.tableName ?? `${app.name}-${id}-${app.stage}`;
|
|
36
35
|
|
|
37
36
|
const tagged = yield* createTagger();
|
|
38
37
|
|
|
39
|
-
const toKeySchema = (props: TableProps) => [
|
|
38
|
+
const toKeySchema = (props: Input.ResolveProps<TableProps>) => [
|
|
40
39
|
{
|
|
41
40
|
AttributeName: props.partitionKey as string,
|
|
42
41
|
KeyType: "HASH" as const,
|
|
@@ -51,8 +50,10 @@ export const tableProvider = (): Layer.Layer<
|
|
|
51
50
|
: []),
|
|
52
51
|
];
|
|
53
52
|
|
|
54
|
-
const toAttributeDefinitions = (
|
|
55
|
-
|
|
53
|
+
const toAttributeDefinitions = (
|
|
54
|
+
attributes: AttributesSchema<any, any, any>,
|
|
55
|
+
) =>
|
|
56
|
+
Object.entries(attributes)
|
|
56
57
|
.flatMap(([name, schema]) => {
|
|
57
58
|
const type = toAttributeType(schema);
|
|
58
59
|
if (isScalarAttributeType(type)) {
|
|
@@ -69,9 +70,11 @@ export const tableProvider = (): Layer.Layer<
|
|
|
69
70
|
})
|
|
70
71
|
.sort((a, b) => a.AttributeName.localeCompare(b.AttributeName));
|
|
71
72
|
|
|
72
|
-
const toAttributeDefinitionsMap = (
|
|
73
|
+
const toAttributeDefinitionsMap = (
|
|
74
|
+
attributes: AttributesSchema<any, any, any>,
|
|
75
|
+
) =>
|
|
73
76
|
Object.fromEntries(
|
|
74
|
-
toAttributeDefinitions(
|
|
77
|
+
toAttributeDefinitions(attributes).map(
|
|
75
78
|
(def) => [def.AttributeName, def.AttributeType] as const,
|
|
76
79
|
),
|
|
77
80
|
);
|
|
@@ -83,6 +86,7 @@ export const tableProvider = (): Layer.Layer<
|
|
|
83
86
|
Effect.flatMap((r) =>
|
|
84
87
|
dynamodb
|
|
85
88
|
.listTagsOfResource({
|
|
89
|
+
// oxlint-disable-next-line no-non-null-asserted-optional-chain
|
|
86
90
|
ResourceArn: r.Table?.TableArn!,
|
|
87
91
|
})
|
|
88
92
|
.pipe(
|
|
@@ -116,34 +120,27 @@ export const tableProvider = (): Layer.Layer<
|
|
|
116
120
|
);
|
|
117
121
|
|
|
118
122
|
return {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const newTableName = createTableName(id, news);
|
|
122
|
-
if (oldTableName !== newTableName) {
|
|
123
|
-
// TODO(sam): if the name is hard-coded, REPLACE is impossible - we need a suffix
|
|
124
|
-
return { action: "replace" } as const;
|
|
125
|
-
}
|
|
126
|
-
|
|
123
|
+
stables: ["tableName", "tableId", "tableArn"],
|
|
124
|
+
diff: Effect.fn(function* ({ news, olds }) {
|
|
127
125
|
if (
|
|
126
|
+
// TODO(sam): if the name is hard-coded, REPLACE is impossible - we need a suffix
|
|
127
|
+
news.tableName !== olds.tableName ||
|
|
128
128
|
olds.partitionKey !== news.partitionKey ||
|
|
129
129
|
olds.sortKey !== news.sortKey
|
|
130
130
|
) {
|
|
131
131
|
return { action: "replace" } as const;
|
|
132
132
|
}
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
for (const [name, type] of Object.entries(
|
|
133
|
+
const oldAttrs = toAttributeDefinitionsMap(olds.attributes);
|
|
134
|
+
const newAttrs = toAttributeDefinitionsMap(news.attributes);
|
|
135
|
+
for (const [name, type] of Object.entries(oldAttrs)) {
|
|
136
136
|
// CloudFormation requires that editing an existing AttributeDefinition is a replace
|
|
137
|
-
if (
|
|
137
|
+
if (newAttrs[name] !== type) {
|
|
138
138
|
return { action: "replace" } as const;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
|
|
142
141
|
// TODO(sam):
|
|
143
142
|
// Replacements:
|
|
144
143
|
// 1. if you change ImportSourceSpecification
|
|
145
|
-
|
|
146
|
-
return { action: "noop" } as const;
|
|
147
144
|
}),
|
|
148
145
|
|
|
149
146
|
create: Effect.fn(function* ({ id, news, session }) {
|
|
@@ -154,7 +151,7 @@ export const tableProvider = (): Layer.Layer<
|
|
|
154
151
|
TableName: tableName,
|
|
155
152
|
TableClass: news.tableClass,
|
|
156
153
|
KeySchema: toKeySchema(news),
|
|
157
|
-
AttributeDefinitions: toAttributeDefinitions(news),
|
|
154
|
+
AttributeDefinitions: toAttributeDefinitions(news.attributes),
|
|
158
155
|
BillingMode: news.billingMode ?? "PAY_PER_REQUEST",
|
|
159
156
|
SSESpecification: news.sseSpecification,
|
|
160
157
|
WarmThroughput: news.warmThroughput,
|
|
@@ -194,17 +191,19 @@ export const tableProvider = (): Layer.Layer<
|
|
|
194
191
|
return {
|
|
195
192
|
tableName,
|
|
196
193
|
tableId: response.TableId!,
|
|
197
|
-
tableArn: response.TableArn! as TableAttrs<
|
|
194
|
+
tableArn: response.TableArn! as TableAttrs<
|
|
195
|
+
Input.Resolve<TableProps>
|
|
196
|
+
>["tableArn"],
|
|
198
197
|
partitionKey: news.partitionKey,
|
|
199
198
|
sortKey: news.sortKey,
|
|
200
|
-
} satisfies TableAttrs<TableProps
|
|
199
|
+
} satisfies TableAttrs<Input.Resolve<TableProps>> as TableAttrs<any>;
|
|
201
200
|
}),
|
|
202
201
|
|
|
203
202
|
update: Effect.fn(function* ({ output, news, olds }) {
|
|
204
203
|
yield* dynamodb.updateTable({
|
|
205
204
|
TableName: output.tableName,
|
|
206
205
|
TableClass: news.tableClass,
|
|
207
|
-
AttributeDefinitions: toAttributeDefinitions(news),
|
|
206
|
+
AttributeDefinitions: toAttributeDefinitions(news.attributes),
|
|
208
207
|
BillingMode: news.billingMode ?? "PAY_PER_REQUEST",
|
|
209
208
|
SSESpecification: news.sseSpecification,
|
|
210
209
|
WarmThroughput: news.warmThroughput,
|
|
@@ -255,12 +254,10 @@ export const tableProvider = (): Layer.Layer<
|
|
|
255
254
|
e._tag === "ResourceInUseException" ||
|
|
256
255
|
e._tag === "InternalServerError" ||
|
|
257
256
|
e._tag === "TimeoutException",
|
|
258
|
-
schedule: Schedule.
|
|
257
|
+
schedule: Schedule.exponential(100),
|
|
259
258
|
}),
|
|
260
259
|
);
|
|
261
260
|
|
|
262
|
-
class TableStillExists extends Data.TaggedError("TableStillExists") {}
|
|
263
|
-
|
|
264
261
|
while (true) {
|
|
265
262
|
const table = yield* dynamodb
|
|
266
263
|
.describeTable({
|
|
@@ -275,6 +272,6 @@ export const tableProvider = (): Layer.Layer<
|
|
|
275
272
|
}
|
|
276
273
|
}
|
|
277
274
|
}),
|
|
278
|
-
} satisfies ProviderService<Table<string, TableProps
|
|
275
|
+
} satisfies ProviderService<Table<string, TableProps<unknown>>>;
|
|
279
276
|
}),
|
|
280
277
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as S from "effect/Schema";
|
|
2
|
+
import type { Input } from "../../input.ts";
|
|
2
3
|
import { Resource } from "../../resource.ts";
|
|
3
4
|
import type { type } from "../../type.ts";
|
|
4
5
|
import type { AccountID } from "../account.ts";
|
|
5
6
|
import type { RegionID } from "../region.ts";
|
|
6
|
-
|
|
7
7
|
import type * as DynamoDB from "itty-aws/dynamodb";
|
|
8
8
|
|
|
9
9
|
export interface TableProps<
|
|
10
|
-
Items = any,
|
|
10
|
+
Items extends any = any,
|
|
11
11
|
Attributes extends AttributesSchema<
|
|
12
12
|
Items,
|
|
13
13
|
PartitionKey,
|
|
@@ -15,42 +15,23 @@ export interface TableProps<
|
|
|
15
15
|
> = AttributesSchema<Items, keyof Items, keyof Items | undefined>,
|
|
16
16
|
PartitionKey extends keyof Items = keyof Items,
|
|
17
17
|
SortKey extends keyof Items | undefined = keyof Items | undefined,
|
|
18
|
-
BillingMode extends DynamoDB.BillingMode = DynamoDB.BillingMode,
|
|
19
|
-
SSESpecification extends DynamoDB.SSESpecification | undefined =
|
|
20
|
-
| DynamoDB.SSESpecification
|
|
21
|
-
| undefined,
|
|
22
|
-
TimeToLiveSpecification extends
|
|
23
|
-
| DynamoDB.TimeToLiveSpecification
|
|
24
|
-
| undefined = DynamoDB.TimeToLiveSpecification | undefined,
|
|
25
|
-
WarmThroughput extends DynamoDB.WarmThroughput | undefined =
|
|
26
|
-
| DynamoDB.WarmThroughput
|
|
27
|
-
| undefined,
|
|
28
|
-
OnDemandThroughput extends DynamoDB.OnDemandThroughput | undefined =
|
|
29
|
-
| DynamoDB.OnDemandThroughput
|
|
30
|
-
| undefined,
|
|
31
|
-
ProvisionedThroughput extends DynamoDB.ProvisionedThroughput | undefined =
|
|
32
|
-
| DynamoDB.ProvisionedThroughput
|
|
33
|
-
| undefined,
|
|
34
|
-
TableClass extends DynamoDB.TableClass | undefined =
|
|
35
|
-
| DynamoDB.TableClass
|
|
36
|
-
| undefined,
|
|
37
18
|
> {
|
|
38
19
|
items: type<Items>;
|
|
39
|
-
tableName?: string;
|
|
40
20
|
attributes: Attributes;
|
|
41
21
|
partitionKey: PartitionKey;
|
|
42
22
|
sortKey?: SortKey;
|
|
43
|
-
|
|
23
|
+
tableName?: string | undefined;
|
|
24
|
+
billingMode?: DynamoDB.BillingMode;
|
|
44
25
|
deletionProtectionEnabled?: boolean;
|
|
45
|
-
onDemandThroughput?: OnDemandThroughput;
|
|
46
|
-
provisionedThroughput?: ProvisionedThroughput;
|
|
47
|
-
sseSpecification?: SSESpecification;
|
|
48
|
-
timeToLiveSpecification?: TimeToLiveSpecification;
|
|
49
|
-
warmThroughput?: WarmThroughput;
|
|
50
|
-
tableClass?: TableClass;
|
|
26
|
+
onDemandThroughput?: DynamoDB.OnDemandThroughput;
|
|
27
|
+
provisionedThroughput?: DynamoDB.ProvisionedThroughput;
|
|
28
|
+
sseSpecification?: DynamoDB.SSESpecification;
|
|
29
|
+
timeToLiveSpecification?: DynamoDB.TimeToLiveSpecification;
|
|
30
|
+
warmThroughput?: DynamoDB.WarmThroughput;
|
|
31
|
+
tableClass?: DynamoDB.TableClass;
|
|
51
32
|
}
|
|
52
33
|
|
|
53
|
-
export interface TableAttrs<Props extends TableProps
|
|
34
|
+
export interface TableAttrs<Props extends Input.Resolve<TableProps>> {
|
|
54
35
|
tableName: Props["tableName"] extends string ? Props["tableName"] : string;
|
|
55
36
|
tableId: string;
|
|
56
37
|
tableArn: `arn:aws:dynamodb:${RegionID}:${AccountID}:table/${this["tableName"]}`;
|
|
@@ -86,71 +67,35 @@ export const Table = Resource<{
|
|
|
86
67
|
>,
|
|
87
68
|
const PartitionKey extends keyof Items,
|
|
88
69
|
const SortKey extends keyof Items | undefined = undefined,
|
|
89
|
-
const BillingMode extends DynamoDB.BillingMode = "PAY_PER_REQUEST",
|
|
90
|
-
const SSESpecification extends
|
|
91
|
-
| DynamoDB.SSESpecification
|
|
92
|
-
| undefined = undefined,
|
|
93
|
-
const TimeToLiveSpecification extends
|
|
94
|
-
| DynamoDB.TimeToLiveSpecification
|
|
95
|
-
| undefined = undefined,
|
|
96
|
-
const WarmThroughput extends
|
|
97
|
-
| DynamoDB.WarmThroughput
|
|
98
|
-
| undefined = undefined,
|
|
99
|
-
const OnDemandThroughput extends
|
|
100
|
-
| DynamoDB.OnDemandThroughput
|
|
101
|
-
| undefined = undefined,
|
|
102
|
-
const ProvisionedThroughput extends
|
|
103
|
-
| DynamoDB.ProvisionedThroughput
|
|
104
|
-
| undefined = undefined,
|
|
105
|
-
const TableClass extends DynamoDB.TableClass | undefined = undefined,
|
|
106
70
|
>(
|
|
107
71
|
id: ID,
|
|
108
|
-
props: TableProps<
|
|
109
|
-
|
|
110
|
-
Attributes,
|
|
111
|
-
PartitionKey,
|
|
112
|
-
SortKey,
|
|
113
|
-
BillingMode,
|
|
114
|
-
SSESpecification,
|
|
115
|
-
TimeToLiveSpecification,
|
|
116
|
-
WarmThroughput,
|
|
117
|
-
OnDemandThroughput,
|
|
118
|
-
ProvisionedThroughput,
|
|
119
|
-
TableClass
|
|
120
|
-
>,
|
|
121
|
-
): Table<
|
|
122
|
-
ID,
|
|
123
|
-
TableProps<
|
|
124
|
-
Items,
|
|
125
|
-
Attributes,
|
|
126
|
-
PartitionKey,
|
|
127
|
-
SortKey,
|
|
128
|
-
BillingMode,
|
|
129
|
-
SSESpecification,
|
|
130
|
-
TimeToLiveSpecification,
|
|
131
|
-
WarmThroughput,
|
|
132
|
-
OnDemandThroughput,
|
|
133
|
-
ProvisionedThroughput,
|
|
134
|
-
TableClass
|
|
135
|
-
>
|
|
136
|
-
>;
|
|
72
|
+
props: TableProps<Items, Attributes, PartitionKey, SortKey>,
|
|
73
|
+
): Table<ID, TableProps<Items, Attributes, PartitionKey, SortKey>>;
|
|
137
74
|
}>("AWS.DynamoDB.Table");
|
|
138
75
|
|
|
139
76
|
export interface AnyTable extends Table<string, any> {}
|
|
140
77
|
|
|
141
78
|
export interface Table<
|
|
142
79
|
ID extends string = string,
|
|
143
|
-
Props extends TableProps = TableProps,
|
|
144
|
-
> extends Resource<
|
|
80
|
+
Props extends TableProps<any, any, any, any> = TableProps<any, any, any, any>,
|
|
81
|
+
> extends Resource<
|
|
82
|
+
"AWS.DynamoDB.Table",
|
|
83
|
+
ID,
|
|
84
|
+
Props,
|
|
85
|
+
TableAttrs<Input.Resolve<Props>>,
|
|
86
|
+
Table
|
|
87
|
+
> {}
|
|
145
88
|
|
|
146
89
|
export declare namespace Table {
|
|
147
90
|
export type PartitionKey<T extends Table> = T["props"]["partitionKey"];
|
|
148
91
|
export type SortKey<T extends Table> = T["props"]["sortKey"];
|
|
92
|
+
export type Items<T extends Table> = T["props"]["items"];
|
|
149
93
|
export type Key<T extends Table> = {
|
|
150
|
-
[K in PartitionKey<T>]: T["props"]["
|
|
151
|
-
} &
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
94
|
+
[K in PartitionKey<T>]: InstanceType<T["props"]["items"]>[K];
|
|
95
|
+
} & {
|
|
96
|
+
[K in Exclude<SortKey<T>, undefined>]: Exclude<
|
|
97
|
+
InstanceType<T["props"]["items"]>[K],
|
|
98
|
+
undefined
|
|
99
|
+
>;
|
|
100
|
+
};
|
|
156
101
|
}
|
package/src/aws/ec2/index.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
export * from "./client.ts";
|
|
2
|
+
export * from "./internet-gateway.provider.ts";
|
|
3
|
+
export * from "./internet-gateway.ts";
|
|
4
|
+
export * from "./route-table-association.provider.ts";
|
|
5
|
+
export * from "./route-table-association.ts";
|
|
6
|
+
export * from "./route-table.provider.ts";
|
|
7
|
+
export * from "./route-table.ts";
|
|
8
|
+
export * from "./route.provider.ts";
|
|
9
|
+
export * from "./route.ts";
|
|
10
|
+
export * from "./subnet.provider.ts";
|
|
11
|
+
export * from "./subnet.ts";
|
|
2
12
|
export * from "./vpc.provider.ts";
|
|
3
13
|
export * from "./vpc.ts";
|
|
14
|
+
|
|
15
|
+
import "../config.ts";
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Schedule from "effect/Schedule";
|
|
3
|
+
|
|
4
|
+
import type { EC2 } from "itty-aws/ec2";
|
|
5
|
+
|
|
6
|
+
import type { ScopedPlanStatusSession } from "../../cli/service.ts";
|
|
7
|
+
import type { ProviderService } from "../../provider.ts";
|
|
8
|
+
import { createTagger, createTagsList } from "../../tags.ts";
|
|
9
|
+
import { Account } from "../account.ts";
|
|
10
|
+
import { Region } from "../region.ts";
|
|
11
|
+
import { EC2Client } from "./client.ts";
|
|
12
|
+
import {
|
|
13
|
+
InternetGateway,
|
|
14
|
+
type InternetGatewayAttrs,
|
|
15
|
+
type InternetGatewayId,
|
|
16
|
+
type InternetGatewayProps,
|
|
17
|
+
} from "./internet-gateway.ts";
|
|
18
|
+
|
|
19
|
+
export const internetGatewayProvider = () =>
|
|
20
|
+
InternetGateway.provider.effect(
|
|
21
|
+
Effect.gen(function* () {
|
|
22
|
+
const ec2 = yield* EC2Client;
|
|
23
|
+
const region = yield* Region;
|
|
24
|
+
const accountId = yield* Account;
|
|
25
|
+
const tagged = yield* createTagger();
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
stables: ["internetGatewayId", "internetGatewayArn", "ownerId"],
|
|
29
|
+
diff: Effect.fn(function* ({ news, olds }) {
|
|
30
|
+
// VPC attachment change can be handled via attach/detach (update)
|
|
31
|
+
// No properties require replacement
|
|
32
|
+
}),
|
|
33
|
+
|
|
34
|
+
create: Effect.fn(function* ({ id, news, session }) {
|
|
35
|
+
// 1. Prepare tags
|
|
36
|
+
const alchemyTags = tagged(id);
|
|
37
|
+
const userTags = news.tags ?? {};
|
|
38
|
+
const allTags = { ...alchemyTags, ...userTags };
|
|
39
|
+
|
|
40
|
+
// 2. Call CreateInternetGateway
|
|
41
|
+
const createResult = yield* ec2.createInternetGateway({
|
|
42
|
+
TagSpecifications: [
|
|
43
|
+
{
|
|
44
|
+
ResourceType: "internet-gateway",
|
|
45
|
+
Tags: createTagsList(allTags),
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
DryRun: false,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const internetGatewayId = createResult.InternetGateway!
|
|
52
|
+
.InternetGatewayId! as InternetGatewayId;
|
|
53
|
+
yield* session.note(`Internet gateway created: ${internetGatewayId}`);
|
|
54
|
+
|
|
55
|
+
// 3. Attach to VPC if specified
|
|
56
|
+
if (news.vpcId) {
|
|
57
|
+
yield* ec2
|
|
58
|
+
.attachInternetGateway({
|
|
59
|
+
InternetGatewayId: internetGatewayId,
|
|
60
|
+
VpcId: news.vpcId,
|
|
61
|
+
})
|
|
62
|
+
.pipe(
|
|
63
|
+
Effect.retry({
|
|
64
|
+
// Retry if VPC is not yet available
|
|
65
|
+
while: (e) => e._tag === "InvalidVpcID.NotFound",
|
|
66
|
+
schedule: Schedule.exponential(100),
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
69
|
+
yield* session.note(`Attached to VPC: ${news.vpcId}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 4. Describe to get full details
|
|
73
|
+
const igw = yield* describeInternetGateway(
|
|
74
|
+
ec2,
|
|
75
|
+
internetGatewayId,
|
|
76
|
+
session,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// 5. Return attributes
|
|
80
|
+
return {
|
|
81
|
+
internetGatewayId,
|
|
82
|
+
internetGatewayArn:
|
|
83
|
+
`arn:aws:ec2:${region}:${accountId}:internet-gateway/${internetGatewayId}` as InternetGatewayAttrs<InternetGatewayProps>["internetGatewayArn"],
|
|
84
|
+
vpcId: news.vpcId,
|
|
85
|
+
ownerId: igw.OwnerId,
|
|
86
|
+
attachments: igw.Attachments?.map((a) => ({
|
|
87
|
+
state: a.State! as
|
|
88
|
+
| "attaching"
|
|
89
|
+
| "available"
|
|
90
|
+
| "detaching"
|
|
91
|
+
| "detached",
|
|
92
|
+
vpcId: a.VpcId!,
|
|
93
|
+
})),
|
|
94
|
+
} satisfies InternetGatewayAttrs<InternetGatewayProps>;
|
|
95
|
+
}),
|
|
96
|
+
|
|
97
|
+
update: Effect.fn(function* ({ news, olds, output, session }) {
|
|
98
|
+
const internetGatewayId = output.internetGatewayId;
|
|
99
|
+
|
|
100
|
+
// Handle VPC attachment changes
|
|
101
|
+
if (news.vpcId !== olds.vpcId) {
|
|
102
|
+
// Detach from old VPC if was attached
|
|
103
|
+
if (olds.vpcId) {
|
|
104
|
+
yield* ec2
|
|
105
|
+
.detachInternetGateway({
|
|
106
|
+
InternetGatewayId: internetGatewayId,
|
|
107
|
+
VpcId: olds.vpcId,
|
|
108
|
+
})
|
|
109
|
+
.pipe(
|
|
110
|
+
Effect.catchTag("Gateway.NotAttached", () => Effect.void),
|
|
111
|
+
);
|
|
112
|
+
yield* session.note(`Detached from VPC: ${olds.vpcId}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Attach to new VPC if specified
|
|
116
|
+
if (news.vpcId) {
|
|
117
|
+
yield* ec2
|
|
118
|
+
.attachInternetGateway({
|
|
119
|
+
InternetGatewayId: internetGatewayId,
|
|
120
|
+
VpcId: news.vpcId,
|
|
121
|
+
})
|
|
122
|
+
.pipe(
|
|
123
|
+
Effect.retry({
|
|
124
|
+
while: (e) => e._tag === "InvalidVpcID.NotFound",
|
|
125
|
+
schedule: Schedule.exponential(100),
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
128
|
+
yield* session.note(`Attached to VPC: ${news.vpcId}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Handle tag updates
|
|
133
|
+
if (
|
|
134
|
+
JSON.stringify(news.tags ?? {}) !== JSON.stringify(olds.tags ?? {})
|
|
135
|
+
) {
|
|
136
|
+
const alchemyTags = tagged(output.internetGatewayId);
|
|
137
|
+
const userTags = news.tags ?? {};
|
|
138
|
+
const allTags = { ...alchemyTags, ...userTags };
|
|
139
|
+
|
|
140
|
+
// Delete old tags that are no longer present
|
|
141
|
+
const oldTagKeys = Object.keys(olds.tags ?? {});
|
|
142
|
+
const newTagKeys = Object.keys(news.tags ?? {});
|
|
143
|
+
const tagsToDelete = oldTagKeys.filter(
|
|
144
|
+
(key) => !newTagKeys.includes(key),
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
if (tagsToDelete.length > 0) {
|
|
148
|
+
yield* ec2.deleteTags({
|
|
149
|
+
Resources: [internetGatewayId],
|
|
150
|
+
Tags: tagsToDelete.map((key) => ({ Key: key })),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Create/update tags
|
|
155
|
+
yield* ec2.createTags({
|
|
156
|
+
Resources: [internetGatewayId],
|
|
157
|
+
Tags: createTagsList(allTags),
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
yield* session.note("Updated tags");
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Re-describe to get current state
|
|
164
|
+
const igw = yield* describeInternetGateway(
|
|
165
|
+
ec2,
|
|
166
|
+
internetGatewayId,
|
|
167
|
+
session,
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
...output,
|
|
172
|
+
vpcId: news.vpcId,
|
|
173
|
+
attachments: igw.Attachments?.map((a) => ({
|
|
174
|
+
state: a.State! as
|
|
175
|
+
| "attaching"
|
|
176
|
+
| "available"
|
|
177
|
+
| "detaching"
|
|
178
|
+
| "detached",
|
|
179
|
+
vpcId: a.VpcId!,
|
|
180
|
+
})),
|
|
181
|
+
};
|
|
182
|
+
}),
|
|
183
|
+
|
|
184
|
+
delete: Effect.fn(function* ({ output, session }) {
|
|
185
|
+
const internetGatewayId = output.internetGatewayId;
|
|
186
|
+
|
|
187
|
+
yield* session.note(
|
|
188
|
+
`Deleting internet gateway: ${internetGatewayId}`,
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
// 1. Detach from all VPCs first
|
|
192
|
+
if (output.attachments && output.attachments.length > 0) {
|
|
193
|
+
for (const attachment of output.attachments) {
|
|
194
|
+
yield* ec2
|
|
195
|
+
.detachInternetGateway({
|
|
196
|
+
InternetGatewayId: internetGatewayId,
|
|
197
|
+
VpcId: attachment.vpcId,
|
|
198
|
+
})
|
|
199
|
+
.pipe(
|
|
200
|
+
Effect.tapError(Effect.logDebug),
|
|
201
|
+
Effect.catchTag("Gateway.NotAttached", () => Effect.void),
|
|
202
|
+
Effect.catchTag(
|
|
203
|
+
"InvalidInternetGatewayID.NotFound",
|
|
204
|
+
() => Effect.void,
|
|
205
|
+
),
|
|
206
|
+
);
|
|
207
|
+
yield* session.note(`Detached from VPC: ${attachment.vpcId}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 2. Delete the internet gateway
|
|
212
|
+
yield* ec2
|
|
213
|
+
.deleteInternetGateway({
|
|
214
|
+
InternetGatewayId: internetGatewayId,
|
|
215
|
+
DryRun: false,
|
|
216
|
+
})
|
|
217
|
+
.pipe(
|
|
218
|
+
Effect.tapError(Effect.logDebug),
|
|
219
|
+
Effect.catchTag(
|
|
220
|
+
"InvalidInternetGatewayID.NotFound",
|
|
221
|
+
() => Effect.void,
|
|
222
|
+
),
|
|
223
|
+
// Retry on dependency violations
|
|
224
|
+
Effect.retry({
|
|
225
|
+
while: (e) => {
|
|
226
|
+
return (
|
|
227
|
+
e._tag === "DependencyViolation" ||
|
|
228
|
+
(e._tag === "ValidationError" &&
|
|
229
|
+
e.message?.includes("DependencyViolation"))
|
|
230
|
+
);
|
|
231
|
+
},
|
|
232
|
+
schedule: Schedule.exponential(1000, 1.5).pipe(
|
|
233
|
+
Schedule.intersect(Schedule.recurs(10)),
|
|
234
|
+
Schedule.tapOutput(([, attempt]) =>
|
|
235
|
+
session.note(
|
|
236
|
+
`Waiting for dependencies to clear... (attempt ${attempt + 1})`,
|
|
237
|
+
),
|
|
238
|
+
),
|
|
239
|
+
),
|
|
240
|
+
}),
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
// 3. Wait for internet gateway to be fully deleted
|
|
244
|
+
yield* waitForInternetGatewayDeleted(ec2, internetGatewayId, session);
|
|
245
|
+
|
|
246
|
+
yield* session.note(
|
|
247
|
+
`Internet gateway ${internetGatewayId} deleted successfully`,
|
|
248
|
+
);
|
|
249
|
+
}),
|
|
250
|
+
} satisfies ProviderService<InternetGateway>;
|
|
251
|
+
}),
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Describe an internet gateway by ID
|
|
256
|
+
*/
|
|
257
|
+
const describeInternetGateway = (
|
|
258
|
+
ec2: EC2,
|
|
259
|
+
internetGatewayId: string,
|
|
260
|
+
_session?: ScopedPlanStatusSession,
|
|
261
|
+
) =>
|
|
262
|
+
Effect.gen(function* () {
|
|
263
|
+
const result = yield* ec2
|
|
264
|
+
.describeInternetGateways({ InternetGatewayIds: [internetGatewayId] })
|
|
265
|
+
.pipe(
|
|
266
|
+
Effect.catchTag("InvalidInternetGatewayID.NotFound", () =>
|
|
267
|
+
Effect.succeed({ InternetGateways: [] }),
|
|
268
|
+
),
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
const igw = result.InternetGateways?.[0];
|
|
272
|
+
if (!igw) {
|
|
273
|
+
return yield* Effect.fail(new Error("Internet gateway not found"));
|
|
274
|
+
}
|
|
275
|
+
return igw;
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Wait for internet gateway to be deleted
|
|
280
|
+
*/
|
|
281
|
+
const waitForInternetGatewayDeleted = (
|
|
282
|
+
ec2: EC2,
|
|
283
|
+
internetGatewayId: string,
|
|
284
|
+
session: ScopedPlanStatusSession,
|
|
285
|
+
) =>
|
|
286
|
+
Effect.gen(function* () {
|
|
287
|
+
yield* Effect.retry(
|
|
288
|
+
Effect.gen(function* () {
|
|
289
|
+
const result = yield* ec2
|
|
290
|
+
.describeInternetGateways({ InternetGatewayIds: [internetGatewayId] })
|
|
291
|
+
.pipe(
|
|
292
|
+
Effect.tapError(Effect.logDebug),
|
|
293
|
+
Effect.catchTag("InvalidInternetGatewayID.NotFound", () =>
|
|
294
|
+
Effect.succeed({ InternetGateways: [] }),
|
|
295
|
+
),
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
if (!result.InternetGateways || result.InternetGateways.length === 0) {
|
|
299
|
+
return; // Successfully deleted
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// Still exists, fail to trigger retry
|
|
303
|
+
return yield* Effect.fail(new Error("Internet gateway still exists"));
|
|
304
|
+
}),
|
|
305
|
+
{
|
|
306
|
+
schedule: Schedule.fixed(2000).pipe(
|
|
307
|
+
Schedule.intersect(Schedule.recurs(15)),
|
|
308
|
+
Schedule.tapOutput(([, attempt]) =>
|
|
309
|
+
session.note(
|
|
310
|
+
`Waiting for internet gateway deletion... (${(attempt + 1) * 2}s)`,
|
|
311
|
+
),
|
|
312
|
+
),
|
|
313
|
+
),
|
|
314
|
+
},
|
|
315
|
+
);
|
|
316
|
+
});
|