alchemy-effect 0.2.0 → 0.3.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 +55038 -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 +14 -74
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +62 -57
- 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 +17 -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 +3 -0
- package/lib/aws/ec2/index.d.ts.map +1 -1
- package/lib/aws/ec2/index.js +3 -0
- package/lib/aws/ec2/index.js.map +1 -1
- 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 +12 -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 +3 -4
- package/lib/aws/ec2/vpc.provider.d.ts.map +1 -1
- package/lib/aws/ec2/vpc.provider.js +11 -26
- package/lib/aws/ec2/vpc.provider.js.map +1 -1
- package/lib/aws/index.d.ts +16 -19
- package/lib/aws/index.d.ts.map +1 -1
- package/lib/aws/index.js +7 -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 +5 -4
- package/lib/aws/lambda/function.provider.d.ts.map +1 -1
- package/lib/aws/lambda/function.provider.js +16 -14
- 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 +4 -4
- package/lib/aws/sqs/queue.provider.d.ts.map +1 -1
- package/lib/aws/sqs/queue.provider.js +3 -3
- 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 +265 -224
- 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.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 +8 -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 +8 -7
- 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 +7 -6
- 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 +16 -0
- package/lib/diff.d.ts.map +1 -0
- package/lib/diff.js +9 -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/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/output.d.ts +143 -0
- package/lib/output.d.ts.map +1 -0
- package/lib/output.js +269 -0
- package/lib/output.js.map +1 -0
- package/lib/plan.d.ts +47 -28
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +257 -151
- 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 +14 -16
- package/lib/provider.d.ts.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 +11 -6
- 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 +51 -10
- package/lib/state.d.ts.map +1 -1
- package/lib/state.js +30 -29
- package/lib/state.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/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 +429 -441
- 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 +35 -39
- package/src/aws/dynamodb/table.ts +29 -84
- package/src/aws/ec2/index.ts +4 -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 +20 -36
- package/src/aws/ec2/vpc.ts +19 -8
- package/src/aws/index.ts +46 -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 +28 -21
- 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 +11 -4
- 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 +9 -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 +9 -8
- 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 +16 -13
- 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 +30 -0
- package/src/env.ts +20 -32
- package/src/exports.ts +21 -0
- package/src/index.ts +10 -5
- package/src/input.ts +81 -0
- package/src/output.ts +518 -0
- package/src/plan.ts +380 -192
- package/src/policy.ts +3 -5
- package/src/provider.ts +25 -23
- package/src/ref.ts +48 -0
- package/src/resource.ts +20 -6
- 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 +138 -60
- package/src/test.ts +117 -16
- 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
package/src/aws/ec2/vpc.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type * as EC2 from "itty-aws/ec2";
|
|
2
|
+
import type { Input } from "../../input.ts";
|
|
2
3
|
import { Resource } from "../../resource.ts";
|
|
3
4
|
import type { AccountID } from "../account.ts";
|
|
4
5
|
import type { RegionID } from "../region.ts";
|
|
@@ -13,7 +14,17 @@ export const Vpc = Resource<{
|
|
|
13
14
|
export interface Vpc<
|
|
14
15
|
ID extends string = string,
|
|
15
16
|
Props extends VpcProps = VpcProps,
|
|
16
|
-
> extends Resource<
|
|
17
|
+
> extends Resource<
|
|
18
|
+
"AWS.EC2.VPC",
|
|
19
|
+
ID,
|
|
20
|
+
Props,
|
|
21
|
+
VpcAttrs<Input.Resolve<Props>>,
|
|
22
|
+
Vpc
|
|
23
|
+
> {}
|
|
24
|
+
|
|
25
|
+
export type VpcId = `vpc-${string}`;
|
|
26
|
+
export const VpcId = <const S extends string>(value: S): S & VpcId =>
|
|
27
|
+
value as S & VpcId;
|
|
17
28
|
|
|
18
29
|
export interface VpcProps {
|
|
19
30
|
/**
|
|
@@ -26,7 +37,7 @@ export interface VpcProps {
|
|
|
26
37
|
/**
|
|
27
38
|
* The ID of an IPv4 IPAM pool you want to use for allocating this VPC's CIDR.
|
|
28
39
|
*/
|
|
29
|
-
ipv4IpamPoolId?: string
|
|
40
|
+
ipv4IpamPoolId?: Input<string>;
|
|
30
41
|
|
|
31
42
|
/**
|
|
32
43
|
* The netmask length of the IPv4 CIDR you want to allocate to this VPC from an IPAM pool.
|
|
@@ -36,7 +47,7 @@ export interface VpcProps {
|
|
|
36
47
|
/**
|
|
37
48
|
* The ID of an IPv6 IPAM pool which will be used to allocate this VPC an IPv6 CIDR.
|
|
38
49
|
*/
|
|
39
|
-
ipv6IpamPoolId?: string
|
|
50
|
+
ipv6IpamPoolId?: Input<string>;
|
|
40
51
|
|
|
41
52
|
/**
|
|
42
53
|
* The netmask length of the IPv6 CIDR you want to allocate to this VPC from an IPAM pool.
|
|
@@ -51,12 +62,12 @@ export interface VpcProps {
|
|
|
51
62
|
/**
|
|
52
63
|
* The ID of an IPv6 address pool from which to allocate the IPv6 CIDR block.
|
|
53
64
|
*/
|
|
54
|
-
ipv6Pool?: string
|
|
65
|
+
ipv6Pool?: Input<string>;
|
|
55
66
|
|
|
56
67
|
/**
|
|
57
68
|
* The Availability Zone or Local Zone Group name for the IPv6 CIDR block.
|
|
58
69
|
*/
|
|
59
|
-
ipv6CidrBlockNetworkBorderGroup?: string
|
|
70
|
+
ipv6CidrBlockNetworkBorderGroup?: Input<string>;
|
|
60
71
|
|
|
61
72
|
/**
|
|
62
73
|
* The tenancy options for instances launched into the VPC.
|
|
@@ -85,14 +96,14 @@ export interface VpcProps {
|
|
|
85
96
|
* Tags to assign to the VPC.
|
|
86
97
|
* These will be merged with alchemy auto-tags (alchemy::app, alchemy::stage, alchemy::id).
|
|
87
98
|
*/
|
|
88
|
-
tags?: Record<string, string
|
|
99
|
+
tags?: Record<string, Input<string>>;
|
|
89
100
|
}
|
|
90
101
|
|
|
91
|
-
export interface VpcAttrs<
|
|
102
|
+
export interface VpcAttrs<_Props extends VpcProps = VpcProps> {
|
|
92
103
|
/**
|
|
93
104
|
* The ID of the VPC.
|
|
94
105
|
*/
|
|
95
|
-
vpcId:
|
|
106
|
+
vpcId: VpcId;
|
|
96
107
|
|
|
97
108
|
/**
|
|
98
109
|
* The Amazon Resource Name (ARN) of the VPC.
|
package/src/aws/index.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import * as Layer from "effect/Layer";
|
|
2
|
+
|
|
3
|
+
// oxlint-disable-next-line no-unused-vars - needed or else provider types are transitively resolved through DynamoDB.Provider<..> lol
|
|
4
|
+
import type { Provider } from "../provider.ts";
|
|
5
|
+
|
|
2
6
|
import * as ESBuild from "../esbuild.ts";
|
|
3
7
|
import * as Account from "./account.ts";
|
|
4
8
|
import * as Credentials from "./credentials.ts";
|
|
@@ -10,45 +14,47 @@ import * as Region from "./region.ts";
|
|
|
10
14
|
import * as S3 from "./s3.ts";
|
|
11
15
|
import * as SQS from "./sqs/index.ts";
|
|
12
16
|
import * as STS from "./sts.ts";
|
|
13
|
-
// TODO(sam): should this be named?
|
|
14
|
-
export * from "./profile.ts";
|
|
15
17
|
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
export { loadProfile, loadSSOCredentials } from "./credentials.ts";
|
|
19
|
+
|
|
20
|
+
import "./config.ts";
|
|
21
|
+
|
|
22
|
+
export const resources = () =>
|
|
23
|
+
Layer.mergeAll(
|
|
24
|
+
DynamoDB.tableProvider(),
|
|
25
|
+
EC2.subnetProvider(),
|
|
26
|
+
EC2.vpcProvider(),
|
|
27
|
+
Lambda.functionProvider(),
|
|
28
|
+
SQS.queueProvider(),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export const bindings = () =>
|
|
32
|
+
Layer.mergeAll(
|
|
33
|
+
DynamoDB.getItemFromLambdaFunction(),
|
|
34
|
+
SQS.queueEventSourceProvider(),
|
|
35
|
+
SQS.sendMessageFromLambdaFunction(),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export const clients = () =>
|
|
39
|
+
Layer.mergeAll(
|
|
40
|
+
DynamoDB.client(),
|
|
41
|
+
EC2.client(),
|
|
42
|
+
IAM.client(),
|
|
19
43
|
Lambda.client(),
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
SQS.client(),
|
|
38
|
-
Lambda.client(),
|
|
39
|
-
DynamoDB.client(),
|
|
40
|
-
EC2.client(),
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
export const defaultProviders = providers.pipe(
|
|
44
|
-
Layer.provideMerge(bindings),
|
|
45
|
-
Layer.provideMerge(Account.fromIdentity()),
|
|
46
|
-
Layer.provideMerge(clients),
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
export const live = defaultProviders.pipe(
|
|
50
|
-
Layer.provide(Region.fromEnv()),
|
|
51
|
-
Layer.provide(Credentials.fromSSO()),
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
export default live;
|
|
44
|
+
S3.client(),
|
|
45
|
+
SQS.client(),
|
|
46
|
+
// STS.client(),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export const utils = () => Layer.mergeAll(ESBuild.layer());
|
|
50
|
+
|
|
51
|
+
export const providers = () =>
|
|
52
|
+
resources().pipe(
|
|
53
|
+
Layer.provideMerge(bindings()),
|
|
54
|
+
Layer.provideMerge(clients()),
|
|
55
|
+
Layer.provideMerge(utils()),
|
|
56
|
+
Layer.provideMerge(Account.fromStageConfig()),
|
|
57
|
+
Layer.provideMerge(STS.client()),
|
|
58
|
+
Layer.provideMerge(Region.fromStageConfig()),
|
|
59
|
+
Layer.provideMerge(Credentials.fromStageConfig()),
|
|
60
|
+
);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { From } from "alchemy-effect";
|
|
2
|
-
import { declare } from "alchemy-effect";
|
|
3
1
|
import type {
|
|
4
2
|
Context as LambdaContext,
|
|
5
3
|
SQSBatchResponse,
|
|
@@ -7,11 +5,14 @@ import type {
|
|
|
7
5
|
} from "aws-lambda";
|
|
8
6
|
import * as Effect from "effect/Effect";
|
|
9
7
|
import * as S from "effect/Schema";
|
|
10
|
-
import
|
|
8
|
+
import { declare, type From } from "../../policy.ts";
|
|
11
9
|
import * as Lambda from "./function.ts";
|
|
10
|
+
import type { Queue } from "../sqs/queue.ts";
|
|
11
|
+
import type { Consume, QueueEvent } from "../sqs/queue.consume.ts";
|
|
12
|
+
import { QueueEventSource } from "../sqs/queue.event-source.ts";
|
|
12
13
|
|
|
13
14
|
export const consume =
|
|
14
|
-
<Q extends
|
|
15
|
+
<Q extends Queue, ID extends string, Req>(
|
|
15
16
|
id: ID,
|
|
16
17
|
{
|
|
17
18
|
queue,
|
|
@@ -19,7 +20,7 @@ export const consume =
|
|
|
19
20
|
}: {
|
|
20
21
|
queue: Q;
|
|
21
22
|
handle: (
|
|
22
|
-
event:
|
|
23
|
+
event: QueueEvent<Q["props"]["schema"]["Type"]>,
|
|
23
24
|
context: LambdaContext,
|
|
24
25
|
) => Effect.Effect<SQSBatchResponse | void, never, Req>;
|
|
25
26
|
},
|
|
@@ -30,7 +31,7 @@ export const consume =
|
|
|
30
31
|
}: Props) =>
|
|
31
32
|
Lambda.Function(id, {
|
|
32
33
|
handle: Effect.fn(function* (event: SQSEvent, context: LambdaContext) {
|
|
33
|
-
yield* declare<
|
|
34
|
+
yield* declare<Consume<From<Q>>>();
|
|
34
35
|
const records = yield* Effect.all(
|
|
35
36
|
event.Records.map(
|
|
36
37
|
Effect.fn(function* (record) {
|
|
@@ -60,4 +61,4 @@ export const consume =
|
|
|
60
61
|
],
|
|
61
62
|
} satisfies SQSBatchResponse;
|
|
62
63
|
}),
|
|
63
|
-
})({ ...props, bindings: bindings.and(
|
|
64
|
+
})({ ...props, bindings: bindings.and(QueueEventSource(queue)) });
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Binding } from "../../binding.ts";
|
|
4
|
+
import type { Capability } from "../../capability.ts";
|
|
5
|
+
import { toEnvKey } from "../../env.ts";
|
|
6
|
+
import { declare, type On } from "../../policy.ts";
|
|
7
|
+
import type { $ } from "../../$.ts";
|
|
4
8
|
import { LambdaClient } from "./client.ts";
|
|
5
9
|
import { Function } from "./function.ts";
|
|
6
10
|
|
|
@@ -8,7 +12,7 @@ export interface InvokeFunction<Resource = unknown>
|
|
|
8
12
|
extends Capability<"AWS.Lambda.InvokeFunction", Resource> {}
|
|
9
13
|
|
|
10
14
|
export const InvokeFunction = Binding<
|
|
11
|
-
<F extends Function>(func: F) => Binding<Function, InvokeFunction
|
|
15
|
+
<F extends Function>(func: F) => Binding<Function, InvokeFunction<On<F>>>
|
|
12
16
|
>(Function, "AWS.Lambda.InvokeFunction");
|
|
13
17
|
|
|
14
18
|
export const invoke = <F extends Function>(func: F, input: any) =>
|
|
@@ -5,29 +5,30 @@ import { FileSystem } from "@effect/platform";
|
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
6
6
|
import * as Schedule from "effect/Schedule";
|
|
7
7
|
|
|
8
|
-
import { App, DotAlchemy, type ProviderService } from "alchemy-effect";
|
|
9
|
-
|
|
10
8
|
import type {
|
|
11
9
|
CreateFunctionRequest,
|
|
12
10
|
CreateFunctionUrlConfigRequest,
|
|
13
11
|
UpdateFunctionUrlConfigRequest,
|
|
14
12
|
} from "itty-aws/lambda";
|
|
13
|
+
import { App } from "../../app.ts";
|
|
14
|
+
import { DotAlchemy } from "../../dot-alchemy.ts";
|
|
15
|
+
import type { ProviderService } from "../../provider.ts";
|
|
15
16
|
import { createTagger, createTagsList, hasTags } from "../../tags.ts";
|
|
16
|
-
import { Account } from "../account.ts";
|
|
17
17
|
import * as IAM from "../iam.ts";
|
|
18
|
-
import { Region } from "../region.ts";
|
|
19
18
|
import { zipCode } from "../zip.ts";
|
|
20
19
|
import { LambdaClient } from "./client.ts";
|
|
21
20
|
import { Function, type FunctionAttr, type FunctionProps } from "./function.ts";
|
|
21
|
+
import { Account } from "../account.ts";
|
|
22
|
+
import { Region } from "../region.ts";
|
|
22
23
|
|
|
23
24
|
export const functionProvider = () =>
|
|
24
25
|
Function.provider.effect(
|
|
25
26
|
Effect.gen(function* () {
|
|
26
27
|
const lambda = yield* LambdaClient;
|
|
27
28
|
const iam = yield* IAM.IAMClient;
|
|
29
|
+
const app = yield* App;
|
|
28
30
|
const accountId = yield* Account;
|
|
29
31
|
const region = yield* Region;
|
|
30
|
-
const app = yield* App;
|
|
31
32
|
const dotAlchemy = yield* DotAlchemy;
|
|
32
33
|
const fs = yield* FileSystem.FileSystem;
|
|
33
34
|
|
|
@@ -68,7 +69,7 @@ export const functionProvider = () =>
|
|
|
68
69
|
}) {
|
|
69
70
|
const env = bindings
|
|
70
71
|
.map((binding) => binding?.env)
|
|
71
|
-
.reduce((acc, env) => ({ ...acc, ...
|
|
72
|
+
.reduce((acc, env) => ({ ...acc, ...env }), {});
|
|
72
73
|
const policyStatements = bindings.flatMap(
|
|
73
74
|
(binding) =>
|
|
74
75
|
binding?.policyStatements?.map((stmt: IAM.PolicyStatement) => ({
|
|
@@ -156,7 +157,10 @@ export const functionProvider = () =>
|
|
|
156
157
|
|
|
157
158
|
const bundleCode = Effect.fn(function* (
|
|
158
159
|
id: string,
|
|
159
|
-
props:
|
|
160
|
+
props: {
|
|
161
|
+
main: string;
|
|
162
|
+
handler?: string;
|
|
163
|
+
},
|
|
160
164
|
) {
|
|
161
165
|
const handler = props.handler ?? "default";
|
|
162
166
|
let file = path.relative(process.cwd(), props.main);
|
|
@@ -215,7 +219,7 @@ export const functionProvider = () =>
|
|
|
215
219
|
functionName,
|
|
216
220
|
}: {
|
|
217
221
|
id: string;
|
|
218
|
-
news: FunctionProps
|
|
222
|
+
news: FunctionProps<any>;
|
|
219
223
|
roleArn: string;
|
|
220
224
|
code: string | Uint8Array<ArrayBufferLike>;
|
|
221
225
|
env: Record<string, string> | undefined;
|
|
@@ -264,17 +268,13 @@ export const functionProvider = () =>
|
|
|
264
268
|
})
|
|
265
269
|
.pipe(
|
|
266
270
|
Effect.retry({
|
|
267
|
-
while: (e) =>
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
e.
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
))
|
|
275
|
-
);
|
|
276
|
-
},
|
|
277
|
-
schedule: Schedule.fixed(100),
|
|
271
|
+
while: (e) =>
|
|
272
|
+
e._tag === "ResourceConflictException" ||
|
|
273
|
+
(e._tag === "InvalidParameterValueException" &&
|
|
274
|
+
e.message?.includes(
|
|
275
|
+
"The role defined for the function cannot be assumed by Lambda.",
|
|
276
|
+
)),
|
|
277
|
+
schedule: Schedule.exponential(100),
|
|
278
278
|
}),
|
|
279
279
|
);
|
|
280
280
|
yield* Effect.logDebug(`updated function code ${id}`);
|
|
@@ -461,12 +461,19 @@ export const functionProvider = () =>
|
|
|
461
461
|
olds.url !== news.url
|
|
462
462
|
) {
|
|
463
463
|
return { action: "replace" };
|
|
464
|
-
}
|
|
464
|
+
}
|
|
465
|
+
if (
|
|
466
|
+
output.code.hash !==
|
|
467
|
+
(yield* bundleCode(id, {
|
|
468
|
+
main: news.main,
|
|
469
|
+
handler: news.handler,
|
|
470
|
+
})).hash
|
|
471
|
+
) {
|
|
465
472
|
// code changed
|
|
466
473
|
return { action: "update" };
|
|
467
474
|
}
|
|
468
475
|
}),
|
|
469
|
-
precreate: Effect.fn(function* ({ id, news
|
|
476
|
+
precreate: Effect.fn(function* ({ id, news }) {
|
|
470
477
|
const { roleName, functionName, roleArn } = createPhysicalNames(id);
|
|
471
478
|
|
|
472
479
|
const role = yield* createRoleIfNotExists({ id, roleName });
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Capability } from "../../capability.ts";
|
|
2
|
+
import { Runtime, type RuntimeProps } from "../../runtime.ts";
|
|
2
3
|
import type * as IAM from "../iam.ts";
|
|
3
4
|
|
|
4
5
|
export type { Context } from "aws-lambda";
|
|
5
6
|
|
|
6
|
-
export interface FunctionProps<Req =
|
|
7
|
+
export interface FunctionProps<Req = unknown>
|
|
8
|
+
extends RuntimeProps<Function, Req> {
|
|
7
9
|
functionName?: string;
|
|
8
10
|
functionArn?: string;
|
|
9
11
|
main: string;
|
|
@@ -38,8 +40,9 @@ export interface FunctionBinding {
|
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
export interface Function extends Runtime<"AWS.Lambda.Function"> {
|
|
41
|
-
props: FunctionProps
|
|
42
|
-
attr: FunctionAttr<Extract<this["props"], FunctionProps
|
|
43
|
+
props: FunctionProps<any>;
|
|
44
|
+
attr: FunctionAttr<Extract<this["props"], FunctionProps<any>>>;
|
|
43
45
|
binding: FunctionBinding;
|
|
46
|
+
base: Function;
|
|
44
47
|
}
|
|
45
48
|
export const Function = Runtime("AWS.Lambda.Function")<Function>();
|
package/src/aws/lambda/index.ts
CHANGED
package/src/aws/profile.ts
CHANGED
package/src/aws/region.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import * as Config from "effect/Config";
|
|
2
|
+
import * as Option from "effect/Option";
|
|
1
3
|
import * as Context from "effect/Context";
|
|
2
4
|
import * as Data from "effect/Data";
|
|
3
5
|
import * as Effect from "effect/Effect";
|
|
4
6
|
import * as Layer from "effect/Layer";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
import { App } from "../app.ts";
|
|
8
|
+
import { loadProfile } from "./credentials.ts";
|
|
7
9
|
|
|
8
10
|
export class Region extends Context.Tag("AWS::Region")<Region, RegionID>() {}
|
|
9
11
|
|
|
12
|
+
export type RegionID = string;
|
|
13
|
+
|
|
10
14
|
export const of = (region: string) => Layer.succeed(Region, region);
|
|
11
15
|
|
|
12
16
|
export const fromEnvOrElse = (region: string) =>
|
|
@@ -19,11 +23,16 @@ export class EnvironmentVariableNotSet extends Data.TaggedError(
|
|
|
19
23
|
variable: string;
|
|
20
24
|
}> {}
|
|
21
25
|
|
|
26
|
+
export const AWS_REGION = Config.string("AWS_REGION");
|
|
27
|
+
|
|
28
|
+
const tryGetAWSRegion = () =>
|
|
29
|
+
Config.option(AWS_REGION).pipe(Effect.map(Option.getOrUndefined));
|
|
30
|
+
|
|
22
31
|
export const fromEnv = () =>
|
|
23
32
|
Layer.effect(
|
|
24
33
|
Region,
|
|
25
34
|
Effect.gen(function* () {
|
|
26
|
-
const region =
|
|
35
|
+
const region = yield* tryGetAWSRegion();
|
|
27
36
|
if (!region) {
|
|
28
37
|
return yield* Effect.fail(
|
|
29
38
|
new EnvironmentVariableNotSet({
|
|
@@ -35,3 +44,33 @@ export const fromEnv = () =>
|
|
|
35
44
|
return region;
|
|
36
45
|
}),
|
|
37
46
|
);
|
|
47
|
+
|
|
48
|
+
export class AWSStageConfigRegionMissing extends Data.TaggedError(
|
|
49
|
+
"AWSStageConfigMissing",
|
|
50
|
+
)<{
|
|
51
|
+
message: string;
|
|
52
|
+
stage: string;
|
|
53
|
+
}> {}
|
|
54
|
+
|
|
55
|
+
export const fromStageConfig = () =>
|
|
56
|
+
Layer.effect(
|
|
57
|
+
Region,
|
|
58
|
+
Effect.gen(function* () {
|
|
59
|
+
const app = yield* App;
|
|
60
|
+
if (app.config.aws?.region) {
|
|
61
|
+
return app.config.aws.region;
|
|
62
|
+
} else if (app.config.aws?.profile) {
|
|
63
|
+
const profile = yield* loadProfile(app.config.aws.profile);
|
|
64
|
+
if (profile.region) {
|
|
65
|
+
return profile.region;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const region = yield* tryGetAWSRegion();
|
|
69
|
+
if (region) {
|
|
70
|
+
return region;
|
|
71
|
+
}
|
|
72
|
+
return yield* Effect.dieMessage(
|
|
73
|
+
"No AWS region found in stage config, SSO profile, or environment variable",
|
|
74
|
+
);
|
|
75
|
+
}),
|
|
76
|
+
);
|
package/src/aws/sqs/index.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { Binding, type From } from "alchemy-effect";
|
|
2
1
|
import * as Effect from "effect/Effect";
|
|
3
2
|
import * as Schedule from "effect/Schedule";
|
|
4
3
|
import type * as Lambda from "itty-aws/lambda";
|
|
4
|
+
import { Binding } from "../../binding.ts";
|
|
5
|
+
import type { From } from "../../policy.ts";
|
|
5
6
|
import { createTagger, hasTags } from "../../tags.ts";
|
|
6
|
-
import { Account } from "../account.ts";
|
|
7
|
-
import {
|
|
8
|
-
Function,
|
|
9
|
-
LambdaClient,
|
|
10
|
-
type FunctionBinding,
|
|
11
|
-
} from "../lambda/index.ts";
|
|
12
|
-
import { Region } from "../region.ts";
|
|
13
7
|
import type { Consume } from "./queue.consume.ts";
|
|
14
8
|
import { Queue, type QueueAttrs, type QueueProps } from "./queue.ts";
|
|
9
|
+
import { Function, type FunctionBinding } from "../lambda/function.ts";
|
|
10
|
+
import { LambdaClient } from "../lambda/client.ts";
|
|
11
|
+
import { Account } from "../account.ts";
|
|
12
|
+
import { Region } from "../region.ts";
|
|
15
13
|
|
|
16
14
|
export interface QueueEventSourceProps {
|
|
17
15
|
batchSize?: number;
|
|
@@ -43,10 +41,9 @@ export const QueueEventSource = Binding<
|
|
|
43
41
|
|
|
44
42
|
export const queueEventSourceProvider = () =>
|
|
45
43
|
QueueEventSource.provider.effect(
|
|
46
|
-
// @ts-expect-error
|
|
47
44
|
Effect.gen(function* () {
|
|
48
|
-
const region = yield* Region;
|
|
49
45
|
const accountId = yield* Account;
|
|
46
|
+
const region = yield* Region;
|
|
50
47
|
const lambda = yield* LambdaClient;
|
|
51
48
|
const tagged = yield* createTagger();
|
|
52
49
|
|
|
@@ -113,45 +110,26 @@ export const queueEventSourceProvider = () =>
|
|
|
113
110
|
return undefined;
|
|
114
111
|
});
|
|
115
112
|
|
|
116
|
-
const createFunctionBinding = (queue: {
|
|
117
|
-
attr: { queueArn: string };
|
|
118
|
-
}) => ({
|
|
119
|
-
// we need the policies to be present before the event source mapping is created
|
|
120
|
-
policyStatements: [
|
|
121
|
-
{
|
|
122
|
-
Sid: "AWS.SQS.Consume",
|
|
123
|
-
Effect: "Allow" as const,
|
|
124
|
-
Action: [
|
|
125
|
-
"sqs:ReceiveMessage",
|
|
126
|
-
"sqs:DeleteMessage",
|
|
127
|
-
"sqs:ChangeMessageVisibility",
|
|
128
|
-
],
|
|
129
|
-
Resource: [queue.attr.queueArn],
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
});
|
|
133
|
-
|
|
134
113
|
return {
|
|
135
|
-
attach: ({ source: queue }) => {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
},
|
|
114
|
+
attach: ({ source: queue, attr }) => ({
|
|
115
|
+
// TODO(sam): bit of a broken model here - we can't know the UUID until post-attach
|
|
116
|
+
uuid: attr?.uuid ?? undefined!,
|
|
117
|
+
// we need the policies to be present before the event source mapping is created
|
|
118
|
+
policyStatements: [
|
|
119
|
+
{
|
|
120
|
+
Sid: "AWS.SQS.Consume",
|
|
121
|
+
Effect: "Allow" as const,
|
|
122
|
+
Action: [
|
|
123
|
+
"sqs:ReceiveMessage",
|
|
124
|
+
"sqs:DeleteMessage",
|
|
125
|
+
"sqs:ChangeMessageVisibility",
|
|
126
|
+
"sqs:GetQueueAttributes",
|
|
127
|
+
"sqs:GetQueueUrl",
|
|
128
|
+
],
|
|
129
|
+
Resource: [queue.attr.queueArn],
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
}),
|
|
155
133
|
postattach: Effect.fn(function* ({
|
|
156
134
|
source: queue,
|
|
157
135
|
props: { batchSize, maxBatchingWindow, scalingConfig } = {},
|
|
@@ -160,11 +138,6 @@ export const queueEventSourceProvider = () =>
|
|
|
160
138
|
attr: { functionName },
|
|
161
139
|
},
|
|
162
140
|
}) {
|
|
163
|
-
console.log(
|
|
164
|
-
"postattaching queue event source",
|
|
165
|
-
queue.id,
|
|
166
|
-
functionName,
|
|
167
|
-
);
|
|
168
141
|
const config:
|
|
169
142
|
| Lambda.CreateEventSourceMappingRequest
|
|
170
143
|
| Lambda.UpdateEventSourceMappingRequest = {
|
|
@@ -220,10 +193,11 @@ export const queueEventSourceProvider = () =>
|
|
|
220
193
|
),
|
|
221
194
|
schedule: Schedule.exponential(100),
|
|
222
195
|
}),
|
|
196
|
+
Effect.orDie,
|
|
223
197
|
);
|
|
224
198
|
return {
|
|
225
199
|
...attr,
|
|
226
|
-
uuid: eventSourceMapping.UUID
|
|
200
|
+
uuid: eventSourceMapping.UUID!,
|
|
227
201
|
};
|
|
228
202
|
}),
|
|
229
203
|
detach: Effect.fn(function* ({
|
|
@@ -235,7 +209,7 @@ export const queueEventSourceProvider = () =>
|
|
|
235
209
|
}) {
|
|
236
210
|
const uuid =
|
|
237
211
|
attr?.uuid ??
|
|
238
|
-
(yield* findEventSourceMapping(queue, functionName))?.UUID
|
|
212
|
+
(yield* findEventSourceMapping(queue, functionName))?.UUID;
|
|
239
213
|
if (uuid) {
|
|
240
214
|
// we found (or were aware of) the event source mapping, so we can delete it
|
|
241
215
|
yield* (
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as Schedule from "effect/Schedule";
|
|
3
3
|
|
|
4
|
-
import { App
|
|
5
|
-
import {
|
|
6
|
-
import { Region } from "../region.ts";
|
|
4
|
+
import { App } from "../../app.ts";
|
|
5
|
+
import type { ProviderService } from "../../provider.ts";
|
|
7
6
|
import { SQSClient } from "./client.ts";
|
|
8
7
|
import { Queue, type QueueProps } from "./queue.ts";
|
|
8
|
+
import { Region } from "../region.ts";
|
|
9
|
+
import { Account } from "../account.ts";
|
|
9
10
|
|
|
10
11
|
export const queueProvider = () =>
|
|
11
12
|
Queue.provider.effect(
|
|
@@ -14,7 +15,13 @@ export const queueProvider = () =>
|
|
|
14
15
|
const app = yield* App;
|
|
15
16
|
const region = yield* Region;
|
|
16
17
|
const accountId = yield* Account;
|
|
17
|
-
const createQueueName = (
|
|
18
|
+
const createQueueName = (
|
|
19
|
+
id: string,
|
|
20
|
+
props: {
|
|
21
|
+
queueName?: string | undefined;
|
|
22
|
+
fifo?: boolean;
|
|
23
|
+
},
|
|
24
|
+
) =>
|
|
18
25
|
props.queueName ??
|
|
19
26
|
`${app.name}-${id}-${app.stage}${props.fifo ? ".fifo" : ""}`;
|
|
20
27
|
const createAttributes = (props: QueueProps) => ({
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
type To,
|
|
9
|
-
} from "alchemy-effect";
|
|
10
|
-
import { Function } from "../lambda/index.ts";
|
|
3
|
+
import { Binding } from "../../binding.ts";
|
|
4
|
+
import type { Capability } from "../../capability.ts";
|
|
5
|
+
import { toEnvKey } from "../../env.ts";
|
|
6
|
+
import { declare, type To } from "../../policy.ts";
|
|
7
|
+
import { Function } from "../lambda/function.ts";
|
|
11
8
|
import { SQSClient } from "./client.ts";
|
|
12
9
|
import { Queue } from "./queue.ts";
|
|
13
10
|
|