Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #103 from api3dao/switch-to-dist-usage
Browse files Browse the repository at this point in the history
Switch Serverless to pre-built files
  • Loading branch information
aquarat authored Jun 6, 2022
2 parents 56ec371 + 7c44d82 commit 52fa0b7
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 57 deletions.
31 changes: 28 additions & 3 deletions aws-lambda-deploy-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,34 @@

Export AWS credentials in your terminal or ensure your local aws installation is logged in.

Run:
**Build Airseeker:**

```shell
yarn build
```

### General Airseeker Deployment Notes

The deployed Airseeker function won't immediately start (due to the scheduler).

There are three main strategies for dealing with this:

1. If an Airseeker is already deployed, deploy the new Airseeker using a different service name in `serverless.yaml`, so
that both Airseekers can run concurrently. Wait for the new Airseeker to start. Once it does, ensure that you're
satisfied that it is functioning correctly (by referring to the target chains and/or CloudWatch logs). You may then
revert the name of the service stack to the old Airseeker and remove it or alternatively delete it using the AWS
CloudFormation console.
2. Deploy Airseeker using the default service name and start the new Airseeker immediately using the invoke commands
below.
3. Deploy Airseeker using the default service name and wait up to 14 minutes for the deployed Airseeker to start.

**Deploy Airseeker:**

```shell
yarn sls deploy --region us-east-1
```

The function won't immediately start (due to the scheduler). If you'd like to immediately start the function you can
invoke it directly using the below commands:
**Invoke Airseeker:** (Optional)

```shell
# Invoke the remote function - this will block until the Lambda times out, so we need to send it to the background and
Expand All @@ -33,5 +53,10 @@ to remove run:
yarn sls remove
```

### Caveats

Sometimes a stack fails to be removed automatically. In these cases navigate to "Cloud Formation" in the AWS console and
check the resources tab of the stack in question to see errors. Manually remove those resources.

In particular AWS will sometimes refuse to delete an associated S3 bucket. Empty the bucket and remove it, then
re-remove the CloudFormation stack.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@
"pm2": "^5.2.0",
"prettier": "^2.6.2",
"rimraf": "^3.0.2",
"serverless": "^3.17.0",
"serverless-plugin-typescript": "^2.1.2",
"serverless": "^3.18.1",
"ts-jest": "^27.1.4",
"ts-node": "^10.7.0",
"typescript": "^4.6.4"
Expand Down
10 changes: 6 additions & 4 deletions serverless.aws.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
service: airseeker

plugins:
- serverless-plugin-typescript

package:
patterns:
- ./config/airseeker.json
- '!terraform'
- '!src'
- '!.*'

provider:
name: aws
Expand All @@ -15,11 +15,13 @@ provider:
architecture: arm64
logRetentionInDays: 14
environment: ${file(load-secrets-env.js)}
deploymentMethod: direct

functions:
airseeker:
handler: src/serverless.handler
handler: dist/serverless.handler
maximumRetryAttempts: 0
maximumEventAge: 60
timeout: 900
memorySize: 512
events:
Expand Down
110 changes: 62 additions & 48 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1517,14 +1517,6 @@
"@types/qs" "*"
"@types/serve-static" "*"

"@types/glob@^7.1.1":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==
dependencies:
"@types/minimatch" "*"
"@types/node" "*"

"@types/graceful-fs@^4.1.2":
version "4.1.5"
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15"
Expand Down Expand Up @@ -1615,11 +1607,6 @@
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a"
integrity sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==

"@types/minimatch@*":
version "3.0.5"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40"
integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==

"@types/node@*", "@types/node@^17.0.31":
version "17.0.36"
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.36.tgz#c0d5f2fe76b47b63e0e0efc3d2049a9970d68794"
Expand Down Expand Up @@ -2123,7 +2110,22 @@ at-least-node@^1.0.0:
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==

aws-sdk@^2.1139.0, aws-sdk@^2.992.0:
aws-sdk@^2.1147.0:
version "2.1148.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1148.0.tgz#028211e724aee5118223eb5fa65495eaae4b5083"
integrity sha512-FUYAyveKmS5eqIiGQgrGVsLZwwtI+K6S6Gz8oJf56pgypZCo9dV+cXO4aaS+vN0+LSmGh6dSKc6G8h8FYASIJg==
dependencies:
buffer "4.9.2"
events "1.1.1"
ieee754 "1.1.13"
jmespath "0.16.0"
querystring "0.2.0"
sax "1.2.1"
url "0.10.3"
uuid "8.0.0"
xml2js "0.4.19"

aws-sdk@^2.992.0:
version "2.1141.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1141.0.tgz#c7b1227c1557c0d188e7af497cca2b292cee2d2a"
integrity sha512-AIZhWB51UEMcU7zKOrbCzCnHtXJTjmO+3PDIjwc5+8tT623Ud/vcrvSlxmqNxrgSnlXThLrxH9fTw/n/sxiXxg==
Expand Down Expand Up @@ -2664,6 +2666,19 @@ cli-progress-footer@^2.3.1:
timers-ext "^0.1.7"
type "^2.6.0"

cli-progress-footer@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/cli-progress-footer/-/cli-progress-footer-2.3.2.tgz#1c13ba3c3dd894ef366f4a4f0620b3067284154d"
integrity sha512-uzHGgkKdeA9Kr57eyH1W5HGiNShP8fV1ETq04HDNM1Un6ShXbHhwi/H8LNV9L1fQXKjEw0q5FUkEVNuZ+yZdSw==
dependencies:
cli-color "^2.0.2"
d "^1.0.1"
es5-ext "^0.10.61"
mute-stream "0.0.8"
process-utils "^4.0.0"
timers-ext "^0.1.7"
type "^2.6.0"

cli-spinners@^2.5.0:
version "2.6.1"
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-2.6.1.tgz#adc954ebe281c37a6319bfa401e6dd2488ffb70d"
Expand Down Expand Up @@ -3422,7 +3437,7 @@ es-to-primitive@^1.2.1:
is-date-object "^1.0.1"
is-symbol "^1.0.2"

es5-ext@^0.10.12, es5-ext@^0.10.35, es5-ext@^0.10.46, es5-ext@^0.10.47, es5-ext@^0.10.49, es5-ext@^0.10.50, es5-ext@^0.10.53, es5-ext@^0.10.59, es5-ext@~0.10.14, es5-ext@~0.10.2, es5-ext@~0.10.46:
es5-ext@^0.10.12, es5-ext@^0.10.35, es5-ext@^0.10.46, es5-ext@^0.10.47, es5-ext@^0.10.49, es5-ext@^0.10.50, es5-ext@^0.10.53, es5-ext@^0.10.59, es5-ext@^0.10.61, es5-ext@~0.10.14, es5-ext@~0.10.2, es5-ext@~0.10.46:
version "0.10.61"
resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.61.tgz#311de37949ef86b6b0dcea894d1ffedb909d3269"
integrity sha512-yFhIqQAzu2Ca2I4SE2Au3rxVfmohU9Y7wqGR+s7+H7krk26NXhIRAZDgqd6xqjCEFUomDEA3/Bo/7fKmIkW1kA==
Expand Down Expand Up @@ -3960,7 +3975,7 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==

fast-glob@^3.0.3, fast-glob@^3.2.7, fast-glob@^3.2.9:
fast-glob@^3.2.7, fast-glob@^3.2.9:
version "3.2.11"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9"
integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==
Expand Down Expand Up @@ -4477,20 +4492,6 @@ globalthis@^1.0.2:
dependencies:
define-properties "^1.1.3"

globby@^10.0.2:
version "10.0.2"
resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.2.tgz#277593e745acaa4646c3ab411289ec47a0392543"
integrity sha512-7dUi7RvCoT/xast/o/dLN53oqND4yk0nsHkhRgn9w65C4PofCLOoJ39iSOg+qVDdWQPIEj+eszMHQ+aLVwwQSg==
dependencies:
"@types/glob" "^7.1.1"
array-union "^2.1.0"
dir-glob "^3.0.1"
fast-glob "^3.0.3"
glob "^7.1.3"
ignore "^5.1.1"
merge2 "^1.2.3"
slash "^3.0.0"

globby@^11.1.0:
version "11.1.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
Expand Down Expand Up @@ -4542,6 +4543,23 @@ got@^11.8.3:
p-cancelable "^2.0.0"
responselike "^2.0.0"

got@^11.8.5:
version "11.8.5"
resolved "https://registry.yarnpkg.com/got/-/got-11.8.5.tgz#ce77d045136de56e8f024bebb82ea349bc730046"
integrity sha512-o0Je4NvQObAuZPHLFoRSkdG2lTgtcynqymzg2Vupdx6PorhaT5MCbIyXG6d4D94kk8ZG57QeosgdiqfJWhEhlQ==
dependencies:
"@sindresorhus/is" "^4.0.0"
"@szmarczak/http-timer" "^4.0.5"
"@types/cacheable-request" "^6.0.1"
"@types/responselike" "^1.0.0"
cacheable-lookup "^5.0.3"
cacheable-request "^7.0.2"
decompress-response "^6.0.0"
http2-wrapper "^1.0.0-beta.5.2"
lowercase-keys "^2.0.0"
p-cancelable "^2.0.0"
responselike "^2.0.0"

graceful-fs@^4.1.10, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0, graceful-fs@^4.2.10, graceful-fs@^4.2.9:
version "4.2.10"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c"
Expand Down Expand Up @@ -4774,7 +4792,7 @@ ieee754@^1.1.13, ieee754@^1.1.4, ieee754@^1.2.1:
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==

ignore@^5.1.1, ignore@^5.1.8, ignore@^5.2.0:
ignore@^5.1.8, ignore@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==
Expand Down Expand Up @@ -6161,7 +6179,7 @@ merge-stream@^2.0.0:
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==

merge2@^1.2.3, merge2@^1.3.0, merge2@^1.4.1:
merge2@^1.3.0, merge2@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
Expand Down Expand Up @@ -7473,33 +7491,24 @@ [email protected]:
parseurl "~1.3.3"
send "0.18.0"

serverless-plugin-typescript@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/serverless-plugin-typescript/-/serverless-plugin-typescript-2.1.2.tgz#a57bb7fcd0c3868f9b0d7e0d970c8916b5814683"
integrity sha512-OxfuixdHY9HfWwkuudvrg+5/GWTh0fkZfv1PYfvrh6K0hWOshlH8cKfahRJY6kMYNOV/JqC8//wNo0lT9DKDbQ==
dependencies:
fs-extra "^7.0.1"
globby "^10.0.2"
lodash "^4.17.21"

serverless@^3.17.0:
version "3.18.1"
resolved "https://registry.yarnpkg.com/serverless/-/serverless-3.18.1.tgz#b80619f035608ae7bbdf1f210dfceb05326722dc"
integrity sha512-cdUdG7RW/0A2sfTnXVwHAgHTOZ4nt45lbYddyR2rMDXST+6CGghPaK7i6c7pdV8UUuU2iS00y/R5TwtKFU9AOg==
serverless@^3.18.1:
version "3.19.0"
resolved "https://registry.yarnpkg.com/serverless/-/serverless-3.19.0.tgz#621bbe620e6b3fb48f6d6d68affc3d488993bf92"
integrity sha512-XqbZ+UhxLjnwnzOEMkecJd68C3P9g9fQGwhHkuQelni3hIjmLlzkVBx6wlxrIBRgAXE9RAllwZvCsi2jZ9h2Ww==
dependencies:
"@serverless/dashboard-plugin" "^6.2.2"
"@serverless/platform-client" "^4.3.2"
"@serverless/utils" "^6.6.0"
ajv "^8.11.0"
ajv-formats "^2.1.1"
archiver "^5.3.1"
aws-sdk "^2.1139.0"
aws-sdk "^2.1147.0"
bluebird "^3.7.2"
cachedir "^2.3.0"
chalk "^4.1.2"
child-process-ext "^2.1.1"
ci-info "^3.3.1"
cli-progress-footer "^2.3.1"
cli-progress-footer "^2.3.2"
d "^1.0.1"
dayjs "^1.11.2"
decompress "^4.2.1"
Expand All @@ -7512,7 +7521,7 @@ serverless@^3.17.0:
fs-extra "^9.1.0"
get-stdin "^8.0.0"
globby "^11.1.0"
got "^11.8.3"
got "^11.8.5"
graceful-fs "^4.2.10"
https-proxy-agent "^5.0.1"
is-docker "^2.2.1"
Expand Down Expand Up @@ -8329,6 +8338,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"
integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==

[email protected]:
version "8.0.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.0.0.tgz#bc6ccf91b5ff0ac07bbcdbf1c7c4e150db4dbb6c"
integrity sha512-jOXGuXZAWdsTH7eZLtyXMqUb9EcWMGZNbL9YcGBJl4MH4nrxHmZJhEHvyLFrkxo+28uLb/NYRcStH48fnD0Vzw==

uuid@^3.2.1:
version "3.4.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
Expand Down

0 comments on commit 52fa0b7

Please sign in to comment.