From 639c23f7753792333a0db24cdf7bea39f504d128 Mon Sep 17 00:00:00 2001 From: KONFeature Date: Fri, 26 Jul 2024 13:16:25 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Test=20erpc=20without=20ALB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iac/Erpc.ts | 35 +++-------- iac/Indexer.ts | 2 + package.json | 2 +- pnpm-lock.yaml | 158 +++++++++++++++++-------------------------------- sst.config.ts | 3 +- 5 files changed, 68 insertions(+), 132 deletions(-) diff --git a/iac/Erpc.ts b/iac/Erpc.ts index abd2245..b3f27d8 100644 --- a/iac/Erpc.ts +++ b/iac/Erpc.ts @@ -3,6 +3,7 @@ import { ContainerImage } from "aws-cdk-lib/aws-ecs"; import { Duration } from "aws-cdk-lib/core"; import { Service, type StackContext, use } from "sst/constructs"; import { ConfigStack } from "./Config"; +import { IndexerStack } from "./Indexer"; import { buildSecretsMap } from "./utils"; /** @@ -35,15 +36,13 @@ export function ErpcStack({ app, stack }: StackContext) { imageTag ); + // Get our indexer service + const indexerService = use(IndexerStack); + // The service itself const erpcService = new Service(stack, "ErpcService", { path: "packages/erpc", port: 4000, - // Domain mapping - customDomain: { - domainName: "erpc.frak.id", - hostedZone: "frak.id", - }, // Setup some capacity options scaling: { minContainers: 1, @@ -66,18 +65,10 @@ export function ErpcStack({ app, stack }: StackContext) { ERPC_LOG_LEVEL: "warn", }, cdk: { - applicationLoadBalancerTargetGroup: { - deregistrationDelay: Duration.seconds(60), - healthCheck: { - // todo: Should have a health path or something like that - path: "/", - port: "traffic-port", - interval: Duration.seconds(20), - healthyThresholdCount: 2, - unhealthyThresholdCount: 5, - healthyHttpCodes: "200-299", - }, - }, + vpc: indexerService.cdk?.vpc, + // Don't auto setup the ALB since we will be using the one from the indexer service + // todo: setup the ALB after the indexer service is deployed + applicationLoadBalancer: false, // Customise fargate service to enable circuit breaker (if the new deployment is failing) fargateService: { circuitBreaker: { @@ -95,16 +86,6 @@ export function ErpcStack({ app, stack }: StackContext) { containerName: "erpc", image: erpcImage, secrets: cdkSecretsMap, - /*healthCheck: { - command: [ - "CMD-SHELL", - "curl -f http://localhost:4001 || exit 1", - ], - interval: Duration.seconds(30), - timeout: Duration.seconds(15), - retries: 3, - startPeriod: Duration.seconds(30), - },*/ }, }, }); diff --git a/iac/Indexer.ts b/iac/Indexer.ts index b069e60..559a1d9 100644 --- a/iac/Indexer.ts +++ b/iac/Indexer.ts @@ -104,4 +104,6 @@ export function IndexerStack({ app, stack }: StackContext) { stack.addOutputs({ indexerServiceId: indexerService.id, }); + + return indexerService; } diff --git a/package.json b/package.json index b39b56b..be00cfe 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "devDependencies": { "@biomejs/biome": "1.8.3", - "@types/aws-lambda": "8.10.142", + "@types/aws-lambda": "8.10.138", "@types/node": "^20.14.12", "aws-cdk-lib": "2.142.1", "sst": "2.43.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2cc68fb..dcd8376 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,14 +12,14 @@ importers: specifier: 1.8.3 version: 1.8.3 '@types/aws-lambda': - specifier: 8.10.142 - version: 8.10.142 + specifier: 8.10.138 + version: 8.10.138 '@types/node': specifier: ^20.14.12 version: 20.14.12 aws-cdk-lib: specifier: 2.142.1 - version: 2.150.0(constructs@10.3.0) + version: 2.142.1(constructs@10.3.0) sst: specifier: 2.43.4 version: 2.43.4(@aws-sdk/client-sso-oidc@3.616.0(@aws-sdk/client-sts@3.616.0(aws-crt@1.21.3))(aws-crt@1.21.3))(aws-crt@1.21.3)(better-sqlite3@11.1.2)(pg@8.12.0) @@ -34,13 +34,13 @@ importers: version: 1.8.3 '@types/aws-lambda': specifier: 8.10.138 - version: 8.10.142 + version: 8.10.138 '@types/node': specifier: ^20.14.9 version: 20.14.12 aws-cdk-lib: specifier: 2.142.1 - version: 2.150.0(constructs@10.3.0) + version: 2.142.1(constructs@10.3.0) sst: specifier: 2.43.4 version: 2.43.4(@aws-sdk/client-sso-oidc@3.620.0(@aws-sdk/client-sts@3.620.0(aws-crt@1.21.3))(aws-crt@1.21.3))(aws-crt@1.21.3)(better-sqlite3@11.1.2)(pg@8.12.0) @@ -52,26 +52,26 @@ importers: dependencies: '@ponder/core': specifier: ^0.5.3 - version: 0.5.3(@aws-sdk/client-rds-data@3.620.0(aws-crt@1.21.3))(@opentelemetry/api@1.9.0)(@types/node@20.14.12)(hono@4.5.1)(typescript@5.5.4)(viem@2.18.2(typescript@5.5.4)(zod@3.23.8))(zod@3.23.8) + version: 0.5.3(@aws-sdk/client-rds-data@3.620.0(aws-crt@1.21.3))(@opentelemetry/api@1.9.0)(@types/node@20.14.12)(hono@4.5.1)(typescript@5.5.4)(viem@1.21.4(typescript@5.5.4)(zod@3.23.8))(zod@3.23.8) hono: specifier: ^4.5.1 version: 4.5.1 viem: specifier: ^1.21.4 - version: 2.18.2(typescript@5.5.4)(zod@3.23.8) + version: 1.21.4(typescript@5.5.4)(zod@3.23.8) devDependencies: '@biomejs/biome': specifier: 1.8.3 version: 1.8.3 '@types/aws-lambda': specifier: 8.10.138 - version: 8.10.142 + version: 8.10.138 '@types/node': specifier: ^20.14.9 version: 20.14.12 aws-cdk-lib: specifier: 2.142.1 - version: 2.150.0(constructs@10.3.0) + version: 2.142.1(constructs@10.3.0) sst: specifier: 2.43.4 version: 2.43.4(@aws-sdk/client-sso-oidc@3.620.0(@aws-sdk/client-sts@3.620.0(aws-crt@1.21.3))(aws-crt@1.21.3))(aws-crt@1.21.3)(better-sqlite3@11.1.2)(pg@8.12.0) @@ -1106,11 +1106,11 @@ packages: resolution: {integrity: sha512-9I2Zn6+NJLfaGoz9jN3lpwDgAYvfGeNYdbAIjJOqzs4Tpc+VU3Jqq4IofSUBKajiDS8k9fZIg18/z13mpk1bsA==} engines: {node: '>=8'} - '@noble/curves@1.4.0': - resolution: {integrity: sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg==} + '@noble/curves@1.2.0': + resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} - '@noble/hashes@1.4.0': - resolution: {integrity: sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==} + '@noble/hashes@1.3.2': + resolution: {integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==} engines: {node: '>= 16'} '@opentelemetry/api@1.9.0': @@ -1242,11 +1242,11 @@ packages: '@scure/base@1.1.7': resolution: {integrity: sha512-PPNYBslrLNNUQ/Yad37MHYsNQtK67EhWb6WtSvNLLPo7SdVZgkUjD6Dg+5On7zNwmskf8OX7I7Nx5oN+MIWE0g==} - '@scure/bip32@1.4.0': - resolution: {integrity: sha512-sVUpc0Vq3tXCkDGYVWGIZTRfnvu8LoTDaev7vbwh0omSvVORONr960MQWdKqJDCReIEmTj3PAr73O3aoxz7OPg==} + '@scure/bip32@1.3.2': + resolution: {integrity: sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA==} - '@scure/bip39@1.3.0': - resolution: {integrity: sha512-disdg7gHuTDZtY+ZdkmLpPCk7fxZSu3gBiEGuoC1XYxv9cGx3Z6cpTggCgW6odSOOIXCiDjuGejW+aJKCY/pIQ==} + '@scure/bip39@1.2.1': + resolution: {integrity: sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==} '@smithy/abort-controller@1.1.0': resolution: {integrity: sha512-5imgGUlZL4dW4YWdMYAKLmal9ny/tlenM81QZY7xYyb76z9Z/QOg7oM5Ak9HQl8QfFTlGVWwcMXl+54jroRgEQ==} @@ -1612,8 +1612,8 @@ packages: '@trpc/server@9.16.0': resolution: {integrity: sha512-IENsJs41ZR4oeFUJhsNNTSgEOtuRN0m9u7ec4u3eG/qOc7bIoo1nDoYtx4bl6OJJSQYEytG9tlcVz9G8OAaHbg==} - '@types/aws-lambda@8.10.142': - resolution: {integrity: sha512-wy2y/2hQKrS6myOS++koXg3N1Hg+LLyPjaggCFajczSHZPqBnOMuT2sdH3kiASrmdBYyM3pmjyz5SoWraRllCQ==} + '@types/aws-lambda@8.10.138': + resolution: {integrity: sha512-71EHMl70TPWIAsFuHd85NHq6S6T2OOjiisPTrH7RgcjzpJpPh4RQJv7PvVvIxc6PIp8CLV7F9B+TdjcAES5vcA==} '@types/estree@1.0.5': resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} @@ -1666,11 +1666,11 @@ packages: zod: optional: true - abitype@1.0.5: - resolution: {integrity: sha512-YzDhti7cjlfaBhHutMaboYB21Ha3rXR9QTkNJFzYC4kC8YclaiwPBBBJY8ejFdu2wnJeZCVZSMlQJ7fi8S6hsw==} + abitype@0.9.8: + resolution: {integrity: sha512-puLifILdm+8sjyss4S+fsUN09obiT1g2YW6CtcQF+QDzxR0euzgEB29MZujC6zMk2a6SVmtttq1fc6+YFA7WYQ==} peerDependencies: typescript: '>=5.0.4' - zod: ^3 >=3.22.0 + zod: ^3 >=3.19.1 peerDependenciesMeta: typescript: optional: true @@ -1804,24 +1804,6 @@ packages: - yaml - mime-types - aws-cdk-lib@2.150.0: - resolution: {integrity: sha512-A5dJ6iIAXlkSgUIKhhSd5slEjvDBiREv6/xw8CgrXU+puoFULu5bC0SOQARjTzcsAgAVtxdlaZ7qy7u9It7nHQ==} - engines: {node: '>= 14.15.0'} - peerDependencies: - constructs: ^10.0.0 - bundledDependencies: - - '@balena/dockerignore' - - case - - fs-extra - - ignore - - jsonschema - - minimatch - - punycode - - semver - - table - - yaml - - mime-types - aws-crt@1.21.3: resolution: {integrity: sha512-oaiP5zoPkXwbM9T3nwSgq6CBZWx0501iefLPg12FODniIgqGMyzbMXHYC+fxbCoP5SOQVmCwtAfbNuIG5bFENg==} @@ -2707,8 +2689,8 @@ packages: peerDependencies: ws: '*' - isows@1.0.4: - resolution: {integrity: sha512-hEzjY+x9u9hPmBom9IIAqdJCwNLax+xrPb51vEPpERoFlIxgmZcHzsT5jKG06nvInKOBGvReAVz80Umed5CczQ==} + isows@1.0.3: + resolution: {integrity: sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg==} peerDependencies: ws: '*' @@ -3616,8 +3598,8 @@ packages: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} - viem@2.18.2: - resolution: {integrity: sha512-kTji8L4wD7Yak9DicXOo7ksuipPvDUCkvJY6DXMCTvGEiJJPKwa4WydfKvzhOUFmT8A2uZTx2vL0n9/eb8S9Zw==} + viem@1.21.4: + resolution: {integrity: sha512-BNVYdSaUjeS2zKQgPs+49e5JKocfo60Ib2yiXOWBT6LuVxY1I/6fFX3waEtpXvL1Xn4qu+BVitVtMh9lyThyhQ==} peerDependencies: typescript: '>=5.0.4' peerDependenciesMeta: @@ -3672,9 +3654,6 @@ packages: resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} engines: {node: '>= 8'} - webauthn-p256@0.0.5: - resolution: {integrity: sha512-drMGNWKdaixZNobeORVIqq7k5DsRC9FnG201K2QjeOoQLmtSDaSsVZdkg6n5jUALJKcAG++zBPJXmv6hy0nWFg==} - webcrypto-core@1.8.0: resolution: {integrity: sha512-kR1UQNH8MD42CYuLzvibfakG5Ew5seG85dMMoAM/1LqvckxaF6pUiidLuraIu4V+YCIFabYecUZAW0TuxAoaqw==} @@ -3731,20 +3710,8 @@ packages: utf-8-validate: optional: true - ws@7.5.9: - resolution: {integrity: sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==} - engines: {node: '>=8.3.0'} - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - - ws@8.17.1: - resolution: {integrity: sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==} + ws@8.13.0: + resolution: {integrity: sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==} engines: {node: '>=10.0.0'} peerDependencies: bufferutil: ^4.0.1 @@ -6176,11 +6143,11 @@ snapshots: '@lukeed/ms@2.0.2': {} - '@noble/curves@1.4.0': + '@noble/curves@1.2.0': dependencies: - '@noble/hashes': 1.4.0 + '@noble/hashes': 1.3.2 - '@noble/hashes@1.4.0': {} + '@noble/hashes@1.3.2': {} '@opentelemetry/api@1.9.0': {} @@ -6205,7 +6172,7 @@ snapshots: '@pkgjs/parseargs@0.11.0': optional: true - '@ponder/core@0.5.3(@aws-sdk/client-rds-data@3.620.0(aws-crt@1.21.3))(@opentelemetry/api@1.9.0)(@types/node@20.14.12)(hono@4.5.1)(typescript@5.5.4)(viem@2.18.2(typescript@5.5.4)(zod@3.23.8))(zod@3.23.8)': + '@ponder/core@0.5.3(@aws-sdk/client-rds-data@3.620.0(aws-crt@1.21.3))(@opentelemetry/api@1.9.0)(@types/node@20.14.12)(hono@4.5.1)(typescript@5.5.4)(viem@1.21.4(typescript@5.5.4)(zod@3.23.8))(zod@3.23.8)': dependencies: '@babel/code-frame': 7.24.7 '@commander-js/extra-typings': 12.1.0(commander@12.1.0) @@ -6213,7 +6180,7 @@ snapshots: '@escape.tech/graphql-armor-max-depth': 2.3.0 '@escape.tech/graphql-armor-max-tokens': 2.4.0 '@hono/node-server': 1.12.0 - '@ponder/utils': 0.1.7(typescript@5.5.4)(viem@2.18.2(typescript@5.5.4)(zod@3.23.8)) + '@ponder/utils': 0.1.7(typescript@5.5.4)(viem@1.21.4(typescript@5.5.4)(zod@3.23.8)) abitype: 0.10.3(typescript@5.5.4)(zod@3.23.8) better-sqlite3: 11.1.2 commander: 12.1.0 @@ -6238,7 +6205,7 @@ snapshots: prom-client: 15.1.3 react: 18.3.1 stacktrace-parser: 0.1.10 - viem: 2.18.2(typescript@5.5.4)(zod@3.23.8) + viem: 1.21.4(typescript@5.5.4)(zod@3.23.8) vite: 5.3.4(@types/node@20.14.12) vite-node: 1.6.0(@types/node@20.14.12) vite-tsconfig-paths: 4.3.2(typescript@5.5.4)(vite@5.3.4(@types/node@20.14.12)) @@ -6283,9 +6250,9 @@ snapshots: - utf-8-validate - zod - '@ponder/utils@0.1.7(typescript@5.5.4)(viem@2.18.2(typescript@5.5.4)(zod@3.23.8))': + '@ponder/utils@0.1.7(typescript@5.5.4)(viem@1.21.4(typescript@5.5.4)(zod@3.23.8))': dependencies: - viem: 2.18.2(typescript@5.5.4)(zod@3.23.8) + viem: 1.21.4(typescript@5.5.4)(zod@3.23.8) optionalDependencies: typescript: 5.5.4 @@ -6343,15 +6310,15 @@ snapshots: '@scure/base@1.1.7': {} - '@scure/bip32@1.4.0': + '@scure/bip32@1.3.2': dependencies: - '@noble/curves': 1.4.0 - '@noble/hashes': 1.4.0 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 '@scure/base': 1.1.7 - '@scure/bip39@1.3.0': + '@scure/bip39@1.2.1': dependencies: - '@noble/hashes': 1.4.0 + '@noble/hashes': 1.3.2 '@scure/base': 1.1.7 '@smithy/abort-controller@1.1.0': @@ -6957,7 +6924,7 @@ snapshots: dependencies: tslib: 2.6.3 - '@types/aws-lambda@8.10.142': {} + '@types/aws-lambda@8.10.138': {} '@types/estree@1.0.5': {} @@ -7019,7 +6986,7 @@ snapshots: typescript: 5.5.4 zod: 3.23.8 - abitype@1.0.5(typescript@5.5.4)(zod@3.23.8): + abitype@0.9.8(typescript@5.5.4)(zod@3.23.8): optionalDependencies: typescript: 5.5.4 zod: 3.23.8 @@ -7150,13 +7117,6 @@ snapshots: '@aws-cdk/asset-node-proxy-agent-v6': 2.0.3 constructs: 10.3.0 - aws-cdk-lib@2.150.0(constructs@10.3.0): - dependencies: - '@aws-cdk/asset-awscli-v1': 2.2.202 - '@aws-cdk/asset-kubectl-v20': 2.1.2 - '@aws-cdk/asset-node-proxy-agent-v6': 2.0.3 - constructs: 10.3.0 - aws-crt@1.21.3: dependencies: '@aws-sdk/util-utf8-browser': 3.259.0 @@ -8071,9 +8031,9 @@ snapshots: dependencies: ws: 8.18.0 - isows@1.0.4(ws@8.17.1): + isows@1.0.3(ws@8.13.0): dependencies: - ws: 8.17.1 + ws: 8.13.0 jackspeak@3.4.3: dependencies: @@ -8254,7 +8214,7 @@ snapshots: readable-stream: 3.6.2 reinterval: 1.1.0 split2: 3.2.2 - ws: 7.5.9 + ws: 7.5.10 xtend: 4.0.2 transitivePeerDependencies: - bufferutil @@ -9124,17 +9084,16 @@ snapshots: vary@1.1.2: {} - viem@2.18.2(typescript@5.5.4)(zod@3.23.8): + viem@1.21.4(typescript@5.5.4)(zod@3.23.8): dependencies: '@adraffy/ens-normalize': 1.10.0 - '@noble/curves': 1.4.0 - '@noble/hashes': 1.4.0 - '@scure/bip32': 1.4.0 - '@scure/bip39': 1.3.0 - abitype: 1.0.5(typescript@5.5.4)(zod@3.23.8) - isows: 1.0.4(ws@8.17.1) - webauthn-p256: 0.0.5 - ws: 8.17.1 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@scure/bip32': 1.3.2 + '@scure/bip39': 1.2.1 + abitype: 0.9.8(typescript@5.5.4)(zod@3.23.8) + isows: 1.0.3(ws@8.13.0) + ws: 8.13.0 optionalDependencies: typescript: 5.5.4 transitivePeerDependencies: @@ -9185,11 +9144,6 @@ snapshots: web-streams-polyfill@3.3.3: {} - webauthn-p256@0.0.5: - dependencies: - '@noble/curves': 1.4.0 - '@noble/hashes': 1.4.0 - webcrypto-core@1.8.0: dependencies: '@peculiar/asn1-schema': 2.3.8 @@ -9250,9 +9204,7 @@ snapshots: ws@7.5.10: {} - ws@7.5.9: {} - - ws@8.17.1: {} + ws@8.13.0: {} ws@8.18.0: {} diff --git a/sst.config.ts b/sst.config.ts index 4655032..2a4806f 100644 --- a/sst.config.ts +++ b/sst.config.ts @@ -1,5 +1,6 @@ import type { SSTConfig } from "sst"; import { ConfigStack } from "./iac/Config"; +import { ErpcStack } from "./iac/Erpc"; import { IndexerStack } from "./iac/Indexer"; export default { @@ -28,7 +29,7 @@ export default { }); app.stack(ConfigStack); - // app.stack(ErpcStack); + app.stack(ErpcStack); app.stack(IndexerStack); }, } satisfies SSTConfig;