diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 00000000000..f8185afb5ff --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,75 @@ +name: 🐛 Bug report +description: Create a bug report +body: + - type: checkboxes + attributes: + label: Are you certain it's a bug? + description: If you're uncertain, please report at https://github.com/serverless/serverless/discussions instead + options: + - label: Yes, it looks like a bug + required: true + - type: checkboxes + attributes: + label: Is the issue caused by a plugin? + description: If it comes from an external plugin, please report in the plugin issue tracker + options: + - label: It is not a plugin issue + required: true + - type: checkboxes + attributes: + label: Are you using the latest version? + description: Latest version can be checked at https://github.com/serverless/serverless/releases/latest + options: + - label: Yes, I'm using the latest version + required: true + - type: checkboxes + attributes: + label: Is there an existing issue for this? + description: Please search to see if an issue already exists + options: + - label: I have searched existing issues, it hasn't been reported yet + required: true + - type: textarea + attributes: + label: Issue description + validations: + required: true + - type: textarea + attributes: + label: Service configuration (serverless.yml) content + description: | + Provide COMPLETE content of serverless.yml, ensuring that: + • It consistently reproduces described issue + • It's as minimal as possible + • Ideally with no plugins involved (plugin related issues need to be reported at plugin repositories) + • Has sensitive parts masked out + + If not applicable, fill with "N/A" + render: yaml + validations: + required: true + - type: input + attributes: + label: Command name and used flags + description: | + Full command name with used flags (If not applicable, fill with "N/A") + placeholder: serverless [...flags] + validations: + required: true + - type: textarea + attributes: + label: Command output + description: | + COMPLETE command output. + + If not applicable, fill with "N/A" + render: shell + validations: + required: true + - type: textarea + attributes: + label: Environment information + description: '"serverless --version" output' + render: shell + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 0f2a901c510..00000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -name: '🐛 Bug report' -about: Create a bug report ---- - - - - - - - - - - - - - -⚠️⚠️ REPLACE WITH DESCRIPTION - - - -
-serverless.yml - -```yaml -# ⚠️⚠️ REPLACE THIS COMMENT WITH FULL serverless.yml CONTENT -``` - -
- - - -
-⚠️⚠️ REPLACE WITH FULL COMMAND NAME output - -``` -⚠️⚠️ REPLACE WITH FULL COMMAND OUTPUT -``` - -
- - - -Installed version - -``` -⚠️⚠️ REPLACE WITH `serverless --version` OUTPUT -``` diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 33cdd346c64..764ab7fadf8 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,5 @@ blank_issues_enabled: false contact_links: - name: Question - url: https://forum.serverless.com/ + url: https://github.com/serverless/serverless/discussions about: Please ask and answer questions here diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml new file mode 100644 index 00000000000..b2e7548b143 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -0,0 +1,21 @@ +name: 🎉 Feature request +description: Suggest an idea +body: + - type: checkboxes + attributes: + label: Is there an existing issue for this? + description: Please search to see if an issue already exists + options: + - label: I have searched existing issues, it hasn't been reported yet + required: true + - type: textarea + attributes: + label: Use case description + description: Describe the problem (use case) that needs to be solved + validations: + required: true + - type: textarea + attributes: + label: Proposed solution (optional) + description: | + e.g. propose how the configuration of the new feature could look diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 668060785ee..00000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -name: '🎉 Feature request' -about: Suggest an idea ---- - - - - - - - - - - - -### Use case description - -⚠️⚠️ REPLACE WITH DESCRIPTION - - - -### Proposed solution - -⚠️⚠️ REPLACE WITH PROPOSAL diff --git a/.github/prepare-canary.js b/.github/prepare-canary.js index f9bc05da9a6..d7ba7dc2780 100755 --- a/.github/prepare-canary.js +++ b/.github/prepare-canary.js @@ -10,7 +10,6 @@ const packageJsonPath = path.resolve(__dirname, '../package.json'); const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); packageJson.version = `${packageJson.version}-${process.env.GITHUB_SHA.slice(0, 8)}`; -packageJson.dependencies['@serverless/components'] = 'canary'; -packageJson.dependencies['@serverless/enterprise-plugin'] = 'canary'; +packageJson.dependencies['@serverless/dashboard-plugin'] = 'canary'; fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`); diff --git a/.github/workflows/integrate.yml b/.github/workflows/integrate.yml index f83c5dd3f30..dbd86bc9a63 100644 --- a/.github/workflows/integrate.yml +++ b/.github/workflows/integrate.yml @@ -9,33 +9,20 @@ on: env: SLS_IGNORE_WARNING: '*' FORCE_COLOR: 1 + SLS_SCHEMA_CACHE_BASE_DIR: '/home/runner' jobs: - linuxNode14: - name: '[Linux] Node.js 14: Publish canary, Unit & packaging tests ' + linuxNode16: + name: '[Linux] Node.js 16: Publish canary, Unit & packaging tests ' runs-on: ubuntu-latest steps: - - name: Resolve last validated commit hash (for `git diff` purposes) - env: - # See https://github.com/serverlessinc/setup-cicd-resources - GET_LAST_VALIDATED_COMMIT_HASH_URL: ${{ secrets.GET_LAST_VALIDATED_COMMIT_HASH_URL }} - PUT_LAST_VALIDATED_COMMIT_HASH_URL: ${{ secrets.PUT_LAST_VALIDATED_COMMIT_HASH_URL }} - run: | - curl -f "$GET_LAST_VALIDATED_COMMIT_HASH_URL" -o /home/runner/last-validated-commit-hash || : - curl -X PUT -H "User-Agent:" -H "Accept:" -H "Content-Type:" -d "$GITHUB_SHA" "$PUT_LAST_VALIDATED_COMMIT_HASH_URL" - - name: Store last validated commit hash (as it's to be used in other job) - uses: actions/upload-artifact@v2 - with: - name: last-validated-commit-hash - path: /home/runner/last-validated-commit-hash - - name: Checkout repository uses: actions/checkout@v2 - name: Install Node.js and npm uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 16.x registry-url: https://registry.npmjs.org - name: Publish canary @@ -55,8 +42,8 @@ jobs: path: | ~/.npm node_modules - key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} - restore-keys: npm-v14-${{ runner.os }}-${{ github.ref }}- + key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + restore-keys: npm-v16-${{ runner.os }}-${{ github.ref }}- - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' @@ -70,8 +57,8 @@ jobs: - name: Packaging tests run: npm run integration-test-run-package - windowsNode14: - name: '[Windows] Node.js v14: Unit tests' + windowsNode16: + name: '[Windows] Node.js v16: Unit tests' runs-on: windows-latest steps: - name: Checkout repository @@ -84,13 +71,13 @@ jobs: path: | ~/.npm node_modules - key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} - restore-keys: npm-v14-${{ runner.os }}-${{ github.ref }}- + key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + restore-keys: npm-v16-${{ runner.os }}-${{ github.ref }}- - name: Install Node.js and npm uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 16.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' @@ -100,8 +87,8 @@ jobs: - name: Unit tests run: npm test -- -b - linuxNode12: - name: '[Linux] Node.js 12: Isolated unit tests' + linuxNode14: + name: '[Linux] Node.js 14: Isolated unit tests' runs-on: ubuntu-latest steps: - name: Checkout repository @@ -114,13 +101,13 @@ jobs: path: | ~/.npm node_modules - key: npm-v12-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} - restore-keys: npm-v12-${{ runner.os }}-${{ github.ref }}- + key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + restore-keys: npm-v14-${{ runner.os }}-${{ github.ref }}- - name: Install Node.js and npm uses: actions/setup-node@v1 with: - node-version: 12.x + node-version: 14.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' @@ -132,8 +119,8 @@ jobs: # Workaround taken from https://github.com/actions/runner/issues/241#issuecomment-577360161 run: script -e -c "npm run test:isolated -- -b" - linuxNode10: - name: '[Linux] Node.js v10: Unit tests with coverage' + linuxNode12: + name: '[Linux] Node.js 12: Unit tests with coverage' runs-on: ubuntu-latest steps: - name: Checkout repository @@ -146,13 +133,13 @@ jobs: path: | ~/.npm node_modules - key: npm-v10-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} - restore-keys: npm-v10-${{ runner.os }}-${{ github.ref }}- + key: npm-v12-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + restore-keys: npm-v12-${{ runner.os }}-${{ github.ref }}- - name: Install Node.js and npm uses: actions/setup-node@v1 with: - node-version: 10.x + node-version: 12.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' @@ -164,21 +151,32 @@ jobs: # Workaround taken from https://github.com/actions/runner/issues/241#issuecomment-577360161 run: script -e -c "npm run coverage" - name: Push coverage - # TODO: Remove inline token, once support for GA is added on Codecov side - # See: https://github.com/codecov/codecov-node/issues/118 - env: - CODECOV_TOKEN: 3898f3e1-f317-453e-a3a9-0462390f93c5 run: npx codecov + linuxNode4: + name: '[Linux] Node.js v4: Node version validation test' + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Node.js and npm + uses: actions/setup-node@v1 + with: + node-version: 4.x + + - name: Node version validation test + run: ./bin/serverless.js 2>&1 | grep -q "does not support" + integrate: name: Integrate runs-on: ubuntu-latest - needs: [linuxNode14, windowsNode14, linuxNode12, linuxNode10] + needs: [linuxNode16, windowsNode16, linuxNode14, linuxNode12, linuxNode4] timeout-minutes: 30 # Default is 360 env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - SLS_AWS_REQUEST_MAX_RETRIES: 21 #Increase number of retries, do to observed "Rate exceeded" fails + SLS_AWS_REQUEST_MAX_RETRIES: 50 #Increase number of retries, due to observed "Rate exceeded" fails SERVERLESS_BINARY_PATH: ./dist/serverless-linux steps: - name: Checkout repository @@ -197,12 +195,18 @@ jobs: path: | ~/.npm node_modules - key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + + # Potentially needed for test/integration/curated-plugins-python.test.js + # (current GA runtime comes with Python 3.8 preinstalled, but that might be subject to changes) + - uses: actions/setup-python@v2 + with: + python-version: '3.8' - name: Install Node.js and npm uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 16.x # Note: No need to install dependencies as we have retrieved cached `node_modules` for very # same `package.json` as stored with previous job @@ -215,21 +219,11 @@ jobs: - name: Full integration tests against standalone binary run: npm run integration-test-run-all - - name: Resolve last validated commit hash (for `git diff` purposes) - uses: actions/download-artifact@v2 - continue-on-error: true - with: - name: last-validated-commit-hash - path: /home/runner - name: Tag if new version run: | - LAST_VALIDATED_COMMIT_HASH=`cat /home/runner/last-validated-commit-hash` || : - if [ -n "$LAST_VALIDATED_COMMIT_HASH" ]; + NEW_VERSION=`git diff -U0 ${{ github.event.before }} package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || : + if [ -n "$NEW_VERSION" ]; then - NEW_VERSION=`git diff -U0 $LAST_VALIDATED_COMMIT_HASH package.json | grep '"version": "' | tail -n 1 | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"` || : - if [ -n "$NEW_VERSION" ]; - then - git tag v$NEW_VERSION - git push --tags - fi + git tag v$NEW_VERSION + git push --tags fi diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a070aafe4a5..ead46dddbdf 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,12 +21,12 @@ jobs: path: | ~/.npm node_modules - key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} - name: Install Node.js and npm uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 16.x registry-url: https://registry.npmjs.org - name: Install dependencies @@ -68,12 +68,12 @@ jobs: path: | ~/.npm node_modules - key: npm-v14-${{ runner.os }}-refs/heads/master-${{ hashFiles('package.json') }} + key: npm-v16-${{ runner.os }}-refs/heads/master-${{ hashFiles('package.json') }} - name: Install Node.js and npm uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 16.x registry-url: https://registry.npmjs.org # Normally we have a guarantee that deps are already there, still it may not be the case when: @@ -126,12 +126,12 @@ jobs: path: | ~/.npm node_modules - key: npm-v14-${{ runner.os }}-refs/heads/master-${{ hashFiles('package.json') }} + key: npm-v16-${{ runner.os }}-refs/heads/master-${{ hashFiles('package.json') }} - name: Install Node.js and npm uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 16.x registry-url: https://registry.npmjs.org # Note: No need to install dependencies as we have retrieved cached `node_modules` for very diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 0e1be5766a9..2436a52d437 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -9,10 +9,11 @@ on: env: SLS_IGNORE_WARNING: '*' FORCE_COLOR: 1 + SLS_SCHEMA_CACHE_BASE_DIR: '/home/runner' jobs: - linuxNode14: - name: '[Linux] Node.js 14: Lint, Formatting, Eventual Commitlint, Eventual Changelog, Unit & packaging tests' + linuxNode16: + name: '[Linux] Node.js 16: Lint, Formatting, Eventual Commitlint, Eventual Changelog, Unit & packaging tests' runs-on: ubuntu-latest steps: - name: Checkout repository @@ -36,15 +37,15 @@ jobs: path: | ~/.npm node_modules - key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} restore-keys: | - npm-v14-${{ runner.os }}-${{ github.ref }}- - npm-v14-${{ runner.os }}-refs/heads/master- + npm-v16-${{ runner.os }}-${{ github.ref }}- + npm-v16-${{ runner.os }}-refs/heads/master- - name: Install Node.js and npm uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 16.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' @@ -72,8 +73,8 @@ jobs: - name: Packaging tests run: npm run integration-test-run-package - windowsNode14: - name: '[Windows] Node.js v14: Unit tests' + windowsNode16: + name: '[Windows] Node.js v16: Unit tests' runs-on: windows-latest steps: - name: Checkout repository @@ -86,15 +87,15 @@ jobs: path: | ~/.npm node_modules - key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + key: npm-v16-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} restore-keys: | - npm-v14-${{ runner.os }}-${{ github.ref }}- - npm-v14-${{ runner.os }}-refs/heads/master- + npm-v16-${{ runner.os }}-${{ github.ref }}- + npm-v16-${{ runner.os }}-refs/heads/master- - name: Install Node.js and npm uses: actions/setup-node@v1 with: - node-version: 14.x + node-version: 16.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' @@ -104,8 +105,8 @@ jobs: - name: Unit tests run: npm test -- -b - linuxNode12: - name: '[Linux] Node.js 12: Isolated unit tests' + linuxNode14: + name: '[Linux] Node.js 14: Isolated unit tests' runs-on: ubuntu-latest steps: - name: Checkout repository @@ -118,15 +119,15 @@ jobs: path: | ~/.npm node_modules - key: npm-v12-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + key: npm-v14-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} restore-keys: | - npm-v12-${{ runner.os }}-${{ github.ref }}- - npm-v12-${{ runner.os }}-refs/heads/master- + npm-v14-${{ runner.os }}-${{ github.ref }}- + npm-v14-${{ runner.os }}-refs/heads/master- - name: Install Node.js and npm uses: actions/setup-node@v1 with: - node-version: 12.x + node-version: 14.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' @@ -138,8 +139,8 @@ jobs: # Workaround taken from https://github.com/actions/runner/issues/241#issuecomment-577360161 run: script -e -c "npm run test:isolated -- -b" - linuxNode10: - name: '[Linux] Node.js v10: Unit tests with coverage' + linuxNode12: + name: '[Linux] Node.js 12: Unit tests with coverage' runs-on: ubuntu-latest steps: - name: Checkout repository @@ -152,15 +153,15 @@ jobs: path: | ~/.npm node_modules - key: npm-v10-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + key: npm-v12-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} restore-keys: | - npm-v10-${{ runner.os }}-${{ github.ref }}- - npm-v10-${{ runner.os }}-refs/heads/master- + npm-v12-${{ runner.os }}-${{ github.ref }}- + npm-v12-${{ runner.os }}-refs/heads/master- - name: Install Node.js and npm uses: actions/setup-node@v1 with: - node-version: 10.x + node-version: 12.x - name: Install dependencies if: steps.cacheNpm.outputs.cache-hit != 'true' @@ -172,8 +173,19 @@ jobs: # Workaround taken from https://github.com/actions/runner/issues/241#issuecomment-577360161 run: script -e -c "npm run coverage" - name: Push coverage - # TODO: Remove inline token, once support for GA is added on Codecov side - # See: https://github.com/codecov/codecov-node/issues/118 - env: - CODECOV_TOKEN: 3898f3e1-f317-453e-a3a9-0462390f93c5 run: npx codecov + + linuxNode4: + name: '[Linux] Node.js v4: Node version validation test' + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Node.js and npm + uses: actions/setup-node@v1 + with: + node-version: 4.x + + - name: Node version validation test + run: ./bin/serverless.js 2>&1 | grep -q "does not support" diff --git a/.gitignore b/.gitignore index 3e71f2a2d15..3f2216472d0 100755 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /node_modules npm-debug.log /package-lock.json +/yarn.lock diff --git a/.prettierignore b/.prettierignore index 222fbdbebe5..9a695cf4754 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,6 +1,6 @@ /.nyc_output /coverage -/test/fixtures/cli/configSyntaxError/serverless.yml +/test/fixtures/cli/config-syntax-error/serverless.yml /test/unit/lib/configuration/variables/sources/fixture/invalid.json /test/unit/lib/configuration/variables/sources/fixture/invalid.yml !/test/fixtures/programmatic/locallyInstalledServerless/node_modules/** diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f02d391e7e..5067688aca4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,1197 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [3.0.1](https://github.com/serverless/serverless/compare/v3.0.0...v3.0.1) (2022-01-28) + +### Bug Fixes + +- Report more meaningful strict schema mode error ([#10574](https://github.com/serverless/serverless/pull/10574)) ([e98d699](https://github.com/serverless/serverless/commit/e98d699e7800780e7d56340d778116e1b3b5b005)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Maintenance Improvements + +- **CLI Onboarding:** Minor wording adjustments ([#10575](https://github.com/serverless/serverless/pull/10575)) ([772a9bb](https://github.com/serverless/serverless/commit/772a9bb86c4b9b4e65f5f834c39620359cfc7c7a)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Templates + +- Update dependencies of `aws-nodejs-typescript` to v3 ([#10582](https://github.com/serverless/serverless/pull/10582)) ([88ac3d0](https://github.com/serverless/serverless/commit/88ac3d0586b3ed98ee0c1b7c618cbca095ee85d3)) ([Paul Lessing](https://github.com/paullessing)) + +## [3.0.0](https://github.com/serverless/serverless/compare/v2.72.2...v3.0.0) (2022-01-27) + +We are excited to announce the release of Serverless Framework v3! + +This new major version brings **a cleaner and redesigned CLI experience** as well as a brand new feature: **stage parameters**. + +Read all about Serverless Framework v3 **[in the official blog post](https://www.serverless.com/blog/serverless-framework-v3-is-live)**. + + + +--- + +### ⚠ BREAKING CHANGES + +Read the [**complete v3 Upgrade Guide**](https://www.serverless.com/framework/docs/guides/upgrading-v3). + +- **Variables:** Old variables resolver is permanently removed. Any resolution error as approached with current resolver is assumed as final (there's no longer fallback to old resolver) +- **AWS Lambda:** + - Default lambda hashing algorithm was changed to `20201221` + - Runtimes `nodejs10.x`, `python2.7`, `ruby2.5` and `dotnetcore2.1` reached end of support on AWS and are no longer recognized in configuration. + - Default runtime has been changed from `nodejs12.x` to `nodejs14.x` + - Properties `service.awsKmsKeyArn` and `functions[].awsKmsKeyArn` are no longer supported. Use `provider.kmsKeyArn` and `functions[].kmsKeyArn` instead. +- **CLI:** + - CLI params put before command tokens are no longer recgonized (e.g. `sls -f deploy function` will no longer work). In all cases construct CLI args in `sls ` order + - Unrecognized CLI options will no longer be supported and will result in an error. + - `enableLocalInstallationFallback` configuration property is no longer supported. + - Remove `studio` command schema + - The `--verbose` CLI flag does no longer support `-v` alias + - Opt-in tab-tab autocompletion feature is removed due to performance and security issues +- **AWS API Gateway:** + - Enabling logs or tracing for imported API Gateway will now result in an error instead of warning + - For authorizers with `request` type and caching disabled (`resultTtlInSeconds: 0`), the `identitySource` will no longer be set to `method.request.header.Authorization` by default. + - Support for `usagePlan`, `resourcePolicy` and `apiKeys` on `provider` level is removed. Use `provider.apiGateway` level instead to set them. + - Support for `http.request.schema` has been removed and replaced with `http.request.schemas`. +- **AWS HTTP API:** Tags from `provider.tags` are applied by default to HTTP API Gateway. +- **AWS CloudFront:** Support for `MinTTL`, `MaxTTL`, `DefaultTTL` and `ForwardedValues` on `cloudfront.behavior` has been removed. +- **AWS EventBridge:** By default, EventBridge resources now will be deployed using native CloudFormation resources instead of Custom Resources. +- **AWS Alexa:** Support for simple `alexaSkill` event was removed and now `appId` is required for all `alexaSkill` events.- Serverless Components (`@serverless/components`) CLI is no longer integrated with Framework CLI. +- **Dashboard:** `tenant` configuration setting is no longer respected. Ensure to rely on `org` instead +- Serverless Components v1 (`@serverless/cli`) CLI is no longer integrated with Framework CLI. +- Custom nested configuration paths will no longer be supported and such usage will result in an error. +- Object notation is no longer supported for `service` property. Set name directly to `service`. +- When creating `Serverless` class instance programatically, both `options` and `commands` have to be passed via `config` to the constructor. +- Duplicate plugin definition in configuration will now result in an error instead of a warning. +- Using `--aws-s3-accelerate` flag will result in an error instead of deprecation when custom S3 bucket is used. +- Removed support for `provider.disableDefaultOutputExportNames` +- Node.js versions lower than 12 is no longer supported +- Lifecycle events marked as deprecated (in context of v1) are no longer evaluated + +### Features + +- **Variables:** Remove old variables resolver ([#10512](https://github.com/serverless/serverless/issues/10512)) ([9bf6c16](https://github.com/serverless/serverless/commit/9bf6c16cb787ae48092d90bd7613d86a1c8ca075)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Packaging:** Deprecate `package.include` and `package.exclude` ([#10348](https://github.com/serverless/serverless/issues/10348)) ([aa4f9e3](https://github.com/serverless/serverless/commit/aa4f9e344e313f1ca64fa7af9475e6b84be8fb56)) ([Mariusz Nowak](https://github.com/medikoo)) +- **CLI:** + - Unconditionally fallback when local installation found ([#10503](https://github.com/serverless/serverless/issues/10503)) ([137554c](https://github.com/serverless/serverless/commit/137554c9d35eb14bf3bba654673b99d343c0a7d1)) ([Mariusz Nowak](https://github.com/medikoo)) + - Simplify `logs` command output ([#10203](https://github.com/serverless/serverless/issues/10203)) ([d4124a3](https://github.com/serverless/serverless/commit/d4124a3ca6d3895289ef605d4dc6e5eb0cd2e3df)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Deprecate support for `deploy -f` alias ([#10346](https://github.com/serverless/serverless/issues/10346)) ([09c9ea3](https://github.com/serverless/serverless/commit/09c9ea3a38afc30c1c15d21c926b8d06dfd81356)) ([Mariusz Nowak](https://github.com/medikoo)) + - Deprecate missing options schema ([#10394](https://github.com/serverless/serverless/issues/10394)) ([0db9c49](https://github.com/serverless/serverless/commit/0db9c49e2d435499e2b836b948e815b4a8839521)) ([Mariusz Nowak](https://github.com/medikoo)) + - Deprecate recognition of `projectDir` configuration setting ([#10511](https://github.com/serverless/serverless/issues/10511)) ([00fcd83](https://github.com/serverless/serverless/commit/00fcd83f49703188f3ddb0317afaa88fbece4801)) ([Mariusz Nowak](https://github.com/medikoo)) + - Global `--debug` flag for debug logging ([#10197](https://github.com/serverless/serverless/issues/10197)) ([3b4f267](https://github.com/serverless/serverless/commit/3b4f2677f8d83fd76a47bfac781bf1b81bfec924)) ([Mariusz Nowak](https://github.com/medikoo)) + - Global `--verbose` flag for verbose logging ([#10197](https://github.com/serverless/serverless/issues/10197)) ([2eef264](https://github.com/serverless/serverless/commit/2eef264bdca3dc7ae270aa09b974f23546425344)) ([Mariusz Nowak](https://github.com/medikoo)) + - Register `-v` as global `--version` alias ([#10332](https://github.com/serverless/serverless/issues/10332)) ([211db81](https://github.com/serverless/serverless/commit/211db8149cad519174490fbb5d2f1f42f859aabb)) ([Mariusz Nowak](https://github.com/medikoo)) + - Remove `-v` alias for `--verbose` flag ([#10153](https://github.com/serverless/serverless/issues/10153)) ([03b77c0](https://github.com/serverless/serverless/commit/03b77c0d2392e74f7d5caf76b9c01675d6d14023)) ([Mariusz Nowak](https://github.com/medikoo)) + - Remove support for unrecognized cli options ([#10172](https://github.com/serverless/serverless/issues/10172)) ([7c2b2ea](https://github.com/serverless/serverless/commit/7c2b2ea6a84c62fcb5c8830c16437376002b2a10)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Simplify CLI args parsing to ` ` format ([#10332](https://github.com/serverless/serverless/issues/10332)) ([8229812](https://github.com/serverless/serverless/commit/8229812e2bd1632efd9c8c8999236f6dff79171c)) ([Mariusz Nowak](https://github.com/medikoo)) + - Support `serverless-tencent` CLI ([#10305](https://github.com/serverless/serverless/issues/10305)) ([10db944](https://github.com/serverless/serverless/commit/10db944c73357014db20062c70ec666898505b0f)) ([Mariusz Nowak](https://github.com/medikoo)) + - Do not decorate `cli.log` logs ([#10196](https://github.com/serverless/serverless/issues/10196)) ([1f44227](https://github.com/serverless/serverless/commit/1f44227b7feeef30ca2ac151fffe219bde6a8461)) ([Mariusz Nowak](https://github.com/medikoo)) + - Expose `sls doctor` command ([#10504](https://github.com/serverless/serverless/issues/10504)) ([d403bfc](https://github.com/serverless/serverless/commit/d403bfc94eb13490d6a91d3352ae3b163caa6d68)) ([Mariusz Nowak](https://github.com/medikoo)) + - Remove `studio` command schema ([#10191](https://github.com/serverless/serverless/issues/10191)) ([7f1e7e1](https://github.com/serverless/serverless/commit/7f1e7e163b65580a2f0d10cad012f69605f32b18)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Remove tab autocomplete feature ([#10414](https://github.com/serverless/serverless/issues/10414)) ([519ce0c](https://github.com/serverless/serverless/commit/519ce0cb77056ba53be92968958f55f8eb7cc779)) ([Mariusz Nowak](https://github.com/medikoo)) +- **AWS Lambda:** + - Change default hashing algorithm ([#10255](https://github.com/serverless/serverless/issues/10255)) ([775debf](https://github.com/serverless/serverless/commit/775debf5e2bebc51346853d99d109776f9856cee)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Change default runtime to `nodejs14.x` ([#10147](https://github.com/serverless/serverless/issues/10147)) ([30e99fb](https://github.com/serverless/serverless/commit/30e99fb92f72a968f8e1c9a1ddbbb81a6bdc5288)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Remove support for `awsKmsKeyArn` setting ([#10146](https://github.com/serverless/serverless/issues/10146)) ([6de37bf](https://github.com/serverless/serverless/commit/6de37bf3b7c14ca84a32188b377e92dfbd0af473)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Remove support for obsolete runtimes ([#10207](https://github.com/serverless/serverless/issues/10207)) ([23cfb63](https://github.com/serverless/serverless/commit/23cfb63cdf400ac4601f13571554f4d8fc5ee0cd)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS HTTP API:** + - Always apply `provider.tags` to HTTP API ([#10141](https://github.com/serverless/serverless/issues/10141)) ([b34d549](https://github.com/serverless/serverless/commit/b34d5497b6290635037f6d8f3b65451803ef6027)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Deprecate `provider.httpApi.useProviderTags` ([#105](https://github.com/serverless/serverless/issues/105)) ([fee410a](https://github.com/serverless/serverless/commit/fee410a445b088d4fb86074924604208043934c0)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS API Gateway:** + - Change default identity source for authorizers ([#10168](https://github.com/serverless/serverless/issues/10168)) ([1139255](https://github.com/serverless/serverless/commit/11392557d2800cdf226bd17bd32407f61a9dba52)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Error on tracing or logs set for external API ([#10198](https://github.com/serverless/serverless/issues/10198)) ([64ea6e5](https://github.com/serverless/serverless/commit/64ea6e59b5bbd1c807a948fd092c5792923e9559)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Remove API specific settings from `provider` ([#10157](https://github.com/serverless/serverless/issues/10157)) ([99941f0](https://github.com/serverless/serverless/commit/99941f0a5723aef0395ea0fb5b059e9ade8321b4)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Remove support for `request.schema` ([#10143](https://github.com/serverless/serverless/issues/10143)) ([b8019d8](https://github.com/serverless/serverless/commit/b8019d82ccabf732a75c2f97c958b84efb1e43ef)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS CloudFront:** Remove support for deprecated `behavior` props ([#10149](https://github.com/serverless/serverless/issues/10149)) ([c22277f](https://github.com/serverless/serverless/commit/c22277f69c327f271ea5cd51c98538c9b4eb7b1b)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS EventBridge:** Change default deployment method to native CF ([#10164](https://github.com/serverless/serverless/issues/10164)) ([46956f3](https://github.com/serverless/serverless/commit/46956f3e9f5dde9367669b0d9c1ca2dc454bfc8e)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS IAM:** Deprecate IAM settings grouped directly at `provider` ([#10348](https://github.com/serverless/serverless/issues/10348)) ([d7fd239](https://github.com/serverless/serverless/commit/d7fd23997f570c868437a5ea0187797403f8fe0a)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **Plugins:** Pass log writers to plugin constructor ([#10140](https://github.com/serverless/serverless/issues/10140)) ([57079b7](https://github.com/serverless/serverless/commit/57079b78a671d7756c768f3136518f6a6f46d8ef)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Config Schema:** Deprecate `warn` as a validation mode default ([#10348](https://github.com/serverless/serverless/issues/10348)) ([6e27cc1](https://github.com/serverless/serverless/commit/6e27cc18c6c50fbd3311427e92c9e7f16055ae85)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Standalone:** Upgrade `npm` to v8 ([#10349](https://github.com/serverless/serverless/issues/10349)) ([6bfdc0c](https://github.com/serverless/serverless/commit/6bfdc0cda4b2009e4433f2fda45356c5d297c172)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Dashboard:** Drop support for `tenant` ([#10525](https://github.com/serverless/serverless/issues/10525)) ([9894875](https://github.com/serverless/serverless/commit/98948750e6cb856c62f1b4f4138a5157da07ae7e)) ([Mariusz Nowak](https://github.com/medikoo)) +- **AWS Alexa:** Remove support for alexaSkill without appId ([#10142](https://github.com/serverless/serverless/issues/10142)) ([a9edd06](https://github.com/serverless/serverless/commit/a9edd063039a41fee1679827f7abe0e754036b45)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Disallow custom nested configuration path ([#10205](https://github.com/serverless/serverless/issues/10205)) ([aeb9a57](https://github.com/serverless/serverless/commit/aeb9a57681cc3ff67c6dedbbf051b0c42d8ba6bb)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Error instead of warning when missing `commands` or `options` ([#10158](https://github.com/serverless/serverless/issues/10158)) ([f86f691](https://github.com/serverless/serverless/commit/f86f69131678a3a9be13acaeba0b56b751e6ce57)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Remove `@serverless/cli` CLI integration ([#10462](https://github.com/serverless/serverless/issues/10462)) ([396cfb9](https://github.com/serverless/serverless/commit/396cfb9621a5db211e2853b8105386103f9f097c)) ([Mariusz Nowak](https://github.com/medikoo)) +- Remove `@serverless/components` CLI integration ([#10327](https://github.com/serverless/serverless/issues/10327)) ([3395395](https://github.com/serverless/serverless/commit/33953958ae354b240e6d949b889e376dcce09cc8)) ([Mariusz Nowak](https://github.com/medikoo)) +- Remove support for `provider.disableDefaultOutputExportNames` ([#10148](https://github.com/serverless/serverless/issues/10148)) ([a9cd331](https://github.com/serverless/serverless/commit/a9cd3317b2e68b1b08c3f7388a2d4d459db1f2d7)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Remove support for Node v10 ([#10186](https://github.com/serverless/serverless/issues/10186)) ([90f00b7](https://github.com/serverless/serverless/commit/90f00b7c02113932034f4e3ee3ef659b1ec0db02)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Remove support for object notation for `service` ([#10156](https://github.com/serverless/serverless/issues/10156)) ([bccd188](https://github.com/serverless/serverless/commit/bccd188a0da7fe335b3e2b573f3ab19ccd0c49f8)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Restrict stage name with pattern ([c8c9f49](https://github.com/serverless/serverless/commit/c8c9f49fd239df723e3841fbfe22abdb90c02dae)) ([Mariusz Nowak](https://github.com/medikoo)) +- Support `params` configuration ([#10400](https://github.com/serverless/serverless/issues/10400)) ([4675b57](https://github.com/serverless/serverless/commit/4675b57117e7d850a6015ab97c81938b9f374bf1)) ([Mariusz Nowak](https://github.com/medikoo)) +- Throw error on duplicated plugin definition ([#10150](https://github.com/serverless/serverless/issues/10150)) ([d3aca0a](https://github.com/serverless/serverless/commit/d3aca0a7955c48b123720a887e6dd7300475fe03)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Throw for `--aws-s3-accelerate` when custom bucket used ([#10151](https://github.com/serverless/serverless/issues/10151)) ([b7d48e5](https://github.com/serverless/serverless/commit/b7d48e59fdbe2a2056c6352d6ac33d4c43099e53)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Maintenance Improvements + +- **AWS Deploy:** Use change sets in CF deployments ([#10390](https://github.com/serverless/serverless/issues/10390)) ([e2c65a2](https://github.com/serverless/serverless/commit/e2c65a2230b9bf9fb78c7445b02d3ee4945ee1aa)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **CLI Onboarding:** Download templates from v3 examples branch ([#10482](https://github.com/serverless/serverless/issues/10482)) ([ded1b0e](https://github.com/serverless/serverless/commit/ded1b0e832c420871ffe37fedff0afe990d1d3e6)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **CLI:** + - Convert `isLocallyInstalled` to export result directly ([#10503](https://github.com/serverless/serverless/issues/10503)) ([ad0bbb0](https://github.com/serverless/serverless/commit/ad0bbb0a9161bc823d1c542e6dbf993f436f6b5a)) ([Mariusz Nowak](https://github.com/medikoo)) + - Export resolved local installation path directly ([#10503](https://github.com/serverless/serverless/issues/10503)) ([fb3b39a](https://github.com/serverless/serverless/commit/fb3b39a5a9bd35e211600530a30fc5583deec0db)) ([Mariusz Nowak](https://github.com/medikoo)) + - Improve post install log to reflect modern style ([#10418](https://github.com/serverless/serverless/issues/10418)) ([843764b](https://github.com/serverless/serverless/commit/843764baf837f195ec8ee911f103c9f3817f9a10)) ([Mariusz Nowak](https://github.com/medikoo)) + - Improve progress for CloudFormation updates ([#10458](https://github.com/serverless/serverless/issues/10458)) ([14b1443](https://github.com/serverless/serverless/commit/14b14432730c77ca34d41000e9aaaad0c29ffb35)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Seclude `paramRegExp` ([#10346](https://github.com/serverless/serverless/issues/10346)) ([703e40f](https://github.com/serverless/serverless/commit/703e40f0d217d925560ba2c1d43b403bb61d335b)) ([Mariusz Nowak](https://github.com/medikoo)) + - Seclude uncaught exception handling ([#10542](https://github.com/serverless/serverless/issues/10542)) ([b4bd0d4](https://github.com/serverless/serverless/commit/b4bd0d437074a29a972ecdbdc3a026554657817e)) ([Mariusz Nowak](https://github.com/medikoo)) + - Unify finalization of a process handling ([#10542](https://github.com/serverless/serverless/issues/10542)) ([29357f4](https://github.com/serverless/serverless/commit/29357f4e182f102504e5ea841fb95915ccfe6821)) ([Mariusz Nowak](https://github.com/medikoo)) + - Move `isLocalyInstalled` util to CLI context ([#105](https://github.com/serverless/serverless/issues/105)) ([3dc8395](https://github.com/serverless/serverless/commit/3dc8395d88dfebf4742625ec054955c40a4e2499)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Config Schema:** + - Upgrade `ajv` to `v8` along with related packages ([#10440](https://github.com/serverless/serverless/issues/10440)) ([15cd724](https://github.com/serverless/serverless/commit/15cd724f723b55ca73cd0bb00d41d67307ffbed8)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Do not rely on `ajv-keywords` ([#10490](https://github.com/serverless/serverless/issues/10490)) ([#10490](https://github.com/serverless/serverless/issues/10490)) ([4a22a4e](https://github.com/serverless/serverless/commit/4a22a4e58cd8c10d6da34a094a0768b5caafbdb9)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **Telemetry:** Include `paramsCount` in telemetry ([#10460](https://github.com/serverless/serverless/issues/10460)) ([dd721b0](https://github.com/serverless/serverless/commit/dd721b0a2038e4b7256593397b5db19833cef387)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Rely on `require.resolve` to detect wether module exist ([#10503](https://github.com/serverless/serverless/issues/10503)) ([040be5f](https://github.com/serverless/serverless/commit/040be5fe7321e051bb6e5e1aa78458c17d2582bc)) ([Mariusz Nowak](https://github.com/medikoo)) +- Remove `legacy` logs ([#10527](https://github.com/serverless/serverless/issues/10527)) ([a92ab91](https://github.com/serverless/serverless/commit/a92ab917128629e4e516d69976fdac1014cb5ebb)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Remove `lib/classes/Error.js` ([#10563](https://github.com/serverless/serverless/issues/10563)) ([44391fa](https://github.com/serverless/serverless/commit/44391fac513c7941447d03bdeae95043590cc52c)) ([Mariusz Nowak](https://github.com/medikoo)) +- Remove evaluation of deprecated lifecycle events ([#10345](https://github.com/serverless/serverless/issues/10345)) ([34bb51e](https://github.com/serverless/serverless/commit/34bb51e71d542e31a13cfb0f56443d57b6e0f89a)) ([Mariusz Nowak](https://github.com/medikoo)) +- Remove internal `suppressLogIfPrintCommand` method ([#10526](https://github.com/serverless/serverless/issues/10526)) ([584286e](https://github.com/serverless/serverless/commit/584286ec7aba94ac96eb747361f79fafb7c0f32b)) ([Mariusz Nowak](https://github.com/medikoo)) +- Unify file naming convention ([#10563](https://github.com/serverless/serverless/issues/10563)) ([Mariusz Nowak](https://github.com/medikoo)) +- Replace `ncjsm/resolve` usage with native `createRequire` ([#10503](https://github.com/serverless/serverless/issues/10503)) ([d18efc2](https://github.com/serverless/serverless/commit/d18efc2d43789dc11857d677851ba4b66e09a6a4)) ([Mariusz Nowak](https://github.com/medikoo)) +- Adapt to rename in `@serverless/dashboard-plugin` ([#10543](https://github.com/serverless/serverless/issues/10543)) ([88234a5](https://github.com/serverless/serverless/commit/88234a51233e74b3155427a5bf0a4022ec182c04)) ([Mariusz Nowak](https://github.com/medikoo)) +- Upgrade `@serverless/utils` to v6 ([74d9c70](https://github.com/serverless/serverless/commit/74d9c70f8abbfab1af4c6440ed93fd163145a597)) ([Mariusz Nowak](https://github.com/medikoo)) + +### [2.72.2](https://github.com/serverless/serverless/compare/v2.72.1...v2.72.2) (2022-01-24) + +### Bug Fixes + +- **Variables:** Fix too eager nested resolution tracking ([#10554](https://github.com/serverless/serverless/issues/10554)) ([8db03c9](https://github.com/serverless/serverless/commit/8db03c90ffba68ebda800d2a009452cd09f7bf7f)) ([Steven Noorbergen](https://github.com/steven-xaroth)) + +### [2.72.1](https://github.com/serverless/serverless/compare/v2.72.0...v2.72.1) (2022-01-21) + +### Maintenance Improvements + +- Refactor direct use of `@serverless/utils/log` ([#10534](https://github.com/serverless/serverless/pull/10534)) ([05fb97f](https://github.com/serverless/serverless/commit/05fb97fdab0c0ddc471ca554e48e09e661f797db)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +## [2.72.0](https://github.com/serverless/serverless/compare/v2.71.0...v2.72.0) (2022-01-17) + +### Features + +- **CLI Onboarding:** Auto login if `org` provided or configured ([#10510](https://github.com/serverless/serverless/pull/10510)) ([dcf5273](https://github.com/serverless/serverless/commit/dcf52731ea3920ecf16b2484e2673080acbfe1cd)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Bug Fixes + +- **CLI:** Respect old Node.js versions in version detection ([#10499](https://github.com/serverless/serverless/pull/10499)) ([427920e](https://github.com/serverless/serverless/commit/427920ee0fc1c98109c0b673c794baac1cc5caf7)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **AWS Deploy:** Improve custom resource generation log ([#10496](https://github.com/serverless/serverless/pull/10496)) ([521861b](https://github.com/serverless/serverless/commit/521861b6510fd345c2b596e4ec9e9ef7be01ac10)) ([Mariusz Nowak](https://github.com/medikoo)) +- **CLI Onboarding:** Improve user message when `app` does not exist ([#10509](https://github.com/serverless/serverless/pull/10509)) ([20afe33](https://github.com/serverless/serverless/commit/20afe339231112e4d5ade9498386ac3c00e37e04)) ([Mariusz Nowak](https://github.com/medikoo)) +- Ensure support for `warn` mode for modern deprecations ([#10502](https://github.com/serverless/serverless/pull/10502)) ([82303b3](https://github.com/serverless/serverless/commit/82303b38942b35fa6cb8ad3f19f2d528a1736587)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Support `conceal` option in modern logs ([#10501](https://github.com/serverless/serverless/pull/10501)) ([0dacf1b](https://github.com/serverless/serverless/commit/0dacf1bb3bd53da32a24cf2286cf081aecf22806)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Templates + +- Ensure `esbuild` dependency in `aws-nodejs-typescript` ([#10484](https://github.com/serverless/serverless/pull/10484)) ([452e4d8](https://github.com/serverless/serverless/commit/452e4d8279802ab2ce1ca300ab2c75ec8588a9e8)) ([François Farge](https://github.com/fargito)) + +## [2.71.0](https://github.com/serverless/serverless/compare/v2.70.0...v2.71.0) (2022-01-10) + +### Features + +- **AWS Cognito:** Support `forceDeploy` setting ([#10435](https://github.com/serverless/serverless/issues/10435)) ([c67a3f1](https://github.com/serverless/serverless/commit/c67a3f1a4fe6c64f2b6c68ef1b184b2642ad2266)) ([TsimpDim](https://github.com/TsimpDim)) +- **Variables:** Resign from `projectDir` concept ([#10478](https://github.com/serverless/serverless/pull/10478)) ([5a76437](https://github.com/serverless/serverless/commit/5a764373c49d5fb313f50218ab8166f1638c2c32)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Bug Fixes + +- **CLI:** Fix handling of provider URL handling ([#10461](https://github.com/serverless/serverless/pull/10461)) ([7ebe133](https://github.com/serverless/serverless/commit/7ebe133b35fa9affafd73b61ee4626d8ce5aee1f)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Config Schema:** Address invalid schema definitions ([#10452](https://github.com/serverless/serverless/pull/10452)) ([9e1fe0a](https://github.com/serverless/serverless/commit/9e1fe0ad5da8b936ccb238041fb2b452e6309faf)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Maintenance Improvements + +- **CLI Onboarding:** Download templates from v2 examples branch ([#10447](https://github.com/serverless/serverless/pull/10447)) ([46d090a](https://github.com/serverless/serverless/commit/46d090a302b9f7f4a3cf479695489b7ffc46b75b)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **CLI:** Ensure telemetry logs are issued at debug level ([#10424](https://github.com/serverless/serverless/pull/10424)) ([7b36038](https://github.com/serverless/serverless/commit/7b360386eadb9a83af73514ced34bc901af43457)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Templates + +- Upgrade `log4j` to `2.17.1` in corresponding templates ([#10430](https://github.com/serverless/serverless/issues/10430)) ([2c3ab1d](https://github.com/serverless/serverless/commit/2c3ab1db9aa7c22c315957d1e474568e62e07e37)) ([Graham Campbell](https://github.com/GrahamCampbell)) + +## [2.70.0](https://github.com/serverless/serverless/compare/v2.69.1...v2.70.0) (2021-12-27) + +### Features + +- **AWS API Gateway:** Allow use of custom authorizer with authorizerId ([#10384](https://github.com/serverless/serverless/pull/10384)) ([c0eda27](https://github.com/serverless/serverless/commit/c0eda272901fd91947c6f37589b33f65c804dc9b)) ([Adam Lanners](https://github.com/darksun)) +- **AWS Local Invocation:** Upgrade `log4j` to version 2.17.0 ([#10396](https://github.com/serverless/serverless/issues/10396)) ([2782ed4](https://github.com/serverless/serverless/commit/2782ed4221caa410708cbabbbd09d45a6363be29)) ([Vassili Gorshkov](https://github.com/atlasgurus)) + +### Bug Fixes + +- **AWS API Gateway:** Meaningfully reject missing `restApiRootResourceId` ([#10371](https://github.com/serverless/serverless/issues/10371)) ([2c0a962](https://github.com/serverless/serverless/commit/2c0a962c4fc0ad82ecbc6a266d56bfaa81ad8054)) ([Sudipto Das](https://github.com/sdas13)) +- **AWS Deploy:** Fix reliability of VPC config change detection in `deploy function` ([#10409](https://github.com/serverless/serverless/issues/10409)) ([0190d0d](https://github.com/serverless/serverless/commit/0190d0df05f4e37c8e965913ef1ceaf6b8a9b525)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Templates + +- Upgrade `log4j` in `aws-lambda-java-log4j2` ([#10383](https://github.com/serverless/serverless/issues/10383)) ([786f5e4](https://github.com/serverless/serverless/commit/786f5e45d54ae9925649367b0a0e8660eda542e6)) ([Marina](https://github.com/MarinaMeza)) +- Upgrade `log4j` in `aws-kotlin-jvm-gradle` ([#10382](https://github.com/serverless/serverless/issues/10382)) ([7bf8f1b](https://github.com/serverless/serverless/commit/7bf8f1b723cc4f6624df7be3d27f246b3a826140)) ([Varun](https://github.com/varun73)) +- Upgrade `log4j` dependencies ([#10392](https://github.com/serverless/serverless/issues/10392)) ([86fa604](https://github.com/serverless/serverless/commit/86fa60445c83cf35f3411ae49c2a1c4fc7fd82f0)) ([Juan Bermúdez](https://github.com/JuanBermudezN)) + +### Maintenance Improvements + +- **Telemetry:** + - Report `didCreateService` property ([#10406](https://github.com/serverless/serverless/pull/10406)) ([4fa20a5](https://github.com/serverless/serverless/commit/4fa20a56eafcab9d8675baa2f0fe6a9c6ee5e184)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Report `projectId` in remove command ([#10415](https://github.com/serverless/serverless/pull/10415)) ([0de3bc3](https://github.com/serverless/serverless/commit/0de3bc3cb9c1685226ea0c610e030f9279e79e4e)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Ensure to report `projectId` for interactive ([#10406](https://github.com/serverless/serverless/pull/10406)) ([08b5acb](https://github.com/serverless/serverless/commit/08b5acbaa901c7ce529064c394151e05bdd43aef)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **CLI:** Replace internal old logging utils with modern interface ([#10417](https://github.com/serverless/serverless/pull/10417)) ([5a451ad](https://github.com/serverless/serverless/commit/5a451ad0249b6924cd4105e5c372028402517ecd)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Variables:** Support custom sources in internal resolver ([#10393](https://github.com/serverless/serverless/pull/10393)) ([365a7f1](https://github.com/serverless/serverless/commit/365a7f13afaf40e9e2d573b0668159d6dea7aa02)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.69.1](https://github.com/serverless/serverless/compare/v2.69.0...v2.69.1) (2021-12-15) + +### Bug Fixes + +- **AWS Lambda:** Fix event config setup for provisioned lambdas ([#10366](https://github.com/serverless/serverless/pull/10366)) ([3b4e453](https://github.com/serverless/serverless/commit/3b4e4539d8b56de6a7cccb2e9c8455f34a5289f6)) ([Mariusz Nowak](https://github.com/medikoo)) +- **CLI:** + - Do not crash on help request ([#10347](https://github.com/serverless/serverless/pull/10347)) ([f6feb0b](https://github.com/serverless/serverless/commit/f6feb0b7b3b5ceb727119056e44e756a8105ec5b)) ([Mariusz Nowak](https://github.com/medikoo)) + - Improve error handler resolution ([#10367](https://github.com/serverless/serverless/pull/10)) ([0dedd3e](https://github.com/serverless/serverless/commit/0dedd3e8790f568527b8a2444720fe47048ba719)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Templates + +- Upgrade `log4j` in Java based templates ([#10363](https://github.com/serverless/serverless/issues/10363)) ([7de020b](https://github.com/serverless/serverless/commit/7de020bbadad0aed47859f2129c9e58409b9ac65)) ([Vassili Gorshkov](https://github.com/atlasgurus)) +- Upgrade `log4j` in Java based templates ([#10339](https://github.com/serverless/serverless/issues/10339)) ([c1df4f8](https://github.com/serverless/serverless/commit/c1df4f860a585ff62c364ac8fd6d8b64b323b156)) ([Vassili Gorshkov](https://github.com/atlasgurus)) + +## [2.69.0](https://github.com/serverless/serverless/compare/v2.68.0...v2.69.0) (2021-12-13) + +### Features + +- **AWS Deploy:** Ensure existence of S3 deployment bucket (if possible) ([#10317](https://github.com/serverless/serverless/pull/10317)) ([f358585](https://github.com/serverless/serverless/commit/f35858599ad749b5417c238f510e726615e221dc)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS Kafka:** Add support for `mTLS` access configuration ([#10273](https://github.com/serverless/serverless/issues/10273)) ([9faf37a](https://github.com/serverless/serverless/commit/9faf37aa153a60784ca783b1e2b7364625e8761f)) ([Misha Bruml](https://github.com/mishabruml)) +- **Standalone:** + - Support installation on M1-based Macs ([#10291](https://github.com/serverless/serverless/pull/10291)) ([92ae054](https://github.com/serverless/serverless/commit/92ae054f02dc631c178628492af7049ce2936204)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Use Node 16 as base for binaries ([#10291](https://github.com/serverless/serverless/pull/10291)) ([eb8f474](https://github.com/serverless/serverless/commit/eb8f474940c4cd69f08ec062adfaa15d62d81ee2)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Bug Fixes + +- **AWS Deploy:** + - Allow removal of stack with bucket missing ([#10306](https://github.com/serverless/serverless/pull/10306)) ([1a85a4a](https://github.com/serverless/serverless/commit/1a85a4a901caf4ca05096bf11bfcad31959c8044)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Ensure to strip all `null` properties from CloudFormation template ([#10304](https://github.com/serverless/serverless/issues/10304)) ([1f58760](https://github.com/serverless/serverless/commit/1f58760f467f2dcb960e23c2eb028f4abef23209)) ([GurmeharS](https://github.com/GurmeharS)) + - Recognize all boolean values at `provider.disableRollback` ([#10324](https://github.com/serverless/serverless/pull/10324)) ([2485c7e](https://github.com/serverless/serverless/commit/2485c7efcc4f6f5b1d65b56d4d0d71297d113fa5)) ([François Farge](https://github.com/fargito)) +- **Variables:** Provide opt-out from forced decryption at`ssm` source ([#10315](https://github.com/serverless/serverless/issues/10315)) ([503c031](https://github.com/serverless/serverless/commit/503c0319b7e9acc2b674d5d61874dfa3fcfc857e)) ([Omer Shacham](https://github.com/omerinvia)) + +### Maintenance Improvements + +- Configure promise returning functions as async ([#10309](https://github.com/serverless/serverless/issues/10309)) ([4d4f863](https://github.com/serverless/serverless/commit/4d4f8637d830ba9a72806fc127fe3497f7c0f23c)) ([mdanyalkhan](https://github.com/mdanyalkhan)) +- Use `async/await` syntax in `bucket.js` ([#10306](https://github.com/serverless/serverless/pull/10306)) ([39e43b5](https://github.com/serverless/serverless/commit/39e43b51e5e13c708900e0ccc4d4f25ccf0df61c)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +## [2.68.0](https://github.com/serverless/serverless/compare/v2.67.0...v2.68.0) (2021-12-02) + +### Features + +- **AWS Deploy:** + - Ensure consistent function state in `deploy function` ([#10288](https://github.com/serverless/serverless/pull/10288)) ([d52526b](https://github.com/serverless/serverless/commit/d52526bb6059ce20eba341c29ad5a2373c238624)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Support all regions from `iso` and `isob` partition ([25eb571](https://github.com/serverless/serverless/commit/25eb571dd3299ac0f61dd1ea40b6b44b355f6898)) ([#10299](https://github.com/serverless/serverless/issues/10299)) ([maafk](https://github.com/maafk)) +- **AWS SQS:** Support `filterPatterns` ([#10297](https://github.com/serverless/serverless/pull/10297)) ([3f0a80a](https://github.com/serverless/serverless/commit/3f0a80acd3fcf9eb7768625eb6cfe06cf572afa0)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS Stream:** Support `filterPatterns` ([#10285](https://github.com/serverless/serverless/issues/10285)) ([fc00505](https://github.com/serverless/serverless/commit/fc0050559cd1ee7b8a53a08fae73940177da93cb)) ([Frédéric Barthelet](https://github.com/fredericbarthelet)) + +### Bug Fixes + +- **AWS SQS:** Accept only plain string form in direct ARN assignement ([#10263](https://github.com/serverless/serverless/issues/10263)) ([f7bbd17](https://github.com/serverless/serverless/commit/f7bbd176866b99725dcf1fef1128b0d2194217e0)) ([Sudipto Das](https://github.com/sdas13)) +- **Variables:** Resolve variables in resolved address & params values ([#10296](https://github.com/serverless/serverless/pull/10296)) ([63d54e1](https://github.com/serverless/serverless/commit/63d54e1537e10ae63c171892edd886f6b81e83f6)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **Variables:** Seclude internal logic for reuse ([#10296](https://github.com/serverless/serverless/pull/10296)) ([9c75044](https://github.com/serverless/serverless/commit/9c75044fd59d8f181c7daee22d53a7bac3786e09)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Templates + +- Update dependencies in `aws-java-maven` ([#10289](https://github.com/serverless/serverless/issues/10289)) ([0714f7d](https://github.com/serverless/serverless/commit/0714f7df0642d7a900c9d72eb26ae8c5ae1eddd7)) ([burakaktasfe](https://github.com/burakaktasfe)) + +## [2.67.0](https://github.com/serverless/serverless/compare/v2.66.2...v2.67.0) (2021-11-26) + +### Features + +- **AWS Deploy:** Support `disableRollback` parameter ([#10236](https://github.com/serverless/serverless/issues/10236)) ([c9fefce](https://github.com/serverless/serverless/commit/c9fefced103e47d5d793d979cbb10072daeabf01)) ([Frédéric Barthelet](https://github.com/fredericbarthelet)) +- **AWS Lambda:** Add `platform` option for container images ([#10237](https://github.com/serverless/serverless/issues/10237)) ([5b61b41](https://github.com/serverless/serverless/commit/5b61b415a0f19ce0755924eae969caf02185d8af)) ([Zane Mountcastle](https://github.com/zanemountcastle)) +- **AWS S3:** Support `Fn::If` CF function for s3 event ([#10272](https://github.com/serverless/serverless/pull/10272)) ([a4fa498](https://github.com/serverless/serverless/commit/a4fa49844d23afea90f7c9aa4616beedd2a80db8)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS SQS:** Support `functionResponseType` ([#10265](https://github.com/serverless/serverless/issues/10265)) ([44511f3](https://github.com/serverless/serverless/commit/44511f343b1a68ca147e8ba9e8b493143b89c324)) ([nicoeft](https://github.com/nicoeft)) + +## [2.66.2](https://github.com/serverless/serverless/compare/v2.66.1...v2.67.0) (2021-11-17) + +### Bug Fixes + +- **CLI:** Fix component template recognition in triage ([#10252](https://github.com/serverless/serverless/issues/10252)) ([4494f77](https://github.com/serverless/serverless/commit/4494f77f6111249d97295923a706883a8910840d)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **CLI:** Expose dashboard provider name when starting deployment ([#10194](https://github.com/serverless/serverless/issues/10194)) ([6698fa6](https://github.com/serverless/serverless/commit/6698fa657e5a5b35908c2b2de0815525f948064f)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Templates + +- Use `iam.role` syntax ([#10227](https://github.com/serverless/serverless/issues/10227)) ([a55d51c](https://github.com/serverless/serverless/commit/a55d51c6a4aa38153f61192d374cb23bf09ff66c)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Update `ts-node` for es2020 and es2021 support in `aws-nodes-typescript` ([#10234](https://github.com/serverless/serverless/issues/10234)) ([e131609](https://github.com/serverless/serverless/commit/e13160902848912a6bb652299d1bc6107cf09eb1)) ([Frédéric Barthelet](https://github.com/fredericbarthelet)) + +### [2.66.1](https://github.com/serverless/serverless/compare/v2.66.0...v2.66.1) (2021-11-10) + +### Bug Fixes + +- **AWS API Gateway:** Ensure proper `apiId` resolution ([#10221](https://github.com/serverless/serverless/pull/10221)) ([95f3a56](https://github.com/serverless/serverless/commit/95f3a5603897ad43ba6e008a7ea2a35d21a4eacf)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Maintenance Improvements + +- **CLI:** Improve timestamp visiblity in `deploy list` output ([#10211](https://github.com/serverless/serverless/pull/10211)) ([55146c4](https://github.com/serverless/serverless/commit/55146c4595024b0e3702dc2023264af784b906e9)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Templates + +- Upgrade `middy` in `aws-nodejs-typescript` ([#10215](https://github.com/serverless/serverless/issues/10215)) ([ad95e03](https://github.com/serverless/serverless/commit/ad95e030b3581a65babc8dd175b8bb69f1215534)) ([Frédéric Barthelet](https://github.com/fredericbarthelet)) +- Use non deprecated API in `aws-nodejs-typescript` ([#10214](https://github.com/serverless/serverless/issues/10214)) ([6671d98](https://github.com/serverless/serverless/commit/6671d98615ab7d003c3c7413c9334b63b2d735e8)) ([Frédéric Barthelet](https://github.com/fredericbarthelet)) + +## [2.66.0](https://github.com/serverless/serverless/compare/v2.65.0...v2.66.0) (2021-11-09) + +### Features + +- Introduce `enforce-hash-update` flag to help Lambda hashing version migration ([#10209](https://github.com/serverless/serverless/pull/10209)) ([afd0a5b](https://github.com/serverless/serverless/commit/afd0a5bd6f131c9b12148199d4995e055e5963f0)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **Variables:** Recognize `:` in variable address to support `output` source ([#10208](https://github.com/serverless/serverless/pull/10208)) ([723927f](https://github.com/serverless/serverless/commit/723927f2dcdcc425025da03ac0be5edd3c203dc7)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Bug Fixes + +- **AWS API Gateway:** Ensure `shouldStartNameWithService` support ([#10177](https://github.com/serverless/serverless/pull/10177)) ([e8c8d25](https://github.com/serverless/serverless/commit/e8c8d259fb79ae04e33e01af162c6666f0060189)) ([Vicary A.](https://github.com/vicary)) +- **CLI:** Do not recommend `frameworkVersion` when running pre release ([#10204](https://github.com/serverless/serverless/pull/10204)) ([53490a5](https://github.com/serverless/serverless/commit/53490a55183db5f304d0e3ef69feadd9a20fa815)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- Ensure to use `legacy.log` instead of `cli.log` ([#10206](https://github.com/serverless/serverless/pull/10206)) ([ea05d7c](https://github.com/serverless/serverless/commit/ea05d7c41e84b0f68017804b06d6435062673d26)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.65.0](https://github.com/serverless/serverless/compare/v2.64.1...v2.65.0) (2021-11-03) + +### Features + +- **AWS Lambda:** + - Support CF intrinsic functions at `functions[].reservedConcurrency` ([#10129](https://github.com/serverless/serverless/issues/10129)) ([7cfddff](https://github.com/serverless/serverless/commit/7cfddff31433582ac031be0a168eba2d356d7ee9)) ([ROSeaboyer](https://github.com/ROSeaboyer)) + - Allow to stick to current default Lambda hashing version mode with `lambdaHashingVersion: 20200924` setting ([#10173](https://github.com/serverless/serverless/pull/10173)) ([50a8457](https://github.com/serverless/serverless/commit/50a845709eb846ce5ca3b60116c4ec278896a8b3)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS EventBridge:** Adjust deprecation of deployment method and allow to keep using old approach ([#10133](https://github.com/serverless/serverless/pull/10133)) ([bf62b7c](https://github.com/serverless/serverless/commit/bf62b7c4dabbecc892fde4d0d988dc2dd2cb7461)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS Local Invocation:** Support decimal serialization for Python ([#10178](https://github.com/serverless/serverless/pull/10178)) ([9ef46ba](https://github.com/serverless/serverless/commit/9ef46ba05ff033dbf04c451a214bf4ced23c90e8)) ([Shane R. Spencer](https://github.com/whardier)) + +### Bug Fixes + +- **AWS Deploy:** Fix handling of deployment bucket extensions ([#10137](https://github.com/serverless/serverless/issues/10137)) ([39bdea0](https://github.com/serverless/serverless/commit/39bdea07500b8fb814a5cce83ec6f78a0c75006c)) ([Mars Lan](https://github.com/mars-lan)) +- **AWS HTTP API:** Recognize max timeout as 30s instead of 29s ([#10119](https://github.com/serverless/serverless/issues/10119)) ([e3e02fe](https://github.com/serverless/serverless/commit/e3e02fe8e2f1bbd236cfa49f80a360fd828c1ead)) ([Caio Fauza](https://github.com/CaioFauza)) +- **CLI:** + - Fix `help` command usage information ([#10175](https://github.com/serverless/serverless/issues/10175)) ([254e70c](https://github.com/serverless/serverless/commit/254e70cd0ad9bb1803d3a5741b966f5807e9d869)) ([Sebastian Bille](https://github.com/TastefulElk)) + - Fix resolution of help for not integrated commands ([#10128](https://github.com/serverless/serverless/pull/10128)) ([204f205](https://github.com/serverless/serverless/commit/204f2051f6a5ca5f046eb905292dfae0c597e33f)) ([Mariusz Nowak](https://github.com/medikoo)) +- Recognize accessible configuration parts on validation errors ([#10134](https://github.com/serverless/serverless/pull/10134)) ([b7a6349](https://github.com/serverless/serverless/commit/b7a634974dc2ee138d85ec58609bf2559c5de9f6)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Performance Improvements + +- **CLI:** Integrate CLI triage into this package (no `@serverless/components` and `@serverless/cli` modules are loaded unless their CLI is used)([#10131](https://github.com/serverless/serverless/pull/10131)) ([415bdef](https://github.com/serverless/serverless/commit/415bdefca092e60cacd867006bacddfda231ed94)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **CLI:** + - Improve file size output in logs ([#10169](https://github.com/serverless/serverless/pull/10169)) ([4448490](https://github.com/serverless/serverless/commit/44484903b38eaa18c3e3838b8a3f217922a233e5)) ([Mariusz Nowak](https://github.com/medikoo)) + - Improve main progress message ([#10183](https://github.com/serverless/serverless/pull/10183)) ([533f709](https://github.com/serverless/serverless/commit/533f709c5833619d5ce86ec987133ff0f148c8e0)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Telemetry:** Add `projectId` to payload ([#10180](https://github.com/serverless/serverless/pull/10180)) ([cc7d7e4](https://github.com/serverless/serverless/commit/cc7d7e4d531090e81bf08842433397588d00afce)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS EventBridge:** Address typos in error messages ([#10165](https://github.com/serverless/serverless/issues/10165)) ([ee38f6a](https://github.com/serverless/serverless/commit/ee38f6a3081a3a0f22ee9fea8975f13520ac18ec)) ([Andreas Kohn](https://github.com/ankon)) +- Seprate internal and plugin output sections ([#10184](https://github.com/serverless/serverless/pull/10184)) ([7bb2520](https://github.com/serverless/serverless/commit/7bb2520f491d008075eb08be64bdb2e0b60ec5c6)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Templates + +- Package lambdas individually in `aws-nodejs-typescript` ([#10106](https://github.com/serverless/serverless/pull/10106)) ([3aab5f8](https://github.com/serverless/serverless/commit/3aab5f86985598d6bb3135f4ab934092ad467df5)) ([Adrien Cacciaguerra](https://github.com/adriencaccia)) +- Upgrade `azure-nodejs-typescript` ([#10163](https://github.com/serverless/serverless/issues/10163)) ([26846d5](https://github.com/serverless/serverless/commit/26846d5879d655ffe299db694a33f1f6d187a941)) ([Giang Nguyen](https://github.com/giangnm)) + +### [2.64.1](https://github.com/serverless/serverless/compare/v2.64.0...v2.64.1) (2021-10-20) + +### Bug Fixes + +- **CLI:** Handle gently case where temp folder is on other device ([#10124](https://github.com/serverless/serverless/issues/10124)) ([a030636](https://github.com/serverless/serverless/commit/a0306365fc2c18c04698640723db2f4efeb34e2f)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.64.0](https://github.com/serverless/serverless/compare/v2.63.0...v2.64.0) (2021-10-20) + +### Features + +- **AWS RabbitMQ:** Support for Amazon MQ RabbitMQ events ([#9919](https://github.com/serverless/serverless/issues/9919)) ([a3edecf](https://github.com/serverless/serverless/commit/a3edecf0c6b4e066bde2de8095582432d9fdd635)) ([Michael](https://github.com/liegeandlief)) + +### Bug Fixes + +- **AWS Deploy:** Recognize `LogicalResourceId` in `stackPolicy` ([#10097](https://github.com/serverless/serverless/pull/10097)) ([1a528c2](https://github.com/serverless/serverless/commit/1a528c2cc0746bfe6a692183f96b0831e3dd92f4)) ([Monsma](https://github.com/jmonsma)) +- **AWS EventBridge:** Allow intrinsic functions in `pattern` ([#10120](https://github.com/serverless/serverless/issues/10120)) ([1c105a4](https://github.com/serverless/serverless/commit/1c105a4c16e8bdca9fc66c5eddf12153ebc9a1fb)) ([Benoît Bouré](https://github.com/bboure)) +- **CLI:** Ensure command validation for service independent commands ([#10115](https://github.com/serverless/serverless/pull/10115)) ([6022fb9](https://github.com/serverless/serverless/commit/6022fb98331e8f7d8893a28d3dcb20d91d0a1e20)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Packaging:** Ensure to show deprecation in all cases ([#10111](https://github.com/serverless/serverless/pull/10111)) ([cc71fc9](https://github.com/serverless/serverless/commit/cc71fc99ffe2e1f2fcc764b29dafa197c665cef1)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **CLI:** + - Support `decoratedMessage` on `ServerlessError` ([#10112](https://github.com/serverless/serverless/pull/10112)) ([2217158](https://github.com/serverless/serverless/commit/2217158764dde8ceee472292b531836ada20d79a)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Enhanced modern error reporting for CloudFormation ([#10112](https://github.com/serverless/serverless/pull/10112)) ([cfd828e](https://github.com/serverless/serverless/commit/cfd828ece872b572cbb46670437e8196f2200903)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Report `credentials` source in modern error output ([#10114](https://github.com/serverless/serverless/pull/10114)) ([b4ff87d](https://github.com/serverless/serverless/commit/b4ff87dc81286b8123830f20bccfb3aa320e4ccd)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Improve style for local fallback modern notice ([#10111](https://github.com/serverless/serverless/pull/10111)) ([73c071b](https://github.com/serverless/serverless/commit/73c071b060216d330974a2f98917eba315eb634b)) ([Mariusz Nowak](https://github.com/medikoo)) + - Introduce `doctor` command for modern handling of deprecations ([#10115](https://github.com/serverless/serverless/pull/10115)) ([452e234](https://github.com/serverless/serverless/commit/452e234306a3703e95ad349305e1e211c165bf22)) ([Mariusz Nowak](https://github.com/medikoo)) + - Do not filter commands by `lifecycleEvents` for help ([#10115](https://github.com/serverless/serverless/pull/10115)) ([6991d66](https://github.com/serverless/serverless/commit/6991d66987d6276665bff07259bf1ca464ffeab7)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.63.0](https://github.com/serverless/serverless/compare/v2.62.0...v2.63.0) (2021-10-15) + +### Features + +- **AWS Deploy:** Introduce warning about `deploy -f` alias ([#10078](https://github.com/serverless/serverless/pull/10078)) ([40f574f](https://github.com/serverless/serverless/commit/40f574f946e2f40cba13e18b22ee82c7aaa31d3f)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS Lambda:** Allow overriding provider VPC with no VPC on function level ([#10060](https://github.com/serverless/serverless/pull/10060)) ([44a81fc](https://github.com/serverless/serverless/commit/44a81fcc6a229ac6ff59b8c8e51742a9470eef15)) ([Oliver](https://github.com/HowManyOliversAreThere)) +- **AWS S3:** Recognize `ExpirationInDays` property for `s3` events ([#10083](https://github.com/serverless/serverless/pull/10083)) ([8e6dcd1](https://github.com/serverless/serverless/commit/8e6dcd1aaed50007b5b99e18f61dfa849b898cd9)) ([ROSeaboyer](https://github.com/ROSeaboyer)) +- **CLI:** + - Introduce deprecation for duplicate plugin definition ([#10080](https://github.com/serverless/serverless/pull/10080)) ([d2a75ea](https://github.com/serverless/serverless/commit/d2a75ea95e814cd5aaba5eca4c5acebd2aad0bb8)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Introduce deprecation instead of warning on S3 Accelerate for user provided bucket ([#10080](https://github.com/serverless/serverless/pull/10080)) ([04b921a](https://github.com/serverless/serverless/commit/04b921acdc5fd486ffd10fe81fcb2243f37329db)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Opt-in support for deployment bucket versioning ([#9912](https://github.com/serverless/serverless/issues/9912)) ([c4cb0f3](https://github.com/serverless/serverless/commit/c4cb0f30f5f565e2fd34877dfc383f6b81d135fd)) ([Mars Lan](https://github.com/mars-lan)) + +### Maintenance Improvements + +- **CLI: New logs (experimental):** + - Adapt `logInfo` to modern logs ([#10078](https://github.com/serverless/serverless/pull/10078)) ([771f99b](https://github.com/serverless/serverless/commit/771f99b18d76060f030d36b5fa619dd41a7000c8)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Adapt `logWarning` to modern logs ([#10078](https://github.com/serverless/serverless/pull/10078)) ([d43298d](https://github.com/serverless/serverless/commit/d43298d25bc9fcf5f5724a800b2693321e88e838)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Cover image building with modern logs ([#10070](https://github.com/serverless/serverless/pull/10070)) ([a2be338](https://github.com/serverless/serverless/commit/a2be3387b16fdb7324e1342a5f6ee3974e4e34f5)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Improve handling of service outputs in modern logs ([#10100](https://github.com/serverless/serverless/pull/10100)) ([7d19ca8](https://github.com/serverless/serverless/commit/7d19ca857230a56bbe40bda4d6704edd34019e4e)) ([Mariusz Nowak](https://github.com/medikoo)) + - Introduce modern warning about resource limit ([#10086](https://github.com/serverless/serverless/pull/10086)) ([ca705b8](https://github.com/serverless/serverless/commit/ca705b8cc2854c302158a56294c2507ba5f2038f)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Minor modern logs updates ([#10071](https://github.com/serverless/serverless/pull/10071)) ([39c09e4](https://github.com/serverless/serverless/commit/39c09e44b6380ec1a13aa50aca9082cffb0aeca1)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Remove empty line in `info` command ([#10086](https://github.com/serverless/serverless/pull/10086)) ([03b4b3d](https://github.com/serverless/serverless/commit/03b4b3d47c25b6f98a46699463288c94b051f42c)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Replace `process.stdout` use with modern logs ([#10087](https://github.com/serverless/serverless/pull/10087)) ([be00a26](https://github.com/serverless/serverless/commit/be00a2672cbc90fb33dee5e4bd44a1f6a127eb7c)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Replace warnings with modern counterparts ([#10080](https://github.com/serverless/serverless/pull/10080)) ([4da0899](https://github.com/serverless/serverless/commit/4da08996736c9a8f2b0a0193f7cca4b24f3fc6f1)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Update link style for modern logs ([#10096](https://github.com/serverless/serverless/pull/10096)) ([6264296](https://github.com/serverless/serverless/commit/62642964bc38eae77b009ea84d05ba741383570f)) ([Mariusz Nowak](https://github.com/medikoo)) +- Fix typo in `lib/classes/Variables.js` ([#10093](https://github.com/serverless/serverless/issues/10093)) ([49f0913](https://github.com/serverless/serverless/commit/49f0913466110ac32d89c7c044fc781e524b9ed9)) ([Chris Poli](https://github.com/chris-poli)) + +### Templates + +- Add `esbuild` to `gitignore` in `aws-nodejs-typescript` ([#10076](https://github.com/serverless/serverless/pull/10076)) ([865f21f](https://github.com/serverless/serverless/commit/865f21f970340b45c6fb341d01647721f0fa5682)) ([ssshun](https://github.com/ssshun)) + +## [2.62.0](https://github.com/serverless/serverless/compare/v2.61.0...v2.62.0) (2021-10-08) + +### Features + +- **AWS Deploy:** Remove `deploy -f` deprecation ([#10063](https://github.com/serverless/serverless/pull/10063)) ([1084251](https://github.com/serverless/serverless/commit/10842513f0c5422f8627b652b6483523e0351a3c)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Config Schema:** Remove validation mode related deprecation ([#10063](https://github.com/serverless/serverless/pull/10063)) ([a9bf916](https://github.com/serverless/serverless/commit/a9bf916fbb15140373a54d22c624296b8a1dbe03)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Packaging:** Remove `package[include|exclude]` deprecation ([#10063](https://github.com/serverless/serverless/pull/10063)) ([70e2736](https://github.com/serverless/serverless/commit/70e27362260f97b68bb1dfaf52fa3fe7877a2adc)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Bug Fixes + +- **AWS Deploy:** Throw on attempt of extending not existing resource ([#10063](https://github.com/serverless/serverless/pull/10063)) ([02be86c](https://github.com/serverless/serverless/commit/02be86ca4954553388ac70845d8ff3aca205abcd)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **CLI: New logs (experimental):** + - Simplify CF deploy progress ([#10068](https://github.com/serverless/serverless/pull/10068)) ([be60ed4](https://github.com/serverless/serverless/commit/be60ed4cee15ec0a47be5c08da9e0ce4a3f54136)) ([Mariusz Nowak](https://github.com/medikoo)) + - Expose function artifact size in deploy summary ([#10062](https://github.com/serverless/serverless/pull/10062)) ([8746100](https://github.com/serverless/serverless/commit/87461007f809c67a78b7dd722847efef2e4f72b3)) ([Mariusz Nowak](https://github.com/medikoo)) + - `create` command ([#10066](https://github.com/serverless/serverless/pull/10066)) ([05f937f](https://github.com/serverless/serverless/commit/05f937f2e731e641e93e9db4af4acd58dc117422)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - `invoke local` command ([#10065](https://github.com/serverless/serverless/pull/10065)) ([82dd1e4](https://github.com/serverless/serverless/commit/82dd1e4c70d335cc10485b5ac20467447809941b)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - `invoke` command ([#10052](https://github.com/serverless/serverless/pull/10052)) ([2af95c0](https://github.com/serverless/serverless/commit/2af95c03865b5b59bacba9e080348dddf11d0bb5)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - `metrics` command ([#10051](https://github.com/serverless/serverless/pull/10051)) ([592596c](https://github.com/serverless/serverless/commit/592596c73bfe0a9b6ef6bdff5d898ae9ef5e2788)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - `remove` command ([#10050](https://github.com/serverless/serverless/pull/10050)) ([3934cad](https://github.com/serverless/serverless/commit/3934cadce052b50d76c1dcd49da588cd9f079175)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - `rollback function` command ([#10064](https://github.com/serverless/serverless/pull/10064)) ([4cbc342](https://github.com/serverless/serverless/commit/4cbc3424dabebb3b533d463b3ead523f2daf4a77)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - `rollback` command ([#10064](https://github.com/serverless/serverless/pull/10064)) ([f0970e0](https://github.com/serverless/serverless/commit/f0970e04fa31774aa7400b4c620920dadcb3cfa2)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - `uninstall` command ([#10034](https://github.com/serverless/serverless/pull/10034)) ([2787ea0](https://github.com/serverless/serverless/commit/2787ea07a9a183695e6f7a58bcc0171e086d456b)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - `upgrade` command ([#10034](https://github.com/serverless/serverless/pull/10034)) ([9b5e6b1](https://github.com/serverless/serverless/commit/9b5e6b12371317356d9cb4600a4a574df305f63f)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Ensure empty line prior final status with progress ([#10063](https://github.com/serverless/serverless/pull/10062)) ([#10062](https://github.com/serverless/serverless/pull/10062)) ([c9f2227](https://github.com/serverless/serverless/commit/c9f22278b3a8c5fd4d1400ef948ae6b72f333223)) ([Mariusz Nowak](https://github.com/medikoo)) + - Reconfigure dashboard related warning ([#10053](https://github.com/serverless/serverless/pull/10053)) ([7c91cde](https://github.com/serverless/serverless/commit/7c91cde7ac5c8bbe983b213de090bde4326af85a)) ([Mariusz Nowak](https://github.com/medikoo)) +- **AWS Deploy:** Improve error message ([#10063](https://github.com/serverless/serverless/pull/10063)) ([d071c5f](https://github.com/serverless/serverless/commit/d071c5f74d2d1deca71edebc53d072a1c90d8bad)) ([Mariusz Nowak](https://github.com/medikoo)) +- Remove _async_ handling from _sync_ function ([#10053](https://github.com/serverless/serverless/pull/10053)) ([5f1a916](https://github.com/serverless/serverless/commit/5f1a916d4d9c8833755833bc064f51e4f89e50e0)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.61.0](https://github.com/serverless/serverless/compare/v2.60.3...v2.61.0) (2021-10-04) + +### Features + +- **AWS Lambda:** Support 64-bit ARM architecture ([#10049](https://github.com/serverless/serverless/pull/10049)) ([fe655d4](https://github.com/serverless/serverless/commit/fe655d4f15ca789a1e3a46ce49dc7d23ca806c00)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Bug Fixes + +- **AWS Credentials:** Fail when profile is already configured ([#10038](https://github.com/serverless/serverless/pull/10038)) ([f8ad7bc](https://github.com/serverless/serverless/commit/f8ad7bca6a26e39864d139fec4aadddd24b34a5b)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Maintenance Improvements + +- **CLI: New logs (experimental):** + - `config credentials` command ([#10038](https://github.com/serverless/serverless/pull/10038)) ([bcb2408](https://github.com/serverless/serverless/commit/bcb240893d89127cc1eada7255864b7bfeb88a61)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - `config tabcompletion install` command ([#10038](https://github.com/serverless/serverless/pull/10038)) ([16a7739](https://github.com/serverless/serverless/commit/16a7739411141487fa33f8a72f88d82db712bfc9)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - `config tabcompletion uninstall` command ([#10038](https://github.com/serverless/serverless/pull/10038)) ([02eebb4](https://github.com/serverless/serverless/commit/02eebb4643435341235340f5da8c7db903cb12e6)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - `config` command ([#10038](https://github.com/serverless/serverless/pull/10038)) ([7926570](https://github.com/serverless/serverless/commit/7926570557e5c0a4dd661c069eecc1d4a0cf9b5d)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - `slstats` command ([#10036](https://github.com/serverless/serverless/pull/10036)) ([0c9dae1](https://github.com/serverless/serverless/commit/0c9dae1210b9456ec96bc38a717a901beaa45a7b)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### [2.60.3](https://github.com/serverless/serverless/compare/v2.60.2...v2.60.3) (2021-10-01) + +### Bug Fixes + +- **CLI:** Fix resolution of handler in case of local fallback ([#10042](https://github.com/serverless/serverless/pull/10042)) ([7d31410](https://github.com/serverless/serverless/commit/7d31410b74efb4c48c1c1b18ca33733a564268f2)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **CLI:** + - Improve modern `info` output ([#10037](https://github.com/serverless/serverless/pull/10037)) ([2828a2c](https://github.com/serverless/serverless/commit/2828a2c44388d731d4396e0ea11ae48953f20b0a)) ([Mariusz Nowak](https://github.com/medikoo)) + - Improve modern error reporting ([#10037](https://github.com/serverless/serverless/pull/10037)) ([a205f88](https://github.com/serverless/serverless/commit/a205f88310653331c96f51402d148c576dd79db8)) ([Mariusz Nowak](https://github.com/medikoo)) + - Improve modern logs for `logs` command ([#10037](https://github.com/serverless/serverless/pull/10037)) ([d1701bf](https://github.com/serverless/serverless/commit/d1701bf13a7155cce388424964e35ca536b2ce8a)) ([Mariusz Nowak](https://github.com/medikoo)) + - Modern logs for `install` command ([#10040](https://github.com/serverless/serverless/pull/10040)) ([bd4d215](https://github.com/serverless/serverless/commit/bd4d215266b16793c26d06a34af8482f00e47844)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Modern logs for `print` command ([#10035](https://github.com/serverless/serverless/pull/10035)) ([4ed34c3](https://github.com/serverless/serverless/commit/4ed34c3e5e21903a3fe9e512621739ef5bf0bd84)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Generalize `writeServiceOutputs` ([#10037](https://github.com/serverless/serverless/pull/10037)) ([8aa700d](https://github.com/serverless/serverless/commit/8aa700dc7947d36aa46bba4b0e475f21fd19ac89)) ([Mariusz Nowak](https://github.com/medikoo)) + +### [2.60.2](https://github.com/serverless/serverless/compare/v2.60.1...v2.60.2) (2021-09-30) + +### Bug Fixes + +- **AWS EventBridge:** Ensure proper support for `deadLetterQueueArn` (instead of `deadLetterConfig`) ([#10030](https://github.com/serverless/serverless/pull/10030)) ([846cfa1](https://github.com/serverless/serverless/commit/846cfa1bcf678a748678014c6359e5f0907d35ff)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### [2.60.1](https://github.com/serverless/serverless/compare/v2.60.0...v2.60.1) (2021-09-29) + +### Bug Fixes + +- **AWS EventBridge:** Fix `MaximumEventAgeInSecond` template reference ([#10023](https://github.com/serverless/serverless/issues/10023)) ([cd03f55](https://github.com/serverless/serverless/commit/cd03f550ae5307ca44e1e27d4d0822bef6cc9dcf)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Standalone:** + - Fix internal npm installation handling ([#10014](https://github.com/serverless/serverless/issues/10014)) ([5a583a9](https://github.com/serverless/serverless/commit/5a583a97980117209a614bfd40630b1bb714b744)) ([Mariusz Nowak](https://github.com/medikoo)) + - Upgrade `npm` version to one that supports Node.js v14 ([#10014](https://github.com/serverless/serverless/issues/10014)) ([62d697c](https://github.com/serverless/serverless/commit/62d697c8615e8103aa07401eef2ebae559cc4a17)) ([Mariusz Nowak](https://github.com/medikoo)) +- **CLI:** Fix handling when local `serverless` is removed in command run ([#10016](https://github.com/serverless/serverless/issues/10016)) ([1a3ccdb](https://github.com/serverless/serverless/commit/1a3ccdbef8cd9c41b87f7fe440ca300970f3e138)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **Plugins:** + - Seclude `plugin install` standalone command ([#9942](https://github.com/serverless/serverless/issues/9942)) ([713ac1e](https://github.com/serverless/serverless/commit/713ac1e2a111426fb501b5fa29588a53efcba9bc)) ([Seungchan Ahn](https://github.com/issea1015)) + - Seclude `plugin uninstall` standalone command ([#10015](https://github.com/serverless/serverless/issues/10015)) ([26ce1c6](https://github.com/serverless/serverless/commit/26ce1c636be7754584cf47a87f1b92d3b7d98122)) ([Seungchan Ahn](https://github.com/issea1015)) + - Fix manual update notice ([#10016](https://github.com/serverless/serverless/issues/10016)) ([0d5884e](https://github.com/serverless/serverless/commit/0d5884ebbf015332c08cedea7a4359d66c3a2761)) ([Mariusz Nowak](https://github.com/medikoo)) +- **CLI: New logs (experimental):** + - `plugin install` command ([#10016](https://github.com/serverless/serverless/issues/10016)) ([8c5f22c](https://github.com/serverless/serverless/commit/8c5f22ceb67c3a2f4ace3adf8e19cf5e69d4c7b3)) ([Mariusz Nowak](https://github.com/medikoo)) + - `plugin list` command ([#10016](https://github.com/serverless/serverless/issues/10016)) ([00e016c](https://github.com/serverless/serverless/commit/00e016c4bba86095744129d24683343f0cc5129f)) ([Mariusz Nowak](https://github.com/medikoo)) + - `plugin search` command ([#10016](https://github.com/serverless/serverless/issues/10016)) ([1463171](https://github.com/serverless/serverless/commit/1463171cae93e9e050350f6eb272e35cfade0204)) ([Mariusz Nowak](https://github.com/medikoo)) + - `plugin uninstall` command ([#10016](https://github.com/serverless/serverless/issues/10016)) ([3094be0](https://github.com/serverless/serverless/commit/3094be0cf06f916d8cf180036433677ecd73e013)) ([Mariusz Nowak](https://github.com/medikoo)) + - interactive setup ([#10024](https://github.com/serverless/serverless/issues/10024)) ([07aed34](https://github.com/serverless/serverless/commit/07aed3429c63ed13ad9ca6262c641a907170f4f9)) ([Mariusz Nowak](https://github.com/medikoo)) + - Local version fallback ([#10024](https://github.com/serverless/serverless/issues/10024)) ([231095d](https://github.com/serverless/serverless/commit/231095d28d4e3f137ef0a456692dd5d6a770a5db)) ([Mariusz Nowak](https://github.com/medikoo)) + - Rely on newly introduced log style functions ([#10024](https://github.com/serverless/serverless/issues/10024)) ([e070110](https://github.com/serverless/serverless/commit/e070110eee0e679694aefd4e6b5f25ecc90793d4)) ([Mariusz Nowak](https://github.com/medikoo)) + - Move variables resolution log to debug level ([#10016](https://github.com/serverless/serverless/issues/10016)) ([b0d854a](https://github.com/serverless/serverless/commit/b0d854af20d46ef9e07e5d4bce26b88e84f4c4f1)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.60.0](https://github.com/serverless/serverless/compare/v2.59.0...v2.60.0) (2021-09-24) + +### Features + +- **CLI:** + - Remove missing CLI options schema deprecation ([#10001](https://github.com/serverless/serverless/issues/10001)) ([5b38232](https://github.com/serverless/serverless/commit/5b38232e631e1fb6d944d5f323f533d7dd7b701f)) ([Mariusz Nowak](https://github.com/medikoo)) + - Revert from unconditional `.env` support announcement ([#10003](https://github.com/serverless/serverless/issues/10003)) ([40cdb4f](https://github.com/serverless/serverless/commit/40cdb4f1a191d330e31ddadc4caaa4b314229e3d)) ([Mariusz Nowak](https://github.com/medikoo)) +- **AWS Stream:** Support `tumblingWindowInSeconds` ([#9979](https://github.com/serverless/serverless/issues/9979)) ([af39fc0](https://github.com/serverless/serverless/commit/af39fc016bd6386ea7d5d1ff71a26553a25b7ec5)) ([Guilherme Martins Crocetti](https://github.com/gmcrocetti)) +- Support `finalize` hook, triggered on command finalization ([#9956](https://github.com/serverless/serverless/issues/9956)) ([cb4f08a](https://github.com/serverless/serverless/commit/cb4f08ad7dd8eed3da69d61d51c6d5379a486bd0)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Bug Fixes + +- **AWS S3:** Recognize `BucketKeyEnabled` setting ([#9985](https://github.com/serverless/serverless/issues/9985)) ([54bb13b](https://github.com/serverless/serverless/commit/54bb13b6a6d3fd41548615fc23f4ae4d6d663dcc)) ([John Armstrong](https://github.com/jlarmstrongiv)) +- **CLI:** Fix general help output when in context of AWS service ([#9994](https://github.com/serverless/serverless/issues/9994)) ([0833fd0](https://github.com/serverless/serverless/commit/0833fd03d17d292bd4393ecec9569328daae68d2)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Plugins:** Ensure to keep `options` as passed to plugins up to date ([#9999](https://github.com/serverless/serverless/issues/9999)) ([e3af1f3](https://github.com/serverless/serverless/commit/e3af1f3a94253a7900de104afaa1c49aa436965c)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Telemetry:** Ensure to not show backend notification on error ([#9999](https://github.com/serverless/serverless/issues/9999)) ([dce0ff1](https://github.com/serverless/serverless/commit/dce0ff1a892959b12414f1bff3915fe50b900ba2)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Templates + +- Improve source maps handling in `aws-nodejs-typescript` ([#9961](https://github.com/serverless/serverless/issues/9961)) ([28d230f](https://github.com/serverless/serverless/commit/28d230f946df6cbcc8173822494b50cd056ef63c)) ([Adrien Cacciaguerra](https://github.com/adriencaccia)) +- Switch to esbuild in `aws-nodejs-typescript` ([#9962](https://github.com/serverless/serverless/issues/9962)) ([aaabb50](https://github.com/serverless/serverless/commit/aaabb50f1beb12683506ca7ab9e93ded75294694)) ([Adrien Cacciaguerra](https://github.com/adriencaccia)) + +### Maintenance Improvements + +- Reorganize hooks resolution ([#9976](https://github.com/serverless/serverless/issues/9976)) ([76006ec](https://github.com/serverless/serverless/commit/76006ec1e80f51e194b51d4c0f2a11c64434158e)) ([Mariusz Nowak](https://github.com/medikoo)) +- Simplify lifecycle event hooks resolution ([#9976](https://github.com/serverless/serverless/issues/9976)) ([8b4498c](https://github.com/serverless/serverless/commit/8b4498c911e24ef7a46daf66380f1c122f988af3)) ([Mariusz Nowak](https://github.com/medikoo)) +- Replace `_.flatMap` usage ([#9948](https://github.com/serverless/serverless/issues/9948)) ([26b8bd5](https://github.com/serverless/serverless/commit/26b8bd5c5fd2154f47fa12804f1aee140000155f)) ([Jonas Matos](https://github.com/JonasMatos0)) +- **CLI: New logs (experimental):** + - Fix final `deploy` statuses timing ([#9967](https://github.com/serverless/serverless/issues/9967)) ([084a995](https://github.com/serverless/serverless/commit/084a9955f440ee18847df8a3087aba38405883b7)) ([Mariusz Nowak](https://github.com/medikoo)) + - Fix CloudFormation update resources status log in _verbose_ mode ([#9967](https://github.com/serverless/serverless/issues/9967)) ([bcd8a02](https://github.com/serverless/serverless/commit/bcd8a022a1e2e50a5d2708c374f4d5bcc30c80b5)) ([Mariusz Nowak](https://github.com/medikoo)) + - Ensure to strip colors from error messages ([#9967](https://github.com/serverless/serverless/issues/9967)) ([80005aa](https://github.com/serverless/serverless/commit/80005aaf6b57aa8d013fe4cda0be52d494cd4d78)) ([Mariusz Nowak](https://github.com/medikoo)) + - Ensure to write outputs on `info` ([#9991](https://github.com/serverless/serverless/issues/9991)) ([43d17de](https://github.com/serverless/serverless/commit/43d17debee20bfc7ee535fd643df0538f8bee9f8)) ([Mariusz Nowak](https://github.com/medikoo)) + - Present deprecations with single summary log ([#9960](https://github.com/serverless/serverless/issues/9960)) ([7eba95f](https://github.com/serverless/serverless/commit/7eba95fcb7f9b09a8a2aebd50c433f92e15cac97)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Add timer to final `deploy` statuses ([#9959](https://github.com/serverless/serverless/issues/9959)) ([7828cc7](https://github.com/serverless/serverless/commit/7828cc77f1fcea8f901887c12b07f5e18b34dcc8)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - _debug_ (previously _verbose_) `deploy` logs ([#9967](https://github.com/serverless/serverless/issues/9967)) ([655140b](https://github.com/serverless/serverless/commit/655140b764c8f2998188c3d47110494cbd742688)) ([Mariusz Nowak](https://github.com/medikoo)) + - Help output ([#9998](https://github.com/serverless/serverless/issues/9998)) ([b2df3cc](https://github.com/serverless/serverless/commit/b2df3cc0c8cba17c1995d3038e4a2caaca2f47f5)) ([Mariusz Nowak](https://github.com/medikoo)) + - `deploy function` command ([#9990](https://github.com/serverless/serverless/issues/9990)) ([4d42ce3](https://github.com/serverless/serverless/commit/4d42ce3fa4f44f63d68a3841752746021500fe4f)) ([Mariusz Nowak](https://github.com/medikoo)) + - `deploy list functions` command ([#10000](https://github.com/serverless/serverless/issues/10000)) ([ffbdfed](https://github.com/serverless/serverless/commit/ffbdfed292fdc379040052e6ec73107e5fdae5a8)) ([Mariusz Nowak](https://github.com/medikoo)) + - `deploy list` command ([#10000](https://github.com/serverless/serverless/issues/10000)) ([9d6482c](https://github.com/serverless/serverless/commit/9d6482c6710cb2d05c8c03a29e207881efcc0138)) ([Mariusz Nowak](https://github.com/medikoo)) + - `package` command ([#9956](https://github.com/serverless/serverless/issues/9956)) ([fa2507d](https://github.com/serverless/serverless/commit/fa2507dad06b037aa5a24b3392432cefc810a972)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - `deploy function` command ([#9990](https://github.com/serverless/serverless/issues/9990)) ([10df2e5](https://github.com/serverless/serverless/commit/10df2e5300e04ec9d00ebd343d9d8fe30c96afa7)) ([Mariusz Nowak](https://github.com/medikoo)) + - _verbose_ logs for `deploy` operation ([#9967](https://github.com/serverless/serverless/issues/9967)) ([e423404](https://github.com/serverless/serverless/commit/e423404290a757a8adfc97d45e9aef7aa93f1404)) ([Mariusz Nowak](https://github.com/medikoo)) + - dapt pre-created log style generators ([#9998](https://github.com/serverless/serverless/issues/9998)) ([8c9bd4a](https://github.com/serverless/serverless/commit/8c9bd4a6eda58d2ed6da08cc3bb806d970df4d17)) ([Mariusz Nowak](https://github.com/medikoo)) + - Convert custom resource packaging related log ([#9989](https://github.com/serverless/serverless/issues/9989)) ([0f0b85a](https://github.com/serverless/serverless/commit/0f0b85a6373dfcd9d21f1668e7fb3e0d20a3b393)) ([Mariusz Nowak](https://github.com/medikoo)) + - `logs` command ([#9991](https://github.com/serverless/serverless/issues/9991)) ([cbd2e64](https://github.com/serverless/serverless/commit/cbd2e64f705e54e37dd9116d0931a3a96bceaa88)) ([Mariusz Nowak](https://github.com/medikoo)) + - Refactor main progress event with `isMainEvent` option ([#9981](https://github.com/serverless/serverless/issues/9981)) ([a6553f8](https://github.com/serverless/serverless/commit/a6553f8668b66e2281626e7e79a3a2042279f92d)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.59.0](https://github.com/serverless/serverless/compare/v2.58.0...v2.59.0) (2021-09-14) + +### Features + +- **CLI Onboarding:** Switch to `httpApi`-based templates ([#9954](https://github.com/serverless/serverless/pull/9954)) ([12216db](https://github.com/serverless/serverless/commit/12216db579f7f2d055410f1ea9449825628631b7)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **CLI:** First iteration of support for `verbose` mode in `deploy` with modern logs ([#9952](https://github.com/serverless/serverless/pull/9952)) ([fbdd124](https://github.com/serverless/serverless/commit/fbdd124029d10ef029ee5446777db44f907e026c)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Bug Fixes + +- **AWS API Gateway:** Ensure consistent default for `cors` conf ([#9909](https://github.com/serverless/serverless/issues/9909)) ([7cd3966](https://github.com/serverless/serverless/commit/7cd3966897fa4432caf3f2bda0037df0c76e382b)) ([Seungchan Ahn](https://github.com/issea1015)) + +### Maintenance Improvements + +- Replace `_.pick` with native property assignment ([#9937](https://github.com/serverless/serverless/issues/9937)) ([6087fa3](https://github.com/serverless/serverless/commit/6087fa3400b508092a5113d40e4b2c4fd8ec22a7)) ([Jonas Matos](https://github.com/JonasMatos0)) + +## [2.58.0](https://github.com/serverless/serverless/compare/v2.57.0...v2.58.0) (2021-09-13) + +### Features + +- **AWS API Gateway:** Support `enabled` for `apiKeys` config ([#9918](https://github.com/serverless/serverless/pull/9918)) ([1107763](https://github.com/serverless/serverless/commit/1107763df8fb07a40ec45529f77d99e5a0f6d4d6)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS CloudFront:** Support `behavior.CachePolicyId` ([#9895](https://github.com/serverless/serverless/issues/9895)) ([3abc2f0](https://github.com/serverless/serverless/commit/3abc2f06428b72d964aa8683c34cdcf1d761d140)) ([Seungchan Ahn](https://github.com/issea1015)) +- **AWS EventBridge:** Support `deadLetterQueue` and `retryPolicy` ([#9903](https://github.com/serverless/serverless/pull/9903)) ([130fb38](https://github.com/serverless/serverless/commit/130fb3838fd3ea382caabffad74fde8a4041d4fc)) ([Eve](https://github.com/evemontalvao) & [JP Bochi](https://github.com/jpbochi)) +- **AWS ActiveMQ:** Add support for `activemq` event ([#8840](https://github.com/serverless/serverless/issues/8840)) ([cacb529](https://github.com/serverless/serverless/commit/cacb529925ed2b2c591984f48bc52cf31f88e698)) ([lewgordon](https://github.com/lewgordon) & [Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS Schedule:** Allow multiple `rate` expressions in single event ([#9892](https://github.com/serverless/serverless/pull/9892)) ([9f0bc68](https://github.com/serverless/serverless/commit/9f0bc689cc2ac3e53b4db665b899e1446ac37456)) ([Federico Jasson](https://github.com/federicojasson)) +- **CLI:** + - Configure log writing with new (experimental) log engine ([#9923](https://github.com/serverless/serverless/pull/9923)) ([ec93174](https://github.com/serverless/serverless/commit/ec93174b8ccfe1715ce3615dcb2223b145ad0f31)) ([Mariusz Nowak](https://github.com/medikoo)) + - Introduce first iteration of modern logs for `deploy` ([#9934](https://github.com/serverless/serverless/issues/9934)) ([171897d](https://github.com/serverless/serverless/commit/171897d60e5adaa590be1f08c99ab2cc76e89ee4)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Do not retry AWS requests if the token has expired ([#9914](https://github.com/serverless/serverless/issues/9914)) ([b0ca237](https://github.com/serverless/serverless/commit/b0ca2376bbfb543d98db1585c3a20a391e1791c6)) ([Mars Lan](https://github.com/mars-lan)) +- Support `error` hook to be triggered on command error ([#9936](https://github.com/serverless/serverless/pull/9936)) ([5c9766c](https://github.com/serverless/serverless/commit/5c9766c085531b04e169aa36a552159755029cca)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Bug Fixes + +- **AWS API Gateway:** Ensure proper `RequestValidator` name ([#9910](https://github.com/serverless/serverless/pull/9910)) ([510b1d1](https://github.com/serverless/serverless/commit/510b1d165924d000aa8e81e74e27c69ac1a2e0b6)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS CloudFront:** Recognize `behavior.TrustedKeyGroups` in schema ([#9884](https://github.com/serverless/serverless/pull/9884)) ([da71df6](https://github.com/serverless/serverless/commit/da71df603295397229589c88dd8366426e06e982)) ([Petr Reshetin](https://github.com/preshetin)) +- **AWS Lambda:** Recognize `Fn::If` function for `environment` ([#9905](https://github.com/serverless/serverless/pull/9905)) ([63743ad](https://github.com/serverless/serverless/commit/63743ade31207049eee1811203db5622bc510f1a)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Maintenance Improvements + +- **CLI:** + - Ensure no monkey patching by progress override ([#9923](https://github.com/serverless/serverless/pull/9923)) ([e46ce80](https://github.com/serverless/serverless/commit/e46ce80d99414ff730355efd1636bab71bb1771c)) ([Mariusz Nowak](https://github.com/medikoo)) + - Ensure to clear progress in expected time points ([#9928](https://github.com/serverless/serverless/pull/9928)) ([29aec52](https://github.com/serverless/serverless/commit/29aec529b53d7dd10f4ec61db7c0dc3859995d27)) ([Mariusz Nowak](https://github.com/medikoo)) +- Replace `fse.access` with `fs.promises.access` ([#9915](https://github.com/serverless/serverless/issues/9915)) ([5155e01](https://github.com/serverless/serverless/commit/5155e0180e0cd5e3130bc74e308a97c0ea1a5c2b)) ([Sudipto Das](https://github.com/sdas13)) +- Replace `fse.readFile` with `fs.promises.readFile` ([#9935](https://github.com/serverless/serverless/issues/9935)) ([f431218](https://github.com/serverless/serverless/commit/f431218790ae31efdc4e0a65a5b17a32605ede3e)) ([Sudipto Das](https://github.com/sdas13)) +- Use `getCompiledTemplateS3Suffix` from `provider.naming` ([#9926](https://github.com/serverless/serverless/pull/9926)) ([95d3024](https://github.com/serverless/serverless/commit/95d3024ef55ce80edf20fe27d9c72ffd15bba2bb)) ([Andreas Kohn](https://github.com/ankon)) +- Internal API to register service outputs ([#9933](https://github.com/serverless/serverless/pull/9933)) ([b425cf1](https://github.com/serverless/serverless/commit/b425cf1582623c1e796ae9f3d33dc060a9492cb5)) ([Mariusz Nowak](https://github.com/medikoo)) +- Register service outputs ([#9933](https://github.com/serverless/serverless/pull/9933)) ([312266e](https://github.com/serverless/serverless/commit/312266e90819866199354183641954636bd5a076)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Templates + +- Remove unnecessary `fmt.Sprintf` in `tencent-go` ([#9847](https://github.com/serverless/serverless/pull/9847)) ([e798c26](https://github.com/serverless/serverless/commit/e798c269df6f456bccf6a1e755015ea1e7631117)) ([kou](https://github.com/kou-pg-0131)) + +## [2.57.0](https://github.com/serverless/serverless/compare/v2.56.0...v2.57.0) (2021-08-31) + +### Features + +- **Variables:** Enable `env` variables in `provider.stage` property ([#9896](https://github.com/serverless/serverless/issues/9896)) ([bbb6c6c](https://github.com/serverless/serverless/commit/bbb6c6cd7dea9100af3ff84dd490b2cac1e2971e)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Bug Fixes + +- **AWS API Gateway:** + - Recognize CF functions at `functions[].events[].http.connectionId` ([#9894](https://github.com/serverless/serverless/issues/9894)) ([3e8858b](https://github.com/serverless/serverless/commit/3e8858b1a8cde32a3659498c6dbdc7d8637e86c6)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Recognize CF functions at `functions[].events[].http.request.headers[].mappedValue` ([#9894](https://github.com/serverless/serverless/issues/9894)) ([868ac02](https://github.com/serverless/serverless/commit/868ac02fd4d41a893d23a3f29101e3a3b952597b)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Recognize CF functions at `functions[].events[].http.request.uri` ([#9894](https://github.com/serverless/serverless/issues/9894)) ([13ce56a](https://github.com/serverless/serverless/commit/13ce56ae314dff1c157fc8351fc702bf15573fce)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Fix request validator triage ([#9887](https://github.com/serverless/serverless/issues/9887)) ([cb109dd](https://github.com/serverless/serverless/commit/cb109dd835ec358bfb1af10fe8f82aa283ffbafe)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Variables:** Fix new sources resolution error message at old resolver ([#9888](https://github.com/serverless/serverless/issues/9888)) ([8dece7f](https://github.com/serverless/serverless/commit/8dece7f6c6544f91366a2c8f70389be8b4b659c8)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **Variables:** Enable early `sls:stage` resolution ([#9890](https://github.com/serverless/serverless/issues/9890)) ([56e9423](https://github.com/serverless/serverless/commit/56e9423cd74dc05cc85b176bb1f0502f7ce05139)) ([Mariusz Nowak](https://github.com/medikoo)) +- Replace `fse.writeFile` with `fs.promises.writeFile` ([#9870](https://github.com/serverless/serverless/issues/9870)) ([05fff98](https://github.com/serverless/serverless/commit/05fff98a0003b22a66e8932c622c0e10c57bf06b)) ([Sudipto Das](https://github.com/sdas13)) +- Upgrade `filesize` to v8 ([#9901](https://github.com/serverless/serverless/issues/9901)) ([9a2511c](https://github.com/serverless/serverless/commit/9a2511cf90c60ba5b67ecea81121328c8dd93702)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.56.0](https://github.com/serverless/serverless/compare/v2.55.0...v2.56.0) (2021-08-25) + +### Features + +- **AWS EventBridge:** Support disabling a rule ([#9865](https://github.com/serverless/serverless/issues/9865)) ([6193d38](https://github.com/serverless/serverless/commit/6193d3867ec826898d4effbd641e49a35d9efbbc)) ([Jake Scott](https://github.com/jakejscott)) +- **AWS HTTP API:** Support `shouldStartNameWithService` option ([#9758](https://github.com/serverless/serverless/issues/9758)) ([ef5a8fa](https://github.com/serverless/serverless/commit/ef5a8faf13a8fbf8564e7c0621e88d1ea5357ea5)) ([Thiago Moraes](https://github.com/thiagomr)) +- **CLI Onboarding:** Improve onboarding messaging ([#9877](https://github.com/serverless/serverless/pull/9877)) ([f69a19c](https://github.com/serverless/serverless/commit/f69a19c6804366a34324e7cfcbbdb3f247a12b85)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Bug Fixes + +- **AWS HTTP API:** Always allow to define catch-all route ([#9840](https://github.com/serverless/serverless/issues/9840)) ([7e9bfd6](https://github.com/serverless/serverless/commit/7e9bfd63fce56f880a3ad0379fd97fdfce89d91b)) ([Karim Kanso](https://github.com/kazkansouh)) +- **CLI:** Mark `dashboard` command with optional service dependency ([#9874](https://github.com/serverless/serverless/pull/9874)) ([9a8e7e4](https://github.com/serverless/serverless/commit/9a8e7e44b44fdcf4c43d6e11c5eefa5051782506)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS Local Invocation:** Support `python3.9` runtime ([#9879](https://github.com/serverless/serverless/issues/9879)) ([ee17ee5](https://github.com/serverless/serverless/commit/ee17ee5aca25af152c2720a55199d92dfab3216d)) ([Shane R. Spencer](https://github.com/whardier)) +- **AWS Lambda:** Prevent external subscription filter removal for CloudWatch ([#9839](https://github.com/serverless/serverless/issues/9839)) ([afc9a13](https://github.com/serverless/serverless/commit/afc9a13386479f79b4c9ef64b65af5bbcdfaa68b)) ([Han Sang Hoon (한상훈)](https://github.com/poerty)) + +### Maintenance Improvements + +- Convert `upload` and `rollback` to `async/await` ([#9866](https://github.com/serverless/serverless/issues/9866)) ([0682ba8](https://github.com/serverless/serverless/commit/0682ba8b6a70d27e74c478d6e5fa5de71b9e0070)) ([Remigiusz Orłowski](https://github.com/remi00)) + +## [2.55.0](https://github.com/serverless/serverless/compare/v2.54.0...v2.55.0) (2021-08-18) + +### Features + +- **AWS Lambda:** Recognize `python3.9` as valid runtime ([#9854](https://github.com/serverless/serverless/pull/9854)) ([1aa24b8](https://github.com/serverless/serverless/commit/1aa24b8991032ba3fe6f2c4b65bf0e70bc4171dd)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Bug Fixes + +- **AWS HTTP API:** Properly handle authorizer function with alias (e.g. with `provisionedConcurrency`) ([#9850](https://github.com/serverless/serverless/pull/9850)) ([0ca6aaa](https://github.com/serverless/serverless/commit/0ca6aaae526b16df2039edff5db166a39bb1de10)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Maintenance Improvements + +- **CLI Onboarding:** Adjust summary messages in deploy step ([#9835](https://github.com/serverless/serverless/pull/9835)) ([b751c50](https://github.com/serverless/serverless/commit/b751c505c8050e229edb77d44016925c4e52a05e)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Replace `fse.stat` with `fs.promises.stat` ([#9845](https://github.com/serverless/serverless/issues/9845)) ([bb0484e](https://github.com/serverless/serverless/commit/bb0484e6b54a3cc6aed46ff23100e08c90c995ce)) ([Sudipto Das](https://github.com/sdas13)) +- **Telemetry:** Recognize `notificationsMode` ([#9851](https://github.com/serverless/serverless/pull/9851)) ([00fdba1](https://github.com/serverless/serverless/commit/00fdba154655b15b5b2de4b9ceca08f8bfce599e)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +## [2.54.0](https://github.com/serverless/serverless/compare/v2.53.1...v2.54.0) (2021-08-12) + +### Features + +- **AWS IAM:** Resign from deprecating old format of IAM settings ([#9778](https://github.com/serverless/serverless/pull/9778)) ([847dd8f](https://github.com/serverless/serverless/commit/847dd8f47503ddf03971122e5700110aa3ff77d1)) ([Mariusz Nowak](https://github.com/medikoo)) +- **AWS Lambda:** Add support for multiple subscription filters ([#9760](https://github.com/serverless/serverless/issues/9760)) ([5c9ca56](https://github.com/serverless/serverless/commit/5c9ca56d14a90dfd9aa5c064bd15137504336ed7)) ([Han Sang Hoon (한상훈)](https://github.com/poerty)) +- **AWS API Gateway:** Deprecate default for `identitySource` for `request` authorizers with disabled caching ([#9825](https://github.com/serverless/serverless/pull/9825)) ([0e01d9e](https://github.com/serverless/serverless/commit/0e01d9e337860b9d1136586fbfaf0c43ac21cde0)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **CLI:** Deprecate `-v` as alias for `--verbose` ([#9811](https://github.com/serverless/serverless/commit/53b41eb53aeefe22dc29b785a428f3b184906d2c)) ([53b41eb](https://github.com/serverless/serverless/commit/53b41eb53aeefe22dc29b785a428f3b184906d2c)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Bug Fixes + +- **AWS Deploy:** Ensure right code for `deploy -f` deprecation ([#9833](https://github.com/serverless/serverless/pull/9833)) ([90877d5](https://github.com/serverless/serverless/commit/90877d575ec9436db30a3a16fc90e5190ea30018)) ([Mariusz Nowak](https://github.com/medikoo)) +- **AWS Layers:** Support references to external layers ([#9826](https://github.com/serverless/serverless/pull/9826)) ([dc74f41](https://github.com/serverless/serverless/commit/dc74f41470447c1fab0a646c15284a4eb212ecb6)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **Variables:** Unconditionally deprecate old vars engine extensions ([#9827](https://github.com/serverless/serverless/pull/9827)) ([b7f4e08](https://github.com/serverless/serverless/commit/b7f4e08661cd149a29ae7107241a16928dc606eb)) ([Mariusz Nowak](https://github.com/medikoo)) + +### [2.53.1](https://github.com/serverless/serverless/compare/v2.53.0...v2.53.1) (2021-08-06) + +### Bug Fixes + +- **AWS API Gateway:** Ensure `MinimumCompressionSize` can be set to 0 ([#9806](https://github.com/serverless/serverless/issues/9806)) ([f0ae032](https://github.com/serverless/serverless/commit/f0ae032252f88d4d864c2bfe526d70064168231a)) ([Lewis Putz](https://github.com/Putzy)) + +### Maintenance Improvements + +- **CLI:** Change formatting of notifications ([#9807](https://github.com/serverless/serverless/issues/9807)) ([7c51f55](https://github.com/serverless/serverless/commit/7c51f55f5b8af6f853560ba5d757c65b1068a7ab)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Use `async` in `lib/utils` ([#9809](https://github.com/serverless/serverless/issues/9809)) ([48c3d99](https://github.com/serverless/serverless/commit/48c3d990beccef7dc3f4b5d29ec5bc4238fd9cf6)) ([Nyambayar Turbat](https://github.com/nyamba)) + +## [2.53.0](https://github.com/serverless/serverless/compare/v2.52.1...v2.53.0) (2021-08-04) + +### Features + +- **Variables:** Accept case-insensitive strings in `strToBool` ([#9770](https://github.com/serverless/serverless/issues/9770)) ([612f668](https://github.com/serverless/serverless/commit/612f668c931013bea21b91f47d9cbfd1c7dbb888)) ([Shane R. Spencer](https://github.com/whardier)) + +### Bug Fixes + +- **AWS API Gateway:** Ensure to attach validator when required parameters are defined ([#9793](https://github.com/serverless/serverless/issues/9793)) ([d275459](https://github.com/serverless/serverless/commit/d2754594c462afd39e1576312e361ca57d4f13f2)) ([Karim Kanso](https://github.com/kazkansouh)) +- **Plugins:** Improve error message when a plugin is missing ([#9798](https://github.com/serverless/serverless/issues/9798)) ([5c9df56](https://github.com/serverless/serverless/commit/5c9df56f1bc89af1fd929519f3cf8dac967e514d)) ([Matthieu Napoli](https://github.com/mnapoli)) + +### Maintenance Improvements + +- **Telemetry:** Recognize used variable sources ([#9790](https://github.com/serverless/serverless/pull/9790)) ([60d729b](https://github.com/serverless/serverless/commit/60d729b5d42ae32cc418b9578582da3dc8492754)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Replace `fse.readdir` with `fs.promises.readdir` ([#9780](https://github.com/serverless/serverless/issues/9780)) ([1e00f9e](https://github.com/serverless/serverless/commit/1e00f9edfb5f7618759f9f03d0dad58701a5a27a)) ([Sudipto Das](https://github.com/sdas13)) +- Use `async` in `lib/plugins/create` ([#9683](https://github.com/serverless/serverless/issues/9683)) ([4b87497](https://github.com/serverless/serverless/commit/4b87497875a19348e444763eea85671ed2c4f0b7)) ([Nyambayar Turbat](https://github.com/nyamba)) +- Use `async` in `lib/plugins/plugin` ([#9680](https://github.com/serverless/serverless/issues/9680)) ([377da09](https://github.com/serverless/serverless/commit/377da097c564778c8d2c42ffe49e38000c520106)) ([Nyambayar Turbat](https://github.com/nyamba)) + +### [2.52.1](https://github.com/serverless/serverless/compare/v2.52.0...v2.52.1) (2021-07-22) + +### Bug Fixes + +- **CLI Onboarding:** Ensure credentials resolution is always performed before deploy step ([#9761](https://github.com/serverless/serverless/pull/9761)) ([b85f393](https://github.com/serverless/serverless/commit/b85f3934ed87e9c78494e9ad26163ee1d041599e)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **CLI:** + - Ensure `processedInput` is properly resolved in local fallback ([#9769](https://github.com/serverless/serverless/pull/9769)) ([464467e](https://github.com/serverless/serverless/commit/464467e2bece1bf3f35fe60041fa170f412087d3)) ([Mariusz Nowak](https://github.com/medikoo)) + - Fix validation of `deprecationNotificationMode` config option ([#9762](https://github.com/serverless/serverless/issues/9762)) ([916c76f](https://github.com/serverless/serverless/commit/916c76f48ca86c3e31b719d2bb655c34d0287cec)) ([frozenbonito](https://github.com/frozenbonito)) +- Fix `functions[]` validation (ignore `null` values) ([#9756](https://github.com/serverless/serverless/pull/9756)) ([922ec00](https://github.com/serverless/serverless/commit/922ec0093f0d4ab6f2b2055c6e6f2d5ec1f9d06e)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **CLI Onboarding:** + - Move `dashboard-login` step from `@serverless/dashboard-plugin` ([#9766](https://github.com/serverless/serverless/pull/9766)) ([adef710](https://github.com/serverless/serverless/commit/adef7102df2958e976445f0c247895f82decebf9)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Move `dashboard-set-org` from `@serverless/dashboard-plugin` ([#9766](https://github.com/serverless/serverless/pull/9766)) ([afdf77c](https://github.com/serverless/serverless/commit/afdf77c960c990f7daa445532789aebb9dc15a53)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **Telemetry:** Use `prompt-with-history` for onboarding telemetry ([#9768](https://github.com/serverless/serverless/pull/9768)) ([4d56be5](https://github.com/serverless/serverless/commit/4d56be562a4bdaf2588bdc42227a451d098d1420)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Replace `fse.unlink` with `fs.promises.unlink` ([#9754](https://github.com/serverless/serverless/issues/9754)) ([daee1d5](https://github.com/serverless/serverless/commit/daee1d5375efdb748b85b85a2a4675ac3277001f)) ([Sudipto Das](https://github.com/sdas13)) + +## [2.52.0](https://github.com/serverless/serverless/compare/v2.51.2...v2.52.0) (2021-07-15) + +### Features + +- **AWS CloudFormation:** Allow to disable default export names ([#9748](https://github.com/serverless/serverless/pull/9748)) ([6f49488](https://github.com/serverless/serverless/commit/6f494888cc01853894ec33859edbd77a06dc9d76)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **CLI:** Automatically expand loaded env variables from `.env` files ([#9615](https://github.com/serverless/serverless/issues/9615)) ([1864969](https://github.com/serverless/serverless/commit/186496922a0c4d69f3101dde0a9f4a0d89995ad0)) ([David Asensio Cañas](https://github.com/d-asensio)) + +### Bug Fixes + +- **CLI:** Do not validate configuration with `plugin ..` commands ([#9741](https://github.com/serverless/serverless/pull/9741)) ([040036d](https://github.com/serverless/serverless/commit/040036d1869ceb207da6dad53f17e1ee1b6ee20a)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Variables:** In `ssm` source auto parse only object JSON notation ([#9747](https://github.com/serverless/serverless/pull/9747)) ([8c741d1](https://github.com/serverless/serverless/commit/8c741d1d97f021995f37a61d7340ddfa749cdab9)) ([Mariusz Nowak](https://github.com/medikoo)) +- Improve `functions` validation ([#9741](https://github.com/serverless/serverless/pull/9741)) ([3e58d62](https://github.com/serverless/serverless/commit/3e58d628e7b8f4dbc8e14adf94dd98546099f3be)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **Telemetry:** Record initial context for interactive setup ([#9736](https://github.com/serverless/serverless/pull/9736)) ([560aee5](https://github.com/serverless/serverless/commit/560aee5feb9f143e93933f6536e76edc9a3e56bb)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **CLI:** Reuse already imported module ([#9741](https://github.com/serverless/serverless/pull/9741)) ([be441cc](https://github.com/serverless/serverless/commit/be441ccd9157b351fffe6ea21664624aeeeb4b29)) ([Mariusz Nowak](https://github.com/medikoo)) +- Add `has-local-credentials` util ([#9736](https://github.com/serverless/serverless/pull/9736)) ([82a35b3](https://github.com/serverless/serverless/commit/82a35b3903ad5d8f761612105036fc11a37e9e55)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### [2.51.2](https://github.com/serverless/serverless/compare/v2.51.1...v2.51.2) (2021-07-08) + +### Bug Fixes + +- **Packaging:** Fix `package.artifact` validation for S3 urls ([#9725](https://github.com/serverless/serverless/issues/9725)) ([ab3c543](https://github.com/serverless/serverless/commit/ab3c543089b0fde4107fc0e579c19f85e0a4ee79)) ([Mariusz Nowak](https://github.com/medikoo)) + +### [2.51.1](https://github.com/serverless/serverless/compare/v2.51.0...v2.51.1) (2021-07-08) + +### Bug Fixes + +- **CLI:** Fix `SIGINT` signal handling ([#9712](https://github.com/serverless/serverless/issues/9712)) ([c5a3f69](https://github.com/serverless/serverless/commit/c5a3f6907a115ea2d511b0aa9905a2e762514867)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Packaging:** Validate `package.artifact` paths ([#9721](https://github.com/serverless/serverless/issues/9721)) ([21c0fed](https://github.com/serverless/serverless/commit/21c0fedc507651bb98687acc4145ed667d853589)) ([Mariusz Nowak](https://github.com/medikoo)) +- **AWS Local Invocation:** Bump AWS Java pom version to pull in fix ([#9714](https://github.com/serverless/serverless/issues/9714)) ([504b42a](https://github.com/serverless/serverless/commit/504b42ae0fefd04ccfa013746371c49a02d8a4d3)) ([tlloyd-synalogik](https://github.com/tlloyd-synalogik)) + +### Maintenance Improvements + +- **Telemetry:** + - Report all interruption signals ([#9712](https://github.com/serverless/serverless/issues/9712)) ([7354c20](https://github.com/serverless/serverless/commit/7354c2000f25d526f8c3fd97c6d4d22054388755)) ([Mariusz Nowak](https://github.com/medikoo)) + - Report whether we're in context of TTY terminal ([#9712](https://github.com/serverless/serverless/issues/9712)) ([9cea555](https://github.com/serverless/serverless/commit/9cea555e88bdaadf717def21b5298a64c7ce79b9)) ([Mariusz Nowak](https://github.com/medikoo)) + - Ensure no doubled telemetry in edge cases ([#9716](https://github.com/serverless/serverless/issues/9716)) ([fd5005e](https://github.com/serverless/serverless/commit/fd5005e404debe103ca54974ca9aee431554ceb8)) ([Mariusz Nowak](https://github.com/medikoo)) +- **CLI:** Improve module imports order ([#9712](https://github.com/serverless/serverless/issues/9712)) ([dff2799](https://github.com/serverless/serverless/commit/dff2799941a1da8c2d5fe76144393db241a7637c)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.51.0](https://github.com/serverless/serverless/compare/v2.50.0...v2.51.0) (2021-07-06) + +### Features + +- **AWS Kafka:** Add support for `SASL/PLAIN` auth to `kafka` event ([#9666](https://github.com/serverless/serverless/pull/9666)) ([3e14f06](https://github.com/serverless/serverless/commit/3e14f063052385026425021379bfc883dac5ff74)) ([Daniele Iasella](https://github.com/overbit)) +- **CLI:** New `warn:summary` (default) deprecations logging mode ([#9693](https://github.com/serverless/serverless/pull/9693)) ([9b624a5](https://github.com/serverless/serverless/commit/9b624a50677a0363c052b4ea567c050af7863073)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Bug Fixes + +- **CLI:** Recognize `--verbose` option in `info` command ([#9695](https://github.com/serverless/serverless/pull/9695)) ([b124152](https://github.com/serverless/serverless/commit/b1241522ec378f7b7b431050ddc861fef040efc4)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **CLI:** Fix typo in error message ([#9682](https://github.com/serverless/serverless/issues/9682)) ([f16c45f](https://github.com/serverless/serverless/commit/f16c45f84b8be1e469bfdd92191fc760b8f1631e)) ([KIDANI Akito](https://github.com/kdnakt)) +- **Telemetry:** + - Properly handle situation when not in service dir in credentials step ([#9678](https://github.com/serverless/serverless/pull/9678)) ([b21c1e4](https://github.com/serverless/serverless/commit/b21c1e415b67cdc8f1fb0ab14152eaf3c6550894)) + - Ensure to pass all steps with configured questions ([#9701](https://github.com/serverless/serverless/pull/9701)) ([b5d3167](https://github.com/serverless/serverless/commit/b5d3167e9fdd5f08af1389b975322f2146b22507)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Correctly report `outcome` for interactive setup ([#9699](https://github.com/serverless/serverless/pull/9699)) ([0c5b8dd](https://github.com/serverless/serverless/commit/0c5b8dd831bcde80628c2ac548172ffaa9ce9ca6)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Ensure telemetry generation and related utils are sync ([#9692](https://github.com/serverless/serverless/pull/9692)) ([e65199c](https://github.com/serverless/serverless/commit/e65199c05213e1bac17acedc84cdd6dfd26ff00a)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Report `commandUsage` as object ([#9690](https://github.com/serverless/serverless/pull/9690)) ([cc24bc2](https://github.com/serverless/serverless/commit/cc24bc2ae280237b3d439e1934ab75710e0f259f)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Handle interruptions and persist telemetry data ([#9699](https://github.com/serverless/serverless/pull/9699)) ([502f7e7](https://github.com/serverless/serverless/commit/502f7e711f0954c2960fb790b749002aeb1789fc)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Drop old variables engine related deprecation ([#9698](https://github.com/serverless/serverless/pull/9698)) ([5b54ed2](https://github.com/serverless/serverless/commit/5b54ed2e2685c24439c0f835b50a024dbf9d39a9)) ([Mariusz Nowak](https://github.com/medikoo)) +- Make deprecations default mode internally modifyable ([#9693](https://github.com/serverless/serverless/pull/9693)) ([07a69a8](https://github.com/serverless/serverless/commit/07a69a836c506e3ab8ab976ef27d4f3b672722f7)) ([Mariusz Nowak](https://github.com/medikoo)) +- Replace `fse.createWriteStream` with `fs.createWriteStream` ([#9687](https://github.com/serverless/serverless/pull/9687)) ([3500f64](https://github.com/serverless/serverless/commit/3500f641f5212f196f75081e67d1d1518ac3bb6b)) ([Sudipto Das](https://github.com/sdas13)) +- Use `async` in `lib/plugins/package` ([#9644](https://github.com/serverless/serverless/issues/9644)) ([db67b35](https://github.com/serverless/serverless/commit/db67b353c9ed578d7dd334d162efa1ec11fbfa18)) ([Nyambayar Turbat](https://github.com/nyamba)) + +## [2.50.0](https://github.com/serverless/serverless/compare/v2.49.0...v2.50.0) (2021-07-01) + +### Features + +- **AWS Lambda:** Support `Fn::If` for `Principal.AWS` ([#9664](https://github.com/serverless/serverless/pull/9664)) ([894ac5b](https://github.com/serverless/serverless/commit/894ac5b6b67eb384dbc29b927161121679afce2d)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS Deploy:** Deprecate `function` option in `deploy` command ([#9364](https://github.com/serverless/serverless/pull/9364)) ([d861d11](https://github.com/serverless/serverless/commit/d861d119ef94baaaa266934783e00a50182d7434)) ([Jaakko Lappalainen](https://github.com/jkklapp) & [Piotr Grzesik](https://github.com/pgrzesik)) +- **Variables:** + - Resolve vars in strings which are subject to be joined ([#9657](https://github.com/serverless/serverless/pull/9657)) ([0e3db01](https://github.com/serverless/serverless/commit/0e3db01db8aeb08b03a98dd7f58a09b66ec8c49e)) ([Mariusz Nowak](https://github.com/medikoo)) + - Support `aws:region` and `aws:accountId` variables ([#9662](https://github.com/serverless/serverless/pull/9662)) ([33794ea](https://github.com/serverless/serverless/commit/33794ea504e714912137796009c29c802f2e24f0)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Support variables across file address resolution ([#9657](https://github.com/serverless/serverless/pull/9657)) ([80b7640](https://github.com/serverless/serverless/commit/80b76406ac305ccb7e55cabd0bd39be6ac7c67c6)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Bug Fixes + +- **AWS Deploy:** Meaningfully report inaccessible file artifacts ([#9668](https://github.com/serverless/serverless/pull/9668)) ([23c290e](https://github.com/serverless/serverless/commit/23c290e4b4049242d62cfb57f4be6aadff6aecf8)) ([Mariusz Nowak](https://github.com/medikoo)) +- **AWS Local Invocation:** Fix error handling of invalid file content ([#9667](https://github.com/serverless/serverless/pull/9667)) ([e836722](https://github.com/serverless/serverless/commit/e836722f976af98eb69fc6d3a85781bb7434dfac)) ([Mariusz Nowak](https://github.com/medikoo)) +- **CLI Onboarding:** + - Do not attempt local fallback during onboarding ([#9660](https://github.com/serverless/serverless/pull/9660)) ([ae5be0f](https://github.com/serverless/serverless/commit/ae5be0f5dafaad933000e98142fcb1ec60e04555)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Only call `handleError` if plugin defined ([#9659](https://github.com/serverless/serverless/pull/9659)) ([a80681f](https://github.com/serverless/serverless/commit/a80681ffbf23391cb31d34b8eecaef310d9599a3)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Maintenance Improvements + +- **Telemetry:** + - Include `commandUsage` in case of error ([#9671](https://github.com/serverless/serverless/pull/9671)) ([ac03d83](https://github.com/serverless/serverless/commit/ac03d832896eec26773e5ce06c22c249d240a9ed)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Increase error location coverage ([#9669](https://github.com/serverless/serverless/pull/9669)) ([7264d16](https://github.com/serverless/serverless/commit/7264d1672e93fdb1046cf7ebe859b607c80e31ca)) ([Mariusz Nowak](https://github.com/medikoo)) + - Report `configValidationMode` ([#9669](https://github.com/serverless/serverless/pull/9669)) ([8e2d48f](https://github.com/serverless/serverless/commit/8e2d48fee5a471a960b6a7b55cbd12edc5eb07e6)) ([Mariusz Nowak](https://github.com/medikoo)) + - Report configuration validation result ([#9669](https://github.com/serverless/serverless/pull/9669)) ([01f1586](https://github.com/serverless/serverless/commit/01f158695b22d721320a77a9a0b68b166c63dc3f)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Templates + +- Adjust `runtime` for `openwhisk-python` template ([#9670](https://github.com/serverless/serverless/pull/9670)) ([6a020d1](https://github.com/serverless/serverless/commit/6a020d121ff2dacd6ad62a824964944ae391a662)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +## [2.49.0](https://github.com/serverless/serverless/compare/v2.48.1...v2.49.0) (2021-06-29) + +### Features + +- **AWS Lambda:** Support `Fn::FindInMap` for `vpc` config ([#9653](https://github.com/serverless/serverless/pull/9653)) ([34a9d91](https://github.com/serverless/serverless/commit/34a9d91870c36d154427830d3555425b5fd2d14c)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **CLI Onboarding:** + - Add deploy step ([#9536](https://github.com/serverless/serverless/pull/9536)) ([28a06a0](https://github.com/serverless/serverless/commit/28a06a05aba4306d2f28d26652067b44ed105151)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Allow to setup Dashboard Provider credentials during onboarding ([#9509](https://github.com/serverless/serverless/pull/9509)) ([feb0421](https://github.com/serverless/serverless/commit/feb04219f6be186cc54462906394bbd82f9747b5)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Bug Fixes + +- **CLI:** Fix standalone detection on Windows ([#9648](https://github.com/serverless/serverless/pull/9648)) ([4bc8e2e](https://github.com/serverless/serverless/commit/4bc8e2e1944364e2c218cbfc05039c43afa9ab01)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Packaging:** Fix artifact generation with temp path on other device ([#9616](https://github.com/serverless/serverless/issues/9616)) ([70fb8b9](https://github.com/serverless/serverless/commit/70fb8b986133789b38fad93c0abab01eaf9dc0c7)) ([Sean Dawson](https://github.com/NoxHarmonium)) + +### Maintenance Improvements + +- Replace `fse.chmod` with `fs.promises.chmod` ([#9647](https://github.com/serverless/serverless/issues/9647)) ([83c7726](https://github.com/serverless/serverless/commit/83c772684d655b233522d1e75128476c29339c83)) ([Sudipto Das](https://github.com/sdas13)) +- Add `resolveRegion` util ([#9509](https://github.com/serverless/serverless/pull/9509)) ([98e3668](https://github.com/serverless/serverless/commit/98e3668a2cbb701c109e1ff8dd70a0ece1770f7b)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Add `resolveStage` util ([#9509](https://github.com/serverless/serverless/pull/9509)) ([09bb4fa](https://github.com/serverless/serverless/commit/09bb4fa12270807702dcc26483dbcb94cf733342)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **Telemetry:** + - Add `hasLocalCredentials` ([#9594](https://github.com/serverless/serverless/pull/9594)) ([5e0d805](https://github.com/serverless/serverless/commit/5e0d80579e857d016fb4db13288b9d81a3859ee1)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Add interactive flow support ([#9594](https://github.com/serverless/serverless/pull/9594)) ([0eba2dc](https://github.com/serverless/serverless/commit/0eba2dcdfeabba58920462ac2cd54d86e3101e05)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Templates + +- Use `amd64` arch for `aws-go` template ([#9646](https://github.com/serverless/serverless/issues/9646)) ([cb9f7e2](https://github.com/serverless/serverless/commit/cb9f7e20eedc1db7bb31671c97449e269e992ded)) ([Andrey Kabylin](https://github.com/sysint64)) + +### [2.48.1](https://github.com/serverless/serverless/compare/v2.48.0...v2.48.1) (2021-06-25) + +### Bug Fixes + +- **AWS API Gateway:** Ensure that `Method` resource depends on `Permission` resource ([#9609](https://github.com/serverless/serverless/pull/9609)) ([93b9027](https://github.com/serverless/serverless/commit/93b9027f0d48650df50d0a8352d0edaf2bd2e0da)) ([Nyambayar Turbat](https://github.com/nyamba)) +- **CLI:** + - Ensure to list version in case of fallback from some versions ([#9641](https://github.com/serverless/serverless/pull/9641)) ([989cb82](https://github.com/serverless/serverless/commit/989cb82db313177a64e062cc800eb85ba501fab5)) ([Mariusz Nowak](https://github.com/medikoo)) + - Fix standalone detection (case of a fallback from standalone) ([#9641](https://github.com/serverless/serverless/pull/9641)) ([1681af4](https://github.com/serverless/serverless/commit/1681af4897eeec20c1d1af292f9bfde5b1e9ffc3)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **Config Schema:** Improve error message and documentation ([#9639](https://github.com/serverless/serverless/pull/9639)) ([a36247b](https://github.com/serverless/serverless/commit/a36247b7ac1212a27f5e8d671ba39ba4c7e4de18)) ([Mariusz Nowak](https://github.com/medikoo)) +- Replace `fse.rename` with `fs.promises.rename` ([#9605](https://github.com/serverless/serverless/issues/9605)) ([e6ff228](https://github.com/serverless/serverless/commit/e6ff2286a55d8cb8f82e58d8173b0a386a4b1767)) ([Sudipto Das](https://github.com/sdas13)) + +## [2.48.0](https://github.com/serverless/serverless/compare/v2.47.0...v2.48.0) (2021-06-21) + +### Features + +- Introduce an opt-in "error" deprecation notification mode ([#9623](https://github.com/serverless/serverless/pull/9623)) ([c22a8b9](https://github.com/serverless/serverless/commit/c22a8b99f2f64a76c592e800a8cf698dbff75b9c)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Bug Fixes + +- **Packaging:** Do not report hashing deprecations for container lambdas ([#9623](https://github.com/serverless/serverless/pull/9623)) ([68c2a08](https://github.com/serverless/serverless/commit/68c2a084f91b58832bd5417efaaa3fd6a6178d53)) ([Mariusz Nowak](https://github.com/medikoo)) +- Ensure to support deprecation settings at early stage of processing ([#9623](https://github.com/serverless/serverless/pull/9623))([011e0ce](https://github.com/serverless/serverless/commit/011e0ce45cec4b1273268fcab4f99e377fae092e)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **Telemetry:** Recognize `constructs` ([#9628](https://github.com/serverless/serverless/pull/9628)) ([9e10cea](https://github.com/serverless/serverless/commit/9e10ceaf81e8b9d13867937fedc9502a1ff4e320)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Ensure early access to configuration in logDeprecation method ([#9623](https://github.com/serverless/serverless/pull/9623)) ([53b9762](https://github.com/serverless/serverless/commit/53b97621dccdef8f9f2e15e2f4f31045b46970e2)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.47.0](https://github.com/serverless/serverless/compare/v2.46.0...v2.47.0) (2021-06-18) + +### Features + +- Deprecate Node.js v10 ([#9600](https://github.com/serverless/serverless/issues/9600)) ([e24fdc9](https://github.com/serverless/serverless/commit/e24fdc9f08f9849aad4136261695e44476484b0d)) ([Milind Vaidya](https://github.com/vaidyamilind)) +- **AWS HTTP API:** Support `payload` version per function ([#9551](https://github.com/serverless/serverless/issues/9551)) ([87ce28e](https://github.com/serverless/serverless/commit/87ce28ee4ea0e975859b8d32be8f2edd824b4cda)) ([Nyambayar Turbat](https://github.com/nyamba)) +- **AWS S3:** Support CloudFormation instrinsic functions at `functions[].events[].s3.bucket` property ([#9617](https://github.com/serverless/serverless/issues/9617)) ([42690a7](https://github.com/serverless/serverless/commit/42690a7352751581a8dbd44a4f776af17ab20da8)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Bug Fixes + +- **AWS Cognito:** Fix user pool premission resource logical id normalization ([#9592](https://github.com/serverless/serverless/issues/9592)) ([f4c9b58](https://github.com/serverless/serverless/commit/f4c9b58b10a45ae342934e9a61dcdea0c2ef11e2)) ([arunkc](https://github.com/Arun-kc)) +- **AWS Invocation:** Fix resolution of options with non-AWS provider ([#9602](https://github.com/serverless/serverless/issues/9602)) ([54da80e](https://github.com/serverless/serverless/commit/54da80e26497b8f1dbcd3027775628d11e1c6814)) ([Corentin Doue](https://github.com/CorentinDoue)) +- **Variables:** Ensure to strip unrecognized legacy `ssm` resolver instructions ([#9601](https://github.com/serverless/serverless/issues/9601)) ([f61859f](https://github.com/serverless/serverless/commit/f61859fd25908b13b6d9638c550e88ef4a08392e)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **Variables:** Improve error message ([#9601](https://github.com/serverless/serverless/issues/9601)) ([4a732e2](https://github.com/serverless/serverless/commit/4a732e2ebf6c7d81f5e0fbdc2e9bcb4715e4cadf)) ([Mariusz Nowak](https://github.com/medikoo)) + +### [2.46.0](https://github.com/serverless/serverless/compare/v2.45.2...v2.46.0) (2021-06-11) + +### Features + +- **CLI Onboarding:** Make it service setup specific, remove `auto-update` step ([#9582](https://github.com/serverless/serverless/pull/9582)) ([519f77e](https://github.com/serverless/serverless/commit/519f77e1a876cea62843a99e58bab1e011e62fa3)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **Config Schema:** Improve error messaging for same type variants ([#9588](https://github.com/serverless/serverless/pull/9588)) ([8ac249b](https://github.com/serverless/serverless/commit/8ac249b1eadf3173359e02886e71bb89234ebd51)) ([Mariusz Nowak](https://github.com/medikoo)) +- Show information on how to turn on auto updates in postinstall step ([#9582](https://github.com/serverless/serverless/pull/9582)) ([93c88c0](https://github.com/serverless/serverless/commit/93c88c0b8d1eea6455ca6ecb9a022f814f8e79b3)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Bug Fixes + +- **Variables:** + - Fix resolution visibility of top level properties (as `outputs`) ([#9591](https://github.com/serverless/serverless/pull/9591)) ([004c6e2](https://github.com/serverless/serverless/commit/004c6e26beec98fbfb757aab05f18a623a03cf76)) ([Mariusz Nowak](https://github.com/medikoo)) + - Improve required properties resolution validation order ([#9591](https://github.com/serverless/serverless/pull/9591)) ([727d7f4](https://github.com/serverless/serverless/commit/727d7f4f089051223db88ceb85a62adabf07dc9e)) ([Mariusz Nowak](https://github.com/medikoo)) + - Meaningfully report misuse of dashboard sources ([#9591](https://github.com/serverless/serverless/pull/9591)) ([cc09c62](https://github.com/serverless/serverless/commit/cc09c62301f15f89febc50120a7a398640935470)) ([Mariusz Nowak](https://github.com/medikoo)) + - Recognize `tenant` setting (while deprecated it's still recognized by plugin) ([#9591](https://github.com/serverless/serverless/pull/9591)) ([aa45876](https://github.com/serverless/serverless/commit/aa4587604476314485a8094bdae04e0148b9e53c)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- Reorganize and document service configuration dependencies ([#9591](https://github.com/serverless/serverless/pull/9591)) ([c86a76c](https://github.com/serverless/serverless/commit/c86a76cb60038765404c988da13dfc6ffde28fe6)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Telemetry:** Optimise reported error location length: + - Remove eventual `/node_modules` prefix ([#9587](https://github.com/serverless/serverless/pull/9587)) ([f3ff6d2](https://github.com/serverless/serverless/commit/f3ff6d21758b61116c748746cefe8c1a3d6ab776)) ([Mariusz Nowak](https://github.com/medikoo)) + - Replace repeated paths with `^` ([#9587](https://github.com/serverless/serverless/pull/9587)) ([f6a7d03](https://github.com/serverless/serverless/commit/f6a7d03b04bd13f91bc247e518a1ad12496ead8c)) ([Mariusz Nowak](https://github.com/medikoo)) + +### [2.45.2](https://github.com/serverless/serverless/compare/v2.45.1...v2.45.2) (2021-06-09) + +### Bug Fixes + +- **Variables:** + - Skip unrecognized sources check with partial resolution ([#9579](https://github.com/serverless/serverless/pull/9579)) ([93b89fc](https://github.com/serverless/serverless/commit/93b89fcb51759d0fe938a40e7de76b6abd313efd)) ([Mariusz Nowak](https://github.com/medikoo)) + - Ensure to report only unrecognized sources ([#9579](https://github.com/serverless/serverless/pull/9579)) ([98701f3](https://github.com/serverless/serverless/commit/98701f367907aa4c0ed61de7c3aeb4a7b7eac174)) ([Mariusz Nowak](https://github.com/medikoo)) + +### [2.45.1](https://github.com/serverless/serverless/compare/v2.45.0...v2.45.1) (2021-06-08) + +### Bug Fixes + +- Fix `projectDir` pattern in config schema ([#9574](https://github.com/serverless/serverless/pull/9574)) ([8954b5f](https://github.com/serverless/serverless/commit/8954b5f9cc3e2431036ccb876c46fb8cc99dc0d9)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.45.0](https://github.com/serverless/serverless/compare/v2.44.0...v2.45.0) (2021-06-08) + +### Features + +- **Variables:** Allow to reference files in scope of a project directory ([#9561](https://github.com/serverless/serverless/pull/9561)) ([8dbb56e](https://github.com/serverless/serverless/commit/8dbb56ecbda2c6b8e8eaccbba7c7842ba8382847)) ([Mariusz Nowak](https://github.com/medikoo)) +- Introduce project directory setting, configurable via `projectDir` ([#9561](https://github.com/serverless/serverless/pull/9561)) ([d6e4b49](https://github.com/serverless/serverless/commit/d6e4b49ae28d5898d92b913a0d2c100bd29f4303)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Bug Fixes + +- **AWS API Gateway:** Don't create log group resource if access logs are disabled ([#9560](https://github.com/serverless/serverless/pull/9560)) ([a116dfe](https://github.com/serverless/serverless/commit/a116dfec22697dd0511623c6a1e6d2d829d4ba10)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **Templates:** Allow usage of `google-nodejs-typescript` template ([#9557](https://github.com/serverless/serverless/pull/9557)) ([accf5bd](https://github.com/serverless/serverless/commit/accf5bd082400f654eba5e7d322bcb205c9ae709)) ([Corentin Doue](https://github.com/CorentinDoue)) + +### Maintenance Improvements + +- Upgrade `dotenv` to v10 ([#9569](https://github.com/serverless/serverless/pull/9569)) ([99d1697](https://github.com/serverless/serverless/commit/99d1697050ac2b2ca675794501c08230f2cc3f7b)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.44.0](https://github.com/serverless/serverless/compare/v2.43.1...v2.44.0) (2021-06-02) + +### Features + +- **CLI Onboarding:** Make it service setup specific: + - If not in service context, immediately go into project setup questions (skip "Do you want to create a new project" question) ([#9524](https://github.com/serverless/serverless/pull/9524)) ([d5e2baf](https://github.com/serverless/serverless/commit/d5e2baf714958c5718610659887f485f9bd161e4)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Remove `tab-completion` from interactive flow ([#9531](https://github.com/serverless/serverless/pull/9531)) ([3bac0f3](https://github.com/serverless/serverless/commit/3bac0f37f0f23abed387f0952772e3cdf5d47320)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Bug Fixes + +- **Variables:** + - Unify error messaging for function resolvers ([#9545](https://github.com/serverless/serverless/pull/9545)) ([bb3b766](https://github.com/serverless/serverless/commit/bb3b766946311848c707abc0fc7e749393f4527c)) ([Mariusz Nowak](https://github.com/medikoo)) + - Ensure to apply a resolution with a new resolver in case of a fallback to a local version ([#9544](https://github.com/serverless/serverless/pull/9544)) ([14a5275](https://github.com/serverless/serverless/commit/14a5275c0d6a127e211935b8b8f57a949e1ffad6)) ([Mariusz Nowak](https://github.com/medikoo)) +- **CLI:** + - Ensure to gently handle missing data from global installation in case of local fallback ([#9539](https://github.com/serverless/serverless/pull/9539)) ([1b90dfb](https://github.com/serverless/serverless/commit/1b90dfb0659dab3852ace330fd7c497321b80710)) ([Mariusz Nowak](https://github.com/medikoo)) +- Fix handling of numeric error codes coming from AWS SDK requests ([#9538](https://github.com/serverless/serverless/pull/9538)) ([f2cdbae](https://github.com/serverless/serverless/commit/f2cdbae1eb6d327935336a38deda099b8f5ffee2)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **Variables:** + - Cleanup handling of `variableSyntax` default ([#9544](https://github.com/serverless/serverless/pull/9544)) ([582d150](https://github.com/serverless/serverless/commit/582d150ceb01d3f597a30fcc82201ffa325c4617)) ([Mariusz Nowak](https://github.com/medikoo)) + - Seclude resolution of sources from external plugins ([#9544](https://github.com/serverless/serverless/pull/9544)) ([6efc161](https://github.com/serverless/serverless/commit/6efc161e5f7892275c798f6003ea5ee557bf3b26)) ([Mariusz Nowak](https://github.com/medikoo)) + +### [2.43.1](https://github.com/serverless/serverless/compare/v2.43.0...v2.43.1) (2021-05-25) + +### Bug Fixes + +- **AWS Local Invocation:** Fix invalid result handling ([#9507](https://github.com/serverless/serverless/pull/9507)) ([bbff029](https://github.com/serverless/serverless/commit/bbff0290db8a56cf599522c5ec0abc901359a0f9)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Telemetry:** Ensure to pass proper config for local fallback error handler ([#9519](https://github.com/serverless/serverless/pull/9519)) ([9b2a111](https://github.com/serverless/serverless/commit/9b2a1114850914a4ac96b19c7fcb0bf031822ea4)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **Variables:** Ensure proper resolution of AWS-related variables in case of errors ([#9518](https://github.com/serverless/serverless/pull/9518)) ([ee66585](https://github.com/serverless/serverless/commit/ee66585fdcfc32d135ed0cdc6bad8d440c7e9e38)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Maintenance Improvements + +- Use `download` from `@serverless/utils` ([#9513](https://github.com/serverless/serverless/pull/9513)) ([716b312](https://github.com/serverless/serverless/commit/716b31216e4873bbb986c5a2a54fda708a591cd1)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **CLI Onboarding:** Use "Starter" not "Empty" for templates ([#9514](https://github.com/serverless/serverless/pull/9514)) ([2984adb](https://github.com/serverless/serverless/commit/2984adb0456f7d6e93b0c778a1c588ee20459928)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **Telemetry:** Improve AWS stack error codes ([#9510](https://github.com/serverless/serverless/issues/9510)) ([c265905](https://github.com/serverless/serverless/commit/c265905f518f8cbea170c5a2774670c60de0e36c)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.43.0](https://github.com/serverless/serverless/compare/v2.42.0...v2.43.0) (2021-05-20) + +### Features + +- **CLI Onboarding:** In `service` step, if possible propose a default project name ([#9503](https://github.com/serverless/serverless/pull/9503)) ([dee54ed](https://github.com/serverless/serverless/commit/dee54ed55c0a0697eefdde99d5ec8aee321ce041)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Bug Fixes + +- **AWS Deploy:** Fix stack errors processing ([#9505](https://github.com/serverless/serverless/pull/9505)) ([18a9b2b](https://github.com/serverless/serverless/commit/18a9b2b6f5734083de751cf182c6be61736be11f)) ([Mariusz Nowak](https://github.com/medikoo)) +- **AWS IAM:** Do not depend on default execution role when custom role provided ([29f0e9c](https://github.com/serverless/serverless/commit/29f0e9c840e4b1ae9949925bc5a2a9d2de742271)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Maintenance Improvements + +- Do not recognize YAML Exception as user error ([#9505](https://github.com/serverless/serverless/pull/9505)) ([db16df2](https://github.com/serverless/serverless/commit/db16df2faad9cc63eb8e98ce90829642707546fb)) ([Mariusz Nowak](https://github.com/medikoo)) +- Do not rely on `serverless.yamlParser` ([#9505](https://github.com/serverless/serverless/pull/9505)) ([aa8f7be](https://github.com/serverless/serverless/commit/aa8f7bec1caed4211adcb87ad0a73cd796f065d5)) ([Mariusz Nowak](https://github.com/medikoo)) +- Ensure codes for user errors ([#9505](https://github.com/serverless/serverless/pull/9505)) ([6adaa9f](https://github.com/serverless/serverless/commit/6adaa9f56ed6e9708065767be602f484d0091679)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.42.0](https://github.com/serverless/serverless/compare/v2.41.2...v2.42.0) (2021-05-19) + +### Features + +- **CLI Onboarding:** + - Switch to templates hosted at [`serverless/examples`](https://github.com/serverless/examples/) ([#9484](https://github.com/serverless/serverless/pull/9484)) ([e4ea50d](https://github.com/serverless/serverless/commit/e4ea50d401628cb22612196b7e9b50c4344dab8a)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Support `--name` CLI option for `service` step ([#9471](https://github.com/serverless/serverless/pull/9471)) ([53575dc](https://github.com/serverless/serverless/commit/53575dc36017ded5ff60e5edf18fb7a9fd9d30e9)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Support `template-path` CLI option for `service` step ([#9471](https://github.com/serverless/serverless/pull/9471)) ([98c9700](https://github.com/serverless/serverless/commit/98c9700bcda328552f04116a51549f66e3d7b026)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Support `template` and `template-url` options for `service` step ([#9495](https://github.com/serverless/serverless/pull/9495)) ([f1a288c](https://github.com/serverless/serverless/commit/f1a288ce2c30e1377d8b411a90db3b1b2857d4fb)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Bug Fixes + +- **AWS API Gateway:** Fix schema for `apiKeys` and `permissionsBoundary` ([#9489](https://github.com/serverless/serverless/pull/9489)) ([5601025](https://github.com/serverless/serverless/commit/5601025dd8a4075cb463e2dcfb67d6c52984582a)) ([lyndoh](https://github.com/lyndoh)) +- **AWS Local Invocation:** Report invalid handler path meaningfully ([#9499](https://github.com/serverless/serverless/pull/9499)) ([a2297ee](https://github.com/serverless/serverless/commit/a2297ee916dd79463d4efcfd6f7fe1f8e0e50d87)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Variables:** + - Fix reporting of variable resolution errors trigger by variable resolution made in JS function resolvers ([#9482](https://github.com/serverless/serverless/pull/9482)) ([f6b7cfa](https://github.com/serverless/serverless/commit/f6b7cfaaaff81b84011f0f6168a651979089e1c9)) ([Mariusz Nowak](https://github.com/medikoo)) + - Ensure report user error as user error ([#9499](https://github.com/serverless/serverless/pull/9499)) ([a8f4aeb](https://github.com/serverless/serverless/commit/a8f4aebe5d482a491d86d3427b259db00674cc72)) ([Mariusz Nowak](https://github.com/medikoo)) +- Expose remote lambda invocation failure as user error (([#9499](https://github.com/serverless/serverless/pull/9499)) [8f3d4e4](https://github.com/serverless/serverless/commit/8f3d4e4bdb1df1e107c5113d013164a2396f0f64)) ([Mariusz Nowak](https://github.com/medikoo)) +- Expose template error with user error ([#9499](https://github.com/serverless/serverless/pull/9499)) ([07b60a6](https://github.com/serverless/serverless/commit/07b60a6bb42796e6f060730ce4bf22762942b0b8)) ([Mariusz Nowak](https://github.com/medikoo)) +- Construct user errors with `ServerlessError` ([#9499](https://github.com/serverless/serverless/pull/9499)) ([c563581](https://github.com/serverless/serverless/commit/c563581ac98764edf653c1a5337d1b7d2b61ea63)) ([Mariusz Nowak](https://github.com/medikoo)) +- Do not stumble on missing resource properties ([#9499](https://github.com/serverless/serverless/pull/9499)) ([f87aee2](https://github.com/serverless/serverless/commit/f87aee268dd19f9b90a7018032c77454d2084f12)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **Telemetry:** + - Report resource types for user configured resources at `resources.Resources` ([#9501](https://github.com/serverless/serverless/pull/9501)) ([8d0ff07](https://github.com/serverless/serverless/commit/8d0ff078f7f0b565c1d35af1319f76a407afeb4b)) ([Mariusz Nowak](https://github.com/medikoo)) + - Normalize AWS request error codes ([#9499](https://github.com/serverless/serverless/pull/9499)) ([5a23931](https://github.com/serverless/serverless/commit/5a23931734ee80b80182008197c92985975f1646)) ([Mariusz Nowak](https://github.com/medikoo)) + - Report error location for non-normative error codes ([#9499](https://github.com/serverless/serverless/pull/9499)) ([07d5b9c](https://github.com/serverless/serverless/commit/07d5b9c19e9f5365af322a4862b03ccdca05655c)) ([Mariusz Nowak](https://github.com/medikoo)) + - Remove dead path error handling ([#9499](https://github.com/serverless/serverless/pull/9499)) ([91b10ed](https://github.com/serverless/serverless/commit/91b10ed208f2dee4b690df633f4275f658355044)) ([Mariusz Nowak](https://github.com/medikoo)) + - Improve granularity of stack deployment error codes ([#9499](https://github.com/serverless/serverless/pull/9499)) ([a6f4dc3](https://github.com/serverless/serverless/commit/a6f4dc3b2be2aa9ba2255d57cf9a9d23eae02994)) ([Mariusz Nowak](https://github.com/medikoo)) +- **CLI Onboarding:** Add `history` and `stepHistory` to `context` ([#9481](https://github.com/serverless/serverless/pull/9481)) ([9eea885](https://github.com/serverless/serverless/commit/9eea885b390fc88bb62c1e2a5c3d108444139703)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Add `create-from-local-template` util ([#9471](https://github.com/serverless/serverless/pull/9471)) ([03011ba](https://github.com/serverless/serverless/commit/03011baf07d262a5b9702b34b75a997e3f525d28)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Ensure to propagate as is stack monitoring error ([#9499](https://github.com/serverless/serverless/pull/9499)) ([a46abe3](https://github.com/serverless/serverless/commit/a46abe3d56cd667ad436fbceb283dd9e0f747d7b)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.41.2](https://github.com/serverless/serverless/compare/v2.41.1...v2.41.2) (2021-05-13) + +### Bug Fixes + +- **CLI:** + - In error handler fallback to local version only if we're not in its context (fix infinite recursion issue which put `serverless` process on stall) ([#9472](https://github.com/serverless/serverless/pull/9472)) ([7047c34](https://github.com/serverless/serverless/commit/7047c349299ea829b0d43efedd191782dad10219)) ([Mariusz Nowak](https://github.com/medikoo)) + - Ensure resolved CLI params are correct in local fallback ([#9472](https://github.com/serverless/serverless/pull/9472)) ([65a1f38](https://github.com/serverless/serverless/commit/65a1f3875cda7f06d3ab47f21362a630d7d0415f)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Telemetry:** If global & local fallback versions are recent enough to report outcome, report with global ([#9472](https://github.com/serverless/serverless/pull/9472)) ([eeddf9f](https://github.com/serverless/serverless/commit/eeddf9f518612f6f7ef805eb3ed9b13fb3036114)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Templates + +- **Templates:** Add `google-nodejs-typescript` template ([#9445](https://github.com/serverless/serverless/issues/9445)) ([9cc05ad](https://github.com/serverless/serverless/commit/9cc05ad2f659709746d1df9811b95118c583db27)) ([Corentin Doue](https://github.com/CorentinDoue)) + +### Maintenance Improvements + +- **CLI Onboarding:** + - Seclude from internal Framework logic ([#9410](https://github.com/serverless/serverless/pull/9410)) ([7864f4d](https://github.com/serverless/serverless/commit/7864f4d28d4c4ed8325e64c8dfca891845edf392)) ([Mariusz Nowak](https://github.com/medikoo)) + - Integrate steps from dashboard plugin ([#9410](https://github.com/serverless/serverless/pull/9410)) ([105807a](https://github.com/serverless/serverless/commit/105807a674820f2d8501f3b8539c3725fceab215)) ([Mariusz Nowak](https://github.com/medikoo)) + - Refactor to async/await ([#9410](https://github.com/serverless/serverless/pull/9410)) ([1060d14](https://github.com/serverless/serverless/commit/1060d1468ba587519df482e95a54bbc8d199cad8)) ([Mariusz Nowak](https://github.com/medikoo)) + - Simplify tabcompletion support check ([#9410](https://github.com/serverless/serverless/pull/9410)) ([c13586e](https://github.com/serverless/serverless/commit/c13586ee23614da75d71f40ff24037b9aad46c2c)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Telemetry:** Make `generatePayload` `serverless` independent ([#9410](https://github.com/serverless/serverless/pull/9410)) ([4f6a50a](https://github.com/serverless/serverless/commit/4f6a50a2e145e664405b00661d801b6ad094f418)) ([Mariusz Nowak](https://github.com/medikoo)) +- **CLI:** Rely internally on `@serverless/utils/log` ([#9410](https://github.com/serverless/serverless/pull/9410)) ([05588f7](https://github.com/serverless/serverless/commit/05588f77c0bbc900198ce458099ea2db066f3601)) ([Mariusz Nowak](https://github.com/medikoo)) +- Refactor `isNpmPackageWritable` to not depend on `serverless` ([b915cc4](https://github.com/serverless/serverless/commit/b915cc467183d146785466965abbe318c349f0c9)) ([Mariusz Nowak](https://github.com/medikoo)) + +### [2.41.1](https://github.com/serverless/serverless/compare/v2.41.0...v2.41.1) (2021-05-11) + +### Bug Fixes + +- **CLI:** Correctly resolve version during local fallback ([#9463](https://github.com/serverless/serverless/pull/9463)) ([bbfe742](https://github.com/serverless/serverless/commit/bbfe742b2458f31254b11128b8ed506a47293abe)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +## [2.41.0](https://github.com/serverless/serverless/compare/v2.40.0...v2.41.0) (2021-05-11) + +### Features + +- **AWS API Gateway:** Support disabling default endpoint ([#9404](https://github.com/serverless/serverless/issues/9404)) ([ec90945](https://github.com/serverless/serverless/commit/ec909452b5167e05d892d2c44bc46b4ff7d7470a)) ([lyndoh](https://github.com/lyndoh)) +- **AWS Lambda:** Deprecate `nodejs12.x` as default runtime ([#9416](https://github.com/serverless/serverless/issues/9416)) ([9e558ee](https://github.com/serverless/serverless/commit/9e558eefd66e9dafcb16b3636b934d753ade001e)) ([Jaakko Lappalainen](https://github.com/jkklapp)) + +### Bug Fixes + +- **AWS API Gateway:** Support `Fn::Split` for `vpcEndpointIds` schema ([#9455](https://github.com/serverless/serverless/pull/9455)) ([56f8587](https://github.com/serverless/serverless/commit/56f85874c6b9da44b8fbc326dfe3bce33bf8c41e)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS Lambda:** Ensure that docker image is build and pushed only once ([#9446](https://github.com/serverless/serverless/pull/9446)) ([277f4e8](https://github.com/serverless/serverless/commit/277f4e8e9c53c0572981407eb45cecba050462a7)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **CLI:** + - Ensure to report only unrecognized sources as unrecognized ([#9449](https://github.com/serverless/serverless/pull/9449)) ([27e21e8](https://github.com/serverless/serverless/commit/27e21e8fca560732df3fa5c36c56682ef89b53c5)) ([Mariusz Nowak](https://github.com/medikoo)) + - Fix local installation fallback ([#9454](https://github.com/serverless/serverless/pull/9454)) ([fa8c076](https://github.com/serverless/serverless/commit/fa8c076c564377ec632992a6a156bc4937ec08e1)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Packaging:** Fix support of the artifact S3 uri with region ([#9411](https://github.com/serverless/serverless/issues/9411)) ([40e56fc](https://github.com/serverless/serverless/commit/40e56fc0e9f71f06068d7d4c30178db8b2260357)) ([Zach Whaley](https://github.com/zachwhaley)) + +### Maintenance Improvements + +- **Telemetry:** + - Ensure telemetry only matches js stacktrace paths ([#9447](https://github.com/serverless/serverless/pull/9447)) ([7361e04](https://github.com/serverless/serverless/commit/7361e049608d40e4199c797abbad552ea831f5a5)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - For local fallback ensure to report locally used version ([#9454](https://github.com/serverless/serverless/pull/9454)) ([096ed96](https://github.com/serverless/serverless/commit/096ed9652bff399965c81c9aedb93b42c2b8caf5)) ([Mariusz Nowak](https://github.com/medikoo)) + - Let old versions report telemetry old way ([#9454](https://github.com/serverless/serverless/pull/9454)) ([4d077d1](https://github.com/serverless/serverless/commit/4d077d1653fcc41e362587e5d13dfa8dd43d3bc3)) ([Mariusz Nowak](https://github.com/medikoo)) + +## [2.40.0](https://github.com/serverless/serverless/compare/v2.39.2...v2.40.0) (2021-05-06) + +### Features + +- **AWS Lambda:** Add `ecr.scanOnPush` configuration option ([#9379](https://github.com/serverless/serverless/issues/9379)) ([078ec59](https://github.com/serverless/serverless/commit/078ec59058e1c37bd81388c7e81087b48fc2ba24)) ([Nicholas Wehr](https://github.com/wwwehr)) + +### Bug Fixes + +- **CLI:** Do not validate command when falling back to old version ([#9437](https://github.com/serverless/serverless/pull/9437)) ([9624338](https://github.com/serverless/serverless/commit/962433864ff4f52bf178b7afc1b6e54e58e58702)) ([Mariusz Nowak](https://github.com/medikoo)) + +### [2.39.2](https://github.com/serverless/serverless/compare/v2.39.1...v2.39.2) (2021-05-04) + +### Bug Fixes + +- **CLI:** + - Fix internal command resolution in case of a fallback to local version from older global version ([#9429](https://github.com/serverless/serverless/pull/9429)) ([b7a113d](https://github.com/serverless/serverless/commit/b7a113d48d634f89a91a31cd05b8d2e57f540c77)) ([Mariusz Nowak](https://github.com/medikoo)) + - Ensure to support `disableDeprecations` setting when validating not supported options ([#9429](https://github.com/serverless/serverless/pull/9429)) ([da476ad](https://github.com/serverless/serverless/commit/da476ad7ac52b331ae47102e01a9270a18b40833)) ([Mariusz Nowak](https://github.com/medikoo)) +- **Telemetry:** + - Do not attempt to report unrecognized commands ([#9427](https://github.com/serverless/serverless/pull/9427)) ([2c2c77f](https://github.com/serverless/serverless/commit/2c2c77f90518e73921b0f4dd02767b5ad4476db4)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Do not share telemetry cache folder with old versions ([#9429](https://github.com/serverless/serverless/pull/9429)) ([ae9442e](https://github.com/serverless/serverless/commit/ae9442e53b04648ff5b9c436ef86765d2ad9d872)) ([Mariusz Nowak](https://github.com/medikoo)) +- **AWS Deploy:** Fix changes detection when VPC with intrinsic CF functions is involved ([#9425](https://github.com/serverless/serverless/pull/9425)) ([2c7f024](https://github.com/serverless/serverless/commit/2c7f024a57dd70c0e05d6ab7f40e530c96f2351a)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Fix `provider.vpc` configuration schema ([#9425](https://github.com/serverless/serverless/pull/9)) ([7338358](https://github.com/serverless/serverless/commit/7338358126ac249374e341b7b19ce83582ecff1d)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### [2.39.1](https://github.com/serverless/serverless/compare/v2.39.0...v2.39.1) (2021-05-03) + +### Bug Fixes + +- **AWS HTTP API:** Ensure to apply tags to stage ([#9407](https://github.com/serverless/serverless/issues/9407)) ([80511a4](https://github.com/serverless/serverless/commit/80511a4b17e77e22cf8b20d1ce50eef7506d4f7f)) ([Filip Golonka](https://github.com/filipgolonka)) + +### Maintenance Improvements + +- **Telemetry:** + - Handle error locations not enclosed in parens ([#9419](https://github.com/serverless/serverless/pull/9419)) ([3ab0628](https://github.com/serverless/serverless/commit/3ab06282fdc9455f364fd73bd14761bae0c8d289)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Properly resolve location when for only relative paths ([#9418](https://github.com/serverless/serverless/issues/9418)) ([3ccf6a3](https://github.com/serverless/serverless/commit/3ccf6a3af3de093fabfa33a966b7a0a922712845)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Split stack lines properly on all OS-es ([#9419](https://github.com/serverless/serverless/pull/9419)) ([bdbf154](https://github.com/serverless/serverless/commit/bdbf154c97abde6ad2ff807dbea3ad1110ee5fec)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +## [2.39.0](https://github.com/serverless/serverless/compare/v2.38.0...v2.39.0) (2021-04-30) + +### Features + +- **AWS IAM:** Support `provider.iam.role.path` ([#9363](https://github.com/serverless/serverless/issues/9363)) ([c8adc0c](https://github.com/serverless/serverless/commit/c8adc0c796a6558c3fe1bc86e3647d3fe711a9ad)) ([Android3000](https://github.com/Android3000)) +- **Variables:** Expose variable resolver function to variable sources ([#9368](https://github.com/serverless/serverless/pull/9368)) ([2ff58b1](https://github.com/serverless/serverless/commit/2ff58b16bf3fe766685d5b6c30fd9a2bb6e22f0f)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Bug Fixes + +- **AWS API Gateway:** Ensure unique name for request validator ([#9382](https://github.com/serverless/serverless/pull/9382)) ([a05e88d](https://github.com/serverless/serverless/commit/a05e88d92e010ddfe019d5b5b873547b7d187d6d)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- **AWS S3:** Fix parsing of the artifact S3 url ([#9380](https://github.com/serverless/serverless/issues/9380)) ([360925d](https://github.com/serverless/serverless/commit/360925d2e0cddb6fbbbb72ca47495aa71a43d1fc)) ([Stephen](https://github.com/bishtawi)) +- **CLI:** Ensure no general help is listed under interactive setup help ([#9406](https://github.com/serverless/serverless/pull/9406)) ([132c830](https://github.com/serverless/serverless/commit/132c830b0a86998efbae1b4984dc9cea85957d61)) ([Mariusz Nowak](https://github.com/medikoo)) + +### Maintenance Improvements + +- **Telemetry:** + - Report failures via telemetry ([#9396](https://github.com/serverless/serverless/pull/9396)) ([5861d08](https://github.com/serverless/serverless/commit/5861d08768a06e2e88609d0785ce590d3f693683)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Ensure that container commands do not trigger telemetry ([#9397](https://github.com/serverless/serverless/pull/9397)) ([85b9e53](https://github.com/serverless/serverless/commit/85b9e5319df48904664f966e988cc725116ce865)) ([Mariusz Nowak](https://github.com/medikoo)) + - Add `commandDurationMs` to payload ([#9401](https://github.com/serverless/serverless/pull/9401)) ([d647125](https://github.com/serverless/serverless/commit/d647125ff5daa07972675fd28690d42746ab223b)) ([Piotr Grzesik](https://github.com/pgrzesik)) + - Add `commandOptionNames` to payload ([#9387](https://github.com/serverless/serverless/pull/9387)) ([f5b2b9b](https://github.com/serverless/serverless/commit/f5b2b9be395c9c2d3de4c4f91f991276bc22dc33)) ([Piotr Grzesik](https://github.com/pgrzesik)) +- Ensure `code` to `ServerlessError` instances ([#9357](https://github.com/serverless/serverless/pull/9357)) ([822a7cf](https://github.com/serverless/serverless/commit/822a7cf9f527514b53fd8cfc5c172ec5dc53f4ce)) ([Piotr Grzesik](https://github.com/pgrzesik)) + +### Templates + +- Update dependencies for `cloudflare` template ([#9373](https://github.com/serverless/serverless/issues/9373)) ([543423d](https://github.com/serverless/serverless/commit/543423d869ba35c6866506bb49a8642700214b3a)) ([YErii](https://github.com/YEriin)) + +## [2.38.0](https://github.com/serverless/serverless/compare/v2.37.2...v2.38.0) (2021-04-23) + +### Features + +- **AWS CloudFormation:** Add default export names to outputs ([#9313](https://github.com/serverless/serverless/issues/9313)) ([7e139bb](https://github.com/serverless/serverless/commit/7e139bb0136e0d053f4f6f8cb2876480bb2a485e)) ([Joseph Cha](https://github.com/js-cha)) + +### Bug Fixes + +- **AWS API Gateway:** Create one request validator and reuse ([#9319](https://github.com/serverless/serverless/issues/9319)) ([154351f](https://github.com/serverless/serverless/commit/154351f1a5925a745873895014ed31f03b2842b3)) ([Jacques](https://github.com/gambit66)) +- **Variables:** Fix unresolved sources notifications ([#9356](https://github.com/serverless/serverless/issues/9356)) ([53a7872](https://github.com/serverless/serverless/commit/53a7872f78f51938b409925e052d34f2dc85abbd)) ([Mariusz Nowak](https://github.com/medikoo)) + ### [2.37.2](https://github.com/serverless/serverless/compare/v2.37.1...v2.37.2) (2021-04-22) ### Bug Fixes diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dcbefafe5e2..ba091cac71d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -99,6 +99,10 @@ Log should be written only if deprecated functionality is used. If applicable (t 2. Document introduced deprecation at `docs/deprecations.md` (new deprecation should be listed as **first** and follow the format of other documented deprecations) +### Service configuration validation + +All newly introduced configuration properties should be covered by proper changes to configuration schema. For more details about configuration validation, please see [docs/configuration-validation](./docs/configuration-validation.md). + # Testing See [test/README](test/README.md) diff --git a/README.md b/README.md index 4b472cde0a4..04fbb2a067e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,4 @@ -⚡ **Serverless Inc. is hiring to build the next generation of serverless development tools, [join us!](https://www.serverless.com/company/jobs/)** - ---- - -[![Serverless Application Framework AWS Lambda API Gateway](https://s3.amazonaws.com/assets.github.serverless/readme-serverless-framework.gif)](http://serverless.com) +[![Serverless Application Framework AWS Lambda API Gateway](https://s3.amazonaws.com/assets.github.serverless/readme-serverless-framework.gif)](https://serverless.com) [![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com) [![Build Status](https://github.com/serverless/serverless/workflows/Integrate/badge.svg)](https://github.com/serverless/serverless/actions?query=workflow%3AIntegrate) @@ -12,66 +8,60 @@ [![Known Vulnerabilities](https://snyk.io/test/github/serverless/serverless/badge.svg)](https://snyk.io/test/github/serverless/serverless) [![license](https://img.shields.io/npm/l/serverless.svg)](https://www.npmjs.com/package/serverless) -

- English | - 简体中文 -

- -[Website](http://www.serverless.com) • [Docs](https://serverless.com/framework/docs/) • [Newsletter](https://serverless.com/subscribe/) • [Swag](https://teespring.com/stores/serverless) • [Gitter](https://gitter.im/serverless/serverless) • [Forum](http://forum.serverless.com) • [Meetups](https://www.meetup.com/pro/serverless/) • [Twitter](https://twitter.com/goserverless) • [We're Hiring](https://serverless.com/company/jobs/) +[Website](http://www.serverless.com) • [Docs](https://serverless.com/framework/docs/) • [Community Slack](https://join.slack.com/t/serverless-contrib/shared_invite/zt-d5qzowja-pnOerTzAIZUrN18hWYUIHA) • [Forum](http://forum.serverless.com) • [Twitter](https://twitter.com/goserverless) • [Meetups](https://www.meetup.com/pro/serverless/) • [We're Hiring](https://serverless.com/company/jobs/) • [简体中文](./README_CN.md) -**The Serverless Framework** – Build applications comprised of microservices that run in response to events, auto-scale for you, and only charge you when they run. This lowers the total cost of maintaining your apps, enabling you to build more logic, faster. +**The Serverless Framework** – Build applications on AWS Lambda and other next-gen cloud services, that auto-scale and only charge you when they run. This lowers the total cost of running and operating your apps, enabling you to build more and manage less. -The Framework uses new event-driven compute services, like AWS Lambda, Google Cloud Functions, and more. It's a command-line tool, providing scaffolding, workflow automation and best practices for developing and deploying your serverless architecture. It's also completely extensible via plugins. +The Serverless Framework is a command-line tool that uses easy and approachable YAML syntax to deploy both your code and cloud infrastructure needed to make tons of serverless application use-cases. It's a multi-language framework that supports Node.js, Typescript, Python, Go, Java, and more. It's also completely extensible via over 1,000 plugins that can add more serverless use-cases and workflows to the Framework. -Check out the [Serverless Framework Dashboard](https://app.serverless.com) for monitoring, troubleshooting, ci/cd and more features for serverless teams. - -Serverless is actively maintained by [Serverless Inc](https://www.serverless.com). +Actively maintained by [Serverless Inc](https://www.serverless.com). ## Contents - - - [Quick Start](#quick-start) - [Examples](https://github.com/serverless/examples) -- [Services](#services) - [Features](#features) - [Plugins](https://github.com/serverless/plugins) - [Contributing](#contributing) - [Community](#community) -- [Consultants](#consultants) - [Licensing](#licensing) - [Previous Version 0.5.x](#v.5) ## Quick Start -1. **Install via npm:** +### Install Via NPM: ```bash npm install -g serverless ``` -2. **Set-up your [Provider Credentials](./docs/providers/aws/guide/credentials.md)**. [Watch the video on setting up credentials](https://youtu.be/VUKDRoUdMek) +### Set Up Your AWS Account Credentials: + +The Serverless Framework deploys to your own AWS account. You'll need to enable Serverless Framework to deploy to your AWS account by giving it access. [Here is a guide to help you set up your credentials securely](https://www.serverless.com/framework/docs/providers/aws/guide/credentials) -3. **Create a Service:** +### Create A Service: -You can create a new service or [install existing services](#how-to-install-a-service). +A "Service" is the Framework's project or app concept. You can create one from scratch or select an existing template by running. ```bash -# Create a new Serverless Service/Project -serverless create --template aws-nodejs --path my-service -# Change into the newly created directory -cd my-service +serverless ``` -4. **Deploy a Service:** +Go through the onboarding flow and then navigate into the newly created directory. + +```bash +cd my-new-service +``` + +### Deploy A Service: Use this when you have made changes to your Functions, Events or Resources in `serverless.yml` or you simply want to deploy all changes within your Service at the same time. ```bash -serverless deploy -v +serverless deploy ``` -5. **Deploy the Function:** +### Deploy A Function: Use this to quickly upload and overwrite your AWS Lambda code on AWS, allowing you to develop faster. @@ -79,7 +69,7 @@ Use this to quickly upload and overwrite your AWS Lambda code on AWS, allowing y serverless deploy function -f hello ``` -6. **Invoke the Function on AWS:** +### Invoke The Function On AWS: Invokes an AWS Lambda Function on AWS and returns logs. @@ -87,7 +77,7 @@ Invokes an AWS Lambda Function on AWS and returns logs. serverless invoke -f hello -l ``` -7. **Invoke the Function on your machine:** +### Invoke The Function Locally: Invokes an AWS Lambda Function on your local machine and returns logs. @@ -95,7 +85,7 @@ Invokes an AWS Lambda Function on your local machine and returns logs. serverless invoke local -f hello -l ``` -8. **Fetch the Function Logs:** +### Stream Function Logs: Open up a separate tab in your console and stream all logs for a specific Function using this command. @@ -103,7 +93,7 @@ Open up a separate tab in your console and stream all logs for a specific Functi serverless logs -f hello -t ``` -9. **Remove the Service:** +### Remove The Service: Removes all Functions, Events and Resources from your AWS account. @@ -111,46 +101,6 @@ Removes all Functions, Events and Resources from your AWS account. serverless remove ``` -### How to Install a Service: - -This is a convenience method to install a pre-made Serverless Service locally by downloading the Github repo and unzipping it. Services are listed below. - -```bash -serverless install -u https://github.com/your-url-to-the-serverless-service -``` - -Check out the [Serverless Framework Guide](./docs/providers/aws/guide/README.md) for more information. - -## Services (V1.0) - -The following are services you can instantly install and use by running `serverless install --url ` - -- [serverless-examples](https://github.com/serverless/examples) -- [CRUD](https://github.com/pmuens/serverless-crud) - CRUD service, [Scala Port](https://github.com/jahangirmohammed/serverless-crud-scala) -- [CRUD with FaunaDB](https://github.com/faunadb/serverless-crud) - CRUD service using FaunaDB -- [CRUD with S3](https://github.com/tscanlin/serverless-s3-crud) - CRUD service using S3 -- [CRUD with Flask and SQLAlchemy](https://github.com/jetbridge/sls-flask) - Python [CRUD API service](https://blog.jetbridge.com/framework/) with Flask, SQLAlchemy and Swagger -- [GraphQL Boilerplate](https://github.com/serverless/serverless-graphql) - GraphQL application Boilerplate service -- [Authentication](https://github.com/laardee/serverless-authentication-boilerplate) - Authentication boilerplate service -- [Mailer](https://github.com/eahefnawy/serverless-mailer) - Service for sending emails -- [Kinesis streams](https://github.com/pmuens/serverless-kinesis-streams) - Service to showcase Kinesis stream support -- [DynamoDB streams](https://github.com/pmuens/serverless-dynamodb-streams) - Service to showcase DynamoDB stream support -- [Landingpage backend](https://github.com/pmuens/serverless-landingpage-backend) - Landingpage backend service to store E-Mail addresses -- [Facebook Messenger Chatbot](https://github.com/pmuens/serverless-facebook-messenger-bot) - Chatbot for the Facebook Messenger platform -- [Lambda chaining](https://github.com/pmuens/serverless-lambda-chaining) - Service which chains Lambdas through SNS -- [Secured API](https://github.com/pmuens/serverless-secured-api) - Service which exposes an API key accessible API -- [Authorizer](https://github.com/eahefnawy/serverless-authorizer) - Service that uses API Gateway custom authorizers -- [Thumbnails](https://github.com/eahefnawy/serverless-thumbnails) - Service that takes an image url and returns a 100x100 thumbnail -- [Boilerplate](https://github.com/eahefnawy/serverless-boilerplate) - Opinionated boilerplate -- [ES6 + Jest](https://github.com/americansystems/serverless-es6-jest) - ES6 + Jest Boilerplate -- [PHP](https://github.com/ZeroSharp/serverless-php) - Call a PHP function from your lambda -- [Ruby](https://github.com/stewartlord/serverless-ruby) - Call a Ruby function from your lambda -- [Slack App](https://github.com/johnagan/serverless-slack-app) - Slack App Boilerplate with OAuth and Bot actions -- [Swift](https://github.com/choefele/swift-lambda-app) - Full-featured project template to develop Lambda functions in Swift -- [Cloudwatch Alerts on Slack](https://github.com/dav009/serverless-aws-alarms-notifier) - Get AWS Cloudwatch alerts notifications on Slack - -**Note**: the `serverless install` command will only work on V1.0 or later. - ## Features - Supports Node.js, Python, Java, Go, C#, Ruby, Swift, Kotlin, PHP, Scala, & F# @@ -173,34 +123,14 @@ Check out our [help wanted](https://github.com/serverless/serverless/labels/help ## Community -- [Email Updates](http://eepurl.com/b8dv4P) -- [Serverless Forum](http://forum.serverless.com) +- [Twitter](https://twitter.com/goserverless) +- [Community Slack](https://join.slack.com/t/serverless-contrib/shared_invite/zt-d5qzowja-pnOerTzAIZUrN18hWYUIHA) - [Gitter Chatroom](https://gitter.im/serverless/serverless) - [Serverless Meetups](http://www.meetup.com/serverless/) - [Stackoverflow](http://stackoverflow.com/questions/tagged/serverless-framework) - [Facebook](https://www.facebook.com/serverless) -- [Twitter](https://twitter.com/goserverless) - [Contact Us](mailto:hello@serverless.com) -## Consultants - -We recommend the following professional services organizations who are experts in serverless development: - -- [Serverless Guru](https://serverlessguru.com/) -- [Antstack](https://www.antstack.io/) -- [Theodo](https://www.theodo.co.uk) - full stack teams passionate about Serverless that also run the Serverless Transformation Newsletter & Blog. -- [null](https://null.tc/) - maintains [Bref](https://bref.sh/) to create serverless PHP applications -- [Nordcloud](https://nordcloud.com) - they created [several plugins](https://github.com/nordcloud?utf8=%E2%9C%93&q=serverless&type=&language=), sponsor [Serverless Days Helsinki](https://helsinki.serverlessdays.io/) and regularly host [Serverless Finland](https://www.meetup.com/Serverless-Finland/) Meetups. -- [API talent](http://www.apitalent.co.nz) - who also run [Serverless-Auckland Meetup](http://www.meetup.com/Serverless-Auckland) -- [EPX Labs](http://www.epxlabs.com/) - runs [Serverless NYC Meetup](https://www.meetup.com/Serverless-NYC/) -- [Seraro](http://www.seraro.com/) - Who also runs Atlanta Serverless Meetup (https://www.meetup.com/Atlanta-CABI-Camp-Cloud-AI-Blockchain-IOT) and Delhi Serverless Meetup (https://www.meetup.com/Delhi-NCR-Serverless-Architecture-Meetup/) -- [superluminar](https://superluminar.io) - runs serverlessdays Hamburg and Serverless Meetup Hamburg -- [JetBridge](https://jetbridge.com) - cloud-native and serverless application development services. - -If you'd like to be featured here, [please contact us](mailto:hello@serverless.com). - ---- - ## Licensing Serverless is licensed under the [MIT License](./LICENSE.txt). @@ -209,6 +139,4 @@ All files located in the node_modules and external directories are externally ma # Previous Serverless Version 0.5.x -You can find projects and plugins relating to version 0.5 [here](./0.5.x-RESOURCES.md). Note that these are not compatible with v1.0 but we are working diligently on updating them. [Guide on building v1.0 plugins](./docs/providers/aws/guide/plugins.md). - You can read the v0.5.x documentation at [readme.io](https://serverless.readme.io/v0.5.0/docs). diff --git a/bin/serverless.js b/bin/serverless.js index c7404e6d86e..57c58f7e4ba 100755 --- a/bin/serverless.js +++ b/bin/serverless.js @@ -1,43 +1,113 @@ #!/usr/bin/env node +// WARNING: Do not use syntax not supported by old Node.js versions (v4 lowest) +// It's to ensure that users running those versions, see properly the error message +// (as constructed below) instead of the syntax error + 'use strict'; +// `EvalError` is used to not pollute global namespace but still have the value accessible globally +// Can already be set, if we're in context of local fallback +const isMainModule = !EvalError.$serverlessCommandStartTime; +if (isMainModule) EvalError.$serverlessCommandStartTime = process.hrtime(); + const nodeVersion = Number(process.version.split('.')[0].slice(1)); +const minimumSupportedVersion = 12; -if (nodeVersion < 10) { +if (nodeVersion < minimumSupportedVersion) { const serverlessVersion = Number(require('../package.json').version.split('.')[0]); - process.stdout.write( - `Serverless: \x1b[91mInitialization error: Node.js v${nodeVersion} is not supported by ` + - `Serverless Framework v${serverlessVersion}. Please upgrade\x1b[39m\n` + process.stderr.write( + `\x1b[91mError: Serverless Framework v${serverlessVersion} does not support ` + + `Node.js v${nodeVersion}. Please upgrade Node.js to the latest ` + + `LTS version (v${minimumSupportedVersion} is a minimum supported version)\x1b[39m\n` ); process.exit(1); } -if (require('../lib/utils/isStandaloneExecutable')) { - require('../lib/utils/standalone-patch'); - if (process.argv[2] === 'binary-postinstall' && process.argv.length === 3) { - require('../scripts/postinstall'); - return; +if (isMainModule) { + if (require('../lib/utils/is-standalone-executable')) { + require('../lib/utils/standalone-patch'); + if (process.argv[2] === 'binary-postinstall' && process.argv.length === 3) { + require('../scripts/postinstall'); + return; + } } -} -// CLI Triage -(() => { - try { - const componentsV1 = require('@serverless/cli'); - const componentsV2 = require('@serverless/components'); + const path = require('path'); + const localInstallationPath = require('../lib/cli/local-serverless-path'); - // Serverless Components v1 CLI (deprecated) - if (componentsV1.runningComponents()) return () => componentsV1.runComponents(); + if (localInstallationPath && localInstallationPath !== path.dirname(__dirname)) { + // Local fallback + const localServerlessBinPath = (() => { + try { + return require.resolve(path.resolve(localInstallationPath, 'bin/serverless')); + } catch (ignore) { + // Unrecognized "serverless" installation, continue with this one + return null; + } + })(); - // Serverless Components CLI - if (componentsV2.runningComponents()) return () => componentsV2.runComponents(); - } catch (error) { - if (process.env.SLS_DEBUG) { - require('../lib/classes/Error').logWarning(`CLI triage crashed with: ${error.stack}`); + if (localServerlessBinPath) { + EvalError.$serverlessInitInstallationVersion = require('../package').version; + const colorSupportLevel = require('supports-color').stdout.level; + let message = 'Running "serverless" from node_modules\n'; + if (colorSupportLevel) { + message = + colorSupportLevel > 2 ? `\x1b[38;5;145m${message}\x1b[39m` : `\x1b[90m${message}\x1b[39m`; + } + process.stderr.write(message); + require(localServerlessBinPath); + return; } } +} - // Serverless Framework CLI - return () => require('../scripts/serverless'); -})()(); +require('../lib/cli/triage')().then((cliName) => { + switch (cliName) { + case 'serverless': + require('../scripts/serverless'); + return; + case 'serverless-tencent': + require('../lib/cli/run-serverless-tencent')().catch((error) => { + // Expose eventual resolution error as regular crash, and not unhandled rejection + process.nextTick(() => { + throw error; + }); + }); + return; + case '@serverless/components': + { + const chalk = require('chalk'); + process.stdout.write( + `${[ + 'Serverless Components CLI is no longer bundled with Serverless Framework CLI', + '', + "To run it, ensure it's installed:", + chalk.bold('npm install -g @serverless/components'), + '', + 'Then run:', + chalk.bold('components '), + ].join('\n')}\n` + ); + } + return; + case '@serverless/cli': + { + const chalk = require('chalk'); + process.stdout.write( + `${[ + 'Serverless Components CLI v1 is no longer bundled with Serverless Framework CLI', + '', + "To run it, ensure it's installed:", + chalk.bold('npm install -g @serverless/cli'), + '', + 'Then run:', + chalk.bold('components-v1 '), + ].join('\n')}\n` + ); + } + return; + default: + throw new Error(`Unrecognized CLI name "${cliName}"`); + } +}); diff --git a/commands/doctor.js b/commands/doctor.js new file mode 100644 index 00000000000..94c57bfc1fe --- /dev/null +++ b/commands/doctor.js @@ -0,0 +1,19 @@ +'use strict'; + +const fsp = require('fs').promises; +const { writeText, log } = require('@serverless/utils/log'); +const healthStatusFilename = require('../lib/utils/health-status-filename'); + +module.exports = async () => { + const healthStatus = await (async () => { + try { + return await fsp.readFile(healthStatusFilename); + } catch (error) { + if (error.code === 'ENOENT') return null; + throw error; + } + })(); + + if (healthStatus) writeText(healthStatus); + else log.notice('No deprecations were reported in the last command'); +}; diff --git a/commands/plugin-install.js b/commands/plugin-install.js new file mode 100644 index 00000000000..d49e26e13f2 --- /dev/null +++ b/commands/plugin-install.js @@ -0,0 +1,141 @@ +'use strict'; + +const spawn = require('child-process-ext/spawn'); +const fsp = require('fs').promises; +const fse = require('fs-extra'); +const path = require('path'); +const _ = require('lodash'); +const isPlainObject = require('type/plain-object/is'); +const yaml = require('js-yaml'); +const cloudformationSchema = require('@serverless/utils/cloudformation-schema'); +const { log, progress, style } = require('@serverless/utils/log'); +const ServerlessError = require('../lib/serverless-error'); +const yamlAstParser = require('../lib/utils/yaml-ast-parser'); +const npmCommandDeferred = require('../lib/utils/npm-command-deferred'); +const { + getPluginInfo, + getServerlessFilePath, + validate, +} = require('../lib/commands/plugin-management'); + +const mainProgress = progress.get('main'); + +module.exports = async ({ configuration, serviceDir, configurationFilename, options }) => { + const commandRunStartTime = Date.now(); + validate({ serviceDir }); + + const pluginInfo = getPluginInfo(options.name); + const pluginName = pluginInfo.name; + const pluginVersion = pluginInfo.version || 'latest'; + const configurationFilePath = getServerlessFilePath({ serviceDir, configurationFilename }); + + const context = { configuration, serviceDir, configurationFilePath, pluginName, pluginVersion }; + mainProgress.notice( + `Installing plugin "${pluginName}${pluginVersion === 'latest' ? '' : `@${pluginVersion}`}"`, + { isMainEvent: true } + ); + await installPlugin(context); + await addPluginToServerlessFile(context); + + log.notice(); + log.notice.success( + `Plugin "${pluginName}${ + pluginVersion === 'latest' ? '' : `@${pluginVersion}` + }" installed ${style.aside(`(${Math.floor((Date.now() - commandRunStartTime) / 1000)}s)`)}` + ); +}; + +const installPlugin = async ({ serviceDir, pluginName, pluginVersion }) => { + const pluginFullName = `${pluginName}@${pluginVersion}`; + await npmInstall(pluginFullName, { serviceDir }); +}; + +const addPluginToServerlessFile = async ({ configurationFilePath, pluginName }) => { + const fileExtension = path.extname(configurationFilePath); + if (fileExtension === '.js' || fileExtension === '.ts') { + requestManualUpdate(configurationFilePath); + return; + } + + const checkIsArrayPluginsObject = (pluginsObject) => + pluginsObject == null || Array.isArray(pluginsObject); + // pluginsObject type determined based on the value loaded during the serverless init. + if (fileExtension === '.json') { + const serverlessFileObj = await fse.readJson(configurationFilePath); + const newServerlessFileObj = serverlessFileObj; + const isArrayPluginsObject = checkIsArrayPluginsObject(newServerlessFileObj.plugins); + // null modules property is not supported + let plugins = isArrayPluginsObject + ? newServerlessFileObj.plugins || [] + : newServerlessFileObj.plugins.modules; + + if (plugins == null) { + throw new ServerlessError( + 'plugins modules property must be present', + 'PLUGINS_MODULES_MISSING' + ); + } + + plugins.push(pluginName); + plugins = _.sortedUniq(plugins); + + if (isArrayPluginsObject) { + newServerlessFileObj.plugins = plugins; + } else { + newServerlessFileObj.plugins.modules = plugins; + } + + await fse.writeJson(configurationFilePath, newServerlessFileObj); + return; + } + + const serverlessFileObj = yaml.load(await fsp.readFile(configurationFilePath, 'utf8'), { + filename: configurationFilePath, + schema: cloudformationSchema, + }); + if (serverlessFileObj.plugins != null) { + // Plugins section can be behind veriables, opt-out in such case + if (isPlainObject(serverlessFileObj.plugins)) { + if ( + serverlessFileObj.plugins.modules != null && + !Array.isArray(serverlessFileObj.plugins.modules) + ) { + requestManualUpdate(configurationFilePath); + return; + } + } else if (!Array.isArray(serverlessFileObj.plugins)) { + requestManualUpdate(configurationFilePath); + return; + } + } + await yamlAstParser.addNewArrayItem( + configurationFilePath, + checkIsArrayPluginsObject(serverlessFileObj.plugins) ? 'plugins' : 'plugins.modules', + pluginName + ); +}; + +const npmInstall = async (name, { serviceDir }) => { + const { command, args } = await npmCommandDeferred; + try { + await spawn(command, [...args, 'install', '--save-dev', name], { + cwd: serviceDir, + stdio: 'pipe', + // To parse quotes used in module versions. E.g. 'serverless@"^1.60.0 || 2"' + // https://stackoverflow.com/a/48015470 + shell: true, + }); + } catch (error) { + log.error(String(error.stderrBuffer)); + throw error; + } +}; + +const requestManualUpdate = (configurationFilePath) => { + log.notice(); + log.notice.skip( + `Can't automatically add plugin into "${path.basename( + configurationFilePath + )}" file. Please add it manually.` + ); +}; diff --git a/commands/plugin-uninstall.js b/commands/plugin-uninstall.js new file mode 100644 index 00000000000..1f47b60f10e --- /dev/null +++ b/commands/plugin-uninstall.js @@ -0,0 +1,121 @@ +'use strict'; + +const spawn = require('child-process-ext/spawn'); +const fsp = require('fs').promises; +const fse = require('fs-extra'); +const path = require('path'); +const _ = require('lodash'); +const isPlainObject = require('type/plain-object/is'); +const yaml = require('js-yaml'); +const cloudformationSchema = require('@serverless/utils/cloudformation-schema'); +const { log, progress, style } = require('@serverless/utils/log'); +const yamlAstParser = require('../lib/utils/yaml-ast-parser'); +const npmCommandDeferred = require('../lib/utils/npm-command-deferred'); +const { + getPluginInfo, + getServerlessFilePath, + validate, +} = require('../lib/commands/plugin-management'); + +const mainProgress = progress.get('main'); + +module.exports = async ({ configuration, serviceDir, configurationFilename, options }) => { + const commandRunStartTime = Date.now(); + validate({ serviceDir }); + + const pluginInfo = getPluginInfo(options.name); + const pluginName = pluginInfo.name; + const configurationFilePath = getServerlessFilePath({ serviceDir, configurationFilename }); + + const context = { configuration, serviceDir, configurationFilePath, pluginName }; + mainProgress.notice(`Uninstalling plugin "${pluginName}"`, { isMainEvent: true }); + await uninstallPlugin(context); + await removePluginFromServerlessFile(context); + + log.notice(); + log.notice.success( + `Plugin "${pluginName}" uninstalled ${style.aside( + `(${Math.floor((Date.now() - commandRunStartTime) / 1000)}s)` + )}` + ); +}; + +const uninstallPlugin = async ({ serviceDir, pluginName }) => { + await npmUninstall(pluginName, { serviceDir }); +}; + +const removePluginFromServerlessFile = async ({ configurationFilePath, pluginName }) => { + const fileExtension = path.extname(configurationFilePath); + if (fileExtension === '.js' || fileExtension === '.ts') { + requestManualUpdate(configurationFilePath); + return; + } + + if (fileExtension === '.json') { + const serverlessFileObj = await fse.readJson(configurationFilePath); + const isArrayPluginsObject = Array.isArray(serverlessFileObj.plugins); + const plugins = isArrayPluginsObject + ? serverlessFileObj.plugins + : serverlessFileObj.plugins && serverlessFileObj.plugins.modules; + + if (plugins) { + _.pull(plugins, pluginName); + if (!plugins.length) { + if (isArrayPluginsObject) { + delete serverlessFileObj.plugins; + } else { + delete serverlessFileObj.plugins.modules; + } + } + await fse.writeJson(configurationFilePath, serverlessFileObj); + } + return; + } + + const serverlessFileObj = yaml.load(await fsp.readFile(configurationFilePath, 'utf8'), { + filename: configurationFilePath, + schema: cloudformationSchema, + }); + if (serverlessFileObj.plugins != null) { + // Plugins section can be behind veriables, opt-out in such case + if (isPlainObject(serverlessFileObj.plugins)) { + if ( + serverlessFileObj.plugins.modules != null && + !Array.isArray(serverlessFileObj.plugins.modules) + ) { + requestManualUpdate(configurationFilePath); + return; + } + } else if (!Array.isArray(serverlessFileObj.plugins)) { + requestManualUpdate(configurationFilePath); + return; + } + } + await yamlAstParser.removeExistingArrayItem( + configurationFilePath, + Array.isArray(serverlessFileObj.plugins) ? 'plugins' : 'plugins.modules', + pluginName + ); +}; + +const npmUninstall = async (name, { serviceDir }) => { + const { command, args } = await npmCommandDeferred; + try { + await spawn(command, [...args, 'uninstall', '--save-dev', name], { + cwd: serviceDir, + stdio: 'pipe', + }); + } catch (error) { + log.error(String(error.stderrBuffer)); + throw error; + } +}; + +const requestManualUpdate = (configurationFilePath) => { + log.notice(); + log.notice.skip( + `Can't automatically remove plugin from "${path.basename( + configurationFilePath + )}" file. Please make it manually.` + ); +}; diff --git a/commitlint.config.js b/commitlint.config.js index 6975195c9dd..59fb85a7521 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -11,6 +11,7 @@ module.exports = { [ '', 'API', + 'AWS ActiveMQ', 'AWS ALB', 'AWS Alexa', 'AWS API Gateway', @@ -25,10 +26,13 @@ module.exports = { 'AWS Info', 'AWS Invocation', 'AWS IOT', + 'AWS Kafka', 'AWS Kinesis', 'AWS Lambda', + 'AWS Layers', 'AWS Local Invocation', 'AWS MSK', + 'AWS RabbitMQ', 'AWS S3', 'AWS Schedule', 'AWS SNS', diff --git a/docs/README.md b/docs/README.md index 730af3fd5dc..2cc0bf92d37 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ - - - -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/guides/access-roles/) - - - -> This document page is related to the deprecated dashboard. We advise using the updated dashboard at app.serverless.com and using the new [Providers feature to manage AWS connections](https://www.serverless.com/framework/docs/guides/providers/) for any new orgs created. - -# Access Roles - -You can use the Serverless Framework Dashboard to set up an AWS Access Role to help you secure your service deployments on AWS by enabling the Serverless Framework to issue temporary AWS Access Keys to deploy your services to AWS. - -If an Access Role is not configured, the Serverless Framework service will use AWS Access Keys stored in [environment variables](https://serverless.com/framework/docs/providers/aws/guide/credentials/) or [AWS Profiles](https://serverless.com/framework/docs/providers/aws/guide/credentials/) to deploy your service. - -With AWS Access Roles the AWS Access Keys are generated by Serverless Framework on every command and the credentials expire after one hour. The Serverless Framework leverages AWS Security Token Service and the AssumeRole API to automate creating and usage of temporary credentials, so your developers can stay productive and work securely without doing this manually. - -If you do not use the Serverless Framework Dashboard to set up an AWS Access Role, then you will need to configure your Serverless Framework open source CLI to use the AWS Access Keys stored in [environment variables](https://serverless.com/framework/docs/providers/aws/guide/credentials/) or [AWS Profiles](https://serverless.com/framework/docs/providers/aws/guide/credentials/). - -## Link your AWS Account - -1. Open the [Dashboard](https://app.serverless.com/) -2. Once logged in, click "**profiles**" near the top of the page. -3. Navigate to the profile you would like to configure with the AWS Access Role. -4. In the **AWS account** tab, click **connect aws** button. -5. Follow the instructions on AWS which will take you through creating an IAM Role for the Serverless Framework. -6. Once the IAM Role is created, your profile will be automatically updated. - -## Use the generated AWS Access Keys in your service - -You don't have to do anything in your `serverless.yml` file. When you run `sls deploy` the Serverless Framework will identify the deployment profile associated with the application or stage and it will generate the AWS Access Keys using the associated AWS Access Role automatically. - -## Deploy using AWS Access Roles - -That’s it! You are now ready to deploy using your AWS Access Roles. - -``` -serverless deploy -``` diff --git a/docs/guides/cicd/README.md b/docs/guides/cicd/README.md index 1e1bd699b38..2bd22320870 100644 --- a/docs/guides/cicd/README.md +++ b/docs/guides/cicd/README.md @@ -1,7 +1,7 @@ diff --git a/docs/guides/cicd/best-practices.md b/docs/guides/cicd/best-practices.md index ced610f3ed7..440ded90ca9 100644 --- a/docs/guides/cicd/best-practices.md +++ b/docs/guides/cicd/best-practices.md @@ -13,7 +13,7 @@ layout: Doc # Serverless CI/CD Best Practices -Serverless Framework Pro provides a lot of capabilities out of the box to help you manage and deploy +Serverless Framework provides a lot of capabilities out of the box to help you manage and deploy your services. As your teams grow and the number of services grow, it can be difficult to know the best way to organize your services for scale. diff --git a/docs/guides/cicd/custom-scripts.md b/docs/guides/cicd/custom-scripts.md index 06ffe7680ac..d0ceaf7e577 100644 --- a/docs/guides/cicd/custom-scripts.md +++ b/docs/guides/cicd/custom-scripts.md @@ -13,7 +13,7 @@ layout: Doc # Custom scripts -Serverless Framework Pro runs three primary operations on your repository when you have CI/CD configured: (1) install NPM packages via `npm install`, (2) run tests, if present, with `npm test`, and (3) deploy your service using `sls deploy`. You can run custom scripts before or after each of these steps if you need to customize the pipeline further. +Serverless Framework runs three primary operations on your repository when you have CI/CD configured: (1) install NPM packages via `npm install`, (2) run tests, if present, with `npm test`, and (3) deploy your service using `sls deploy`. You can run custom scripts before or after each of these steps if you need to customize the pipeline further. To run custom scripts before & after NPM install and running tests, use the lifecycle hooks built into `scripts` of your `package.json` file. The `preinstall`, `postinstall`, `pretest`, and `posttest`, scripts are run automatically at each of these steps. @@ -85,7 +85,7 @@ plugins: custom: scripts: hooks: - ‘before:deploy:deploy': + 'before:deploy:deploy': ``` **After serverless deploy** @@ -98,7 +98,7 @@ plugins: custom: scripts: hooks: - ‘deploy:finalize’: + 'deploy:finalize': ``` ## Additional lifecycle hooks diff --git a/docs/guides/cicd/faq.md b/docs/guides/cicd/faq.md index f9903827997..62cd5574048 100644 --- a/docs/guides/cicd/faq.md +++ b/docs/guides/cicd/faq.md @@ -13,7 +13,7 @@ layout: Doc # Frequently Asked Questions -# Is there a free tier? +## Is there a free tier? Yes, up to 1 concurrent build with the Free tier. No credit card required, just sign up. @@ -45,10 +45,6 @@ Yes! Serverless CI/CD is designed around the Serverless Framework to provide a s Anything you can deploy with the Serverless Framework you can deploy with Serverless CI/CD. The Serverless Framework is extensible with Plugins , so it works with a broad range of services. -## Is Serverless CI/CD also available for Serverless Framework Pro Enterprise tier? - -Yes, Serverless CI/CD works with the Serverless Framework Pro Enterprise tier and it is available for self-hosting. - ## Are all runtimes supported? Only the most popular runtimes, Node and Python, are currently supported. These two runtimes account for about 90% of diff --git a/docs/guides/cicd/notifications.md b/docs/guides/cicd/notifications.md index 7e6e1c75174..4c36a72569b 100644 --- a/docs/guides/cicd/notifications.md +++ b/docs/guides/cicd/notifications.md @@ -13,7 +13,7 @@ layout: Doc # Notifications -Serverless Framework Pro has integrated Slack, email, SNS and webhook notifications for CI/CD status updates. +Serverless Framework has integrated Slack, email, SNS and webhook notifications for CI/CD status updates. Notifications for CI/CD events are not setup by default, so you will not get notified of deployments starting, completing of failing. These notifications must be added manually. diff --git a/docs/guides/cicd/preview-deployments.md b/docs/guides/cicd/preview-deployments.md index aa7898a2278..e63f37e8885 100644 --- a/docs/guides/cicd/preview-deployments.md +++ b/docs/guides/cicd/preview-deployments.md @@ -37,7 +37,7 @@ Branch names may also include characters such as `/` which are invalid character ## Automatically deleting preview deployments (recommended) -The recommended method for deleting preview service instances is to select "Destroy stage and resources when branch is deleted". If the changes in the PR are accepted then they will be merged and then the branch is deleted. If the changes are rejected the branch is also deleted. Whenever the branch is deleted, Serverless Framework Pro will automatically run `sls remove` on this service instance. +The recommended method for deleting preview service instances is to select "Destroy stage and resources when branch is deleted". If the changes in the PR are accepted then they will be merged and then the branch is deleted. If the changes are rejected the branch is also deleted. Whenever the branch is deleted, Serverless Framework will automatically run `sls remove` on this service instance. ## Manually deleting preview deployments diff --git a/docs/guides/cicd/running-in-your-own-cicd.md b/docs/guides/cicd/running-in-your-own-cicd.md index ad245764192..17100de8bd5 100644 --- a/docs/guides/cicd/running-in-your-own-cicd.md +++ b/docs/guides/cicd/running-in-your-own-cicd.md @@ -48,7 +48,7 @@ Follow these steps to create an access token: 5. Provide a name and press “Create” 6. You will be presented with the access key on the new page. -**Note**: The access token has permission to the tenant; however, it is associated with your account. If your account is deleted, then the access token will be revoked too. +**Note**: The access token has permission to the org; however, it is associated with your account. If your account is deleted, then the access token will be revoked too. ### Configure environment variables diff --git a/docs/guides/dashboard.md b/docs/guides/dashboard.md index 2a208201cba..c8befead0dc 100644 --- a/docs/guides/dashboard.md +++ b/docs/guides/dashboard.md @@ -1,5 +1,5 @@ @@ -13,44 +13,116 @@ layout: Doc # Parameters -The Serverless Framework Dashboard enables you to create and manage parameters, helping you to configure and secure your services by securely storing parameters used by your Serverless Framework services. The [Serverless Framework Dashboard](https://app.serverless.com/) provides an interface to store and encrypt parameters and manage access to those parameters from your services. The Serverless Framework loads the parameters when the service is deployed. +Parameters can be defined in `serverless.yml` or in [Serverless Dashboard](https://www.serverless.com/secrets). They can be used for example to: -All parameters are treated as sensitive values, therefore they are always encrypted at rest, and only decrypted during deployment or to load them in the dashboard. +- adapt the configuration based on the stage +- store secrets securely +- share configuration values between team members -## Managing parameter using the dashboard +## Stage parameters -Parameters can be added to either services or instances. +Parameters can be defined **for each stage** in `serverless.yml` under the `params` key: -To manage parameters on the service, go to the **apps** section of the dashboard, and select **settings** under the **...** menu. +```yaml +params: + prod: + domain: myapp.com + dev: + domain: preview.myapp.com +``` -To manage parameters on the instance, go to the **app** section of the dashboard, select the instance, and go to the **params** tab. +Use the `default` key to define parameters that apply to all stages by default: -### Inheritance and overriding +```yaml +params: + default: + domain: ${sls:stage}.preview.myapp.com + prod: + domain: myapp.com + dev: + domain: preview.myapp.com +``` -Parameters set on instances take precedence over parameters set on services when deploying. If a parameter with the same key is set on both the instance and the service, then the value set on the instance will be used. If a parameter is set on the service, but not the instance, then the value set on the service will be used. +Parameters can then be used via the `${param:XXX}` variables: -This enables you to treat the parameters on services as defaults. This is especially useful in development when you may deploy instances to ephemeral stages (e.g. "feature-x"). In development the instance might not have any new parameters, therefore it will default to the parameters set on the service. However, in other stages, like "prod", or "staging", you may override the service-level parameters with instance-level parameters to use values unique to that stage. +```yaml +provider: + environment: + APP_DOMAIN: ${param:domain} +``` -## Using a Parameter in serverless.yml +The variable will be resolved based on the current stage. -In your `serverless.yml` file add the variable `${param:}` anywhere you would like to use the parameter. The `` references the parameter key configured in the profile. +## Serverless Dashboard parameters -When you run `serverless deploy` the parameter values will be obtained, decrypted and used to replace the variables in the `serverless.yml` for the deployment. +[Serverless Dashboard](https://www.serverless.com/secrets) lets you create and manage parameters, which is perfect for storing secrets securely or sharing configuration values across team members. -## Use parameters from the command line +On top of that, Dashboard parameters can be stored on the service (applies to all stages) or on a specific instance (applies to a specific stage). -Parameters can also be accessed on the CLI. You can use this at development time to look up the parameters without opening the dashboard, or in your CI/CD pipeline to use the parameters in custom scripts. +Dashboard parameters are treated as sensitive values, they are always encrypted at rest, and only decrypted during deployment or to view them in the dashboard. -### List parameters +Just like any other parameter, they can be used in `serverless.yml` via the `${param:XXX}` variables: -`sls param list [--org ] [--app ] [--service ] [--stage ] [--region ]` +```yaml +provider: + environment: + STRIPE_SECRET_KEY: ${param:stripeSecret} +``` -If you are in a working directory with a `serverless.yml` then the parameters will be listed for the org, app, and service specified in the `serverless.yml` file. +### Creating Serverless Dashboard parameters -If you are not in a working directory, without a `serverless.yml`, or if you want to access parameters from another org, app, service, stage, or region, you can pass in the optional flags. +Parameters can be created in the [Dashboard](https://app.serverless.com/) at the service level (applies to all stages) or instance level (stage-specific). -### Get a parameter +To manage parameters on a service, go to the **apps** section of the dashboard, and select **settings** under the **...** menu. -`sls param get --name [--org ] [--app ] [--service ] [--stage ] [--region ]` +To manage parameters on an instance, go to the **app** section of the dashboard, select the instance, and go to the **params** tab. + +### Retrieving parameters from the command line + +Dashboard parameters can also be accessed on the CLI. You can use this at development time to look up the parameters without opening the dashboard, or in your CI/CD pipeline to use the parameters in custom scripts. + +#### List parameters + +If you are in a directory with a `serverless.yml`, the parameters will be listed for the org, app, and service specified in the `serverless.yml` file: + +```bash +serverless param list [--stage ] +``` + +If you are in a directory without a `serverless.yml`, or if you want to access parameters from another org, app, service, stage, or region, you can pass in the optional flags: + +```bash +serverless param list + [--org ] + [--app ] + [--service ] + [--stage ] + [--region ] +``` + +#### Get a parameter Individual parameters can also be accessed from the CLI using the `param get` sub-command. This command requires the `--name ` flag to identify the parameter name. Like the `sls param list`, you can optionally specify a different org, app, service, stage, ore region using flags. + +```bash +serverless param get --name + [--org ] + [--app ] + [--service ] + [--stage ] + [--region ] +``` + +## Inheritance and overriding + +Parameters can be defined in `serverless.yml` per stage, as well as in Serverless Dashboard on the service or the instance (stage). Here is the priority used to resolve a `${param:XXX}` variable: + +- First, look in `params.` in `serverless.yml` +- If not found, then look in the instance's parameters in the Dashboard +- If not found, then look in `params.default` in `serverless.yml` +- If not found, then look in the service's parameters in the Dashboard +- If not found, throw an error, or use the fallback value if one was provided: `${param:XXX, 'default value'}` + +This gives you flexibility to mix `serverless.yml` parameters as well as secure Serverless Dashboard parameters. + +This is especially useful in development when deploying to ephemeral stages (e.g. "feature-x"). The stage might not have any parameter, therefore it will default to the parameters set on the service. However, in other stages, like "prod", or "staging", you may override the service-level parameters with stage-level parameters to use values unique to that stage. diff --git a/docs/guides/plugins/README.md b/docs/guides/plugins/README.md new file mode 100644 index 00000000000..1b4265101c5 --- /dev/null +++ b/docs/guides/plugins/README.md @@ -0,0 +1,87 @@ + + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/guides/plugins) + + + +# Plugins + +A plugin is custom JavaScript code that extends the Serverless Framework with new features. + +If you or your organization have a specific workflow, install a pre-written plugin or write one to customize the Framework to your needs. + +Since the Serverless Framework is a group of "core" plugins, custom plugins are written exactly the same way as core plugins. Learn more about [creating a custom plugin](creating-plugins.md). + +Explore existing plugins in the [Serverless Framework Plugins repository](https://www.serverless.com/plugins). + +## Installing plugins + +Plugins are installed per service. They are not applied globally. + +To install a plugin, run the following command in a service directory: + +``` +serverless plugin install -n custom-serverless-plugin +``` + +This command will install the plugin via NPM and register it in `serverless.yml`. + +You can also install the plugin manually via NPM: + +``` +npm install --save custom-serverless-plugin +``` + +and then register it in `serverless.yml` in the `plugins` section: + +```yml +# serverless.yml file + +plugins: + - custom-serverless-plugin +``` + +Some plugins require extra configuration. The `custom` section in `serverless.yml` is where you can add extra configuration for plugins (the plugin's documentation will tell you if you need to add anything there): + +```yml +plugins: + - custom-serverless-plugin + +custom: + customkey: customvalue +``` + +Note for plugin authors: read [Extending the configuration](custom-configuration.md) to learn how to enhance `serverless.yml` with configuration validation. + +## Service local plugin + +If you are working on a plugin, or have a plugin that is just designed for one project, it can be loaded from local files: + +```yml +plugins: + - ./local-directory/custom-serverless-plugin +``` + +The path must start with `./` and is relative to the root of your service. + +## Load Order + +Keep in mind that the order you define your plugins matters. Serverless loads all the core plugins, and then the custom plugins in the order you've defined them. + +```yml +# serverless.yml + +plugins: + - plugin1 + - plugin2 +``` + +In this case `plugin1` is loaded before `plugin2`. diff --git a/docs/guides/plugins/cli-output.md b/docs/guides/plugins/cli-output.md new file mode 100644 index 00000000000..d7f32ac00f3 --- /dev/null +++ b/docs/guides/plugins/cli-output.md @@ -0,0 +1,263 @@ + + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/guides/plugins/cli-output) + + + +# CLI output in plugins + +Plugins can integrate and extend the CLI output of the Serverless Framework in different ways. + +## Writing to the output + +In Serverless Framework v2, plugins could write to the CLI output via `serverless.cli.log()`: + +```js +// This approach is deprecated: +serverless.cli.log('Message'); +``` + +The method above is deprecated. It should no longer be used in Serverless Framework v3. + +Instead, plugins can log messages to the CLI output via a standard `log` interface: + +```js +class MyPlugin { + constructor(serverless, cliOptions, { log }) { + log.error('Error'); + log.warning('Warning'); + log.notice('Message'); + log.info('Verbose message'); // --verbose log + log.debug('Debug message'); // --debug log + } +} +``` + +Some aliases exist to make log levels more explicit: + +```js +log('Here is a message'); +// is an alias to: +log.notice('Here is a message'); + +log.verbose('Here is a verbose message'); // displayed with --verbose +// is an alias to: +log.info('Here is a verbose message'); // displayed with --verbose +``` + +To write a formatted "success" message, use the following helper: + +```js +log.success('The task executed with success'); +``` + +Log methods also support the printf format: + +```js +log.warning('Here is a %s log', 'formatted'); +``` + +**Best practices:** + +- **Keep the default CLI output minimal.** +- Log most information to the `--verbose` output. +- Warnings should be used exceptionally. Consider whether the plugin should instead throw an exception, log a `--verbose` message or trigger a deprecation (see below). +- Before using `log.error()`, consider [throwing an exception](#errors): exceptions are automatically caught by the Serverless Framework and formatted with details. +- Debugging logs should be logged to the `--debug` level. Debug logs can be namespaced following the [`debug` convention](https://github.com/visionmedia/debug#usage) via `log.get('my-namespace').debug('Debug message')`. Such logs can then be filtered in the CLI output via `--debug=plugin-name:my-namespace`. + +**By default, logs are written to `stderr`**, which displays in terminals (humans cannot tell the difference). This is intentional: plugins can safely log extra messages to any command, even commands meant to be piped or parsed by another program. Read the next section to learn more. + +### Writing command output to `stdout` + +By default, plugins should write messages to `stderr` via the `log` object. To write command output to `stdout` instead, use `writeText()`: + +```js +class MyPlugin { + constructor(serverless, cliOptions, { writeText }) { + writeText('Command output'); + writeText(['Here is a', 'multi-line output']); + } +} +``` + +**Best practices:** + +- `stdout` output is usually meant to be piped to/parsed by another program. +- Plugins should only write to `stdout` in commands they define (to avoid breaking the output of other commands). +- The only content written to `stdout` should be the main output of the command. + +Take, for example, the `serverless invoke` command: + +- Its output is the result of the Lambda invocation: by writing that result (and only that) to `stdout`, it allows any script to parse the result of the Lambda invocation. +- All other messages should be written to `stderr`: such logs are useful to humans, for example configuration warnings, upgrade notifications, Lambda logs… Since they are written to `stderr`, they do not break the parsable output of `stdout`. + +**If unsure, write to `stderr`** (with the `log` object) instead of `stdout`. Why: human users will not see any difference, but the door will stay open to write a parsable output later in the future. + +### Colors and formatting + +To format and color text output, use the [chalk](https://github.com/chalk/chalk) package. For example: + +```js +log.notice(chalk.gray('Here is a message')); +``` + +**Best practices:** + +- Write primary information in **white**, secondary information in **gray**. + - Primary information is the direct outcome of a command (e.g. deployment result of the `deploy` command, or result of the `invoke` command). Secondary information is everything else. +- Plugins should generally not use any other color, nor introduce any other custom formatting. Output formatting is meant to be minimalistic. +- Plugins should use built-in formats documented in this page: success messages (`log.success()`), interactive progress… + +The "Serverless red" color (`#fd5750`) is used to grab the user's attention: + +- It should be used minimally, and maximum once per command. +- It should be used only to grab attention to the command's most important information. + +## Errors + +The Serverless Framework differentiates between 2 errors: + +- user errors (wrong input, invalid configuration, etc.) +- programmer errors (aka bugs) + +To throw a **user error** and have it properly formatted, use Serverless' error class: + +```js +throw new serverless.classes.Error('Invalid configuration in X'); +``` + +All other errors are considered programmer errors by default (and are properly formatted in the CLI output as well). + +**Best practices:** + +- If an error should stop the execution of the command, use `throw`. +- If an error should _not_ stop the execution of the command (which should be exceptional), log it via `log.error()`. + - For example any execution error in `serverless-offline` should not stop the local server. + +## Interactive progress + +Plugins can create an interactive progress: + +```js +class MyPlugin { + constructor(serverless, cliOptions, { progress }) { + const myProgress = progress.create({ + message: 'Doing extra work in my-plugin', + }); + // ... + myProgress.update('Almost finished'); + // ... + myProgress.remove(); + } +} +``` + +In case of parallel processing (for example compiling multiple files in parallel), it is possible to create multiple progress items if that is useful to users. + +**Best practices:** + +- Create a progress for tasks that usually take **more than 2 seconds**. Below that threshold, plugins can operate silently and log to `--verbose` only. +- Users should know which plugin is working from the progress message: + - Bad: "Compiling" + - Bad: "[Webpack] Compiling" (avoid prefixes) + - Good: "Compiling with webpack" +- Displaying multiple progresses should be exceptional, and limited to 3-4 progresses at a time. It is better to keep the output minimal than too noisy. + +Note that it is possible to give a unique name to a progress. That name can be used to retrieve the progress without having to pass the instance around: + +```js +// Progress without any name: +const myProgress = progress.create({ + message: 'Doing extra work in my-plugin', +}); + +// Progress with a unique name +progress.create({ + message: 'Doing extra work in my-plugin', + name: 'my-plugin-progress', // Try to make the name unique across all plugins +}); +// elsewhere... +progress.get('my-plugin-progress').update('Almost finished'); +// elsewhere... +progress.get('my-plugin-progress').remove(); +``` + +## Service information + +Plugins can add their own sections to the "Service information", i.e. the information displayed after `serverless deploy` or in `serverless info`. + +To add a single item: + +```js +serverless.addServiceOutputSection('my section', 'content'); +``` + +The example above will be displayed as: + +``` +$ serverless info +functions: + ... +my section: content +``` + +To add a multi-line section: + +```js +serverless.addServiceOutputSection('my section', ['line 1', 'line 2']); +``` + +The example above will be displayed as: + +``` +$ serverless info +functions: + ... +my section: + line 1 + line 2 +``` + +## Deprecations + +Plugins can signal deprecated features to users via `logDeprecation()`: + +```js +serverless.logDeprecation( + 'DEPRECATION_CODE', + 'Feature X of my-plugin is deprecated. Please use Y instead.' +); +``` + +These deprecations will integrate with the deprecation system of the Serverless Framework. + +**Best practices:** + +- Prefix the deprecation code with the plugin name, for example: `OFFLINE_XXX`. +- Make the message actionable for users: if a feature is deprecated, what should users use instead? Feel free to add links if necessary. + +## Retrieving the I/O API + +As shown in the examples above, the I/O API is injected in the constructor of plugins: + +```js +class MyPlugin { + constructor(serverless, cliOptions, { writeText, log, progress }) { + // ... + } +} +``` + +However, it is also possible to retrieve it from any JavaScript file by requiring the `@serverless/utils` package: + +```js +const { writeText, log, progress } = require('@serverless/utils/log'); +``` diff --git a/docs/guides/plugins/creating-plugins.md b/docs/guides/plugins/creating-plugins.md new file mode 100644 index 00000000000..94b1e6565c8 --- /dev/null +++ b/docs/guides/plugins/creating-plugins.md @@ -0,0 +1,189 @@ + + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/guides/plugins/creating-plugins) + + + +# Creating custom plugins + +Creating a custom plugin lets you: + +- [Hook into _lifecycle events_ to add new logic](#lifecycle-events) +- [Define new CLI commands](custom-commands.md) +- [Define new variable sources](custom-variables.md) +- [Extend the `serverless.yml` syntax](custom-configuration.md) +- [Write extra information to the CLI output](cli-output.md) +- Add support for new cloud providers + +## Creating a plugin + +The simplest way to create a Serverless Framework plugin is to write a JavaScript file: + +```javascript +'use strict'; + +class MyPlugin { + constructor() { + // The plugin is loaded + } +} + +module.exports = MyPlugin; +``` + +The plugin can then be loaded in `serverless.yml` via a local path: + +```yaml +# serverless.yml +service: app + +functions: + # ... + +plugins: + - ./my-plugin.js +``` + +### Distributing a plugin via NPM + +Plugins can also be published to NPM and later installed in separate projects. + +To correctly configure the plugin's NPM package, set the `main` property to point to your plugin file in `package.json`: + +```json +{ + "main": "my-plugin.js" +} +``` + +It is also a good practice to add `serverless` to the `peerDependencies` section. That ensures that your plugin runs only with the Serverless Framework versions it supports. + +```json +{ + ... + "peerDependencies": { + "serverless": "^2.60 || 3" + } +} +``` + +Once the plugin is published on NPM, follow the documentation on [Installing plugins](README.md) to use the custom plugin. + +## Lifecycle events + +Lifecycle events are events that fire sequentially during a CLI command. + +Additionally, for each event an additional `before` and `after` event is created. For example: + +- `before:package:package` +- `package:package` +- `after:package:package` +- `before:deploy:deploy` +- `deploy:deploy` +- `after:deploy:deploy` + +The `initialize` event is shared across all CLI commands and runs when the CLI starts. + +Plugins can "hook" into existing lifecycle events to add behavior to commands like `deploy`, `package`, etc. via the `hooks` helper: + +```javascript +'use strict'; + +class MyPlugin { + constructor() { + this.hooks = { + 'initialize': () => this.init(), + 'before:deploy:deploy': () => this.beforeDeploy(), + 'after:deploy:deploy': () => this.afterDeploy(), + }; + } + + init() { + // Initialization + } + + beforeDeploy() { + // Before deploy + } + + afterDeploy() { + // After deploy + } +} + +module.exports = MyPlugin; +``` + +Plugins can also create their own commands (with their own lifecycle events): read the [Custom commands documentation](custom-commands.md). + +## Serverless instance + +The `serverless` parameter provides access to the service configuration at runtime: + +```javascript +'use strict'; + +class MyPlugin { + constructor(serverless) { + this.serverless = serverless; + this.hooks = { + initialize: () => this.init(), + }; + } + + init() { + console.log('Serverless instance: ', this.serverless); + + // `serverless.service` contains the (resolved) serverless.yml config + const service = this.serverless.service; + console.log('Provider name: ', service.provider.name); + console.log('Functions: ', service.functions); + } +} + +module.exports = MyPlugin; +``` + +**Note:** configuration values are only resolved _after_ plugins are initialized. Do not try to read configuration in the plugin constructor, as variables aren't resolved yet. Read configuration in lifecycle events only. + +## CLI options + +The `options` parameter provides access to the CLI options provided to the command: + +```javascript +class MyPlugin { + constructor(serverless, options) { + // Log if a --verbose option was passed: + console.log(options.verbose); + } +} +``` + +## Provider-specific plugins + +Plugins can be provider specific, which means that run only with a specific provider. + +**Note:** Binding a plugin to a provider is optional. Serverless will always consider your plugin if you don't specify a `provider`. + +To bind to a specific provider, retrieve it and set the `this.provider` property in the plugin constructor: + +```javascript +class MyPlugin { + constructor(serverless, options) { + // bind to a specific provider + this.provider = serverless.getProvider('providerX'); + + // ... + } +} +``` + +The plugin will now only be executed when the service's provider matches the given provider. diff --git a/docs/guides/plugins/custom-commands.md b/docs/guides/plugins/custom-commands.md new file mode 100644 index 00000000000..76f5b17f1d5 --- /dev/null +++ b/docs/guides/plugins/custom-commands.md @@ -0,0 +1,125 @@ + + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/guides/plugins/custom-commands) + + + +# Custom commands + +Serverless Framework plugins can define custom CLI commands. + +These commands can then be called by users, for example: `serverless my-command`. + +```javascript +class MyPlugin { + constructor() { + this.commands = { + 'my-command': { + lifecycleEvents: ['resources', 'functions'], + }, + }; + } +} + +module.exports = MyPlugin; +``` + +A CLI _Command_ that can be called by a user, e.g. `serverless foo`. A Command has no logic, but simply defines the CLI configuration (e.g. command, parameters) and the _Lifecycle Events_ for the command. Every command defines its own lifecycle events. + +## Lifecycle events + +By default, a command has no logic. Use _lifecycle event hooks_ to add logic when the command runs: + +```javascript +class MyPlugin { + constructor() { + this.commands = { + 'my-command': { + lifecycleEvents: ['run'], + }, + }; + + this.hooks = { + 'my-command:run': () => { + // Do something + }, + }; + } +} +``` + +For each event, an additional `before` and `after` event is created: + +```js +this.hooks = { + 'before:my-command:run': () => { + // Before my command runs + }, + 'my-command:run': () => { + // My command runs + }, + 'after:my-command:run': () => { + // After + }, +}; +``` + +Note that a command can define multiple events: these will be called sequentially. + +## Command options + +Commands can have CLI options: + +- either passed with a double dash (`--`): `serverless my-command --function functionName`. +- or as a shortcut with a single dash (`-`): `serverless my-command -f functionName`. + +Options can be specified in the command definition. The value of the CLI option can be retrieved via the `options` parameter of the plugin: + +```javascript +class MyPlugin { + constructor(serverless, options) { + this.options = options; + + this.commands = { + 'my-command': { + // The 'usage' property is used to display the 'serverless --help' output + usage: 'This is my new custom command!', + lifecycleEvents: ['run'], + options: { + // Define the '--function' option with the '-f' shortcut + function: { + usage: 'Specify the function you want to handle (e.g. "--function myFunction")', + shortcut: 'f', + required: true, + type: 'string', // Possible values: 'string', 'boolean', 'multiple' + }, + }, + }, + }; + + this.hooks = { + 'my-command:run': () => this.run(), + }; + } + + run() { + console.log('The option was: ', this.options.function); + } +} +``` + +If an option is not required, a `default` property can be set in the option definition. + +## Command naming + +Command names must be unique across all plugins. For example instead of defining a custom `deploy` command, name it `my-company-deploy` instead. + +If a plugin defines a command name that conflicts with Serverless Framework core or another plugin, the CLI will exit with an error. diff --git a/docs/guides/plugins/custom-configuration.md b/docs/guides/plugins/custom-configuration.md new file mode 100644 index 00000000000..3f1cf75133a --- /dev/null +++ b/docs/guides/plugins/custom-configuration.md @@ -0,0 +1,345 @@ + + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/guides/plugins/custom-configuration) + + + +# Extending the configuration + +Plugin can extend the `serverless.yml` syntax with custom configuration: + +```yaml +service: app +provider: + name: aws + +# ... + +my-plugin: + my-plugin-config: foo +``` + +To do so, plugins must define schema validation (see below), and can retrieve configuration values via `serverless.service`: + +```js +class MyPlugin { + constructor(serverless) { + this.serverless = serverless; + this.hooks = { + 'before:deploy': () => this.beforeDeploy(), + }; + } + + beforeDeploy() { + // `service` contains the (resolved) serverless.yml config + const service = this.serverless.service; + console.log('Provider name: ', service.provider.name); + console.log('Functions: ', service.functions); + console.log('Custom plugin config: ', service['my-plugin']['my-plugin-config']); + } +} + +module.exports = MyPlugin; +``` + +**Note:** configuration values are only resolved _after_ plugins are initialized. Do not try to read configuration in the plugin constructor, as variables aren't resolved yet. Read configuration in lifecycle events only. + +## Validating the configuration + +Any additional configuration defined by plugins in `serverless.yml` must come with validation rules. + +Serverless Framework uses JSON schema validation backed by [the AJV library](https://github.com/ajv-validator/ajv). You can extend [the base schema](/lib/configSchema/index.js) in plugins via: + +- `defineTopLevelProperty` +- `defineCustomProperties` +- `defineFunctionEvent` +- `defineFunctionEventProperties` +- `defineFunctionProperties` +- `defineProvider` + +Use the following map to know which helper suits your needs: + +```yml +custom: + my-plugin: + customProperty: foobar # <-- use defineCustomProperties + +my-plugin: # <-- use defineTopLevelProperty + customProperty: foobar + +provider: + name: new-provider # <-- use defineProvider + my-plugin: + customProperty: foobar + +functions: + someFunc: + handler: handler.main + customProperty: foobar # <-- use defineFunctionProperties + events: + - yourPluginEvent: # <-- use defineFunctionEvent + customProperty: foobar + - http: + customProperty: foobar # <-- use defineFunctionEventProperties +``` + +We'll walk though those helpers. You may also want to check out examples from [helpers tests](tests/fixtures/configSchemaExtensions/test-plugin.js) + +### Top-level properties via `defineTopLevelProperty` + +If your plugin requires additional top-level properties (like `provider`, `custom`, `service`...), you can use the `defineTopLevelProperty` helper to add their definition. For example: + +```yml +# serverless.yml +service: my-service + +myPlugin: + someProperty: foobar +``` + +Add validation for the `myPlugin:` section: + +```javascript +class MyPlugin { + constructor(serverless) { + // For reference on JSON schema, see https://github.com/ajv-validator/ajv + serverless.configSchemaHandler.defineTopLevelProperty('myPlugin', { + type: 'object', + properties: { + someProperty: { type: 'string' }, + }, + required: ['someProperty'], + }); + } +} +``` + +This way, if the user sets `someProperty` by mistake to `false`, the Framework would display an error: + +``` +Configuration error: yourPlugin.someProperty should be string +``` + +### Properties in `custom` via `defineCustomProperties` + +If your plugin depends on properties defined in the `custom:` section, you can use the `defineCustomProperties` helper. For example: + +```yml +# serverless.yml + +custom: + myCustomProperty: foobar +``` + +Add validation for the `myCustomProperty` property: + +```javascript +class MyPlugin { + constructor(serverless) { + // For reference on JSON schema, see https://github.com/ajv-validator/ajv + serverless.configSchemaHandler.defineCustomProperties({ + type: 'object', + properties: { + myCustomProperty: { type: 'string' }, + }, + required: ['myCustomProperty'], + }); + } +} +``` + +This way, if the user sets `myCustomProperty` by mistake to `false`, the Framework would display an error: + +``` +Configuration error: custom.myCustomProperty should be string +``` + +### Function properties via `defineFunctionProperties` + +If your plugin adds new properties to functions, you can use the `defineFunctionProperties` helper. For example: + +```yml +# serverless.yml + +functions: + foo: + handler: handler.main + someCustomProperty: my-property-value +``` + +Add validation for the `someCustomProperty` property: + +```javascript +class MyPlugin { + constructor(serverless) { + // For reference on JSON schema, see https://github.com/ajv-validator/ajv + serverless.configSchemaHandler.defineFunctionProperties('providerName', { + properties: { + someCustomProperty: { type: 'string' }, + anotherProperty: { type: 'number' }, + }, + required: ['someCustomProperty'], + }); + } +} +``` + +This way, if the user sets `anotherProperty` by mistake to `hello`, the Framework would display an error: + +``` +Configuration error at 'functions.foo.anotherProperty': should be number +``` + +### Function events via `defineFunctionEvent` + +If your plugin adds support to a new function event, you can use the `defineFunctionEvent` helper. For example: + +```yml +# serverless.yml + +functions: + someFunc: + handler: handler.main + events: + - myPluginEvent: + someProp: hello + anotherProp: 1 +``` + +Add validation for the `myPluginEvent` event: + +```javascript +class MyPlugin { + constructor(serverless) { + // For reference on JSON schema, see https://github.com/ajv-validator/ajv + serverless.configSchemaHandler.defineFunctionEvent('providerName', 'myPluginEvent', { + type: 'object', + properties: { + someProp: { type: 'string' }, + anotherProp: { type: 'number' }, + }, + required: ['someProp'], + additionalProperties: false, + }); + } +} +``` + +This way, if the user sets `anotherProp` by mistake to `some-string`, the Framework would display an error: + +``` +Configuration error: functions.someFunc.events[0].myPluginEvent.anotherProp should be number +``` + +### Function event properties via `defineFunctionEventProperties` + +If your plugin adds new properties to a function event, you can use the `defineFunctionEventProperties` helper. For example: + +```yml +# serverless.yml + +functions: + foo: + handler: handler.main + events: + - http: + path: '/quote' + method: GET + documentation: Get a quote +``` + +In the example above, the plugin adds a new `documentation` property on `http` events for `aws`. To validate that properties: + +```javascript +class MyPlugin { + constructor(serverless) { + // For reference on JSON schema, see https://github.com/ajv-validator/ajv + serverless.configSchemaHandler.defineFunctionEventProperties('aws', 'http', { + properties: { + documentation: { type: 'string' }, + }, + required: ['documentation'], + }); + } +} +``` + +This way, if the user sets `documentation` by mistake to `false`, the Framework would display an error: + +``` +Configuration error: functions.foo.events[0].http.documentation should be a string +``` + +### New provider via `defineProvider` + +If your plugin provides support for a new provider, register it via `defineProvider`: + +```javascript +class MyPlugin { + constructor(serverless) { + // For reference on JSON schema, see https://github.com/ajv-validator/ajv + serverless.configSchemaHandler.defineProvider('newProvider', { + // Eventual reusable schema definitions (will be put to top level "definitions" object) + definitions: { + // ... + }, + + // Top level "provider" properties + provider: { + properties: { + stage: { type: 'string' }, + remoteFunctionData: { type: 'null' }, + }, + }, + + // Function level properties + function: { + properties: { handler: { type: 'string' } }, + }, + + // Function events definitions (can be defined here or via `defineFunctionEvent` helper) + functionEvents: { + someEvent: { + name: 'someEvent', + schema: { + type: 'object', + properties: { + someRequiredStringProp: { type: 'string' }, + someNumberProp: { type: 'number' }, + }, + required: ['someRequiredStringProp'], + additionalProperties: false, + }, + }, + }, + + // Definition for eventual top level "resources" section + resources: { + type: 'object', + properties: { + // ... + }, + }, + + // Definition for eventual top level "layers" section + layers: { + type: 'object', + additionalProperties: { + type: 'object', + properties: { + // ... + }, + }, + }, + }); + } +} +``` diff --git a/docs/guides/plugins/custom-variables.md b/docs/guides/plugins/custom-variables.md new file mode 100644 index 00000000000..a7233ad81d7 --- /dev/null +++ b/docs/guides/plugins/custom-variables.md @@ -0,0 +1,128 @@ + + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/guides/plugins/custom-variables) + + + +# Custom variables + +Plugins can register custom variables sources, for example `${foo:some-variable}`. + +Custom sources can be registered via `configurationVariablesSources` as an object with a `resolve` function: + +```javascript +'use strict'; + +class MyPlugin { + constructor() { + this.configurationVariablesSources = { + foo: { + async resolve({ address }) { + // `address` contains the name of the variable to resolve: + // In `${foo:some-variable}`, address will contain `some-variable`. + + // Resolver is expected to return an object with the value in the `value` property: + return { + // + value: `Resolving variable ${address}`, + }; + }, + }, + }; + } +} + +module.exports = MyPlugin; +``` + +The variable source defined above (registered via a plugin) can be used as follows: + +```yaml +service: test +# ... + +custom: + value1: ${foo:bar} + +plugins: + - ./my-plugin +``` + +The configuration will be resolved into the following: + +```yaml +service: test +# ... + +custom: + value1: Resolving variable bar + +plugins: + - ./my-plugin +``` + +## Variable parameters + +Variable sources can support advanced use cases via parameters: + +```yaml +service: test +# ... + +custom: + value1: ${foo(one, two):bar} +``` + +Parameters can be retrieved in the `params` argument: + +```javascript +class MyPlugin { + constructor() { + this.configurationVariablesSources = { + foo: { + async resolve({ address, params }) { + return { + // In the example below, ${foo(one, two):bar} will + // resolve to "one,two" + value: (params || []).join(','), + }; + }, + }, + }; + } +} +``` + +## Resolving variables, configuration values and options + +It is possible to retrieve other variables, configuration values and CLI options in the variable resolver: + +```javascript +class MyPlugin { + constructor() { + this.configurationVariablesSources = { + foo: { + async resolve({ resolveVariable, options }) { + // `options` is CLI options + // `resolveVariable` resolves other variables (for example here: `${sls:stage}`) + const stage = await resolveVariable('sls:stage'); + // To retrieve a configuration value from serverless.yml, use the `self:xxx` variable source, for example: + // await resolveVariable('self:provider.region') + + return { + value: `The stage is ${stage}`, + }; + }, + }, + }; + } +} +``` diff --git a/docs/guides/profiles.md b/docs/guides/profiles.md deleted file mode 100644 index 87415feff1e..00000000000 --- a/docs/guides/profiles.md +++ /dev/null @@ -1,82 +0,0 @@ - - - - -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/guides/profiles/) - - - -> This is a deprecated feature of the dashboard. Please look at our documentaion for [Providers](https://www.serverless.com/framework/docs/guides/providers/) and -> [Parameters](https://www.serverless.com/framework/docs/guides/parameters/) which replaces the use of deployment profiles for setting up AWS connections and parameters. - -# Deployment Profiles - -Deployment Profiles enable each stage of your Serverless application to use a unique set of [Safeguards](./safeguards.md), [Parameters](./parameters.md) and [Access Roles](./access-roles.md). - -## Deprecation and Migration from Deployment Profile - -Prior to the January 11th, 2021 release, deployment profiles supported setting AWS Access Role ARNs and managing parameters. Support for using AWS Access Roles for deployments has moved from deployment profiles to Providers. Support for managing Parameters has moved from deployment profiles to services and instances. - -**Deployment profiles will be deprecated on February 28th, 2021**. Migration from deployment profiles to providers and parameters will be automatic; however, there are two required action items to use the new features. - -### Action Items - -- You **MUST** upgrade to use the Enterprise Plugin version 4.4.1 or higher. -- You **MUST** relink your AWS Account via the providers UI by no later than February 28th, 2021. - -### Automatic Migration - -Parameters and Providers were migrated automatically from deployment profiles on January 31st, 2021. - -The automatic migration replaced deployment profiles with providers by performing the following: - -- **A new provider will be created for each deployment profile using the same AWS Access Role ARN**. If the deployment profile doesn’t contain an AWS Access Role ARN, it will be skipped. -- **A provider will be added to each service for the corresponding default stage in the app**. The provider will be the provider corresponding to the deployment profile which was associated with the default stage of the parent app. For example, if `app1` has `service1` and the _`default`_ stage of `app1` links to the `dev` deployment profile, then the `dev` provider will be added to `service1`. This is repeated for all services in all apps. -- **A provider will be added to each instance for the corresponding stage in the app**. The provider will be the provider corresponding to the deployment profile which was associated with the stage of the instance. For example, if `app1` has `service1` and `app1` has a stage `prod` linked to the `prod` deployment profile, then the `prod` provider will be added to the `service1` instances deployed to the `prod` stage. -- **Parameters from the deployment profile associated with the default stage in the app will be copied to the service**. -- **Parameters from the deployment profile associated with a stage in an app will be copied to the instance**. - -## Use Deployment Profiles - -Deployment profiles are managed in the [Serverless Framework Dashboard](https://app.serverless.com). When you run `serverless deploy`, the CLI obtains the Safeguard policies, Parameters, and the generated AWS Credentials. - -### Creating a new Deployment Profile - -Create a new deployment profile by navigating to **profiles** in the [Serverless Framework Dashboard](https://app.serverless.com) and click **add**. - -#### name - -This is a user-readable name for the deployment profile. Most often it has a name that maps to a stage (e.g. “dev”, “prod”), or in larger organizations the line of business or environment (e.g. “apac-banking-prod”). This name will uniquely identify the deployment profile when associating it with a stage in an application. - -#### description - -The description helps provide additional context when listing the deployment profiles. - -#### access roles, parameters and safeguards - -Access Roles, Parameters and Safeguards have individual configuration guides: - -- [access roles](./access-roles.md#link-your-aws-account) -- [safeguard policies](./safeguards.md#configuring-policies) -- [parameters](./parameters.md) - -### Add a deployment profile to your application and stage - -Create a new stage by navigating to **applications** in the [Serverless Framework Dashboard](https://app.serverless.com). - -1. Expand the application and click into the **stages** tab. -2. Click **add stage** in the tab -3. Provide the **name** and select the **deployment profile**. - -You can also set the **default deployment profile** field in the application. You can use this to set the deployment profile on all services in that application. When deploying to a stage which hasn't be defined in the dashboard, then the default deployment profile will be used. - -### Using a Deployment Profile to deploy - -When you run `serverless deploy` Serverless Framework will obtain the AWS Access Key, Parameter and Safeguards associated with the deployment profile configured for that application and stage based on the values for `app` and `stage` in your `serverless.yml` file. - -The Serverless Framework will first try to match the current stage from `serverless.yml` with a stage configured on that application in the dashboard. If they match, it will use the deployment profile associated with that stage. If the stages do not match, then the default deployment profile from that application will be used. diff --git a/docs/guides/providers.md b/docs/guides/providers.md index ce5e30c2aac..fbf99775fa3 100644 --- a/docs/guides/providers.md +++ b/docs/guides/providers.md @@ -27,11 +27,11 @@ There are many benefits to using providers over managing accounts manually: - No need to share credentials out of band (e.g. sending slack messages) - Some providers, like AWS Access Roles, provide an additional layer of security as credentials are generated per deployment and have a short TTL. -# Adding providers in the dashboard +## Adding providers in the dashboard To use providers you must add the providers to your organization and then link the provider to a service. Optionally you can link the provider to an instance instead if you need to use different providers for different stages or regions. -## Adding providers to your organization +### Adding providers to your organization To add a provider to your organization go the **org** section of the [dashboard](https://app.serverless.com). Under the **providers** tab, click **add** and follow the instructions. @@ -39,25 +39,25 @@ You’ll be able to select the provider, like AWS, Stripe, and Twilio, name the It is recommended that you deploy your Serverless Framework apps to different accounts for each stage. To accomplish this we recommend adding a `dev` and `prod` provider to decouple the prod environment from all other environments. -## Setting a default organization provider +### Setting a default organization provider A Provider at the organization level can also be designated as the default provider for the organization. This provider will be used in any deployments where the service or instance do not have a provider set. To set the organizatwion default, go to the **orgs** section of the dashboard, and select the **providers** tab, under the **...** menu of the provider select **set as default**. -## Adding a provider to a service +### Adding a provider to a service Adding the providers to the organization alone will not be sufficient, you must also link that provider with the service. To add a provider to a service, go to the **apps** section of the dashboard, and select **settings** under the **...** menu of the service for which you would like to use providers. On the service settings page navigate to the **providers** tab. From there you can click **add provider** which will allow you to add the providers from the organization into your service. -## Adding a provider to an instance +### Adding a provider to an instance If your service is deployed to the same account for each stage and region, then you do not need to configure providers per instance. However, if you have multiple providers, like one for each stages or regions, then you can add a provider to each instance. To add a provider to an instance, navigate to the instance details page for that service instance, go to the **providers** tab, from the **add providers** dropdown you can add any provider from the organization into the instance. -## Inheritance and overriding +### Inheritance and overriding If you are deploying a traditional Serverless Framework app, an instance of the service is created for that stage and region. If you are using a Component-based service, then an instance is created for each stage of the service. @@ -65,7 +65,7 @@ Serverless Framework, on deployment, will use the provider associate with the In The organization default provider enables you to deploy using that organization default provider without needing to set a provider at the service or instance level. Similarly, setting a provider at the service level enables you to create new instances and deploy right away without needing to set a provider on the instance. -### Different accounts per stage +#### Different accounts per stage This inheritance model is useful for deploying to different accounts for each stage. For example, if you have a `dev` and `prod` account, then you can setup providers to deploy to `dev` by default, and use the `prod` account for only the `prod` instances. @@ -73,7 +73,7 @@ To accomplish this, you can add the `dev` provider to the service, and then add If you deploy to a new stage, like `int`, it will then use the `dev` provider from the service. -### Preview account for CI/CD preview deployments +#### Preview account for CI/CD preview deployments If you are using the Serverless CI/CD service or any 3rd party CI/CD service, you may be deploying to unique stages to isolate the preview deployments from PRs from all other deployments. @@ -81,8 +81,126 @@ To accomplish this, you can create two providers, `preview`, and `prod`, for two Now if you deploy to a preview stage, like `feature-x` it will automatically use the provider from the service, `preview`. If you merge your changes and deploy them to the `prod` stage, it will automatically use the `prod` provider as it is associated with that stage. -# Using providers in serverless.yml +## Using providers in serverless.yml To use providers with serverless.yml you do not need to do anything. Upon deployment the Serverless Framework will retrieve the necessary credentials from the provider associate with the instance or service, and it will use those credentials to deploy. If the providers are not found, then the Serverless Framework will look for credentials locally. + +## Using a Custom IAM Role and Policy + +Creating a provider with an IAM Role and default policy using the provided Cloud Formation template is the easiest and most secure way to enable Serverless Framework to deploy from CI/CD, monitor your services, and deploy a range of resources to your AWS account using short-lived credentials. However, advanced IAM users may want to create a custom IAM Role and Policy with more restrictive permissions. + +Please be aware that this policy is used to _provision_ your Serverless applications to your AWS account(s). The lambda function will also require a role, which is created by the Serverless Framework during deployments, hence why `iam:CreateRole` is required. + +Using a custom policy provides additional control and granularity, but it will require your organization to manage and maintain the policy and role to ensure it provides both minimal and sufficient access for Serverless Framework deployments to work correctly. + +Below is a sample IAM Policy you can use to get started. This policy works with the Serverless Framework dashboard to enable all the functionality, and deploy a basic Node.js Lambda function. + +If you are create a custom IAM Role with this policy, you will need to add a Trust relationship to the AWS Account with ID 377024778620 (arn:aws:iam::377024778620:root) in order for the Serverless Framework to Assume the Role with the provided policy. + +**Sample IAM Policy** + +``` +{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "lambda:CreateFunction", + "logs:DeleteSubscriptionFilter", + "s3:CreateBucket", + "iam:CreateRole", + "lambda:GetFunctionConfiguration", + "cloudformation:DescribeStackResource", + "iam:PutRolePolicy", + "s3:GetObject*", + "cloudformation:DescribeStackEvents", + "s3:DeleteBucketWebsite", + "logs:GetLogEvents", + "cloudformation:UpdateStack", + "lambda:ListLayerVersions", + "lambda:ListLayers", + "lambda:DeleteFunction", + "events:RemoveTargets", + "logs:FilterLogEvents", + "lambda:GetAlias", + "s3:DeleteObject", + "s3:ListBucket", + "apigateway:GET", + "cloudformation:ListStackResources", + "iam:GetRole", + "events:DescribeRule", + "lambda:ListFunctions", + "lambda:InvokeFunction", + "lambda:GetEventSourceMapping", + "lambda:ListAliases", + "iam:DeleteRole", + "iam:UpdateAssumeRolePolicy", + "s3:DeleteBucketPolicy", + "logs:CreateLogGroup", + "cloudformation:DescribeStacks", + "lambda:UpdateFunctionCode", + "s3:PutObject", + "cloudformation:DeleteStack", + "lambda:ListEventSourceMappings", + "lambda:PublishVersion", + "logs:PutSubscriptionFilter", + "apigateway:POST", + "cloudformation:ValidateTemplate", + "lambda:ListVersionsByFunction", + "lambda:GetLayerVersion", + "s3:DeleteObjectVersion", + "events:PutRule", + "lambda:GetAccountSettings", + "lambda:GetLayerVersionPolicy", + "s3:PutEncryptionConfiguration", + "apigateway:DELETE", + "iam:PassRole", + "lambda:ListTags", + "iam:DeleteRolePolicy", + "apigateway:PATCH", + "s3:DeleteBucket", + "logs:DescribeLogGroups", + "logs:DeleteLogGroup", + "apigateway:PUT", + "lambda:GetFunction", + "lambda:UpdateFunctionConfiguration", + "events:PutTargets", + "lambda:AddPermission", + "cloudformation:CreateStack", + "s3:PutBucketPolicy", + "sts:GetCallerIdentity", + "lambda:RemovePermission", + "s3:GetBucketLocation", + "lambda:GetPolicy" + ], + "Resource": "*" + } + ] +} +``` + +## Migration from Deployment Profile + +Prior to the January 11th, 2021 release, deployment profiles supported setting AWS Access Role ARNs and managing parameters. Support for using AWS Access Roles for deployments has moved from deployment profiles to Providers. Support for managing Parameters has moved from deployment profiles to services and instances. + +**Deployment profiles will be deprecated on February 28th, 2021**. Migration from deployment profiles to providers and parameters will be automatic; however, there are two required action items to use the new features. + +### Action Items + +- You **MUST** upgrade to use the Enterprise Plugin version 4.4.1 or higher. +- You **MUST** relink your AWS Account via the providers UI by no later than February 28th, 2021. + +### Automatic Migration + +Parameters and Providers were migrated automatically from deployment profiles on January 31st, 2021. + +The automatic migration replaced deployment profiles with providers by performing the following: + +- **A new provider will be created for each deployment profile using the same AWS Access Role ARN**. If the deployment profile doesn’t contain an AWS Access Role ARN, it will be skipped. +- **A provider will be added to each service for the corresponding default stage in the app**. The provider will be the provider corresponding to the deployment profile which was associated with the default stage of the parent app. For example, if `app1` has `service1` and the _`default`_ stage of `app1` links to the `dev` deployment profile, then the `dev` provider will be added to `service1`. This is repeated for all services in all apps. +- **A provider will be added to each instance for the corresponding stage in the app**. The provider will be the provider corresponding to the deployment profile which was associated with the stage of the instance. For example, if `app1` has `service1` and `app1` has a stage `prod` linked to the `prod` deployment profile, then the `prod` provider will be added to the `service1` instances deployed to the `prod` stage. +- **Parameters from the deployment profile associated with the default stage in the app will be copied to the service**. +- **Parameters from the deployment profile associated with a stage in an app will be copied to the instance**. diff --git a/docs/guides/safeguards.md b/docs/guides/safeguards.md deleted file mode 100644 index d0a733e657a..00000000000 --- a/docs/guides/safeguards.md +++ /dev/null @@ -1,22 +0,0 @@ - - - - -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/guides/safeguards/) - - - -# Safeguards - -**Safeguards** is a policy-as-code framework for Serverless Framework which enables you to inspect your serverless.yml file, and the generated Cloud Formation templates, for compliance with security, operational, and organizational, best practices. - -Safeguards was a feature of the Serverless Framework Pro dashboard and available under the legacy team tier. On August 1st, 2020, it was open sourced and made available free-of-charge as a stand-alone Serverless Framework Plugin free of charge. - -You can find the new plugin at [serverless/safeguards-plugin](https://github.com/serverless/safeguards-plugin/). - -You can easily migrate your safeguard policies from the SF Pro dashboard to the `@serverless/safegurds-plugin` by following the [Migration from Serverless Framework Pro guide](https://github.com/serverless/safeguards-plugin/#migrating-from-serverless-framework-pro). diff --git a/docs/guides/sdk/nodejs.md b/docs/guides/sdk/nodejs.md index 5e29d32d59d..3996fe996a0 100644 --- a/docs/guides/sdk/nodejs.md +++ b/docs/guides/sdk/nodejs.md @@ -10,7 +10,9 @@ layout: Doc -# `captureError` +# Node.js SDK + +## `captureError` Your lambda function may throw an exception, but your function handles it in order to respond to the requester without throwing the error. One very common example is functions tied to HTTP @@ -59,7 +61,7 @@ module.exports.hello = async (event) => { }; ``` -# `span` +## `span` While the `serverless_sdk` automatically instruments AWS SDK and HTTP spans, you may be interested in capturing span data for functions that do numerical computation or functions making database @@ -79,7 +81,7 @@ module.exports.handler = async (event, context) => { }; ``` -Example from context with an sync function: +Example from context with a sync function: ```javascript module.exports.handler = async (event, context) => { @@ -102,7 +104,7 @@ module.exports.handler = async (event, context) => { }; ``` -# `tagEvent` +## `tagEvent` Busy applications can invoke hundreds of thousands of requests per minute! At these rates, finding specific invocations can be like searching for a needle in a haystack. We've felt this pain, which is why we've introduced tagged events. @@ -129,7 +131,7 @@ module.exports.hello = async (event, context) => { }; ``` -# Automatic route instrumentation with application middleware +## Automatic route instrumentation with application middleware Faced with practical considerations (a big one being CloudFormation stack resource limit), developers often reach for a single function solution with routing being handled by the application layer. This is usually accomplished either by leveraging plugins that extend popular application frameworks to play nicely with the Lambda runtime (e.g. [serverless-express](https://serverless.com/plugins/serverless-express/)), using a purpose-built one (like [lambda-api](https://github.com/jeremydaly/lambda-api)), or even rolling their own (via [lambda-router](https://github.com/trek10inc/lambda-router)). @@ -141,7 +143,7 @@ If your application is using a custom-built router, you can still work around th Once set, invocations can be explored and inspected by endpoint in the Dashboard. -# `setEndpoint` +## `setEndpoint` Allows the application to explicitly set the routed endpoint for an invocation. Like the other SDK methods, `setEndpoint` is available on either the context object: `context.serverlessSdk`, or can be imported manually from the base directory: `const { setEndpoint } = require('./serverless_sdk')`. Example usage: diff --git a/docs/guides/sdk/python.md b/docs/guides/sdk/python.md index 2915cdeaf1f..e070e230983 100644 --- a/docs/guides/sdk/python.md +++ b/docs/guides/sdk/python.md @@ -10,7 +10,9 @@ layout: Doc -# `capture_exception` +# Python SDK + +## `capture_exception` Your lambda function may throw an exception, but your function handles it in order to respond to the requester without throwing the error. One very common example is functions tied to HTTP @@ -55,7 +57,7 @@ def hello(event, context): } ``` -# `span` +## `span` While the `serverless_sdk` automatically instruments AWS SDK and HTTP spans, you may be interested in capturing span data for functions that do numerical computation or functions making database @@ -80,7 +82,7 @@ def handler(event, context): It also works as an async context manager for use with `async with`. -# `tag_event` +## `tag_event` Busy applications can invoke hundreds of thousands of requests per minute! At these rates, finding specific invocations can be like searching for a needle in a haystack. We've felt this pain, which is why we've introduced tagged events. @@ -107,7 +109,7 @@ def hello(event, context): } ``` -# Automatic route instrumentation with application middleware +## Automatic route instrumentation with application middleware Faced with practical considerations (a big one being CloudFormation stack resource limit), developers often reach for a single function solution with routing being handled by the application layer. This is typically accomplished by leveraging the [serverless-wsgi](https://github.com/logandk/serverless-wsgi) plugin to deploy existing WSGI applications (Flask/Django/Pyramid etc). Rolling your own custom router is another option as well. @@ -119,7 +121,7 @@ If your application is using a custom-built router, you can still work around th Once set, invocations can be explored and inspected by endpoint in the Dashboard. -# `set_endpoint` +## `set_endpoint` Allows the application to explicitly set the routed endpoint for an invocation. Like the other SDK methods, `setEndpoint` is available on either the context object: `context.serverless_sdk`. diff --git a/docs/guides/upgrading-v3.md b/docs/guides/upgrading-v3.md new file mode 100644 index 00000000000..d2be60d54fd --- /dev/null +++ b/docs/guides/upgrading-v3.md @@ -0,0 +1,326 @@ + + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/guides/upgrading-v3/) + + + +# Upgrading to Serverless Framework v3 + +Serverless Framework v3 contains a few breaking changes that may impact some projects. + +This guide helps users upgrade from Serverless Framework v2 to v3. + +## Am I impacted by breaking changes? + +Serverless Framework v2 signals any deprecated feature via a deprecation warning. The simplest way to upgrade to v3 is to: + +1. [Upgrade Serverless Framework](../getting-started.md#upgrade) to the latest v2 version +2. Run `serverless` commands in the project to see if there are any deprecation warnings + +Projects that do not have any deprecations can be immediately upgraded to v3. Projects that have deprecation warnings should first solve these deprecations, then upgrade to v3. + +## What about plugins? + +We have worked with the most popular plugins to make sure they support Serverless Framework v3. As long as a project has no deprecations, it can be safely upgraded to v3. + +That being said, some plugins need to be updated to be installable with v3. In most cases, it is a matter of allowing the plugin to be installed with Serverless Framework v3 in `package.json` (updating the `peerDependencies` requirement). Feel free to open an issue or pull request in the GitHub repository of the plugin. + +## Upgrading to v3 + +First, [upgrade to the latest v2 version](../getting-started.md#upgrade) and make sure that you do not get any deprecation warning when running `serverless` commands. + +Then, to upgrade to Serverless Framework v3, run: + +```bash +npm install -g serverless +``` + +If you [installed `serverless` as a standalone binary](../getting-started.md#install-as-a-standalone-binary), run the following command instead: + +- MacOS/Linux standalone binary: `serverless upgrade --major` +- Windows: `choco upgrade serverless` + +## Update `frameworkVersion` setting for v3 + +In all projects that you want to upgrade to Serverless Framework v3, you need to make sure that `frameworkVersion` specified in project configuration allows v3 version. You can achieve it by setting it in the following manner: + +```yml +frameworkVersion: '3' +``` + +## Using v2 and v3 in different projects + +It is possible to use v3 in some projects and v2 in other projects. To achieve that, install the Serverless Framework locally via NPM (`npm i --save-dev serverless`). + +There are 2 scenarios: + +- Using v3 globally, and v2 in specific projects. + + This is the simplest. Upgrade the global version to v3, and install v2 in specific projects (via NPM). The `serverless` command will automatically run the correct version (v3 can run v2). + +- Using v2 globally, and v3 in specific projects. + + To achieve that, install v3 in specific projects (via NPM). Then, use `serverless` for v2 projects, and `npx serverless` for v3 projects. + +## Breaking changes + +You will find below a complete list of all breaking changes. All those breaking changes were signaled via deprecation messages in Serverless Framework v2. + +### CLI commands and options + +The `serverless` CLI no longer runs on Node v10 because [that version is obsolete](https://endoflife.date/nodejs): upgrade to v12 or greater to run `serverless` on your machine. + +The `serverless` CLI used to accept free-form CLI options. This feature was deprecated and has been removed. The main reason is that this prevented us from detecting typos in options, which sometimes created unexpected situations and overall a bad user experience. [Learn more about this change](../deprecations.md#handling-of-unrecognized-cli-options). + +Additionally, all CLI options must now be passed at the end of the commands: + +```bash +# Will no longer work in v3: +serverless --verbose deploy + +# Correct syntax: +serverless deploy --verbose +``` + +This change makes the CLI much more robust at detecting arguments from options and their values. + +On that note, the `-v` option is no longer recognized (it was ambiguous with `--version`): use the full `--verbose` option instead. + +When the `serverless` CLI is installed globally and locally (in the project’s `node_modules`), the local version will always be used. It is no longer possible to disable that behavior ([learn more](../deprecations.md#support-for-enablelocalinstallationfallback-setting-is-to-be-removed)). + +Finally, the `serverless studio` command has been removed: that feature was deprecated and is no longer available. + +### Service configuration + +The default Lambda runtime has changed from NodeJS 12 to NodeJS 14, given this is now the default runtime recommended by AWS. + +Additionally, the `nodejs10.x`, `python2.7`, `ruby2.5` and `dotnetcore2.1` runtimes [are no longer supported and accepted by AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html). As such, these runtimes will no longer be accepted in v3. + +In `serverless.yml`, the `service` key no longer accepts a YAML object ([learn more](../deprecations.md#service-property-object-notation)). + +```yaml +# Deprecated in v2, removed in v3: +service: + name: my-service + +# Correct syntax: +service: my-service +``` + +All options that used to be defined inside the `service` key have been moved to other sections (mentioned below in that document). This change clears up confusion that existed between the `service` and `provider` sections. + +### API Gateway + +When configuring API Gateway, some configuration options have moved to a dedicated sub-section of `provider`. That will help clear up confusion with similar `httpApi` settings. + +```yaml +provider: + # Deprecated in v2, removed in v3: + apiKeys: ... + resourcePolicy: ... + usagePlan: ... + + # Correct syntax: + apiGateway: + apiKeys: ... + resourcePolicy: ... + usagePlan: ... +``` + +The `schema` option on HTTP events has also been renamed to `schemas`. That change allowed us to support much more schema validation features: + +```yaml +functions: + hello: + handler: hello.handler + events: + - http: + ... + request: + # Deprecated in v2, removed in v3: + schema: ... + # Correct syntax: + schemas: ... +``` + +Learn more about [schema changes](../deprecations.md#aws-api-gateway-schemas). + +When an external API Gateway is used and imported via `provider.apiGateway.restApiId`, both `provider.logs.restApi` and `provider.tracing.apiGateway` options are ignored. In v3, an error will be thrown if these options are defined. Indeed, these settings are applicable only if the API Gateway is provisioned by Serverless Framework. + +The CloudFormation tags defined in `provider.tags` will now be correctly applied to HTTP APIs stages ([learn more](../deprecations.md#http-api-provider-tags)). + +Starting with v3, AWS's recommended behavior for API Gateway authorizers will become the default: `functions[].events[].http.authorizer.identitySource` will no longer be set to `method.request.header.Authorization` by default when caching is disabled (i.e. for authorizers of type "request" with `resultTtlInSeconds` set to "0") ([learn more](../deprecations.md#default-identitysource-for-httpauthorizer)). + +### CloudFront + +Some CloudFront `behavior` options where deprecated by AWS: ForwardedValues, MinTTL, MaxTTL and DefaultTTL. These options have been removed. Use the new ["cache policy" feature](../providers/aws/events/cloudfront.md#cache-policy-configuration) instead ([learn more](../deprecations.md#cloudfront-event-behaviorforwardedvalues-property)). + +### EventBridge + +By default, all EventBridge resources (including Lambda triggers) will now be deployed using native CloudFormation resources, instead of a custom resource ([learn more](../deprecations.md#aws-eventbridge-lambda-event-triggers)). The change has the benefit of relying on native AWS features now, which will be more stable and future-proof. + +Since this is a hard breaking change for Serverless Framework v2 users, it is possible to keep the legacy behavior (based on custom resources) by using this flag: + +```yaml +provider: + eventBridge: + useCloudFormation: false +``` + +With this flag, v2 users can upgrade to v3 without breaking change. Note that `useCloudFormation: false` will be deprecated eventually, and will not be supported in the future. + +### KMS + +When configuring KMS keys, some configuration options have moved ([learn more](../deprecations.md#awskmskeyarn-references)): + +```yaml +# Deprecated in v2, removed in v3: +service: + awsKmsKeyArn: ... +functions: + hello: + awsKmsKeyArn: ... + +# Correct syntax: +provider: + kmsKeyArn: ... +functions: + hello: + kmsKeyArn: ... +``` + +That allowed us to make the KMS configuration consistent with all other AWS resources: these are now configured in the `provider` section. + +### Alexa skill + +`alexaSkill` events now require an `appId` ([learn more](../deprecations.md#support-for-alexaskill-event-without-appid-is-to-be-removed)). That change was required to implement a more stable deployment, as well as to deploy more restricted IAM permissions. + +### Lambda Hashing Algorithm + +By default, Lambda version hashes will now be generated using an improved algorithm (fixes determinism issues). As it is a breaking change that requires more manual effort during migration, it is still possible (but not recommended) to keep using the old algorithm by using the following configuration: + +``` +provider: + lambdaHashingVersion: 20200924 +``` + +However, we highly encourage an upgrade to the new algorithm. To upgrade, you must redeploy your service with code or configuration change in all functions. You can do it by following the guide below: + +**NOTE**: Please keep in mind that these changes require two deployments with manual configuration adjustment between them. It also creates two additional versions and temporarily overrides descriptions of your functions. Migration will need to be done separately for each of your environments/stages. + +1. Run `sls deploy` with additional `--enforce-hash-update` flag: that flag will override the description for Lambda functions, which will force the creation of new versions. +2. Set `provider.lambdaHashingVersion` to `20201221` in your configuration: your service will now always deploy with the new Lambda version hashes (which is the new defualt in v3). +3. Run `sls deploy`, this time without additional `--enforce-hash-update` flag: that will restore the original descriptions on all Lambda functions. + +Now your whole service is fully migrated to the new Lambda Hashing Algorithm. + +If you do not want to temporarily override descriptions of your functions or would like to avoid creating unnecessary versions of your functions, you might want to use one of the following approaches: + +- Ensure that code for all your functions will change during deployment, set `provider.lambdaHashingVersion: 20201221` in your configuration, and run `sls deploy`. Due to the fact that all functions have code changed, all your functions will be migrated to new hashing algorithm. Please note that the change can be caused by e.g. upgrading a dependency used by all your functions so you can pair it with regular chores. +- Add a dummy file that will be included in deployment artifacts for all your functions, set `provider.lambdaHashingVersion: 20201221` in your configuration, and run `sls deploy`. Due to the fact that all functions have code changed, all your functions will be migrated to new hashing algorithm. +- If it is safe in your case (e.g. it's only development sandbox), you can also tear down the whole service by `sls remove`, set `provider.lambdaHashingVersion: 20201221` in your configuration, and run `sls deploy`. Newly recreated environment will be using new hashing algorithm. + +### Low-level changes + +Internal changes that may impact plugins or advanced use cases: + +- Plugins can no longer define custom variables via the legacy variable resolver ([learn more](../deprecations.md#new-variables-resolver)). + + The new variable resolver API was introduced to provide a simpler and more stable way of defining custom variables. Most plugins have switched to that new variable resolver, but older plugins may still require some updates. + +- CloudFormation outputs are now always exported ([learn more](../deprecations.md#disable-default-output-export-names) + + This change allows us to simplify and clean up the internals by removing options and logic switches. The use cases for not exporting CloudFormation outputs were very uncommon. + +- When using the Serverless Framework programmatically, the service configuration must be at the root directory of the service ([learn more](../deprecations.md#service-configurations-should-not-be-nested-in-service-sub-directories)) and the arguments have changed ([learn more here](../deprecations.md#serverless-constructor-service-configuration-dependency) as well as [here](../deprecations.md#serverless-constructor-configcommands-and-configoptions-requirement)). + + Using the Serverless Framework programmatically is a very unusual and low-level scenario: we took advantage of the major version to improve the API. + +### Deprecated features that will be kept in v3 + +Some Serverless Framework v2 features were marked as deprecated. However, given they are still widely used, we have chosen to keep the following features in v3. + +IAM configuration has changed, yet both syntaxes are supported in v3: + +```yaml +# Older syntax, still supported in v3 +provider: + role: ... + rolePermissionsBoundary: ... + iamRoleStatements: ... + iamManagedPolicies: ... + cfnRole: ... + +# New syntax +provider: + iam: + role: + name: ... + permissionsBoundary: ... + statements: ... + managedPolicies: ... + deploymentRole: ... +``` + +In the same spirit, packaging configuration has changed but both syntaxes are supported in v3: + +```yaml +# Older syntax, still supported in v3 +package: + exclude: + - 'src/**' + include: + - src/function/handler.js + +# New syntax +package: + patterns: + - '!src/**' + - src/function/handler.js +``` + +Configuration validation is still kept at the "warning" level by default (instead of turning to errors, as initially planned). To turn validation issues into errors, use: + +```yaml +# v2 and v3 both keep the same default behavior: warnings by default +configValidationMode: warn + +# Opt-in errors via: +configValidationMode: error +``` + +Unlike planned initially, loading `.env` files is kept opt-in via `useDotenv: true`. + +Additionally, the short form `serverless deploy -f ` is still allowed in v3, but `serverless deploy function -f ` stays the preferred form. + +### Plugins + +The [`serverless-dotenv-plugin`](https://github.com/neverendingqs/serverless-dotenv-plugin) is directly impacted by v3. Indeed, for technical reasons the plugin will no longer be able to resolve `${env:xxx}` variables from `.env` files. + +However, `.env` files are now natively supported by Serverless Framework v3. Set `useDotenv: true` to use `.env` variables with `${env:xxx}`: + +```yaml +useDotenv: true + +provider: + environment: + FOO: ${env:FOO} +``` + +The plugin can still be used as usual if you want to automatically import **all** variables from `.env` into functions. + +```yaml +plugins: + - serverless-dotenv-plugin + +provider: + environment: + # With the plugin enabled, all variables in .env are automatically imported +``` diff --git a/docs/providers/aliyun/cli-reference/invoke.md b/docs/providers/aliyun/cli-reference/invoke.md index 74a1e517c89..6a0086b6725 100644 --- a/docs/providers/aliyun/cli-reference/invoke.md +++ b/docs/providers/aliyun/cli-reference/invoke.md @@ -14,7 +14,7 @@ layout: Doc # Alibaba Cloud - Invoke -Invokes deployed function. It allows to send event data to the function, read logs and display other important information of the function invocation. +Invokes a deployed function. You can send event data, read logs and display other important information of the function invocation. ```bash serverless invoke --function functionName diff --git a/docs/providers/aliyun/guide/events.md b/docs/providers/aliyun/guide/events.md index a0d30a987e5..21c486b43dd 100644 --- a/docs/providers/aliyun/guide/events.md +++ b/docs/providers/aliyun/guide/events.md @@ -16,7 +16,7 @@ layout: Doc Simply put, events are the things that trigger your functions to run. -If you are using Alibaba Cloud as your provider, all `events` in the service are anything in Alibaba Cloud that can trigger your Functions, like HTTP endpoints, OSS events, etc.. +If you are using Alibaba Cloud as your provider, `events` in the service are limited to the Alibaba Cloud triggers HTTP and OSS. [View the Alibaba Cloud Function Compute events section for a list of supported events](../events) @@ -40,7 +40,7 @@ functions: ## Types -The Serverless Framework supports all of Alibaba Cloud Function Compute events. Instead of listing them here, we've put them in a separate section. [Check out the events section for more information.](../events) +The Serverless Framework supports the Alibaba Cloud Function Compute events `oss` and `http`. Instead of listing them here, we've put them in a separate section. [Check out the events section for more information.](../events) ## Deploying diff --git a/docs/providers/aliyun/guide/plugins.md b/docs/providers/aliyun/guide/plugins.md deleted file mode 100644 index 4c31df76220..00000000000 --- a/docs/providers/aliyun/guide/plugins.md +++ /dev/null @@ -1,304 +0,0 @@ - - - - -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aliyun/guide/plugins) - - - -# Alibaba Cloud - Plugins - -A Plugin is custom Javascript code that creates new or extends existing commands within the Serverless Framework. The Serverless Framework is merely a group of Plugins that are provided in the core. If you or your organization have a specific workflow, install a pre-written Plugin or write a plugin to customize the Framework to your needs. External Plugins are written exactly the same way as the core Plugins. - -- [How to create serverless plugins - Part 1](https://serverless.com/blog/writing-serverless-plugins/) -- [How to create serverless plugins - Part 2](https://serverless.com/blog/writing-serverless-plugins-2/) - -## Installing Plugins - -External Plugins are added on a per service basis and are not applied globally. Make sure you are in your Service's root directory, then install the corresponding Plugin with the help of npm: - -``` -npm install --save custom-serverless-plugin -``` - -We need to tell Serverless that we want to use the plugin inside our service. We do this by adding the name of the Plugin to the `plugins` section in the `serverless.yml` file. - -```yml -# serverless.yml file - -plugins: - - custom-serverless-plugin -``` - -Plugins might want to add extra information which should be accessible to Serverless. The `custom` section in the `serverless.yml` file is the place where you can add necessary configurations for your plugins (the plugins author / documentation will tell you if you need to add anything there): - -```yml -plugins: - - custom-serverless-plugin - -custom: - customkey: customvalue -``` - -## Service local plugin - -If you are working on a plugin or have a plugin that is just designed for one project you can add them to the `.serverless_plugins` directory at the root of your service, and in the `plugins` array in `serverless.yml`. - -The plugin will be loaded based on being named `custom-serverless-plugin.js` or `custom-serverless-plugin\index.js` in the root of `.serverless_plugins` folder. - -### Load Order - -Keep in mind that the order you define your plugins matters. When Serverless loads all the core plugins and then the custom plugins in the order you've defined them. - -```yml -# serverless.yml - -plugins: - - plugin1 - - plugin2 -``` - -In this case `plugin1` is loaded before `plugin2`. - -## Writing Plugins - -### Concepts - -#### Plugin - -Code which defines _Commands_, any _Events_ within a _Command_, and any _Hooks_ assigned to an _Lifecycle Event_. - -- Command // CLI configuration, commands, subcommands, options - - LifecycleEvent(s) // Events that happen sequentially when the command is run - - Hook(s) // Code that runs when a Lifecycle Event happens during a Command - -#### Command - -A CLI _Command_ that can be called by a user, e.g. `serverless deploy`. A Command has no logic, but simply defines the CLI configuration (e.g. command, subcommands, parameters) and the _Lifecycle Events_ for the command. Every command defines its own lifecycle events. - -```javascript -'use strict'; - -class MyPlugin { - constructor() { - this.commands = { - deploy: { - lifecycleEvents: ['resources', 'functions'], - }, - }; - } -} - -module.exports = MyPlugin; -``` - -#### Lifecycle Events - -Events that fire sequentially during a Command. The above example list two Events. However, for each Event, and additional `before` and `after` event is created. Therefore, six Events exist in the above example: - -- `before:deploy:resources` -- `deploy:resources` -- `after:deploy:resources` -- `before:deploy:functions` -- `deploy:functions` -- `after:deploy:functions` - -The name of the command in front of lifecycle events when they are used for Hooks. - -#### Hooks - -A Hook binds code to any lifecycle event from any command. - -```javascript -'use strict'; - -class Deploy { - constructor() { - this.commands = { - deploy: { - lifecycleEvents: ['resources', 'functions'], - }, - }; - - this.hooks = { - 'before:deploy:resources': this.beforeDeployResources, - 'deploy:resources': this.deployResources, - 'after:deploy:functions': this.afterDeployFunctions, - }; - } - - beforeDeployResources() { - console.log('Before Deploy Resources'); - } - - deployResources() { - console.log('Deploy Resources'); - } - - afterDeployFunctions() { - console.log('After Deploy Functions'); - } -} - -module.exports = Deploy; -``` - -### Nesting Commands - -You can also nest commands, e.g. if you want to provide a command `serverless deploy single`. Those nested commands have their own lifecycle events and do not inherit them from their parents. - -```javascript -'use strict'; - -class MyPlugin { - constructor() { - this.commands = { - deploy: { - lifecycleEvents: ['resources', 'functions'], - commands: { - function: { - lifecycleEvents: ['package', 'deploy'], - }, - }, - }, - }; - } -} - -module.exports = MyPlugin; -``` - -### Defining Options - -Each (sub)command can have multiple Options. - -Options are passed in with a double dash (`--`) like this: `serverless function deploy --function functionName`. - -Option Shortcuts are passed in with a single dash (`-`) like this: `serverless function deploy -f functionName`. - -The `options` object will be passed in as the second parameter to the constructor of your plugin. - -In it, you can optionally add a `shortcut` property, as well as a `required` property. The Framework will return an error if a `required` Option is not included. - -**Note:** At this time, the Serverless Framework does not use parameters. - -```javascript -'use strict'; - -class Deploy { - constructor(serverless, options) { - this.serverless = serverless; - this.options = options; - - this.commands = { - deploy: { - lifecycleEvents: ['functions'], - options: { - function: { - usage: 'Specify the function you want to deploy (e.g. "--function myFunction")', - shortcut: 'f', - required: true, - }, - }, - }, - }; - - this.hooks = { - 'deploy:functions': this.deployFunction.bind(this), - }; - } - - deployFunction() { - console.log('Deploying function: ', this.options.function); - } -} - -module.exports = Deploy; -``` - -### Provider Specific Plugins - -Plugins can be provider specific which means that they are bound to a provider. - -**Note:** Binding a plugin to a provider is optional. Serverless will always consider your plugin if you don't specify a `provider`. - -The provider definition should be added inside the plugins constructor: - -```javascript -'use strict'; - -class ProviderDeploy { - constructor(serverless, options) { - this.serverless = serverless; - this.options = options; - - // set the providers name here - this.provider = this.serverless.getProvider('providerName'); - - this.commands = { - deploy: { - lifecycleEvents: ['functions'], - options: { - function: { - usage: 'Specify the function you want to deploy (e.g. "--function myFunction")', - required: true, - }, - }, - }, - }; - - this.hooks = { - 'deploy:functions': this.deployFunction.bind(this), - }; - } - - deployFunction() { - console.log('Deploying function: ', this.options.function); - } -} - -module.exports = ProviderDeploy; -``` - -The Plugin's functionality will now only be executed when the Serverless Service's provider matches the provider name which is defined inside the plugins constructor. - -### Serverless Instance - -The `serverless` instance which enables access to global service config during runtime is passed in as the first parameter to the plugin constructor. - -```javascript -'use strict'; - -class MyPlugin { - constructor(serverless, options) { - this.serverless = serverless; - this.options = options; - - this.commands = { - log: { - lifecycleEvents: ['serverless'], - }, - }; - - this.hooks = { - 'log:serverless': this.logServerless.bind(this), - }; - } - - logServerless() { - console.log('Serverless instance: ', this.serverless); - } -} - -module.exports = MyPlugin; -``` - -### Command Naming - -Command names need to be unique. If we load two commands and both want to specify the same command (e.g. we have an integrated command `deploy` and an external command also wants to use `deploy`) the Serverless CLI will print an error and exit. If you want to have your own `deploy` command you need to name it something different like `myCompanyDeploy` so they don't clash with existing plugins. diff --git a/docs/providers/aws/README.md b/docs/providers/aws/README.md index a08cc56c7a3..b205dbfe6c3 100644 --- a/docs/providers/aws/README.md +++ b/docs/providers/aws/README.md @@ -21,7 +21,6 @@ layout: Doc
  • Intro
  • -
  • Installation
  • Credentials
  • Services
  • Functions
  • diff --git a/docs/providers/aws/cli-reference/config-credentials.md b/docs/providers/aws/cli-reference/config-credentials.md index d7eb8168cb4..adb3fb81b56 100644 --- a/docs/providers/aws/cli-reference/config-credentials.md +++ b/docs/providers/aws/cli-reference/config-credentials.md @@ -43,7 +43,11 @@ This example will configure the `default` profile with the `aws_access_key_id` o ### Configure a custom profile ```bash -serverless config credentials --provider aws --key 1234 --secret 5678 --profile custom-profile +serverless config credentials \ + --provider aws \ + --key 1234 \ + --secret 5678 \ + --profile custom-profile ``` This example create and configure a `custom-profile` profile with the `aws_access_key_id` of `1234` and the `aws_secret_access_key` of `5678`. @@ -51,7 +55,12 @@ This example create and configure a `custom-profile` profile with the `aws_acces ### Update an existing profile ```bash -serverless config credentials --provider aws --key 1234 --secret 5678 --profile custom-profile --overwrite +serverless config credentials \ + --provider aws \ + --key 1234 \ + --secret 5678 \ + --profile custom-profile \ + --overwrite ``` This example overwrite `custom-profile` profile with the `aws_access_key_id` of `1234` and the `aws_secret_access_key` of `5678`. diff --git a/docs/providers/aws/cli-reference/config.md b/docs/providers/aws/cli-reference/config.md new file mode 100644 index 00000000000..21bb7d7c10b --- /dev/null +++ b/docs/providers/aws/cli-reference/config.md @@ -0,0 +1,40 @@ + + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/cli-reference/config) + + + +# AWS - Config + +The purpose of `serverless config` is to allow to enable or disable automatic update mechanism of the Framework. Additionally, it supports `config credentials` subcommand. For more details about them, please refer to their corresponding documentation pages. Auto update mechanism is supported for global installations across all operating systems with the exception of standalone binary installation on Windows. + +## Options + +- `--autoupdate` Turn on auto update mechanism +- `--no-autoupdate` Turn off auto update mechanism + +## Provided lifecycle events + +- `config:config` + +## Examples + +### Turn on auto update mechanism + +```bash +serverless config --autoupdate +``` + +### Turn off auto update mechanism + +```bash +serverless config --no-autoupdate +``` diff --git a/docs/providers/aws/cli-reference/create.md b/docs/providers/aws/cli-reference/create.md index 7a6f9a491f3..516749102b4 100644 --- a/docs/providers/aws/cli-reference/create.md +++ b/docs/providers/aws/cli-reference/create.md @@ -16,22 +16,24 @@ layout: Doc Creates a new service in the current working directory based on the provided template. -**Create service in current working directory:** +**Create a service in the current working directory:** ```bash serverless create --template aws-nodejs ``` -**Create service in new folder:** +**Create a service in a new folder:** ```bash serverless create --template aws-nodejs --path myService ``` -**Create service in new folder using a custom template:** +**Create a service in a new folder using a custom template:** ```bash -serverless create --template-url https://github.com/serverless/serverless/tree/master/lib/plugins/create/templates/aws-nodejs --path myService +serverless create \ + --template-url https://github.com/serverless/serverless/tree/master/lib/plugins/create/templates/aws-nodejs \ + --path myService ``` ## Options @@ -106,7 +108,10 @@ renamed to `my-new-service`. ### Creating a new service using a local template ```bash -serverless create --template-path path/to/my/template/folder --path path/to/my/service --name my-new-service +serverless create \ + --template-path path/to/my/template/folder \ + --path path/to/my/service \ + --name my-new-service ``` This will copy the `path/to/my/template/folder` folder into `path/to/my/service` and rename the service to `my-new-service`. diff --git a/docs/providers/aws/cli-reference/deploy-function.md b/docs/providers/aws/cli-reference/deploy-function.md index c9a22f4b236..1ae83240171 100644 --- a/docs/providers/aws/cli-reference/deploy-function.md +++ b/docs/providers/aws/cli-reference/deploy-function.md @@ -43,7 +43,9 @@ serverless deploy function --function helloWorld ### Deployment with stage and region options ```bash -serverless deploy function --function helloWorld --stage dev --region us-east-1 +serverless deploy function --function helloWorld \ + --stage dev \ + --region us-east-1 ``` ### Deploy only configuration changes diff --git a/docs/providers/aws/cli-reference/deploy.md b/docs/providers/aws/cli-reference/deploy.md index 7a52946b012..23fda45ca63 100644 --- a/docs/providers/aws/cli-reference/deploy.md +++ b/docs/providers/aws/cli-reference/deploy.md @@ -23,7 +23,6 @@ serverless deploy ## Options - `--config` or `-c` Name of your configuration file, if other than `serverless.yml|.yaml|.js|.json`. -- `--noDeploy` or `-n` Skips the deployment steps and leaves artifacts in the `.serverless` directory - `--stage` or `-s` The stage in your service that you want to deploy to. - `--region` or `-r` The region in that stage that you want to deploy to. - `--package` or `-p` path to a pre-packaged directory and skip packaging step. diff --git a/docs/providers/aws/cli-reference/generate-event.md b/docs/providers/aws/cli-reference/generate-event.md new file mode 100644 index 00000000000..b94be8e3e47 --- /dev/null +++ b/docs/providers/aws/cli-reference/generate-event.md @@ -0,0 +1,56 @@ + + +# AWS - Generate Event + +Creates sample Lambda function payloads for different types of events. + +```bash +serverless generate-event --type eventType +``` + +## Options + +- `--type` or `-t` The type of the event to generate payload for. **Required**. +- `--body` or `-b` The body for the message, request, or stream event. + +## Available event types + +- aws:alexaSkill +- aws:alexaSmartHome +- aws:apiGateway +- aws:cloudWatch +- aws:cloudWatchLog +- aws:cognitoUserPool +- aws:dynamo +- aws:iot +- aws:kinesis +- aws:s3 +- aws:sns +- aws:sqs +- aws:websocket + +## Examples + +### Generate SQS event payload + +```bash +serverless generate-event -t aws:sqs +``` + +### Generate Kinesis event payload with body + +```bash +serverless generate-event -t aws:kinesis -b '{"foo": "bar"}' +``` + +### Generate SQS event and save it to a file + +```bash +serverless generate-event -t aws:sqs > event.json +``` diff --git a/docs/providers/aws/cli-reference/invoke-local.md b/docs/providers/aws/cli-reference/invoke-local.md index dcdfe955280..117d2067bc5 100644 --- a/docs/providers/aws/cli-reference/invoke-local.md +++ b/docs/providers/aws/cli-reference/invoke-local.md @@ -98,7 +98,8 @@ serverless invoke local --function functionName --context "hello world" ### Local function invocation with context passing ```bash -serverless invoke local --function functionName --contextPath lib/context.json +serverless invoke local --function functionName \ + --contextPath lib/context.json ``` This example will pass the json context in the `lib/context.json` file (relative to the root of the service) while invoking the specified/deployed function. @@ -110,7 +111,9 @@ serverless invoke local -f functionName -e VAR1=value1 # Or more than one variable -serverless invoke local -f functionName -e VAR1=value1 -e VAR2=value2 +serverless invoke local -f functionName \ + -e VAR1=value1 \ + -e VAR2=value2 ``` When using [AWS CloudFormation intrinsic functions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html) as environment variables value, **only Fn::ImportValue and Ref** will be automatically resolved for function invocation. Other intrinsic functions use will result in the corresponding configuration object passed in the function as environment variable. @@ -147,7 +150,7 @@ They _will not_ be set during the parsing of the `serverless.yml` file. ## Resource permissions -Lambda functions assume an _IAM role_ during execution: the framework creates this role, and set all the permission provided in the `iamRoleStatements` section of `serverless.yml`. +Lambda functions assume an _IAM role_ during execution: the framework creates this role, and set all the permission provided in the `provider.iam.role.statements` section of `serverless.yml`. Unless you explicitly state otherwise, every call to the AWS SDK inside the lambda function is made using this role (a temporary pair of key / secret is generated and set by AWS as environment variables, `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`). diff --git a/docs/providers/aws/cli-reference/invoke.md b/docs/providers/aws/cli-reference/invoke.md index d04ee3962cf..cc48d21aa54 100644 --- a/docs/providers/aws/cli-reference/invoke.md +++ b/docs/providers/aws/cli-reference/invoke.md @@ -14,7 +14,7 @@ layout: Doc # AWS - Invoke -Invokes deployed function. It allows to send event data to the function, read logs and display other important information of the function invocation. +Invokes a deployed function. You can send event data, read logs and display other important information of the function invocation. ```bash serverless invoke [local] --function functionName @@ -72,19 +72,19 @@ output the result of the invocation in your terminal. #### Function invocation with data ```bash -serverless invoke --function functionName --stage dev --region us-east-1 --data "hello world" +serverless invoke --function functionName --data "hello world" ``` #### Function invocation with custom context ```bash -serverless invoke --function functionName --stage dev --region us-east-1 --context "hello world" +serverless invoke --function functionName --context "hello world" ``` #### Function invocation with context passing ```bash -serverless invoke --function functionName --stage dev --region us-east-1 --contextPath lib/context.json +serverless invoke --function functionName --contextPath lib/context.json ``` This example will pass the json context in the `lib/context.json` file (relative to the root of the service) while invoking the specified/deployed function. @@ -92,13 +92,13 @@ This example will pass the json context in the `lib/context.json` file (relative #### Function invocation with data from standard input ```bash -node dataGenerator.js | serverless invoke --function functionName --stage dev --region us-east-1 +node dataGenerator.js | serverless invoke --function functionName ``` #### Function invocation with logging ```bash -serverless invoke --function functionName --stage dev --region us-east-1 --log +serverless invoke --function functionName --log ``` Just like the first example, but will also outputs logging information about your invocation. @@ -106,7 +106,7 @@ Just like the first example, but will also outputs logging information about you #### Function invocation with data passing ```bash -serverless invoke --function functionName --stage dev --region us-east-1 --path lib/data.json +serverless invoke --function functionName --path lib/data.json ``` This example will pass the json data in the `lib/data.json` file (relative to the root of the service) while invoking @@ -132,14 +132,15 @@ serverless invoke local --function functionName --context "hello world" ### Local function invocation with context passing ```bash -serverless invoke local --function functionName --contextPath lib/context.json +serverless invoke local --function functionName \ + --contextPath lib/context.json ``` This example will pass the json context in the `lib/context.json` file (relative to the root of the service) while invoking the specified/deployed function. ### Limitations -Currently, `invoke local` only supports the NodeJs and Python runtimes. +Currently, `invoke local` only supports the Node.js, Python, Java and Ruby runtimes. ## Resource permissions diff --git a/docs/providers/aws/cli-reference/login.md b/docs/providers/aws/cli-reference/login.md index 511644bf59f..b34339d2f79 100644 --- a/docs/providers/aws/cli-reference/login.md +++ b/docs/providers/aws/cli-reference/login.md @@ -20,7 +20,4 @@ It will create a new serverless platform account if one doesn't already exist. ```bash serverless login - -# Shorthand -sls login ``` diff --git a/docs/providers/aws/cli-reference/logs.md b/docs/providers/aws/cli-reference/logs.md index 8cae90f8492..2c05bb88cd4 100644 --- a/docs/providers/aws/cli-reference/logs.md +++ b/docs/providers/aws/cli-reference/logs.md @@ -19,7 +19,7 @@ Lets you watch the logs of a specific function. ```bash serverless logs -f hello -# Optionally tail the logs with -t +# Optionally tail the logs with --tail or -t serverless logs -f hello -t ``` diff --git a/docs/providers/aws/cli-reference/metrics.md b/docs/providers/aws/cli-reference/metrics.md index 1ea7cad9370..c562803d779 100644 --- a/docs/providers/aws/cli-reference/metrics.md +++ b/docs/providers/aws/cli-reference/metrics.md @@ -59,7 +59,9 @@ Displays all `hello` function metrics for the last 24h. ### See metrics for the function `hello` of a specific timespan ```bash -serverless metrics --function hello --startTime 2016-01-01 --endTime 2016-01-02 +serverless metrics --function hello \ + --startTime 2016-01-01 \ + --endTime 2016-01-02 ``` Displays all `hello` function metrics for the time between January 1, 2016 and January 2, 2016. diff --git a/docs/providers/aws/cli-reference/print.md b/docs/providers/aws/cli-reference/print.md index 135db376ff7..c679cdcd412 100644 --- a/docs/providers/aws/cli-reference/print.md +++ b/docs/providers/aws/cli-reference/print.md @@ -1,7 +1,7 @@ diff --git a/docs/providers/aws/cli-reference/rollback-function.md b/docs/providers/aws/cli-reference/rollback-function.md index 5a152b57fc3..43ecfd5f5f2 100644 --- a/docs/providers/aws/cli-reference/rollback-function.md +++ b/docs/providers/aws/cli-reference/rollback-function.md @@ -17,7 +17,8 @@ layout: Doc Rollback a function service to a specific version. ```bash -serverless rollback function --function --function-version +serverless rollback function --function \ + --function-version ``` **Note:** You can only rollback a function which was previously deployed through `serverless deploy`. Functions are not versioned when running `serverless deploy function`. diff --git a/docs/providers/aws/cli-reference/slstats.md b/docs/providers/aws/cli-reference/slstats.md index f30177402a4..c01ca586a62 100644 --- a/docs/providers/aws/cli-reference/slstats.md +++ b/docs/providers/aws/cli-reference/slstats.md @@ -1,7 +1,7 @@ @@ -55,6 +55,6 @@ The following is a list of the events that we collect: ## Signed in to the Dashboard -If you are signed in to the [Serverless Dashboard](https://app.serverless.com), we do receive your userId as part of the event payloads. We can use this information to understand your tenant and users interactions with the CLI and building services. +If you are signed in to the [Serverless Dashboard](https://app.serverless.com), we do receive your userId as part of the event payloads. We can use this information to understand your org and users interactions with the CLI and building services. If you are not signed in, we do not send any identifying information, such as an userId, within any of the event payloads. diff --git a/docs/providers/aws/events/README.md b/docs/providers/aws/events/README.md index f84270e0356..6b76c265844 100644 --- a/docs/providers/aws/events/README.md +++ b/docs/providers/aws/events/README.md @@ -14,6 +14,8 @@ layout: Doc Welcome to the AWS Serverless Events Glossary. -Please select a section on the left to get started. +Please select a section on the left to get started, or see the [user +guide](../guide/events.md) for general information regarding Lambda Events in +Serverless. If you have questions, join the [chat in gitter](https://gitter.im/serverless/serverless) or [post over on the forums](https://forum.serverless.com/) diff --git a/docs/providers/aws/events/activemq.md b/docs/providers/aws/events/activemq.md new file mode 100644 index 00000000000..384e6b55107 --- /dev/null +++ b/docs/providers/aws/events/activemq.md @@ -0,0 +1,77 @@ + + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/events/activemq) + + + +# ActiveMQ + +An ActiveMQ message broker can be used as an event source for AWS Lambda. + +## Simple event definition + +In the following example, we specify that the `compute` function should be triggered whenever there are new messages available to consume from defined ActiveMQ `queue`. + +In order to configure `activemq` event, you have to provide three required properties: + +- `basicAuthArn`, which is a [AWS Secrets Manager](https://aws.amazon.com/secrets-manager/) ARN for credentials required to do basic auth to allow Lambda to connect to your message broker +- `queue` to consume messages from. +- `arn` arn for your Amazon MQ message broker + +```yml +functions: + compute: + handler: handler.compute + events: + - activemq: + arn: arn:aws:mq:us-east-1:0000:broker:ExampleMQBroker:b-xxx-xxx + queue: queue-name + basicAuthArn: arn:aws:secretsmanager:us-east-1:01234567890:secret:MySecret +``` + +## Enabling and disabling ActiveMQ event + +The `activemq` event also supports `enabled` parameter, which is used to control if the event source mapping is active. Setting it to `false` will pause polling for and processing new messages. + +In the following example, we specify that the `compute` function's `activemq` event should be disabled. + +```yml +functions: + compute: + handler: handler.compute + events: + - activemq: + arn: arn:aws:mq:us-east-1:0000:broker:ExampleMQBroker:b-xxx-xxx + queue: queue-name + enabled: false + basicAuthArn: arn:aws:secretsmanager:us-east-1:01234567890:secret:MySecret +``` + +## Specifying batch size and batch window + +You can also specify `batchSize` of number of items to retrieve in a single batch. If not specified, this will default to `100`. +Likewise `maximumBatchingWindow` can be set to determine the amount of time the Lambda spends gathering records before invoking the function. The default is 0, but **if you set `batchSize` to more than 10, you must set `maximumBatchingWindow` to at least 1**. The maximum is 300. + +```yml +functions: + compute: + handler: handler.compute + events: + - activemq: + arn: arn:aws:mq:us-east-1:0000:broker:ExampleMQBroker:b-xxx-xxx + queue: queue-name + batchSize: 5000 + maximumBatchingWindow: 30 + basicAuthArn: arn:aws:secretsmanager:us-east-1:01234567890:secret:MySecret +``` + +## IAM Permissions + +The Serverless Framework will automatically configure the most minimal set of IAM permissions for you. However you can still add additional permissions if you need to. Read the official [AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/with-mq.html#events-mq-permissions) for more information about IAM Permissions for Amazon MQ events. diff --git a/docs/providers/aws/events/alb.md b/docs/providers/aws/events/alb.md index 0573b3a2205..c6293250758 100644 --- a/docs/providers/aws/events/alb.md +++ b/docs/providers/aws/events/alb.md @@ -198,7 +198,7 @@ functions: ## Specifying explicitly the target group names -If you want full control over the name used for the target group you can specify it using the `targetGroupName` property. Note that the name must be unique accross the entire region and is limited to 32 characters with only alphanumerics and hyphens allowed. +If you want full control over the name used for the target group you can specify it using the `targetGroupName` property. Note that the name must be unique across the entire region and is limited to 32 characters with only alphanumerics and hyphens allowed. This setting is exclusive with the `provider.alb.targetGroupPrefix` setting. diff --git a/docs/providers/aws/events/apigateway.md b/docs/providers/aws/events/apigateway.md index 9df1dcc0599..efd1bf56d7d 100644 --- a/docs/providers/aws/events/apigateway.md +++ b/docs/providers/aws/events/apigateway.md @@ -12,51 +12,63 @@ layout: Doc -# API Gateway - -- [API Gateway](#api-gateway) - - [Lambda Proxy Integration](#lambda-proxy-integration) - - [Simple HTTP Endpoint](#simple-http-endpoint) - - [Example "LAMBDA-PROXY" event (default)](#example-lambda-proxy-event-default) - - [HTTP Endpoint with Extended Options](#http-endpoint-with-extended-options) - - [Enabling CORS](#enabling-cors) - - [HTTP Endpoints with `AWS_IAM` Authorizers](#http-endpoints-with-aws_iam-authorizers) - - [HTTP Endpoints with Custom Authorizers](#http-endpoints-with-custom-authorizers) - - [HTTP Endpoints with `operationId`](#http-endpoints-with-operationId) - - [Catching Exceptions In Your Lambda Function](#catching-exceptions-in-your-lambda-function) - - [Setting API keys for your Rest API](#setting-api-keys-for-your-rest-api) - - [Configuring endpoint types](#configuring-endpoint-types) - - [Request Parameters](#request-parameters) - - [Request Schema Validators](#request-schema-validators) - - [Setting source of API key for metering requests](#setting-source-of-api-key-for-metering-requests) - - [Lambda Integration](#lambda-integration) - - [Example "LAMBDA" event (before customization)](#example-lambda-event-before-customization) - - [Request templates](#request-templates) - - [Default Request Templates](#default-request-templates) - - [Custom Request Templates](#custom-request-templates) - - [Pass Through Behavior](#pass-through-behavior) - - [Responses](#responses) - - [Custom Response Headers](#custom-response-headers) - - [Custom Response Templates](#custom-response-templates) - - [Status Codes](#status-codes) - - [Available Status Codes](#available-status-codes) - - [Using Status Codes](#using-status-codes) - - [Custom Status Codes](#custom-status-codes) - - [Setting an HTTP Proxy on API Gateway](#setting-an-http-proxy-on-api-gateway) - - [Accessing private resources using VPC Link](#accessing-private-resources-using-vpc-link) - - [Mock Integration](#mock-integration) - - [Share API Gateway and API Resources](#share-api-gateway-and-api-resources) - - [Easiest and CI/CD friendly example of using shared API Gateway and API Resources.](#easiest-and-cicd-friendly-example-of-using-shared-api-gateway-and-api-resources) - - [Manually Configuring shared API Gateway](#manually-configuring-shared-api-gateway) - - [Note while using authorizers with shared API Gateway](#note-while-using-authorizers-with-shared-api-gateway) - - [Share Authorizer](#share-authorizer) - - [Resource Policy](#resource-policy) - - [Compression](#compression) - - [Binary Media Types](#binary-media-types) - - [Detailed CloudWatch Metrics](#detailed-cloudwatch-metrics) - - [AWS X-Ray Tracing](#aws-x-ray-tracing) - - [Tags / Stack Tags](#tags--stack-tags) - - [Logs](#logs) +# API Gateway REST API + +API Gateway lets you deploy HTTP APIs. It comes [in two versions](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html): + +- v1, also called **REST API** +- v2, also called **HTTP API**, which is faster and cheaper than v1 + +Despite their confusing name, both versions allow deploying any HTTP API (like REST, GraphQL, etc.). Read the full comparison [in the AWS documentation](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html). + +This guide documents using API Gateway **v1 REST API** via the `http` event. + +To use API Gateway **v2 HTTP API** instead, follow the [HTTP API guide](http-api.md). + +Summary: + +- [Lambda Proxy Integration](#lambda-proxy-integration) + - [Simple HTTP Endpoint](#simple-http-endpoint) + - [Example "LAMBDA-PROXY" event (default)](#example-lambda-proxy-event-default) + - [HTTP Endpoint with Extended Options](#http-endpoint-with-extended-options) + - [Enabling CORS](#enabling-cors) + - [HTTP Endpoints with `AWS_IAM` Authorizers](#http-endpoints-with-aws_iam-authorizers) + - [HTTP Endpoints with Custom Authorizers](#http-endpoints-with-custom-authorizers) + - [HTTP Endpoints with `operationId`](#http-endpoints-with-operationId) + - [Catching Exceptions In Your Lambda Function](#catching-exceptions-in-your-lambda-function) + - [Setting API keys for your Rest API](#setting-api-keys-for-your-rest-api) + - [Configuring endpoint types](#configuring-endpoint-types) + - [Request Parameters](#request-parameters) + - [Request Schema Validators](#request-schema-validators) + - [Setting source of API key for metering requests](#setting-source-of-api-key-for-metering-requests) +- [Lambda Integration](#lambda-integration) + - [Example "LAMBDA" event (before customization)](#example-lambda-event-before-customization) + - [Request templates](#request-templates) + - [Default Request Templates](#default-request-templates) + - [Custom Request Templates](#custom-request-templates) + - [Pass Through Behavior](#pass-through-behavior) + - [Responses](#responses) + - [Custom Response Headers](#custom-response-headers) + - [Custom Response Templates](#custom-response-templates) + - [Status Codes](#status-codes) + - [Available Status Codes](#available-status-codes) + - [Using Status Codes](#using-status-codes) + - [Custom Status Codes](#custom-status-codes) +- [Setting an HTTP Proxy on API Gateway](#setting-an-http-proxy-on-api-gateway) +- [Accessing private resources using VPC Link](#accessing-private-resources-using-vpc-link) +- [Mock Integration](#mock-integration) +- [Share API Gateway and API Resources](#share-api-gateway-and-api-resources) + - [Easiest and CI/CD friendly example of using shared API Gateway and API Resources.](#easiest-and-cicd-friendly-example-of-using-shared-api-gateway-and-api-resources) + - [Manually Configuring shared API Gateway](#manually-configuring-shared-api-gateway) + - [Note while using authorizers with shared API Gateway](#note-while-using-authorizers-with-shared-api-gateway) +- [Share Authorizer](#share-authorizer) +- [Resource Policy](#resource-policy) +- [Compression](#compression) +- [Binary Media Types](#binary-media-types) +- [Detailed CloudWatch Metrics](#detailed-cloudwatch-metrics) +- [AWS X-Ray Tracing](#aws-x-ray-tracing) +- [Tags / Stack Tags](#tags--stack-tags) +- [Logs](#logs) _Are you looking for tutorials on using API Gateway? Check out the following resources:_ @@ -327,7 +339,8 @@ functions: - X-Amz-Security-Token - X-Amz-User-Agent allowCredentials: false - cacheControl: 'max-age=600, s-maxage=600, proxy-revalidate' # Caches on browser and proxy for 10 minutes and doesnt allow proxy to serve out of date content + # Caches on browser and proxy for 10 minutes and doesnt allow proxy to serve out of date content + cacheControl: 'max-age=600, s-maxage=600, proxy-revalidate' ``` CORS header accepts single value too @@ -355,8 +368,10 @@ module.exports.hello = function (event, context, callback) { const response = { statusCode: 200, headers: { - 'Access-Control-Allow-Origin': '*', // Required for CORS support to work - 'Access-Control-Allow-Credentials': true, // Required for cookies, authorization headers with HTTPS + // Required for CORS support to work + 'Access-Control-Allow-Origin': '*', + // Required for cookies, authorization headers with HTTPS + 'Access-Control-Allow-Credentials': true, }, body: JSON.stringify({ message: 'Hello World!' }), }; @@ -608,7 +623,7 @@ In case an exception is thrown in your lambda function AWS will send an error me ### Setting API keys for your Rest API -You can specify a list of API keys to be used by your service Rest API by adding an `apiKeys` array property to the `provider.apiGateway` object in `serverless.yml`. You'll also need to explicitly specify which endpoints are `private` and require one of the api keys to be included in the request by adding a `private` boolean property to the `http` event object you want to set as private. API Keys are created globally, so if you want to deploy your service to different stages make sure your API key contains a stage variable as defined below. When using API keys, you can optionally define usage plan quota and throttle, using `usagePlan` object. +You can specify a list of API keys to be used by your service Rest API by adding an `apiKeys` array property to the `provider.apiGateway` object in `serverless.yml`. You'll also need to explicitly specify which endpoints are `private` and require one of the api keys to be included in the request by adding a `private` boolean property to the `http` event object you want to set as private. API Keys are created globally, so if you want to deploy your service to different stages make sure your API key contains a stage variable as defined below. When using API keys, you can optionally define usage plan quota and throttle, using `usagePlan` object. Additionally, you can also disable selected API keys by setting `enabled` property to `false`. When setting the value, you need to be aware that changing value will require replacement and CloudFormation doesn't allow two API keys with the same name. It means that you need to change the name also when changing the value. If you don't care @@ -624,10 +639,12 @@ provider: apiKeys: - myFirstKey - ${opt:stage}-myFirstKey - - ${env:MY_API_KEY} # you can hide it in a serverless variable + # you can hide it in a serverless variable + - ${env:MY_API_KEY} - name: myThirdKey value: myThirdKeyValue - - value: myFourthKeyValue # let cloudformation name the key (recommended when setting api key value) + # let cloudformation name the key (recommended when setting api key value) + - value: myFourthKeyValue description: Api key description # Optional customerId: A string that will be set as the customerID for the key # Optional usagePlan: @@ -1637,16 +1654,17 @@ provider: name: aws runtime: nodejs12.x - resourcePolicy: - - Effect: Allow - Principal: '*' - Action: execute-api:Invoke - Resource: - - execute-api:/*/*/* - Condition: - IpAddress: - aws:SourceIp: - - '123.123.123.123' + apiGateway: + resourcePolicy: + - Effect: Allow + Principal: '*' + Action: execute-api:Invoke + Resource: + - execute-api:/*/*/* + Condition: + IpAddress: + aws:SourceIp: + - '123.123.123.123' ``` ## Compression @@ -1664,31 +1682,35 @@ provider: API Gateway makes it possible to return binary media such as images or files as responses. -Configuring API Gateway to return binary media can be done via the `binaryMediaTypes` config: +To return binary media in proxy integration, set the `binaryMediaTypes` config: ```yml provider: apiGateway: binaryMediaTypes: - '*/*' +functions: + binaryExample: + handler: binaryExample.handler + events: + - http: + path: binary + method: GET ``` -In your Lambda function you need to ensure that the correct `content-type` header is set. Furthermore you might want to return the response body in base64 format. +Having that in your Lambda function, you need to ensure that the correct `content-type` header is set and provide a base64 encoded string for a body. +e.g., Assuming that there's an `image.jpg` file located aside of `binaryExample.js` lambda handler, the handler can be set up as follows: -To convert the request or response payload, you can set the [contentHandling](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-payload-encodings-workflow.html) property (if set, the response contentHandling property will be passed to integration responses with 2XXs method response statuses). +```js +const fsp = require('fs').promises; +const path = require('path'); -```yml -functions: - create: - handler: posts.create - events: - - http: - path: posts/create - method: post - request: - contentHandling: CONVERT_TO_TEXT - response: - contentHandling: CONVERT_TO_TEXT +module.exports.handler = async () => ({ + statusCode: 200, + headers: { 'Content-type': 'image/jpeg' }, + body: (await fsp.readFile(path.resolve(__dirname, 'image.jpg'))).toString('base64'), + isBase64Encoded: true, +}); ``` ## Detailed CloudWatch Metrics @@ -1835,3 +1857,13 @@ provider: level: INFO fullExecutionData: false ``` + +## Disable Default Endpoint + +By default, clients can invoke your API with the default https://{api_id}.execute-api.{region}.amazonaws.com endpoint. To require that clients use a custom domain name to invoke your API, disable the default endpoint. + +```yml +provider: + apiGateway: + disableDefaultEndpoint: true +``` diff --git a/docs/providers/aws/events/cloudfront.md b/docs/providers/aws/events/cloudfront.md index 29e1fe521bb..125216aa4bb 100644 --- a/docs/providers/aws/events/cloudfront.md +++ b/docs/providers/aws/events/cloudfront.md @@ -35,7 +35,7 @@ Lambda@Edge has four options when the Lambda function is triggered **MEMORY AND TIMEOUT LIMITS:** According to [AWS Limits on Lambda@Edge](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html#limits-lambda-at-edge) the limits for viewer-request and viewer-response are 128MB memory and 5 seconds timeout and for origin-request and origin-response are 3008MB memory and 30 seconds timeout. -**RUNTIME LIMITS:** According to [AWS Requirements on Lambda@Edge](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-requirements-limits.html) the runtimes supported by Lambda@Edge functions are: `Python 3.8`, `Python 3.7`, `Node.js 12.x`, `Node.js 10.x`. +**RUNTIME LIMITS:** According to [AWS Requirements on Lambda@Edge](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-requirements-limits.html) the runtimes supported by Lambda@Edge functions are: `Python 3.8`, `Python 3.7`, `Node.js 14.x`, `Node.js 12.x`, `Node.js 10.x`. ## Simple event definition @@ -238,6 +238,20 @@ functions: id: 658327ea-f89d-4fab-a63d-7e88639e58f6 # references AWS Managed Policy named Managed-CachingOptimized ``` +It is also possible to reference policies with `behavior.CachePolicyId` property. When both `cachePolicy.id` and `behavior.CachePolicyId` are specified, setting from `cachePolicy.id` will be used. Similarily, when `cachePolicy.name` and `behavior.CachePolicyId` are specified, setting from `cachePolicy.name` will be used. + +```yml +functions: + myLambdaAtEdge: + handler: myLambdaAtEdge.handler + events: + - cloudFront: + eventType: viewer-response + origin: s3://bucketname.s3.amazonaws.com/files + behavior: + CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6 # references AWS Managed Policy named Managed-CachingOptimized +``` + ### CloudFront Distribution configurations Amazon CloudFront distribution configurations can be set in the resources block of the serverless.yml, by defining `CloudFrontDistribution`. diff --git a/docs/providers/aws/events/cognito-user-pool.md b/docs/providers/aws/events/cognito-user-pool.md index a8b9129f9a5..5fb141949b7 100644 --- a/docs/providers/aws/events/cognito-user-pool.md +++ b/docs/providers/aws/events/cognito-user-pool.md @@ -134,5 +134,21 @@ resources: Type: AWS::Cognito::UserPool ``` +## Forcing deploying of triggers + +A Cognito User Pool with triggers attached may not be correctly updated by AWS Cloudformation on subsequent deployments. To circumvent this issue you can use the `forceDeploy` flag which will try to force Cloudformation to update the triggers no matter what. This flag has to be used in conjuction with the `existing: true` flag. + +```yml +functions: + preSignUp: + handler: preSignUp.handler + events: + - cognitoUserPool: + pool: MyUserPool1 + trigger: PreSignUp + existing: true + forceDeploy: true +``` + [aws-triggers-guide]: http://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html [aws-triggers-list]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-userpool-lambdaconfig.html diff --git a/docs/providers/aws/events/event-bridge.md b/docs/providers/aws/events/event-bridge.md index 2b8f29c6428..ad23168ff35 100644 --- a/docs/providers/aws/events/event-bridge.md +++ b/docs/providers/aws/events/event-bridge.md @@ -16,7 +16,7 @@ layout: Doc The [EventBridge](https://aws.amazon.com/eventbridge/) makes it possible to connect applications using data from external sources (e.g. own applications, SaaS) or AWS services. The `eventBridge` event types helps setting up AWS Lambda functions to react to events coming in via the EventBridge. -_Note_: Prior to `2.27.0` version of the Framework, `eventBridge` resources were provisioned with Custom Resources. With `2.27.0` an optional support for native CloudFormation was introduced and can be turned on by setting `provider.eventBridge.useCloudFormation` property to `true`. It is recommended to migrate to native CloudFormation as it will become a default with next major version. It also adds the ability to define `eventBus` with CF intrinsic functions as values. +_Note_: Prior to `2.27.0` version of the Framework, `eventBridge` resources were provisioned with Custom Resources. With `2.27.0` an optional support for native CloudFormation was introduced and can be turned on by setting `provider.eventBridge.useCloudFormation: true`. It is recommended to migrate to native CloudFormation as it will become a default with v3. It also adds the ability to define `eventBus` with CF intrinsic functions as values. ## Setting up a scheduled event @@ -31,6 +31,22 @@ functions: key1: value1 ``` +## Enabling / Disabling + +**Note:** `eventBridge` events are enabled by default. Use `enabled: false` to disable the rule. + +```yml +functions: + myFunction: + handler: index.handler + events: + - eventBridge: + enabled: false + schedule: rate(10 minutes) + input: + key1: value1 +``` + ## Setting up event pattern matching ```yml @@ -71,7 +87,13 @@ functions: ### Re-using an existing event bus -If you want to reuse an existing event bus, you can define it with literal `arn` or with a reference to an existing event bus name via CF intrinsic functions. Referencing via intrinsic functions in available only if you use native CloudFormation support with `provider.eventBridge.useCloudFormation: true` setting. +If you want to reuse an existing event bus, you can define it with literal `arn` or with a reference to an existing event bus name via CF intrinsic functions. Referencing via intrinsic functions is available only if you use native CloudFormation support with `provider.eventBridge.useCloudFormation: true` setting: + +```yml +provider: + eventBridge: + useCloudFormation: true +``` Using literal `arn`: @@ -164,3 +186,46 @@ functions: eventTime: '$.time' inputTemplate: '{"time": , "key1": "value1"}' ``` + +## Adding a DLQ to an event rule + +DeadLetterQueueArn is not available for custom resources, only for native CloudFormation. + +```yml +functions: + myFunction: + handler: index.handler + events: + - eventBridge: + eventBus: custom-saas-events + pattern: + source: + - saas.external + deadLetterQueueArn: + Fn::GetAtt: + - QueueName + - Arn +``` + +## Adding a retry policy to an event rule + +RetryPolicy is not available for custom resources, only for native CloudFormation. + +```yml +functions: + myFunction: + handler: index.handler + events: + - eventBridge: + eventBus: custom-saas-events + pattern: + source: + - saas.external + deadLetterQueueArn: + Fn::GetAtt: + - QueueName + - Arn + retryPolicy: + maximumEventAge: 3600 + maximumRetryAttempts: 3 +``` diff --git a/docs/providers/aws/events/http-api.md b/docs/providers/aws/events/http-api.md index 0333c0c58b0..6ff6fa8e102 100644 --- a/docs/providers/aws/events/http-api.md +++ b/docs/providers/aws/events/http-api.md @@ -12,11 +12,18 @@ layout: Doc -# HTTP API +# API Gateway HTTP API -HTTP APIs are a special flavored [API Gateway](https://aws.amazon.com/api-gateway/) implementation which offer more features and improved performance. They have some benefits and drawbacks compared to the traditional API Gateway REST APIs. Read the differences in the [AWS Documentation](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html). +API Gateway lets you deploy HTTP APIs. It comes [in two versions](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html): -The Serverless Framework makes it possible to setup [API Gateway](https://aws.amazon.com/api-gateway/) HTTP APIs via the `httpApi` event. +- v1, also called **REST API** +- v2, also called **HTTP API**, which is faster and cheaper than v1 + +Despite their confusing name, both versions allow deploying any HTTP API (like REST, GraphQL, etc.). Read the full comparison [in the AWS documentation](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html). + +This guide documents using API Gateway **v2 HTTP API** via the `httpApi` event. + +To use API Gateway **v1 REST API** instead, follow the [API Gateway REST API guide](apigateway.md). ## Event Definition @@ -392,6 +399,20 @@ provider: payload: '1.0' ``` +The payload version can also be specified at the function level with httpApi.payload property and it will take precedence over the payload version configured at the provider level. It can be configured as: + +```yaml +functions: + hello: + handler: index.handler + httpApi: + payload: '1.0' + events: + - httpApi: + path: /hello + method: GET +``` + ### Detailed Metrics With HTTP API we may configure detailed metrics that can be used setup monitoring and alerting in Cloudwatch. @@ -406,7 +427,7 @@ provider: ### Tags -When using HTTP API, it is possible to tag the corresponding API Gateway. By setting `provider.httpApi.useProviderTags` to `true`, all tags defined on `provider.tags` will be applied to API Gateway. +When using HTTP API, it is possible to tag the corresponding API Gateway resources. By setting `provider.httpApi.useProviderTags` to `true`, all tags defined on `provider.tags` will be applied to API Gateway and API Gateway Stage. ```yaml provider: @@ -416,6 +437,80 @@ provider: useProviderTags: true ``` -In the above example, the tag project: myProject will be applied to API Gateway. +In the above example, the tag project: myProject will be applied to API Gateway and API Gateway Stage. _Note: If the API Gateway has any existing tags applied outside of Serverless Framework, they will be removed during deployment._ + +### Disable Default Endpoint + +By default, clients can invoke your API with the default https://{api_id}.execute-api.{region}.amazonaws.com endpoint. To require that clients use a custom domain name to invoke your API, disable the default endpoint. + +```yml +provider: + httpApi: + disableDefaultEndpoint: true +``` + +### Service Naming + +You can use the `shouldStartNameWithService` option to change the naming scheme for HTTP API from the default `${stage}-${service}` to `${service}-${stage}`. + +```yml +provider: + httpApi: + shouldStartNameWithService: true +``` + +## Custom domains + +API Gateway generates URLs for HTTP APIs in the following format: + +``` +https://.execute-api..amazonaws.com/ +``` + +It is possible to replace those URLs by a custom domain. + +Step 1, create an HTTPS certificate in AWS ACM: + +- Open [AWS ACM](https://console.aws.amazon.com/acm/home) (AWS Certificate Manager) +- Switch to the region of your application +- Click "Request a certificate" +- Select "Request a public certificate" and continue +- Add your domain and continue +- Choose the domain validation of your choice: + - Email validation will require you to click a link you will receive in an email sent to admin@your-domain.com + - Domain validation will require you to add CNAME entries to your DNS configuration +- Validate the domain via the method chosen above + +Step 2, set up the custom domain in API Gateway: + +- Open [API Gateway's "Custom Domain" configuration](https://console.aws.amazon.com/apigateway/main/publish/domain-names) +- Switch to the region of your application +- Click "Create" +- Enter your domain name, select the certificate you created above and validate the page +- After the domain is created, click the "API mappings" tab +- Click "Configure API mappings" and "Add new mapping" +- Select your HTTP API and the `$default` stage +- Click "Save" + +Step 3, configure the DNS of the domain: + +- If using Route53: + - Open the Hosted Zone in the [Route53 console](https://console.aws.amazon.com/route53/v2/hostedzones) + - Click "Create record" + - Select "Record type" of type "A" + - "Route traffic to": select "Alias", and then select your API Gateway + - Finish the record creation +- If using any other domain registrar + - Open the "Configurations" tab on the custom domain name you just created + - Note the "API Gateway domain name" which should look like this: `d-1234567890.execute-api.us-east-1.amazonaws.com` + - Create a CNAME entry to point your domain name to the API Gateway domain + +Once a custom domain is set up, you can [disable the default API Gateway endpoint](#disable-default-endpoint): + +```yaml +provider: + httpApi: + disableDefaultEndpoint: true +``` diff --git a/docs/providers/aws/events/kafka.md b/docs/providers/aws/events/kafka.md index 73a8c43f18d..63e3df7320f 100644 --- a/docs/providers/aws/events/kafka.md +++ b/docs/providers/aws/events/kafka.md @@ -15,15 +15,53 @@ layout: Doc A self-managed Apache Kafka cluster can be used as an event source for AWS Lambda. -## Simple event definition +In order to configure lambda to trigger via `kafka` events, you must provide three required properties: -In the following example, we specify that the `compute` function should be triggered whenever there are new messages available to consume from defined Kafka `topic`. +- `accessConfigurations` which defines the chosen [authentication](#authentication) method configuration +- `topic` to consume messages from +- `bootstrapServers` - an array of bootstrap server addresses for your Kafka cluster -In order to configure `kafka` event, you have to provide three required properties: +## Authentication -- `accessConfigurations`, which is either secret credentials required to do [SASL_SCRAM auth](https://docs.confluent.io/platform/current/kafka/authentication_sasl/authentication_sasl_scram.html), or this is VPC configuration to allow Lambda to connect to your cluster -- `topic` to consume messages from. -- `bootstrapServers` an array of bootstrap server addresses for your Kafka cluster +You must authenticate your Lambda with a self-managed Apache Kafka cluster using one of; + +- VPC - subnet(s) and security group +- SASL SCRAM/PLAIN - AWS Secrets Manager secret containing credentials +- Mutual TLS (mTLS) - AWS Secrets Manager secret containing client certificate, private key, and optionally a CA certificate + +You can provide this configuration via `accessConfigurations` + +You must provide at least one method, but it is possible to use VPC in parallel with other methods. For example, you may choose to authenticate via mTLS or SASL/SCRAM, and also place your Lambda and cluster within a VPC. + +Valid options for `accessConfigurations` are: + +```yaml +saslPlainAuth: arn:aws:secretsmanager:us-east-1:01234567890:secret:SaslPlain +saslScram256Auth: arn:aws:secretsmanager:us-east-1:01234567890:secret:SaslScram256 +saslScram512Auth: arn:aws:secretsmanager:us-east-1:01234567890:secret:SaslScram512 +clientCertificateTlsAuth: arn:aws:secretsmanager:us-east-1:01234567890:secret:ClientCertificateTLS +serverRootCaCertificate: arn:aws:secretsmanager:us-east-1:01234567890:secret:ServerRootCaCertificate +vpcSubnet: + - subnet-0011001100 + - subnet-0022002200 +vpcSecurityGroup: sg-0123456789 +``` + +For more information see: + +- [AWS Documentation - Using Lambda with self-managed Apache Kafka](https://docs.aws.amazon.com/lambda/latest/dg/with-kafka.html#smaa-authentication) + +- [AWS Documentation - AWS::Lambda::EventSourceMapping SourceAccessConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-sourceaccessconfiguration.html) + +- [Confluent documentation - Authentication with SASL/PLAIN](https://docs.confluent.io/platform/current/kafka/authentication_sasl/authentication_sasl_plain.html) + +- [Confluent documentation - Authentication with SASL/SCRAM](https://docs.confluent.io/platform/current/kafka/authentication_sasl/authentication_sasl_scram.html) + +- [Confluent documentation Encryption and Authentication with SSL](https://docs.confluent.io/platform/current/kafka/authentication_ssl.html) + +## Basic Example: SASL/SCRAM + +In the following example, we specify that the `compute` function should be triggered whenever there are new messages available to consume from Kafka topic `MySelfManagedKafkaTopic` from self-hosted cluster at `xyz.com`. The cluster has been authenticated using SASL/SCRAM, the credentials are stored at secret `MyBrokerSecretName` ```yml functions: @@ -33,7 +71,26 @@ functions: - kafka: accessConfigurations: saslScram512Auth: arn:aws:secretsmanager:us-east-1:01234567890:secret:MyBrokerSecretName - topic: AWSKafkaTopic + topic: MySelfManagedKafkaTopic + bootstrapServers: + - abc3.xyz.com:9092 + - abc2.xyz.com:9092 +``` + +## Example: Using mTLS + +In this example, the lambda event source is a self-managed Apache kafka cluster authenticated via mTLS. The value of `clientCertificateTlsAuth` is an arn of a secret containing the client certificate and privatekey required for the mTLS handshake. The value of `serverRootCaCertificate` is an arn of a secret containing the Certificate Authority (CA) Certificate. This is optional, you only need to provide if your cluster requires it. + +```yml +functions: + compute: + handler: handler.compute + events: + - kafka: + accessConfigurations: + clientCertificateTlsAuth: arn:aws:secretsmanager:us-east-1:01234567890:secret:ClientCertificateTLS + serverRootCaCertificate: arn:aws:secretsmanager:us-east-1:01234567890:secret:ServerRootCaCertificate + topic: MySelfManagedMTLSKafkaTopic bootstrapServers: - abc3.xyz.com:9092 - abc2.xyz.com:9092 @@ -60,7 +117,7 @@ functions: - abc2.xyz.com:9092 ``` -## Enabling and disabling Kafka event +## Enabling and disabling Kafka event trigger The `kafka` event also supports `enabled` parameter, which is used to control if the event source mapping is active. Setting it to `false` will pause polling for and processing new messages. @@ -84,3 +141,28 @@ functions: ## IAM Permissions The Serverless Framework will automatically configure the most minimal set of IAM permissions for you. However you can still add additional permissions if you need to. Read the official [AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/kafka-smaa.html) for more information about IAM Permissions for Kafka events. + +## Setting the BatchSize, MaximumBatchingWindow and StartingPosition + +You can set the `batchSize`, which effects how many messages can be processed in a single Lambda invocation. The default `batchSize` is 100, and the max `batchSize` is 10000. +Likewise `maximumBatchingWindow` can be set to determine the amount of time the Lambda spends gathering records before invoking the function. The default is 0, but **if you set `batchSize` to more than 10, you must set `maximumBatchingWindow` to at least 1**. The maximum is 300. +In addition, you can also configure `startingPosition`, which controls the position at which Lambda should start consuming messages from the topic. It supports two possible values, `TRIM_HORIZON` and `LATEST`, with `TRIM_HORIZON` being the default. + +In the following example, we specify that the `compute` function should have a `kafka` event configured with `batchSize` of 1000, `maximumBatchingWindow` of 30 seconds and `startingPosition` equal to `LATEST`. + +```yml +functions: + compute: + handler: handler.compute + events: + - kafka: + accessConfigurations: + saslScram512Auth: arn:aws:secretsmanager:us-east-1:01234567890:secret:MyBrokerSecretName + topic: MySelfManagedKafkaTopic + bootstrapServers: + - abc3.xyz.com:9092 + - abc2.xyz.com:9092 + batchSize: 1000 + maximumBatchingWindow: 30 + startingPosition: LATEST +``` diff --git a/docs/providers/aws/events/msk.md b/docs/providers/aws/events/msk.md index d67121fb5bf..94bb5e0d05b 100644 --- a/docs/providers/aws/events/msk.md +++ b/docs/providers/aws/events/msk.md @@ -43,12 +43,13 @@ functions: topic: mytopic ``` -## Setting the BatchSize and StartingPosition +## Setting the BatchSize, MaximumBatchingWindow and StartingPosition For the MSK event integration, you can set the `batchSize`, which effects how many messages can be processed in a single Lambda invocation. The default `batchSize` is 100, and the max `batchSize` is 10000. +Likewise `maximumBatchingWindow` can be set to determine the amount of time the Lambda spends gathering records before invoking the function. The default is 0, but **if you set `batchSize` to more than 10, you must set `maximumBatchingWindow` to at least 1**. The maximum is 300. In addition, you can also configure `startingPosition`, which controls the position at which Lambda should start consuming messages from MSK topic. It supports two possible values, `TRIM_HORIZON` and `LATEST`, with `TRIM_HORIZON` being the default. -In the following example, we specify that the `compute` function should have an `msk` event configured with `batchSize` of 1000 and `startingPosition` equal to `LATEST`. +In the following example, we specify that the `compute` function should have an `msk` event configured with `batchSize` of 1000, `maximumBatchingWindow` to 30 seconds and `startingPosition` equal to `LATEST`. ```yml functions: @@ -59,6 +60,7 @@ functions: arn: arn:aws:kafka:region:XXXXXX:cluster/MyCluster/xxxx-xxxxx-xxxx topic: mytopic batchSize: 1000 + maximumBatchingWindow: 30 startingPosition: LATEST ``` diff --git a/docs/providers/aws/events/rabbitmq.md b/docs/providers/aws/events/rabbitmq.md new file mode 100644 index 00000000000..01a664f50b7 --- /dev/null +++ b/docs/providers/aws/events/rabbitmq.md @@ -0,0 +1,77 @@ + + + + +### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/events/rabbitmq) + + + +# RabbitMQ + +A RabbitMQ message broker can be used as an event source for AWS Lambda. + +## Simple event definition + +In the following example, we specify that the `compute` function should be triggered whenever there are new messages available to consume from defined RabbitMQ `queue`. + +In order to configure `rabbitmq` event, you have to provide three required properties: + +- `basicAuthArn`, which is a [AWS Secrets Manager](https://aws.amazon.com/secrets-manager/) ARN for credentials required to do basic auth to allow Lambda to connect to your message broker +- `queue` to consume messages from. +- `arn` arn for your Amazon MQ message broker + +```yml +functions: + compute: + handler: handler.compute + events: + - rabbitmq: + arn: arn:aws:mq:us-east-1:0000:broker:ExampleMQBroker:b-xxx-xxx + queue: queue-name + basicAuthArn: arn:aws:secretsmanager:us-east-1:01234567890:secret:MySecret +``` + +## Enabling and disabling RabbitMQ event + +The `rabbitmq` event also supports `enabled` parameter, which is used to control if the event source mapping is active. Setting it to `false` will pause polling for and processing new messages. + +In the following example, we specify that the `compute` function's `rabbitmq` event should be disabled. + +```yml +functions: + compute: + handler: handler.compute + events: + - rabbitmq: + arn: arn:aws:mq:us-east-1:0000:broker:ExampleMQBroker:b-xxx-xxx + queue: queue-name + enabled: false + basicAuthArn: arn:aws:secretsmanager:us-east-1:01234567890:secret:MySecret +``` + +## Specifying batch size and batch window + +You can also specify `batchSize` of number of items to retrieve in a single batch. If not specified, this will default to `100`. +Likewise `maximumBatchingWindow` can be set to determine the amount of time the Lambda spends gathering records before invoking the function. The default is 0, but **if you set `batchSize` to more than 10, you must set `maximumBatchingWindow` to at least 1**. The maximum is 300. + +```yml +functions: + compute: + handler: handler.compute + events: + - rabbitmq: + arn: arn:aws:mq:us-east-1:0000:broker:ExampleMQBroker:b-xxx-xxx + queue: queue-name + batchSize: 5000 + maximumBatchingWindow: 30 + basicAuthArn: arn:aws:secretsmanager:us-east-1:01234567890:secret:MySecret +``` + +## IAM Permissions + +The Serverless Framework will automatically configure the most minimal set of IAM permissions for you. However you can still add additional permissions if you need to. Read the official [AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/with-mq.html#events-mq-permissions) for more information about IAM Permissions for Amazon MQ events. diff --git a/docs/providers/aws/events/schedule.md b/docs/providers/aws/events/schedule.md index 1e46a5e79c2..1840dc938bb 100644 --- a/docs/providers/aws/events/schedule.md +++ b/docs/providers/aws/events/schedule.md @@ -69,3 +69,24 @@ events: description: 'your scheduled rate event description' rate: rate(2 hours) ``` + +## Specify multiple schedule expressions + +An array of schedule expressions (i.e. using either `rate` or `cron` syntax) can be specified, in order to avoid repeating other configuration variables. +This is specially useful in situations in which there's no other way than using multiple cron expressions to schedule a function. + +This will trigger the function at certain times on weekdays and on different times on weekends, using the same input: + +```yaml +functions: + foo: + handler: foo.handler + events: + - schedule: + rate: + - cron(0 0/4 ? * MON-FRI *) + - cron(0 2 ? * SAT-SUN *) + input: + key1: value1 + key2: value2 +``` diff --git a/docs/providers/aws/events/sqs.md b/docs/providers/aws/events/sqs.md index 669097b09ae..40ba80713ce 100644 --- a/docs/providers/aws/events/sqs.md +++ b/docs/providers/aws/events/sqs.md @@ -51,7 +51,11 @@ functions: For the SQS event integration, you can set the `batchSize`, which effects how many SQS messages can be included in a single Lambda invocation. The default `batchSize` is `10`. The max `batchSize` is `10000` for a standard queue, `10` for a FIFO queue. -You can also set `maximumBatchingWindow` to standard queues to specify the maximum amount of time in seconds to gather records before invoking the function. The max `maximumBatchingWindow` is `300` seconds. Check [AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html) for more details. +You can also set `maximumBatchingWindow` to standard queues to specify the maximum amount of time in seconds to gather records before invoking the function. The max `maximumBatchingWindow` is `300` seconds. + +You can set `functionResponseType` to `ReportBatchItemFailures` to let your function return a partial success result if one or more messages in the batch have failed. + +Check [AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html) for more details. ```yml functions: @@ -62,8 +66,59 @@ functions: arn: arn:aws:sqs:region:XXXXXX:myQueue batchSize: 10 maximumBatchingWindow: 60 + functionResponseType: ReportBatchItemFailures +``` + +## Setting filter patterns + +This configuration allows customers to filter event before lambda invocation. It accepts up to 5 filter patterns by default and up to 10 with quota extension. If one event matches at least 1 pattern, lambda will process it. + +For more details and examples of filter patterns, please see the [AWS event filtering documentation](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html) + +Note: Serverless only sets this property if you explicitly add it to the `sqs` configuration (see an example below). The following example will only process records where field `a` is equal to 1 or 2. + +```yml +functions: + onlyOneOrTwo: + handler: handler.preprocess + events: + - sqs: + arn: arn:aws:sqs:region:XXXXXX:myQueue + filterPatterns: + - a: [1, 2] ``` ## IAM Permissions The Serverless Framework will automatically configure the most minimal set of IAM permissions for you. However you can still add additional permissions if you need to. Read the official [AWS documentation](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-configure-lambda-function-trigger.html) for more information about IAM Permissions for SQS events. + +## Deploying SQS queues + +The examples above show how to consume messages from an existing SQS queue. To create an SQS queue in `serverless.yml`, you can either write custom CloudFormation, or you can use Lift. + +[Lift](https://github.com/getlift/lift) is a Serverless Framework plugin that simplifies deploying pieces of applications via "[constructs](https://github.com/getlift/lift#constructs)". Lift can be installed via: + +``` +serverless plugin install -n serverless-lift +``` + +We can use the [`queue` construct](https://github.com/getlift/lift/blob/master/docs/queue.md) to deploy an SQS queue with its Lambda consumer: + +```yaml +constructs: + my-queue: + type: queue + worker: + handler: handler.compute + +plugins: + - serverless-lift +``` + +The `queue` construct deploys: + +- An SQS queue +- A `worker` Lambda function: this function processes messages sent to the queue. +- An SQS "[dead letter queue](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html)": this queue stores all the messages that failed to be processed. + +Read the [`queue` construct documentation](https://github.com/getlift/lift/blob/master/docs/queue.md) to find a complete example with code, and to learn how to configure the batch size, retries and other options. diff --git a/docs/providers/aws/events/streams.md b/docs/providers/aws/events/streams.md index 12fed255ccb..1a53ba41660 100644 --- a/docs/providers/aws/events/streams.md +++ b/docs/providers/aws/events/streams.md @@ -77,8 +77,6 @@ functions: This configuration sets up a disabled Kinesis stream event for the `preprocess` function which has a batch size of `100`. The starting position is `LATEST`. -**Note:** The `stream` event will hook up your existing streams to a Lambda function. Serverless won't create a new stream for you. - ```yml functions: preprocess: @@ -106,8 +104,6 @@ The `batchWindow` property specifies a maximum amount of time to wait before tri For more information, read the [AWS release announcement](https://aws.amazon.com/about-aws/whats-new/2019/09/aws-lambda-now-supports-custom-batch-window-for-kinesis-and-dynamodb-event-sources/) for this property. -**Note:** The `stream` event will hook up your existing streams to a Lambda function. Serverless won't create a new stream for you. - ```yml functions: preprocess: @@ -126,8 +122,6 @@ This configuration provides the ability to recursively split a failed batch and [Related AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-bisectbatchonfunctionerror) -**Note:** The `stream` event will hook up your existing streams to a Lambda function. Serverless won't create a new stream for you. - ```yml functions: preprocess: @@ -146,8 +140,6 @@ This configuration sets up the maximum number of times to retry when the functio [Related AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumretryattempts) -**Note:** The `stream` event will hook up your existing streams to a Lambda function. Serverless won't create a new stream for you. - ```yml functions: preprocess: @@ -169,8 +161,6 @@ This configuration sets up the maximum age of a record that Lambda sends to a fu [Related AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumrecordageinseconds) -**Note:** The `stream` event will hook up your existing streams to a Lambda function. Serverless won't create a new stream for you. - ```yml functions: preprocess: @@ -255,8 +245,6 @@ The `parallelizationFactor` property specifies the number of concurrent Lambda i For more information, read the [AWS release announcement](https://aws.amazon.com/blogs/compute/new-aws-lambda-scaling-controls-for-kinesis-and-dynamodb-event-sources/) for this property. -**Note:** The `stream` event will hook up your existing streams to a Lambda function. Serverless won't create a new stream for you. - ```yml functions: preprocess: @@ -273,8 +261,6 @@ This configuration allows customers to automatically checkpoint records that hav For more information, read the [AWS release announcement](https://aws.amazon.com/about-aws/whats-new/2020/12/aws-lambda-launches-checkpointing-for-amazon-kinesis-and-amazon-dynamodb-streams/) -Note: Serverless only sets this property if you explicitly add it to the stream configuration (see example below). - ```yml functions: preprocess: @@ -320,3 +306,45 @@ functions: ``` For more information, read this [AWS blog post](https://aws.amazon.com/blogs/compute/increasing-real-time-stream-processing-performance-with-amazon-kinesis-data-streams-enhanced-fan-out-and-aws-lambda/) or this [AWS documentation](https://docs.aws.amazon.com/streams/latest/dev/introduction-to-enhanced-consumers.html). + +## Setting TumblingWindowInSeconds + +This configuration allows customers to aggregate values in near-realtime, allowing state to by passed forward by Lambda invocations. A event source created with this property adds several new attributes to the events delivered to the Lambda function. + +- **window**: beginning and ending timestamps of the tumbling window; +- **state**: an object containing state of a previous execution. Initially empty can contain up to **1mb** of data; +- **isFinalInvokeForWindow**: indicates if this is the last execution for the tumbling window; +- **isWindowTerminatedEarly**: happens only when the state object exceeds maximum allowed size of 1mb. + +For more information and examples, read the [AWS release announcement](https://aws.amazon.com/blogs/compute/using-aws-lambda-for-streaming-analytics/) + +Note: Serverless only sets this property if you explicitly add it to the stream configuration (see example below). + +```yml +functions: + preprocess: + handler: handler.preprocess + events: + - stream: + arn: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 + tumblingWindowInSeconds: 30 +``` + +## Setting filter patterns + +This configuration allows customers to filter event before lambda invocation. It accepts up to 5 filter patterns by default and up to 10 with quota extension. If one event matches at least 1 pattern, lambda will process it. + +For more details and examples of filter patterns, please see the [AWS event filtering documentation](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html) + +Note: Serverless only sets this property if you explicitly add it to the stream configuration (see an example below). The following example will only process inserted items in the DynamoDB table (it will skip removed and modified items). + +```yml +functions: + handleInsertedDynamoDBItem: + handler: handler.preprocess + events: + - stream: + arn: arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 + filterPatterns: + - eventName: [INSERT] +``` diff --git a/docs/providers/aws/examples/hello-world/csharp/README.md b/docs/providers/aws/examples/hello-world/csharp/README.md index a590b3c0645..982534e5f4f 100644 --- a/docs/providers/aws/examples/hello-world/csharp/README.md +++ b/docs/providers/aws/examples/hello-world/csharp/README.md @@ -13,7 +13,7 @@ layout: Doc # Hello World C# Example -Make sure `serverless` is installed. [See installation guide](../../../guide/installation.md). +Make sure `serverless` is installed. [See installation guide](https://www.serverless.com/framework/docs/getting-started). Once installed the Serverless CLI can be called with `serverless` or the shorthand `sls` command. @@ -31,7 +31,7 @@ Commands ## 1. Create a service -``` +```bash sls create --template aws-csharp --path myService ``` @@ -41,19 +41,19 @@ The `--path` or shorthand `-p` is the location to be created with the template s ## 2. Build using .NET Core 3.1 CLI tools and create zip package -``` +```bash # Linux or Mac OS ./build.sh ``` -``` +```bash # Windows PowerShell .\build.cmd ``` ## 3. Deploy -``` +```bash sls deploy ``` @@ -61,7 +61,7 @@ This will deploy your function to AWS Lambda based on the settings in `serverles ## 4. Invoke deployed function -``` +```bash sls invoke -f hello ``` @@ -69,14 +69,14 @@ Invoke deployed function with command `invoke` and `--function` or shorthand `-f In your terminal window you should see the response from AWS Lambda. -```bash +```json { - "Message": "Go Serverless v1.0! Your function executed successfully!", - "Request": { - "Key1": null, - "Key2": null, - "Key3": null - } + "Message": "Go Serverless v1.0! Your function executed successfully!", + "Request": { + "Key1": null, + "Key2": null, + "Key3": null + } } ``` diff --git a/docs/providers/aws/examples/hello-world/fsharp/README.md b/docs/providers/aws/examples/hello-world/fsharp/README.md index e918bbf330c..bd0e8afb829 100644 --- a/docs/providers/aws/examples/hello-world/fsharp/README.md +++ b/docs/providers/aws/examples/hello-world/fsharp/README.md @@ -13,7 +13,7 @@ layout: Doc # Hello World F# Example -Make sure `serverless` is installed. [See installation guide](../../../guide/installation.md). +Make sure `serverless` is installed. [See installation guide](https://www.serverless.com/framework/docs/getting-started). Once installed the Serverless CLI can be called with `serverless` or the shorthand `sls` command. @@ -29,7 +29,7 @@ Commands ## 1. Create a service -``` +```bash sls create --template aws-fsharp --path myService ``` @@ -39,19 +39,19 @@ The `--path` or shorthand `-p` is the location to be created with the template s ## 2. Build using .NET Core 3.1.x CLI tools and create zip package -``` +```bash # Linux or Mac OS ./build.sh ``` -``` +```bash # Windows PowerShell ./build.cmd ``` ## 3. Deploy -``` +```bash sls deploy ``` @@ -59,7 +59,7 @@ This will deploy your function to AWS Lambda based on the settings in `serverles ## 4. Invoke deployed function -``` +```bash sls invoke -f hello ``` @@ -67,14 +67,14 @@ Invoke deployed function with command `invoke` and `--function` or shorthand `-f In your terminal window you should see the response from AWS Lambda. -```bash +```json { - "Message": "Go Serverless v1.0! Your function executed successfully!", - "Request": { - "Key1": null, - "Key2": null, - "Key3": null - } + "Message": "Go Serverless v1.0! Your function executed successfully!", + "Request": { + "Key1": null, + "Key2": null, + "Key3": null + } } ``` diff --git a/docs/providers/aws/examples/hello-world/go/README.md b/docs/providers/aws/examples/hello-world/go/README.md index 792750628d9..7c29a2fc8ec 100644 --- a/docs/providers/aws/examples/hello-world/go/README.md +++ b/docs/providers/aws/examples/hello-world/go/README.md @@ -13,7 +13,7 @@ layout: Doc # Hello World Go Example -Make sure `serverless` is installed. [See installation guide](../../../guide/installation.md). +Make sure `serverless` is installed. [See installation guide](https://www.serverless.com/framework/docs/getting-started). Once installed the Serverless CLI can be called with `serverless` or the shorthand `sls` command. @@ -39,7 +39,7 @@ The Serverless Framework includes starter templates for various languages and pr `aws-go` fetches dependencies using standard `go get`. -``` +```bash sls create --template aws-go --path myService ``` @@ -47,7 +47,7 @@ sls create --template aws-go --path myService `aws-go-dep` uses [go dep](https://github.com/golang/dep) and requires your project to be in `$GOPATH/src`. -``` +```bash sls create --template aws-go-dep --path myService ``` @@ -55,7 +55,7 @@ sls create --template aws-go-dep --path myService `aws-go-mod` uses standard [Go modules] and requires your project to be **outside** `$GOPATH` and to use Go 1.13+. -``` +```bash sls create --template aws-go-mod --path myService ``` @@ -88,7 +88,7 @@ Run `make build` to build both functions. Successful build should generate the f ## 3. Deploy -``` +```bash sls deploy ``` @@ -96,11 +96,11 @@ This will deploy your function to AWS Lambda based on the settings in `serverles ## 4. Invoke deployed function -``` +```bash sls invoke -f hello ``` -``` +```bash sls invoke -f world ``` diff --git a/docs/providers/aws/examples/hello-world/node/README.md b/docs/providers/aws/examples/hello-world/node/README.md index 468585566d1..be9a78158fb 100644 --- a/docs/providers/aws/examples/hello-world/node/README.md +++ b/docs/providers/aws/examples/hello-world/node/README.md @@ -13,7 +13,7 @@ layout: Doc # Hello World Node.js Example -Make sure `serverless` is installed. [See installation guide](../../../guide/installation.md). +Make sure `serverless` is installed. [See installation guide](https://www.serverless.com/framework/docs/getting-started). Once installed the Serverless CLI can be called with `serverless` or the shorthand `sls` command. @@ -29,7 +29,7 @@ Commands ## 1. Create a service -``` +```bash sls create --template aws-nodejs --path myService ``` @@ -39,7 +39,7 @@ The `--path` or shorthand `-p` is the location to be created with the template s ## 2. Deploy -``` +```bash sls deploy ``` @@ -47,7 +47,7 @@ This will deploy your function to AWS Lambda based on the settings in `serverles ## 3. Invoke deployed function -``` +```bash sls invoke -f hello ``` @@ -55,10 +55,10 @@ Invoke deployed function with command `invoke` and `--function` or shorthand `-f In your terminal window you should see the response from AWS Lambda. -```bash +```json { - "statusCode": 200, - "body": "{\"message\":\"Go Serverless v1.0! Your function executed successfully!\",\"input\":{}}" + "statusCode": 200, + "body": "{\"message\":\"Go Serverless v1.0! Your function executed successfully!\",\"input\":{}}" } ``` diff --git a/docs/providers/aws/examples/hello-world/python/README.md b/docs/providers/aws/examples/hello-world/python/README.md index 89d61fcc3f2..8bdbed0b0ad 100644 --- a/docs/providers/aws/examples/hello-world/python/README.md +++ b/docs/providers/aws/examples/hello-world/python/README.md @@ -13,7 +13,7 @@ layout: Doc # Hello World Python Example -Make sure `serverless` is installed. [See installation guide](../../../guide/installation.md). +Make sure `serverless` is installed. [See installation guide](https://www.serverless.com/framework/docs/getting-started). Once installed the Serverless CLI can be called with `serverless` or the shorthand `sls` command. @@ -29,8 +29,8 @@ Commands ## 1. Create a service -``` -sls create --template aws-python --path myService +```bash +sls create --template aws-python3 --path myService ``` Using the `create` command we can specify one of the available [templates](https://serverless.com/framework/docs/providers/aws/cli-reference/create#available-templates). For this example use aws-python with the `--template` or shorthand `-t` flag. @@ -39,7 +39,7 @@ The `--path` or shorthand `-p` is the location to be created with the template s ## 2. Deploy -``` +```bash sls deploy ``` @@ -47,7 +47,7 @@ This will deploy your function to AWS Lambda based on the settings in `serverles ## 3. Invoke deployed function -``` +```bash sls invoke -f hello ``` @@ -55,10 +55,10 @@ Invoke deployed function with command `invoke` and `--function` or shorthand `-f In your terminal window you should see the response from AWS Lambda. -```bash +```json { - "statusCode": 200, - "body": "{\"message\":\"Go Serverless v1.0! Your function executed successfully!\",\"input\":{}}" + "statusCode": 200, + "body": "{\"message\":\"Go Serverless v1.0! Your function executed successfully!\",\"input\":{}}" } ``` diff --git a/docs/providers/aws/examples/hello-world/ruby/README.md b/docs/providers/aws/examples/hello-world/ruby/README.md index 9aa16fb7eb1..c40a574add0 100644 --- a/docs/providers/aws/examples/hello-world/ruby/README.md +++ b/docs/providers/aws/examples/hello-world/ruby/README.md @@ -13,7 +13,7 @@ layout: Doc # Hello World Ruby Example -Make sure `serverless` is installed. [See installation guide](../../../guide/installation.md). +Make sure `serverless` is installed. [See installation guide](https://www.serverless.com/framework/docs/getting-started). Once installed the Serverless CLI can be called with `serverless` or the shorthand `sls` command. @@ -29,7 +29,7 @@ Commands ## 1. Create a service -``` +```bash sls create --template aws-ruby --path myService ``` @@ -39,7 +39,7 @@ The `--path` or shorthand `-p` is the location to be created with the template s ## 2. Deploy -``` +```bash sls deploy ``` @@ -47,7 +47,7 @@ This will deploy your function to AWS Lambda based on the settings in `serverles ## 3. Invoke deployed function -``` +```bash sls invoke -f hello ``` diff --git a/docs/providers/aws/guide/credentials.md b/docs/providers/aws/guide/credentials.md index eabd2d50a22..994f36b3bcd 100644 --- a/docs/providers/aws/guide/credentials.md +++ b/docs/providers/aws/guide/credentials.md @@ -91,7 +91,8 @@ export AWS_SECRET_ACCESS_KEY= # AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are now available for serverless to use serverless deploy -# 'export' command is valid only for unix shells. In Windows - use 'set' instead of 'export' +# 'export' command is valid only for unix shells +# In Windows use 'set' instead of 'export' ``` **Please note:** _If you are using a self-signed certificate you'll need to do one of the following:_ @@ -109,8 +110,8 @@ export cafile="/path/to/cafile.pem" # or multiple, comma separated export cafile="/path/to/cafile1.pem,/path/to/cafile2.pem" - -# 'export' command is valid only for unix shells. In Windows - use 'set' instead of 'export' +# 'export' command is valid only for unix shells +# In Windows use 'set' instead of 'export' ``` #### Using AWS Profiles @@ -124,7 +125,10 @@ Serverless provides a convenient way to configure AWS profiles with the help of Here's an example how you can configure the `default` AWS profile: ```bash -serverless config credentials --provider aws --key AKIAIOSFODNN7EXAMPLE --secret wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY +serverless config credentials \ + --provider aws \ + --key AKIAIOSFODNN7EXAMPLE \ + --secret wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY ``` Take a look at the [`config` CLI reference](../cli-reference/config-credentials.md) for more information about credential configuration. diff --git a/docs/providers/aws/guide/deploying.md b/docs/providers/aws/guide/deploying.md index 9d38cb7dac2..fee64a62dea 100644 --- a/docs/providers/aws/guide/deploying.md +++ b/docs/providers/aws/guide/deploying.md @@ -83,6 +83,8 @@ The Serverless Framework translates all syntax in `serverless.yml` to a single A - You can disable creation of default S3 bucket policy by setting `skipPolicySetup` under `deploymentBucket` config. It only applies to deployment bucket that is automatically created by the Serverless Framework. +- You can enable versioning for the deployment bucket by setting `versioning` under `deploymentBucket` config to `true`. + Check out the [deploy command docs](../cli-reference/deploy.md) for all details and options. - For information on multi-region deployments, [checkout this article](https://serverless.com/blog/build-multiregion-multimaster-application-dynamodb-global-tables). diff --git a/docs/providers/aws/guide/events.md b/docs/providers/aws/guide/events.md index d0cb9b1c17e..80c8f99af96 100644 --- a/docs/providers/aws/guide/events.md +++ b/docs/providers/aws/guide/events.md @@ -22,6 +22,13 @@ If you are using AWS as your provider, all `events` in the service are anything Upon deployment, the framework will deploy any infrastructure required for an event (e.g., an API Gateway endpoint) and configure your `function` to listen to it. +Infrastructure which is created to support events in the `events` list may be +referenced using CloudFormation intrinsic functions like `Fn::GetAtt` or +`Fn::Ref` (or their shorthand counterparts). For details on referencing created +resources in AWS, see the [AWS CloudFormation Resource +Reference](./resources.md#aws-cloudformation-resource-reference) section on the +[AWS - Resources](./resources.md) page. + ## Configuration Events belong to each Function and can be found in the `events` property in `serverless.yml`. @@ -32,9 +39,7 @@ functions: createUser: # Function name handler: handler.createUser # Reference to file handler.js & exported function 'createUser' events: # All events associated with this function - - http: - path: users/create - method: post + - httpApi: 'POST /users/create' ``` Events are objects, which can contain event-specific information. @@ -49,15 +54,9 @@ functions: createUser: # Function name handler: handler.users # Reference to file handler.js & exported function 'users' events: # All events associated with this function - - http: - path: users/create - method: post - - http: - path: users/update - method: put - - http: - path: users/delete - method: delete + - httpApi: 'POST /users/create' + - httpApi: 'PUT /users/update' + - httpApi: 'DELETE /users/delete' ``` ## Types @@ -74,9 +73,7 @@ functions: createUser: # Function name handler: handler.users # Reference to file handler.js & exported function 'users' events: # All events associated with this function - - http: - path: users/{id} - method: get + - httpApi: 'GET /users/{id}' ``` ## Deploying diff --git a/docs/providers/aws/guide/functions.md b/docs/providers/aws/guide/functions.md index abbbb61f80f..870236b4a8b 100644 --- a/docs/providers/aws/guide/functions.md +++ b/docs/providers/aws/guide/functions.md @@ -187,14 +187,15 @@ functions: memorySize: 512 ``` -You can also use an existing IAM role by adding your IAM Role ARN in the `role` property. For example: +You can also use an existing IAM role by adding your IAM Role ARN in the `iam.role` property. For example: ```yml # serverless.yml service: new-service provider: name: aws - role: arn:aws:iam::YourAccountNumber:role/YourIamRole + iam: + role: arn:aws:iam::YourAccountNumber:role/YourIamRole ``` See the documentation about [IAM](./iam.md) for function level IAM roles. @@ -203,7 +204,17 @@ See the documentation about [IAM](./iam.md) for function level IAM roles. Alternatively lambda environment can be configured through docker images. Image published to AWS ECR registry can be referenced as lambda source (check [AWS Lambda – Container Image Support](https://aws.amazon.com/blogs/aws/new-for-aws-lambda-container-image-support/)). In addition, you can also define your own images that will be built locally and uploaded to AWS ECR registry. -In service configuration, images can be configured via `provider.ecr.images`. To define an image that will be built locally, you need to specify `path` property, which should point to valid docker context directory. Optionally, you can also set `file` to specify Dockerfile that should be used when building an image. It is also possible to define images that already exist in AWS ECR repository. In order to do that, you need to define `uri` property, which should follow `.dkr.ecr..amazonaws.com/@` or `.dkr.ecr..amazonaws.com/:` format. Additionally, with `buildArgs` property, you can define arguments that will be passed to `docker build` command with `--build-arg` flag. They might be later referenced via `ARG` within your `Dockerfile`. The `cacheFrom` property can be used to specify which images to use as a source for layer caching in the `docker build` command with `--cache-from` flag. When `uri` is defined for an image, `buildArgs` and `cacheFrom` cannot be defined. +Serverless will create an ECR repository for your image, but it currently does not manage updates to it. An ECR repository is created only for new services or the first time that a function configured with an `image` is deployed. In service configuration, you can configure the ECR repository to scan for CVEs via the `provider.ecr.scanOnPush` property, which is `false` by default. (See [documentation](https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-scanning.html)) + +In service configuration, images can be configured via `provider.ecr.images`. To define an image that will be built locally, you need to specify `path` property, which should point to valid docker context directory. Optionally, you can also set `file` to specify Dockerfile that should be used when building an image. It is also possible to define images that already exist in AWS ECR repository. In order to do that, you need to define `uri` property, which should follow `.dkr.ecr..amazonaws.com/@` or `.dkr.ecr..amazonaws.com/:` format. + +Additionally, you can define arguments that will be passed to the `docker build` command via the following properties: + +- `buildArgs`: With the `buildArgs` property, you can define arguments that will be passed to `docker build` command with `--build-arg` flag. They might be later referenced via `ARG` within your `Dockerfile`. (See [Documentation](https://docs.docker.com/engine/reference/builder/#arg)) +- `cacheFrom`: The `cacheFrom` property can be used to specify which images to use as a source for layer caching in the `docker build` command with `--cache-from` flag. (See [Documentation](https://docs.docker.com/engine/reference/builder/#usage)) +- `platform`: The `platform` property can be used to specify the architecture target in the `docker build` command with the `--platform` flag. If not specified, Docker will build for your computer's architecture by default. AWS Lambda typically uses `x86` architecture unless otherwise specified in the Lambda's runtime settings. In order to avoid runtime errors when building on an ARM-based machine (e.g. Apple M1 Mac), `linux/amd64` must be used here. The options for this flag are `linux/amd64` (`x86`-based Lambdas), `linux/arm64` (`arm`-based Lambdas), or `windows/amd64`. (See [Documentation](https://docs.docker.com/engine/reference/builder/#from)) + +When `uri` is defined for an image, `buildArgs`, `cacheFrom`, and `platform` cannot be defined. Example configuration @@ -212,6 +223,7 @@ service: service-name provider: name: aws ecr: + scanOnPush: true images: baseimage: path: ./path/to/context @@ -220,6 +232,7 @@ provider: STAGE: ${opt:stage} cacheFrom: - my-image:latest + platform: linux/amd64 anotherimage: uri: 000000000000.dkr.ecr.sa-east-1.amazonaws.com/test-lambda-docker@sha256:6bb600b4d6e1d7cf521097177dd0c4e9ea373edb91984a505333be8ac9455d38 ``` @@ -281,6 +294,27 @@ functions: During the first deployment when locally built images are used, Framework will automatically create a dedicated ECR repository to store these images, with name `serverless--`. Currently, the Framework will not remove older versions of images uploaded to ECR as they still might be in use by versioned functions. During `sls remove`, the created ECR repository will be removed. During deployment, Framework will attempt to `docker login` to ECR if needed. Depending on your local configuration, docker authorization token might be stored unencrypted. Please refer to documentation for more details: https://docs.docker.com/engine/reference/commandline/login/#credentials-store +## Instruction set architecture + +By default, Lambda functions are run by 64-bit x86 architecture CPUs. However, [using arm64 architecture](https://docs.aws.amazon.com/lambda/latest/dg/foundation-arch.html) (AWS Graviton2 processor) may result in better pricing and performance. + +To switch all functions to AWS Graviton2 processor, configure `architecture` at `provider` level as follows: + +```yml +provider: + ... + architecture: arm64 +``` + +To toggle instruction set architecture per function individually, set it directly at `functions[]` context: + +```yaml +functions: + hello: + ... + architecture: arm64 +``` + ## VPC Configuration You can add VPC configuration to a specific function in `serverless.yml` by adding a `vpc` object property in the function configuration. This object should contain the `securityGroupIds` and `subnetIds` array properties needed to construct VPC for this function. Here's an example configuration: @@ -333,6 +367,29 @@ functions: Then, when you run `serverless deploy`, VPC configuration will be deployed along with your lambda function. +If you have a provider VPC set but wish to have specific functions with no VPC, you can set the `vpc` value for these functions to `~` (null). For example: + +```yml +# serverless.yml +service: service-name +provider: + name: aws + vpc: + securityGroupIds: + - securityGroupId1 + - securityGroupId2 + subnetIds: + - subnetId1 + - subnetId2 + +functions: + hello: # this function will have no vpc configured + handler: handler.hello + vpc: ~ + users: # this function will inherit the service level vpc config above + handler: handler.users +``` + **VPC IAM permissions** The Lambda function execution role must have permissions to create, describe and delete [Elastic Network Interfaces](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_ElasticNetworkInterfaces.html) (ENI). When VPC configuration is provided the default AWS `AWSLambdaVPCAccessExecutionRole` will be associated with your Lambda execution role. In case custom roles are provided be sure to include the proper [ManagedPolicyArns](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#cfn-iam-role-managepolicyarns). For more information please check [configuring a Lambda Function for Amazon VPC Access](http://docs.aws.amazon.com/lambda/latest/dg/vpc.html) @@ -460,15 +517,15 @@ functions: By default, the framework creates function versions for every deploy. This behavior is optional, and can be turned off in cases where you don't invoke past versions by their qualifier. If you would like to do this, you can invoke your functions as `arn:aws:lambda:....:function/myFunc:3` to invoke version 3 for example. -To turn off this feature, set the provider-level option `versionFunctions`. +Versions are not cleaned up by serverless, so make sure you use a plugin or other tool to prune sufficiently old versions. The framework can't clean up versions because it doesn't have information about whether older versions are invoked or not. This feature adds to the number of total stack outputs and resources because a function version is a separate resource from the function it refers to. + +To turn off function versioning, set the provider-level option `versionFunctions`. ```yml provider: versionFunctions: false ``` -These versions are not cleaned up by serverless, so make sure you use a plugin or other tool to prune sufficiently old versions. The framework can't clean up versions because it doesn't have information about whether older versions are invoked or not. This feature adds to the number of total stack outputs and resources because a function version is a separate resource from the function it refers to. - ## Dead Letter Queue (DLQ) When AWS lambda functions fail, they are [retried](http://docs.aws.amazon.com/lambda/latest/dg/retries-on-errors.html). If the retries also fail, AWS has a feature to send information about the failed request to a SNS topic or SQS queue, called the [Dead Letter Queue](http://docs.aws.amazon.com/lambda/latest/dg/dlq.html), which you can use to track and diagnose and react to lambda failures. @@ -608,4 +665,29 @@ functions: - securityGroupId1 subnetIds: - subnetId1 +``** + +## Lambda Hashing Algorithm migration + +**Note** Below migration guide is intended to be used if you are already using `v3` version of the Framework and you have `provider.lambdaHashingVersion` property set to `20200924` in your configuration file. If you are still on v2 and want to upgrade to v3, please refer to [V3 Upgrade docs](../../../guides/upgrading-v3.md#lambda-hashing-algorithm). + +In `v3`, Lambda version hashes are generated using an improved algorithm that fixes determinism issues. If you are still using the old hashing algorithm, you can follow the guide below to migrate to new default version. + +Please keep in mind that these changes require two deployments with manual configuration adjustment between them. It also creates two additional versions and temporarily overrides descriptions of your functions. Migration will need to be done separately for each of your environments/stages. + +1. Run `sls deploy` with additional `--enforce-hash-update` flag: that flag will override the description for Lambda functions, which will force the creation of new versions. +2. Remove `provider.lambdaHashingVersion` setting from your configuration: your service will now always deploy with the new Lambda version hashes (which is the new default in v3). +3. Run `sls deploy`, this time without additional `--enforce-hash-update` flag: that will restore the original descriptions on all Lambda functions. + +Now your whole service is fully migrated to the new Lambda Hashing Algorithm. + +If you do not want to temporarily override descriptions of your functions or would like to avoid creating unnecessary versions of your functions, you might want to use one of the following approaches: + +- Ensure that code for all your functions will change during deployment, remove `provider.lambdaHashingVersion` from your configuration, and run `sls deploy`. Due to the fact that all functions have code changed, all your functions will be migrated to new hashing algorithm. Please note that the change can be caused by e.g. upgrading a dependency used by all your functions so you can pair it with regular chores. +- Add a dummy file that will be included in deployment artifacts for all your functions, remove `provider.lambdaHashingVersion` from your configuration, and run `sls deploy`. Due to the fact that all functions have code changed, all your functions will be migrated to new hashing algorithm. +- If it is safe in your case (e.g. it's only development sandbox), you can also tear down the whole service by `sls remove`, remove `provider.lambdaHashingVersion` from your configuration, and run `sls deploy`. Newly recreated environment will be using new hashing algorithm. + + + + ``` diff --git a/docs/providers/aws/guide/iam.md b/docs/providers/aws/guide/iam.md index 8de6af6b2d0..2a3d4bc6e3b 100644 --- a/docs/providers/aws/guide/iam.md +++ b/docs/providers/aws/guide/iam.md @@ -24,12 +24,14 @@ All IAM-related properties of provider are grouped under `iam` property: provider: iam: role: + name: custom-role-name + path: /custom-role-path/ statements: - - Effect: 'Allow', - Resource: '*', - NotAction: 'iam:DeleteUser', + - Effect: 'Allow' + Resource: '*' + Action: 'iam:DeleteUser' managedPolicies: - - 'arn:aws:iam::123456789012:user/*', + - 'arn:aws:iam::123456789012:user/*' permissionsBoundary: arn:aws:iam::123456789012:policy/boundaries tags: key: value @@ -120,6 +122,21 @@ provider: name: your-custom-name-${sls:stage}-role ``` +### Path for the Default IAM Role + +By default, it will use a path of: `/` + +This can be overridden by setting `provider.iam.role.path`: + +```yml +service: new-service + +provider: + iam: + role: + path: /your-custom-path/ +``` + ## Custom IAM Roles **WARNING:** You need to take care of the overall role setup as soon as you define custom roles. diff --git a/docs/providers/aws/guide/installation.md b/docs/providers/aws/guide/installation.md deleted file mode 100644 index 864db1f8e0f..00000000000 --- a/docs/providers/aws/guide/installation.md +++ /dev/null @@ -1,53 +0,0 @@ - - - - -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/guide/installation) - - - -# AWS - Installation - -### Installing Node.js - -Serverless is a [Node.js](https://nodejs.org) CLI tool so the first thing you need to do is to install Node.js on your machine. - -Go to the official [Node.js website](https://nodejs.org), download and follow the [installation instructions](https://nodejs.org/en/download/) to install Node.js on your local machine. - -**Note:** Serverless runs on Node v6 or higher. - -You can verify that Node.js is installed successfully by running `node --version` in your terminal. You should see the corresponding Node version number printed out. - -### Installing the Serverless Framework - -Next, install the Serverless Framework via [npm](https://npmjs.org) which was already installed when you installed Node.js. - -Open up a terminal and type `npm install -g serverless` to install Serverless. - -```bash -npm install -g serverless -``` - -Once the installation process is done you can verify that Serverless is installed successfully by running the following command in your terminal: - -```bash -serverless -``` - -To see which version of serverless you have installed run: - -```bash -serverless --version -``` - -### Setting up AWS - -To run serverless commands that interface with your AWS account, you will need to setup your AWS account credentials on your machine. - -[Follow these instructions on setting up AWS credentials](./credentials.md) diff --git a/docs/providers/aws/guide/intro.md b/docs/providers/aws/guide/intro.md index a00e42da9f1..553d52e3310 100644 --- a/docs/providers/aws/guide/intro.md +++ b/docs/providers/aws/guide/intro.md @@ -71,10 +71,10 @@ service: users functions: # Your "Functions" usersCreate: events: # The "Events" that trigger this function - - http: post users/create + - httpApi: 'POST /users/create' usersDelete: events: - - http: delete users/delete + - httpApi: 'DELETE /users/delete' resources: # The "Resources" your "Functions" use. Raw AWS CloudFormation goes in here. ``` @@ -88,14 +88,14 @@ _serverless.json_ "usersCreate": { "events": [ { - "http": "post users/create" + "httpApi": "POST /users/create" } ] }, "usersDelete": { "events": [ { - "http": "delete users/delete" + "httpApi": "DELETE /users/delete" } ] } @@ -117,14 +117,14 @@ module.exports = { usersCreate: { events: [ { - http: 'post users/create', + httpApi: 'POST /users/create', }, ], }, usersDelete: { events: [ { - http: 'delete users/delete', + httpApi: 'DELETE /users/delete', }, ], }, @@ -145,14 +145,14 @@ const serverlessConfiguration: Serverless = { usersCreate: { events: [ { - http: 'post users/create', + httpApi: 'POST /users/create', }, ], }, usersDelete: { events: [ { - http: 'delete users/delete', + httpApi: 'DELETE /users/delete', }, ], }, @@ -163,6 +163,8 @@ const serverlessConfiguration: Serverless = { module.exports = serverlessConfiguration; ``` +> If deploying using a serverless.ts file, ts-node needs to be installed separately as a dev dependency. + When you deploy with the Framework by running `serverless deploy`, everything in the service configuration file is deployed at once. > For the sake of simplicity, most code snippet detailed in this documentation only refer to the `serverless.yml` YAML service file format. However, all functionalities work as well in the other available service file formats. @@ -178,3 +180,5 @@ plugins: - serverless-offline - serverless-secrets ``` + +Read more about plugins in the [Plugin documentation](../../../guides/plugins). diff --git a/docs/providers/aws/guide/layers.md b/docs/providers/aws/guide/layers.md index 9ad2c3fb58d..7bd10e6d4ee 100644 --- a/docs/providers/aws/guide/layers.md +++ b/docs/providers/aws/guide/layers.md @@ -35,6 +35,9 @@ layers: description: Description of what the lambda layer does # optional, Description to publish to AWS compatibleRuntimes: # optional, a list of runtimes this layer is compatible with - python3.8 + compatibleArchitectures: # optional, a list of architectures this layer is compatible with + - x86_64 + - arm64 licenseInfo: GPLv3 # optional, a string specifying license information # allowedAccounts: # optional, a list of AWS account IDs allowed to access this layer. # - '*' diff --git a/docs/providers/aws/guide/packaging.md b/docs/providers/aws/guide/packaging.md index 4c7953504a9..567955a009c 100644 --- a/docs/providers/aws/guide/packaging.md +++ b/docs/providers/aws/guide/packaging.md @@ -112,14 +112,14 @@ functions: package: artifact: hello.jar events: - - http: - path: hello - method: get + - httpApi: 'GET /hello' ``` #### Artifacts hosted on S3 -Artifacts can also be fetched from a remote S3 bucket. In this case you just need to provide the S3 object URL as the artifact value. This applies to both, service-wide and function-level artifact setups. +Artifacts can also be fetched from a remote S3 bucket. In this case you just need to provide the S3 object URI (old style or new) as the artifact value. This applies to both, service-wide and function-level artifact setups. + +**Note:** At this time, only S3 URIs are supported. Serverless does not yet support fetching artifacts from non-S3 remote locations. ##### Service package @@ -127,7 +127,7 @@ Artifacts can also be fetched from a remote S3 bucket. In this case you just nee service: my-service package: - artifact: https://s3.amazonaws.com/some-bucket/service-artifact.zip + artifact: s3://some-bucket/path/to/service-artifact.zip ``` ##### Individual function packages @@ -142,7 +142,7 @@ functions: hello: handler: com.serverless.Handler package: - artifact: https://s3.amazonaws.com/some-bucket/function-artifact.zip + artifact: s3://some-bucket/path/to/service-artifact.zip ``` ### Packaging functions separately diff --git a/docs/providers/aws/guide/plugins.md b/docs/providers/aws/guide/plugins.md deleted file mode 100644 index a1c1dfe3b65..00000000000 --- a/docs/providers/aws/guide/plugins.md +++ /dev/null @@ -1,725 +0,0 @@ - - - - -### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/guide/plugins) - - - -# Plugins - -A Plugin is custom Javascript code that creates new or extends existing commands within the Serverless Framework. The Serverless Framework is merely a group of Plugins that are provided in the core. If you or your organization have a specific workflow, install a pre-written Plugin or write a plugin to customize the Framework to your needs. External Plugins are written exactly the same way as the core Plugins. - -- [How to create serverless plugins - Part 1](https://serverless.com/blog/writing-serverless-plugins/) -- [How to create serverless plugins - Part 2](https://serverless.com/blog/writing-serverless-plugins-2/) - -## Installing Plugins - -External Plugins are added on a per service basis and are not applied globally. Make sure you are in your Service's root directory, then install the corresponding Plugin with the help of NPM: - -``` -npm install --save custom-serverless-plugin -``` - -We need to tell Serverless that we want to use the plugin inside our service. We do this by adding the name of the Plugin to the `plugins` section in the `serverless.yml` file. - -```yml -# serverless.yml file - -plugins: - - custom-serverless-plugin -``` - -The `plugins` section supports two formats: - -Array object: - -```yml -plugins: - - plugin1 - - plugin2 -``` - -Enhanced plugins object: - -```yml -plugins: - localPath: './custom_serverless_plugins' - modules: - - plugin1 - - plugin2 -``` - -Plugins might want to add extra information which should be accessible to Serverless. The `custom` section in the `serverless.yml` file is the place where you can add necessary configurations for your plugins (the plugins author / documentation will tell you if you need to add anything there): - -```yml -plugins: - - custom-serverless-plugin - -custom: - customkey: customvalue -``` - -## Service local plugin - -If you are working on a plugin or have a plugin that is just designed for one project, it can be loaded from the local `.serverless_plugins` folder at the root of your service. Local plugins can be added in the `plugins` array in `serverless.yml`. - -```yml -plugins: - - custom-serverless-plugin -``` - -Local plugins folder can be changed by enhancing `plugins` object: - -```yml -plugins: - localPath: './custom_serverless_plugins' - modules: - - custom-serverless-plugin -``` - -The `custom-serverless-plugin` will be loaded from the `custom_serverless_plugins` directory at the root of your service. If the `localPath` is not provided or empty, the `.serverless_plugins` directory will be used. - -The plugin will be loaded based on being named `custom-serverless-plugin.js` or `custom-serverless-plugin\index.js` in the root of `localPath` folder (`.serverless_plugins` by default). - -If you want to load a plugin from a specific directory without affecting other plugins, you can also specify a path relative to the root of your service: - -```yaml -plugins: - # This plugin will be loaded from the `.serverless_plugins/` or `node_modules/` directories - - custom-serverless-plugin - # This plugin will be loaded from the `sub/directory/` directory - - ./sub/directory/another-custom-plugin -``` - -### Load Order - -Keep in mind that the order you define your plugins matters. When Serverless loads all the core plugins and then the custom plugins in the order you've defined them. - -```yml -# serverless.yml - -plugins: - - plugin1 - - plugin2 -``` - -In this case `plugin1` is loaded before `plugin2`. - -## Writing Plugins - -**Note:** In order to ensure that your plugin works correctly with Framework in `v2.x`, keep the following things in mind: - -- Do not depend on `Bluebird` API for Promises returned by Framework internals - we are actively migrating away from `Bluebird` at this point -- If your plugin adds new properties, ensure to define corresponding schema definitions, please refer to: [Extending validation schema](#extending-validation-schema) -- Avoid using `subcommands` as the support for them might become deprecated or removed in next major version of the Framework -- Add `serverless` to `peerDependencies` in order to ensure officially supported Framework version(s) - -### Concepts - -#### Plugin - -Code which defines _Commands_, any _Events_ within a _Command_, and any _Hooks_ assigned to a _Lifecycle Event_. - -- Command // CLI configuration, commands, options - - LifecycleEvent(s) // Events that happen sequentially when the command is run - - Hook(s) // Code that runs when a Lifecycle Event happens during a Command - -#### Command - -A CLI _Command_ that can be called by a user, e.g. `serverless foo`. A Command has no logic, but simply defines the CLI configuration (e.g. command, parameters) and the _Lifecycle Events_ for the command. Every command defines its own lifecycle events. - -```javascript -'use strict'; - -class MyPlugin { - constructor() { - this.commands = { - foo: { - lifecycleEvents: ['resources', 'functions'], - }, - }; - } -} - -module.exports = MyPlugin; -``` - -#### Lifecycle Events - -Events that fire sequentially during a Command. The above example lists two Events. However, for each Event, an additional `before` and `after` event is created. Therefore, six Events exist in the above example: - -- `before:foo:resources` -- `foo:resources` -- `after:foo:resources` -- `before:foo:functions` -- `foo:functions` -- `after:foo:functions` - -The name of the command in front of lifecycle events when they are used for Hooks. - -#### Hooks - -A Hook binds code to any lifecycle event from any command. - -```javascript -'use strict'; - -class MyPugin { - constructor() { - this.commands = { - foo: { - lifecycleEvents: ['resources', 'functions'], - }, - }; - - this.hooks = { - 'before:foo:resources': this.beforeFooResources, - 'foo:resources': this.fooResources, - 'after:foo:functions': this.afterFooFunctions, - }; - } - - beforeFooResources() { - console.log('Before Foo Resources'); - } - - fooResources() { - console.log('Foo Resources'); - } - - afterFooFunctions() { - console.log('After Foo Functions'); - } -} - -module.exports = MyPlugin; -``` - -### Custom Variable Types - -Plugins may register its own configuration variables resolution sources. - -Resolvers should be configured at `configurationVariablesSources` in form of a plain object that exposes `resolve` function. -Check below example - -```javascript -'use strict'; - -class SomePlugin { - constructor() { - - this.configurationVariablesSources = { - foo: { - async resolve({ address, params, resolveConfigurationProperty, options }) { - // `address` and `params` reflect values configured with a variable: - // ${foo(param1, param2):address} - // Note: they're passed if they're configured into variable - - // `options` is CLI options - // `resolveConfigurationProperty` allows to access other configuration properties, - // and guarantees to return a fully resolved form (even if property is configured with variables) - const stage = options.stage || await resolveConfigurationProperty(["provider", "stage"]) || "dev"; - - // Resolver is expected to return plain object, with resolved value set on `value` property. - // Resolve value can be any JSON value - return { - // - value: `Resolution of "foo" source for "${stage}" stage at "${address || ""}" addresss with "${(params || []).join(", ")}" params` - } - } - } - -} -``` - -Having an above source resolver (as provided with a plugin), we may use new variable source in configuration as follows: - -```yaml -service: test -provider: aws -custom: - value1: ${foo(one, two):whatever} -plugins: - - ./some-plugin -``` - -Configuration will be resolved into following form: - -```yaml -service: test -provider: aws -custom: - value1: Resolution of "foo" source for "dev" stage at "whatever" address with "one, two" params -plugins: - - ./some-plugin -``` - -### Defining Options - -Each command can have multiple Options. - -Options are passed in with a double dash (`--`) like this: `serverless foo --function functionName`. - -Option Shortcuts are passed in with a single dash (`-`) like this: `serverless foo -f functionName`. - -The `options` object will be passed in as the second parameter to the constructor of your plugin. - -In it, you can optionally add a `shortcut` property, as well as a `required` property. The Framework will return an error if a `required` Option is not included. You can also set a `default` property if your option is not required. - -Additionally `type` for each option should be set. Supported types are `string`, `boolean` and `multiple` (multiple strings). - -**Note:** At this time, the Serverless Framework does not use parameters. - -```javascript -'use strict'; - -class MyPlugin { - constructor(serverless, options) { - this.serverless = serverless; - this.options = options; - - this.commands = { - foo: { - lifecycleEvents: ['functions'], - options: { - function: { - usage: 'Specify the function you want to handle (e.g. "--function myFunction")', - shortcut: 'f', - required: true, - type: 'string', // Possible options: "string", "boolean", "multiple" - }, - }, - }, - }; - - this.hooks = { - 'foo:functions': this.fooFunction.bind(this), - }; - } - - fooFunction() { - console.log('Foo function: ', this.options.function); - } -} - -module.exports = MyPlugin; -``` - -### Provider Specific Plugins - -Plugins can be provider specific which means that they are bound to a provider. - -**Note:** Binding a plugin to a provider is optional. Serverless will always consider your plugin if you don't specify a `provider`. - -The provider definition should be added inside the plugins constructor: - -```javascript -'use strict'; - -class ProviderX { - constructor(serverless, options) { - this.serverless = serverless; - this.options = options; - - // set the providers name here - this.provider = this.serverless.getProvider('providerX'); - - this.commands = { - foo: { - lifecycleEvents: ['functions'], - options: { - function: { - usage: 'Specify the function you want to handle (e.g. "--function myFunction")', - required: true, - type: 'string', // Possible options: "string", "boolean", "multiple" - }, - }, - }, - }; - - this.hooks = { - 'foo:functions': this.fooFunction.bind(this), - }; - } - - fooFunction() { - console.log('Foo function: ', this.options.function); - } -} - -module.exports = ProviderX; -``` - -The Plugin's functionality will now only be executed when the Serverless Service's provider matches the provider name which is defined inside the plugins constructor. - -### Serverless Instance - -The `serverless` instance which enables access to global service config during runtime is passed in as the first parameter to the plugin constructor. - -```javascript -'use strict'; - -class MyPlugin { - constructor(serverless, options) { - this.serverless = serverless; - this.options = options; - - this.commands = { - log: { - lifecycleEvents: ['serverless'], - }, - }; - - this.hooks = { - 'log:serverless': this.logServerless.bind(this), - }; - } - - logServerless() { - console.log('Serverless instance: ', this.serverless); - } -} - -module.exports = MyPlugin; -``` - -**Note:** [Variable references](./variables.md#reference-properties-in-serverlessyml) in the `serverless` instance are not resolved before a Plugin's constructor is called, so if you need these, make sure to wait to access those from your [hooks](#hooks). - -### Command Naming - -Command names need to be unique. If we load two commands and both want to specify the same command (e.g. we have an integrated command `deploy` and an external command also wants to use `deploy`) the Serverless CLI will print an error and exit. If you want to have your own `deploy` command you need to name it something different like `myCompanyDeploy` so they don't clash with existing plugins. - -### Extending validation schema - -If your plugin adds support for additional params in `serverless.yml` file, you should also add validation rules to the Framework's schema. Otherwise, the Framework may place validation errors to command output about your params. - -The Framework uses JSON-schema validation backed by [AJV](https://github.com/ajv-validator/ajv). You can extend [initial schema](/lib/configSchema/index.js) inside your plugin constuctor by using `defineTopLevelProperty`, `defineCustomProperties`, `defineFunctionEvent`, `defineFunctionEventProperties`, `defineFunctionProperties` or `defineProvider` helpers. - -Use the following map to know which helper suits best your needs. - -```yml -custom: - my-plugin: - customProperty: foobar # <-- use defineCustomProperties - -my-plugin: # <-- use defineTopLevelProperty - customProperty: foobar - -provider: - name: new-provider # <-- use defineProvider - my-plugin: - customProperty: foobar - -functions: - someFunc: - handler: handler.main - customProperty: foobar # <-- use defineFunctionProperties - events: - - yourPluginEvent: # <-- use defineFunctionEvent - customProperty: foobar - - http: - customProperty: foobar # <-- use defineFunctionEventProperties -``` - -We'll walk though those helpers. You may also want to check out examples from [helpers tests](tests/fixtures/configSchemaExtensions/test-plugin.js) - -#### `defineTopLevelProperty` helper - -If your plugin requires additional top-level properties (like `provider`, `custom`, `service`...), you can use the `defineTopLevelProperty` helper to add their definition. - -Considering the following example - -```yml -// serverless.yml - -service: my-service - -yourPlugin: - someProperty: foobar -``` - -you'll need to add validation rules as described below: - -```javascript -class NewTopLevelPropertyPlugin { - constructor(serverless) { - this.serverless = serverless; - - // Create schema for your properties. For reference use https://github.com/ajv-validator/ajv - const newCustomPropSchema = { - type: 'object', - properties: { - someProperty: { type: 'string' }, - }, - required: ['someProperty'], - }; - - // Attach your piece of schema to main schema at top level - serverless.configSchemaHandler.defineTopLevelProperty('yourPlugin', newCustomPropSchema); - } -} -``` - -This way, if user sets `someProperty` by mistake to `false`, the Framework would display an error: - -``` -Serverless: Configuration error: yourPlugin.someProperty should be string -``` - -#### `defineCustomProperties` helper - -Let's say your plugin depends on some properties defined in `custom` section of `serverless.yml` file. - -```yml -// serverless.yml - -custom: - yourPlugin: - someProperty: foobar -``` - -To add validation rules to these properties, your plugin would look like this: - -```javascript -class NewEventPlugin { - constructor(serverless) { - this.serverless = serverless; - - // Create schema for your properties. For reference use https://github.com/ajv-validator/ajv - const newCustomPropSchema = { - type: 'object', - properties: { - someProperty: { type: 'string' }, - }, - required: ['someProperty'], - }; - - // Attach your piece of schema to main schema - serverless.configSchemaHandler.defineCustomProperties(newCustomPropSchema); - } -} -``` - -This way, if user sets `someProperty` by mistake to `false`, the Framework would display an error: - -``` -Serverless: Configuration error: custom.yourPlugin.someProperty should be string -``` - -#### `defineFunctionEvent` helper - -Let's say your plugin adds support to a new `yourPluginEvent` function event. To use this event, a user would need to have `serverless.yml` file like this: - -```yml -// serverless.yml - -functions: - someFunc: - handler: handler.main - events: - - yourPluginEvent: - someProp: hello - anotherProp: 1 -``` - -In this case your plugin should add validation rules inside your plugin constructor. Otherwise, the Framework would display an error message saying that your event is not supported: - -``` -Serverless: Configuration error: Unsupported function event 'yourPluginEvent' -``` - -To fix this error and more importantly to provide validation rules for your event, modify your plugin constructor with code like this: - -```javascript -class NewEventPlugin { - constructor(serverless) { - this.serverless = serverless; - - // Create schema for your properties. For reference use https://github.com/ajv-validator/ajv - serverless.configSchemaHandler.defineFunctionEvent('providerName', 'yourPluginEvent', { - type: 'object', - properties: { - someProp: { type: 'string' }, - anotherProp: { type: 'number' }, - }, - required: ['someProp'], - additionalProperties: false, - }); - } -} -``` - -This way, if user sets `anotherProp` by mistake to `some-string`, the Framework would display an error: - -``` -Serverless: Configuration error: functions.someFunc.events[0].yourPluginEvent.anotherProp should be number -``` - -#### `defineFunctionEventProperties` helper - -When your plugin extend other plugin events definition for a specific provider, you can use the `defineFunctionEventProperties` to extend event definition with your custom properties. - -For example, if your plugin adds support to a new `documentation` property on `http` event from `aws` provider, you should add validations rules inside your plugin constructor for this new property. - -```javascript -class NewEventPlugin { - constructor(serverless) { - this.serverless = serverless; - - // Create schema for your properties. For reference use https://github.com/ajv-validator/ajv - serverless.configSchemaHandler.defineFunctionEventProperties('aws', 'http', { - properties: { - documentation: { type: 'object' }, - }, - required: ['documentation'], - }); - } -} -``` - -This way, if user sets `documentation` by mistake to `anyString`, the Framework would display an error: - -``` -Serverless: Configuration error: functions.someFunc.events[0].http.documentation should be object -``` - -#### `defineFunctionProperties` helper - -Let's say your plugin adds support to a new `someProperty` function property. To use this property, a user would need to have `serverless.yml` file like this: - -```yml -// serverless.yml - -functions: - someFunc: - handler: handler.main - someProperty: my-property-value -``` - -In this case your plugin should add validation rules inside your plugin constructor. Otherwise, the Framework would display an error message saying that your property is not supported: - -``` -ServerlessError: Configuration error: -at 'functions.someFunc': unrecognized property 'someProperty' -``` - -To fix this error and more importantly to provide validation rules for your property, modify your plugin constructor with code like this: - -```javascript -class NewFunctionPropertiesPlugin { - constructor(serverless) { - this.serverless = serverless; - - // Create schema for your properties. For reference use https://github.com/ajv-validator/ajv - serverless.configSchemaHandler.defineFunctionProperties('providerName', { - properties: { - someProperty: { type: 'string' }, - anotherProperty: { type: 'number' }, - }, - required: ['someProperty'], - }); - } -} -``` - -This way, if user sets `anotherProperty` by mistake to `hello`, the Framework would display an error: - -``` -ServerlessError: Configuration error at 'functions.someFunc.anotherProperty': should be number -``` - -#### `defineProvider` helper - -In case your plugin provides support for new provider, you would want to adjust validation schema. Here is example: - -```javascript -class NewProviderPlugin { - constructor(serverless) { - this.serverless = serverless; - - // Create schema for your provider. For reference use https://github.com/ajv-validator/ajv - serverless.configSchemaHandler.defineProvider('newProvider', { - // Eventual reusable schema definitions (will be put to top level "definitions" object) - definitions: { - // ... - }, - - // Top level "provider" properties - provider: { - properties: { - stage: { type: 'string' }, - remoteFunctionData: { type: 'null' }, - }, - }, - - // Function level properties - function: { - properties: { handler: { type: 'string' } }, - }, - - // Function events definitions (can be defined here or via `defineFunctionEvent` helper) - functionEvents: { - someEvent: { - name: 'someEvent', - schema: { - type: 'object', - properties: { - someRequiredStringProp: { type: 'string' }, - someNumberProp: { type: 'number' }, - }, - required: ['someRequiredStringProp'], - additionalProperties: false, - }, - }, - }, - - // Definition for eventual top level "resources" section - resources: { - type: 'object', - properties: { - // ... - }, - }, - - // Definition for eventual top level "layers" section - layers: { - type: 'object', - additionalProperties: { - type: 'object', - properties: { - // ... - }, - }, - }, - }); - } -} -``` - -### Extending the `info` command - -The `info` command which is used to display information about the deployment has detailed `lifecycleEvents` you can hook into to add and display custom information. - -Here's an example overview of the info lifecycle events the AWS implementation exposes: - -``` --> info:info - -> aws:info:validate - -> aws:info:gatherData - -> aws:info:displayServiceInfo - -> aws:info:displayApiKeys - -> aws:info:displayEndpoints - -> aws:info:displayFunctions - -> aws:info:displayStackOutputs -``` - -Here you could e.g. hook into `after:aws:info:gatherData` and implement your own data collection and display it to the user. - -**Note:** Every provider implements its own `info` plugin so you might want to take a look into the `lifecycleEvents` the provider `info` plugin exposes. diff --git a/docs/providers/aws/guide/quick-start.md b/docs/providers/aws/guide/quick-start.md deleted file mode 100644 index eabf18166d1..00000000000 --- a/docs/providers/aws/guide/quick-start.md +++ /dev/null @@ -1,180 +0,0 @@ - - -# Quick Start - -Complete the steps in this guide to install the Serverless Framework open-source CLI and deploy a sample Service on AWS that reports deployment information and operational metrics to the Serverless Framework Dashboard. - -## Initial Setup - -There are a few prerequisites you need to install and configure: - -- [Install Node.js 6.x or later on your local machine](#install-nodejs-and-npm) -- [Install the Serverless Framework open-source CLI version 1.47.0 or later](#install-the-serverless-framework-open-source-cli) - -If you already have these prerequisites setup you can skip ahead to deploy an example Service. - -### Install Node.js and NPM - -- Follow these [installation instructions](https://nodejs.org/en/download/). -- At the end, you should be able to run `node -v` from your command line and get a result like this... - -```sh -$ node -v -vx.x.x -``` - -- You should also be able to run `npm -v` from your command line and should see... - -```sh -$ npm -v -x.x.x -``` - -### Install the Serverless Framework open-source CLI - -- Run this command in your terminal - -```sh -npm install -g serverless -``` - -- After install is complete, you should be able to run `serverless -v` from your command line and get a result like this... - -```sh -$ serverless -v -x.x.x -``` - -## Create and deploy a serverless Service - -Now that you’ve completed your setup, let’s create and deploy a serverless Service. - -### Create a new Service from a Template - -Use the Serverless Framework open-source CLI to create a new Service. - -```sh -# Create a new Serverless service/project -$ serverless - -# Change into the newly created directory -$ cd your-service-name -``` - -The `serverless` command will guide you through creating a new Node or Python Service, [configuring your AWS Account](https://serverless.com/framework/docs/providers/aws/guide/credentials/) to work with the Serverless Framework, and setting up a free Serverless Framework Dashboard account so you can monitor, troubleshoot, and test your new service. - -Looking to get started with something other than Node or Python? No problem. You can use the [`create`](https://serverless.com/framework/docs/providers/aws/cli-reference/create/) command to get started with a variety of other languages. - -### Set up an endpoint - -An Event is anything that can trigger your serverless functions. In this case, you need to define an endpoint in your `serverless.yml` that will trigger your serverless function. - -```yaml -functions: - hello: - handler: handler.hello - # Add the following lines: - events: - - http: - path: hello - method: post -``` - -### Deploy the Service - -Use this command to deploy your service for the first time and after you make changes to your Functions, Events or Resources in `serverless.yml` and want to deploy all changes within your Service at the same time. - -```bash -serverless deploy -v -``` - -### Test your Service - -Replace the URL in the following curl command with your returned endpoint URL, which you can find in the `sls deploy` output, to hit your URL endpoint. - -```bash -$ curl -X POST https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/hello -``` - -### Invoke your Service's function - -Invokes a Function and returns logs. - -```bash -serverless invoke -f hello -l -``` - -### Fetch the Function Logs - -Open up a separate tab in your console and stream all logs for a specific Function using this command. - -```bash -serverless logs -f hello -t -``` - -### Monitor your Service - -Use either of the two commands below to generate mock errors that you will then be able to visualize in the Serverless Framework Dashboard. If you use the curl command remember to replace the URL in the command with your returned endpoint URL, which you can find in your `sls deploy` output. - -```bash -serverless invoke -f hello -d '{"body": "not a json string"}' # causes a JSON parsing error so error Insights will populate -``` - -```bash -$ curl https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/hello --data-binary 'not a json string' # causes a JSON parsing error so error Insights will populate -``` - -## Cleanup - -### Remove your Service - -If at any point you no longer need your Service, you can run the following command to remove the Functions, Events and Resources that were created. This will delete the AWS resources you created and ensure that you don't incur any unexpected charges. It will also remove the Service from your Serverless Framework Dashboard. - -```sh -serverless remove -``` - -## Deploy more Services! - -Now you are ready to leverage the hundreds of Service Examples available to you from Serverless, Inc. and our large and growing community to build your own Services. - -### Create a new Service from an Example - -The `serverless` introduction above guided you through creating a new service for a simple Node.js project. However, if you want to create a project for a more advanced use case and you don’t want to start from scratch, check out the list of available examples. - -Clone a Service from the Serverless Inc. repository of [Examples](https://serverless.com/examples/) - -```sh -# replace folder-name below with the folder name of the example you want to use -$ serverless create -u https://github.com/serverless/examples/tree/master/folder-name -n my-project -``` - -Or, clone a Service example from the Serverless open-source community - -```sh -$ serverless create -u https://github.com/author/project -n my-project -``` - -### Remember to configure your new Service to work with the Serverless Framework account for monitoring, troubleshooting and testing features. - -Run the `serverless` command in your new project to connect it to your Serverless Framework Dashboard account to enable the monitoring, troubleshooting and testing features. - -```sh -$ serverless -``` - -Deploy your service - -```sh -$ sls deploy -``` - -## Additional Tutorials - -Want to learn more? Check out a list of available tutorials [here](https://serverless.com/courses/). diff --git a/docs/providers/aws/guide/resources.md b/docs/providers/aws/guide/resources.md index 1b7de0741f4..9f2750ffc4f 100644 --- a/docs/providers/aws/guide/resources.md +++ b/docs/providers/aws/guide/resources.md @@ -115,10 +115,7 @@ functions: write-post: handler: handler.writePost events: - - http: - method: post - path: ${self:service}/api/posts/new - cors: true + - httpApi: 'POST /api/posts/new' resources: extensions: diff --git a/docs/providers/aws/guide/serverless.yml.md b/docs/providers/aws/guide/serverless.yml.md index b7eb727ca72..fce4c91ae10 100644 --- a/docs/providers/aws/guide/serverless.yml.md +++ b/docs/providers/aws/guide/serverless.yml.md @@ -16,109 +16,268 @@ layout: Doc Here is a list of all available properties in `serverless.yml` when the provider is set to `aws`. +## Root properties + ```yml # serverless.yml -service: myService +# Service name +service: myservice -frameworkVersion: '2' -configValidationMode: warn # Modes for config validation. `error` throws an exception, `warn` logs error to console, `off` disables validation at all. The default is warn. -enableLocalInstallationFallback: false # If set to 'true', guarantees that it's a locally (for service, in its node_modules) installed framework which processes the command -useDotenv: false # If set to 'true', environment variables will be automatically loaded from .env files -variablesResolutionMode: null # To crash on variable resolution errors (as coming from new resolver), set this value to "20210326" -unresolvedVariablesNotificationMode: warn # If set to 'error', references to variables that cannot be resolved will result in an error being thrown (applies to legacy resolver) +# Framework version constraint (semver constraint): '3', '^2.33' +frameworkVersion: '3' -disabledDeprecations: # Disable deprecation logs by their codes. Default is empty. +# Configuration validation: 'error' (fatal error), 'warn' (logged to the output) or 'off' (default: warn) +# See https://www.serverless.com/framework/docs/configuration-validation +configValidationMode: error +# Load environment variables from .env files (default: false) +# See https://www.serverless.com/framework/docs/environment-variables +useDotenv: true +# 'warn' reports deprecations on the go, 'error' will result with an exception being thrown on first approached deprecation +deprecationNotificationMode: warn:summary +# Disable deprecations by their codes (default: empty) +# See https://www.serverless.com/framework/docs/deprecations +disabledDeprecations: - DEP_CODE_1 # Deprecation code to disable - '*' # Disable all deprecation messages +``` + +### Parameters + +Learn more about stage parameters in the [Parameters documentation](../../../guides/parameters.md). + +```yml +# serverless.yml + +# Stage parameters +params: + # Values for the "prod" stage + prod: + my-parameter: foo + # Values for the "dev" stage + dev: + my-parameter: bar +``` + +## Provider + +### General settings + +```yml +# serverless.yml provider: name: aws + # Default stage (default: dev) + stage: dev + # Default region (default: us-east-1) + region: us-east-1 + # The AWS profile to use to deploy (default: "default" profile) + profile: production + # Use a custom name for the CloudFormation stack + stackName: custom-stack-name + # Optional CloudFormation tags to apply to APIs and functions + tags: + foo: bar + baz: qux + # Optional CloudFormation tags to apply to the stack + stackTags: + key: value + # List of existing Amazon SNS topics in the same region where notifications about stack events are sent. + notificationArns: + - 'arn:aws:sns:us-east-1:XXXXXX:mytopic' + stackParameters: + - ParameterKey: 'Keyname' + ParameterValue: 'Value' + # Disable automatic rollback by CloudFormation on failure. To be used for non-production environments. + disableRollback: true + rollbackConfiguration: + MonitoringTimeInMinutes: 20 + RollbackTriggers: + - Arn: arn:aws:cloudwatch:us-east-1:000000000000:alarm:health + Type: AWS::CloudWatch::Alarm + - Arn: arn:aws:cloudwatch:us-east-1:000000000000:alarm:latency + Type: AWS::CloudWatch::Alarm + tracing: + # Can only be true if API Gateway is inside a stack. + apiGateway: true + # Optional, can be true (true equals 'Active'), 'Active' or 'PassThrough' + lambda: true +``` + +### General function settings + +Some function settings can be defined for all functions inside the `provider` key: + +```yml +# serverless.yml + +provider: runtime: nodejs14.x - stage: dev # Default stage to be used. Default is "dev" - region: us-east-1 # Default region to be used. Default is "us-east-1" - stackName: custom-stack-name # Use a custom name for the CloudFormation stack - apiName: custom-api-name # Use a custom name for the API Gateway API - websocketsApiName: custom-websockets-api-name # Use a custom name for the websockets API - websocketsApiRouteSelectionExpression: $request.body.route # custom route selection expression - profile: production # The default profile to use with this service - memorySize: 512 # Overwrite the default memory size. Default is 1024 - timeout: 10 # The default is 6 seconds. Note: API Gateway current maximum is 30 seconds - logRetentionInDays: 14 # Set the default RetentionInDays for a CloudWatch LogGroup - kmsKeyArn: arn:aws:kms:us-east-1:XXXXXX:key/some-hash # KMS key arn which will be used for encryption for all functions + # Default memory size for functions (default: 1024MB) + memorySize: 512 + # Default timeout for functions (default: 6 seconds) + # Note: API Gateway has a maximum timeout of 30 seconds + timeout: 10 + # Function environment variables + environment: + APP_ENV_VARIABLE: FOOBAR + # Duration for CloudWatch log retention (default: forever) + logRetentionInDays: 14 + # KMS key ARN to use for encryption for all functions + kmsKeyArn: arn:aws:kms:us-east-1:XXXXXX:key/some-hash + # Version of hashing algorithm used by Serverless Framework for function packaging + lambdaHashingVersion: 20201221 + # Use function versioning (enabled by default) + versionFunctions: false + # Processor architecture: 'x86_64' or 'arm64' via Graviton2 (default: x86_64) + architecture: x86_64 +``` + +### Deployment bucket + +Serverless Framework needs a S3 bucket to store artifacts for deploying. That bucket is automatically created and managed by Serverless, but you can configure it explicitly if needed: + +```yaml +provider: + # The S3 prefix under which deployed artifacts are stored (default: serverless) + deploymentPrefix: serverless + # Configure the S3 bucket used by Serverless Framework to deploy code packages to Lambda deploymentBucket: - blockPublicAccess: true # Prevents public access via ACLs or bucket policies. Default is false - skipPolicySetup: false # Prevents creation of default bucket policy when framework creates the deployment bucket. Default is false - name: com.serverless.${self:provider.region}.deploys # Deployment bucket name. Default is generated by the framework - maxPreviousDeploymentArtifacts: 10 # On every deployment the framework prunes the bucket to remove artifacts older than this limit. The default is 5 - serverSideEncryption: AES256 # server-side encryption method - sseKMSKeyId: arn:aws:kms:us-east-1:xxxxxxxxxxxx:key/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa # when using server-side encryption - sseCustomerAlgorithim: AES256 # when using server-side encryption and custom keys - sseCustomerKey: string # when using server-side encryption and custom keys - sseCustomerKeyMD5: md5sum # when using server-side encryption and custom keys - tags: # Tags that will be added to each of the deployment resources + # Name of an existing bucket to use (default: created by serverless) + name: com.serverless.${self:provider.region}.deploys + # On deployment, serverless prunes artifacts older than this limit (default: 5) + maxPreviousDeploymentArtifacts: 10 + # Prevents public access via ACLs or bucket policies (default: false) + # Note: the deployment bucket is not public by default. These are additional ACLs. + blockPublicAccess: true + # Skip the creation of a default bucket policy when the deployment bucket is created (default: false) + skipPolicySetup: true + # Enable bucket versioning (default: false) + versioning: true + # Server-side encryption method + serverSideEncryption: AES256 + # For server-side encryption + sseKMSKeyId: arn:aws:kms:us-east-1:xxxxxxxxxxxx:key/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa + # For server-side encryption with custom keys + sseCustomerAlgorithim: AES256 + sseCustomerKey: string + sseCustomerKeyMD5: md5sum + # Tags that will be added to each of the deployment resources + tags: key1: value1 key2: value2 - deploymentPrefix: serverless # The S3 prefix under which deployed artifacts should be stored. Default is serverless - lambdaHashingVersion: 20201221 # optional, version of hashing algorithm that should be used by the framework - ecr: - images: # Definitions of images that later can be referenced by key in `function.image` - baseimage: - uri: 000000000000.dkr.ecr.us-east-1.amazonaws.com/test-image@sha256:6bb600b4d6e1d7cf521097177d111111ea373edb91984a505333be8ac9455d38 # Image uri of existing Docker image in ECR - anotherimage: - path: ./image/ # Path to Docker context that will be used when building that image locally - file: Dockerfile.dev # Name of Dockerfile that should be used when building image locally. Equal to 'Dockerfile' by default - buildArgs: - STAGE: ${opt:stage} - cacheFrom: - - my-image:latest - cloudFront: - myCachePolicy1: # used as a reference in function.events[].cloudfront.cachePolicy.name - DefaultTTL: 60 - MinTTL: 30 - MaxTTL: 3600 - Comment: my brand new cloudfront cache policy # optional - ParametersInCacheKeyAndForwardedToOrigin: - CookiesConfig: - CookieBehavior: whitelist # Possible values are 'none', 'whitelist', 'allExcept' and 'all' - Cookies: - - my-public-cookie - EnableAcceptEncodingBrotli: true # optional - EnableAcceptEncodingGzip: true - HeadersConfig: - HeadersBehavior: whitelist # Possible values are 'none' and 'whitelist' - Headers: - - authorization - - content-type - QueryStringsConfig: - QueryStringBehavior: allExcept # Possible values are 'none', 'whitelist', 'allExcept' and 'all' - QueryStrings: - - not-cached-query-string - versionFunctions: false # Optional function versioning - environment: # Service wide environment variables - serviceEnvVar: 123456789 - endpointType: regional # Optional endpoint configuration for API Gateway REST API. Default is Edge. - apiGateway: # Optional API Gateway global config - restApiId: xxxxxxxxxx # REST API resource ID. Default is generated by the framework - restApiRootResourceId: xxxxxxxxxx # Root resource ID, represent as / path - restApiResources: # List of existing resources that were created in the REST API. This is required or the stack will be conflicted - '/users': xxxxxxxxxx - '/users/create': xxxxxxxxxx - websocketApiId: # Websocket API resource ID. Default is generated by the framework - apiKeySourceType: HEADER # Source of API key for usage plan. HEADER or AUTHORIZER. - apiKeys: # List of API keys to be used by your service API Gateway REST API +``` + +### API Gateway v2 HTTP API + +The `httpApi` settings apply to [API Gateway v2 HTTP APIs](../events/http-api.md): + +```yml +provider: + httpApi: + # Attach to an externally created HTTP API via its ID: + id: xxxx + # Set a custom name for the API Gateway API (default: ${sls:stage}-${self:service}) + name: dev-my-service + # Payload format version (note: use quotes in YAML: '1.0' or '2.0') (default: '2.0') + payload: '2.0' + # Disable the default 'execute-api' HTTP endpoint (default: false) + # Useful when using a custom domain. + disableDefaultEndpoint: true + # Enable detailed CloudWatch metrics (default: false) + metrics: true + # Enable CORS HTTP headers with default settings (allow all) + # Can be fine-tuned with specific options + cors: true + authorizers: + # JWT API authorizer + someJwtAuthorizer: + identitySource: $request.header.Authorization + issuerUrl: https://cognito-idp.us-east-1.amazonaws.com/us-east-1_xxxxx + audience: + - xxxx + - xxxx + # Custom Lambda request authorizer + someCustomLambdaAuthorizer: + # Should be set to 'request' for custom Lambda authorizers + type: request + # Mutually exclusive with `functionArn` + functionName: authorizerFunc + # Mutually exclusive with `functionName` + functionArn: arn:aws:lambda:us-east-1:11111111111:function:external-authorizer + # Optional. Custom name for created authorizer + name: customAuthorizerName + # Optional. Time to live for cached authorizer results, accepts values from 0 (no caching) to 3600 (1 hour) + # When set to non-zero value, 'identitySource' must be defined as well + resultTtlInSeconds: 300 + # Set if authorizer function will return authorization responses in simple format (default: false) + enableSimpleResponses: true + # Version of payload that will be sent to authorizer function (default: '2.0') + payloadVersion: '2.0' + # Optional. One or more mapping expressions of the request parameters in form of e.g `$request.header.Auth`. + # Specified values are verified to be non-empty and not null by authorizer. + # It is a required property when `resultTtlInSeconds` is non-zero as `identitySource` is additionally + # used as cache key for authorizer responses caching. + identitySource: + - $request.header.Auth + - $request.header.Authorization + # Optional. Applicable only when using externally defined authorizer functions + # to prevent creation of permission resource + managedExternally: true +``` + +### API Gateway v1 REST API + +The `apiGateway` settings apply to [API Gateway v1 REST APIs](../events/apigateway.md) and [websocket APIs](../events/websocket.md): + +```yml +provider: + # Use a custom name for the API Gateway API + apiName: custom-api-name + # Endpoint type for API Gateway REST API: edge or regional (default: edge) + endpointType: regional + # Use a custom name for the websockets API + websocketsApiName: custom-websockets-api-name + # custom route selection expression + websocketsApiRouteSelectionExpression: $request.body.route + # Optional API Gateway REST API global config + apiGateway: + # Attach to an externally created REST API via its ID: + restApiId: xxxx + # Root resource ID, represent as / path + restApiRootResourceId: xxxx + # List of existing resources that were created in the REST API. This is required or the stack will be conflicted + restApiResources: + '/users': xxxx + '/users/create': xxxx + # Attach to an externally created Websocket API via its ID: + websocketApiId: xxxx + # Disable the default 'execute-api' HTTP endpoint (default: false) + disableDefaultEndpoint: true + # Source of API key for usage plan: HEADER or AUTHORIZER + apiKeySourceType: HEADER + # List of API keys for the REST API + apiKeys: - myFirstKey value: myFirstKeyValue description: myFirstKeyDescription customerId: myFirstKeyCustomerId - - ${opt:stage}-myFirstKey + # Can be used to disable the API key without removing it (default: true) + enabled: false + - ${sls:stage}-myFirstKey - ${env:MY_API_KEY} # you can hide it in a serverless variable - minimumCompressionSize: 1024 # Compress response when larger than specified size in bytes (must be between 0 and 10485760) - description: Some Description # Optional description for the API Gateway stage deployment - binaryMediaTypes: # Optional binary media types the API might return + # Compress response when larger than specified size in bytes (must be between 0 and 10485760) + minimumCompressionSize: 1024 + # Description for the API Gateway stage deployment + description: Some description + # Optional binary media types the API might return + binaryMediaTypes: - '*/*' - metrics: false # Optional detailed Cloud Watch Metrics - shouldStartNameWithService: false # Use `${service}-${stage}` naming for API Gateway. Will be `true` by default in next major version. + # Optional detailed Cloud Watch Metrics + metrics: false + # Use `${service}-${stage}` naming for API Gateway. Will be `true` by default in v3. + shouldStartNameWithService: false resourcePolicy: - Effect: Allow Principal: '*' @@ -129,7 +288,8 @@ provider: IpAddress: aws:SourceIp: - '123.123.123.123' - usagePlan: # Optional usage plan configuration + # Optional usage plan configuration + usagePlan: quota: limit: 5000 offset: 2 @@ -138,81 +298,154 @@ provider: burstLimit: 200 rateLimit: 100 request: - schemas: # Optional request schema validation models that can be reused in `http` events. It is always defined for `application/json` content type + # Request schema validation models that can be reused in `http` events + # It is always defined for `application/json` content type + schemas: global-model: - name: GlobalModel # Optional: Name of the API Gateway model - description: "A global model that can be referenced in functions" # Optional: Description of the API Gateway model - schema: ${file(schema.json)} # Valid JSON Schema + # JSON Schema + schema: ${file(schema.json)} + # Optional: Name of the API Gateway model + name: GlobalModel + # Optional: Description of the API Gateway model + description: "A global model that can be referenced in functions" +``` + +### ALB + +Configure [Application Load Balancer](../events/alb.md): + +```yml +provider: alb: - targetGroupPrefix: xxxxxxxxxx # Optional prefix to prepend when generating names for target groups + # Optional prefix to prepend when generating names for target groups + targetGroupPrefix: xxxx authorizers: myFirstAuth: type: 'cognito' - userPoolArn: 'arn:aws:cognito-idp:us-east-1:123412341234:userpool/us-east-1_123412341', # required - userPoolClientId: '1h57kf5cpq17m0eml12EXAMPLE', # required - userPoolDomain: 'your-test-domain' # required - onUnauthenticatedRequest: 'deny' # If set to 'allow' this allows the request to be forwarded to the target when user is not authenticated. When omitted it defaults 'deny' which makes a HTTP 401 Unauthorized error be returned. Alternatively configure to 'authenticate' to redirect request to IdP authorization endpoint. - requestExtraParams: # optional. The query parameters (up to 10) to include in the redirect request to the authorization endpoint - prompt: 'login' + # Required + userPoolArn: 'arn:aws:cognito-idp:us-east-1:123412341234:userpool/us-east-1_123412341' + # Required + userPoolClientId: '1h57kf5cpq17m0eml12EXAMPLE' + # Required + userPoolDomain: your-test-domain + # If set to 'allow' this allows the request to be forwarded to the target when user is not authenticated. + # When omitted it defaults 'deny' which makes a HTTP 401 Unauthorized error be returned. + # Alternatively configure to 'authenticate' to redirect request to IdP authorization endpoint. + onUnauthenticatedRequest: deny + # optional. The query parameters (up to 10) to include in the redirect request to the authorization endpoint + requestExtraParams: + prompt: login redirect: false - scope: 'first_name age' # Can be a combination of any system-reserved scopes or custom scopes associated with the client. The default is openid - sessionCookieName: '🍪' # The name of the cookie used to maintain session information. The default is AWSELBAuthSessionCookie - sessionTimeout: 7000 # The maximum duration of the authentication session, in seconds. The default is 604800 seconds (7 days). + # Combination of any system-reserved scopes or custom scopes associated with the client (default: openid) + scope: 'first_name age' + # Name of the cookie used to maintain session information (default: AWSELBAuthSessionCookie) + sessionCookieName: '🍪' + # Maximum duration of the authentication session in seconds (default: 604800 seconds/7 days) + sessionTimeout: 7000 mySecondAuth: - type: 'oidc' - authorizationEndpoint: 'https://example.com', # required. The authorization endpoint of the IdP. Must be a full URL, including the HTTPS protocol, the domain, and the path - clientId: 'i-am-client', # required - clientSecret: 'i-am-secret', # if creating a rule this is required. If modifying a rule, this can be omitted if you set useExistingClientSecret to true (as below) - useExistingClientSecret: true # only required if clientSecret is omitted - issuer: 'https://www.iamscam.com', # required. The OIDC issuer identifier of the IdP. This must be a full URL, including the HTTPS protocol, the domain, and the path - tokenEndpoint: 'http://somewhere.org', # required - userInfoEndpoint: 'https://another-example.com' # required - onUnauthenticatedRequest: 'deny' # If set to 'allow' this allows the request to be forwarded to the target when user is not authenticated. Omit or set to 'deny' (default) to make a HTTP 401 Unauthorized error be returned instead. Alternatively configure to 'authenticate' to redirect request to IdP authorization endpoint. + type: oidc + # Required. The authorization endpoint of the IdP. + # Must be a full URL, including the HTTPS protocol, the domain, and the path + authorizationEndpoint: 'https://example.com' + # Required + clientId: i-am-client + # If creating a rule this is required + # If modifying a rule, this can be omitted if you set useExistingClientSecret to true (as below) + clientSecret: i-am-secret + # Only required if clientSecret is omitted + useExistingClientSecret: true + # Required. The OIDC issuer identifier of the IdP + # This must be a full URL, including the HTTPS protocol, the domain, and the path + issuer: 'https://www.iamscam.com' + # Required + tokenEndpoint: 'http://somewhere.org' + # Required + userInfoEndpoint: 'https://another-example.com' + # If set to 'allow' this allows the request to be forwarded to the target when user is not authenticated. + # Omit or set to 'deny' (default) to make a HTTP 401 Unauthorized error be returned instead. + # Alternatively configure to 'authenticate' to redirect request to IdP authorization endpoint. + onUnauthenticatedRequest: 'deny' requestExtraParams: - prompt: 'login' + prompt: login redirect: false - scope: 'first_name age' + scope: first_name age sessionCookieName: '🍪' sessionTimeout: 7000 - httpApi: - id: 'my-id' # If we want to attach to externally created HTTP API its id should be provided here - name: 'dev-my-service' # Use custom name for the API Gateway API, default is ${sls:stage}-${self:service} - payload: '2.0' # Specify payload format version for Lambda integration ('1.0' or '2.0'), default is '2.0' - cors: true # Implies default behavior, can be fine tuned with specific options - authorizers: - # JWT authorizer to back HTTP API endpoints - someJwtAuthorizer: - identitySource: $request.header.Authorization - issuerUrl: https://cognito-idp.us-east-1.amazonaws.com/us-east-1_xxxxx - audience: - - xxxx - - xxxx - # Custom Lambda request authorizer to back HTTP API endpoints - someCustomLambdaAuthorizer: - type: request # Should be set to `request` for custom Lambda authorizers. - functionName: authorizerFunc # Mutually exclusive with `functionArn` - functionArn: arn:aws:lambda:us-east-1:11111111111:function:external-authorizer # Mutually exclusive with `functionName` - name: customAuthorizerName # Optional. Custom name for created authorizer - resultTtlInSeconds: 300 # Optional. Time to live for cached authorizer results, accepts values from 0 (no caching) to 3600 (1 hour). When set to non-zero value, `identitySource` must be defined as well. - enableSimpleResponses: true # Optional. Flag that specifies if authorizer function will return authorization responses in simple format. Defaults to `false`. - payloadVersion: '2.0' # Optional. Version of payload that will be sent to authorizer function. Defaults to `'2.0'`. - identitySource: # Optional. One or more mapping expressions of the request parameters in form of e.g `$request.header.Auth`. Specified values are verified to be non-empty and not null by authorizer. It is a required property when `resultTtlInSeconds` is non-zero as `identitySource` is additionally used as cache key for authorizer responses caching. - - $request.header.Auth - - $request.header.Authorization - managedExternally: true # Optional. Applicable only when using externally defined authorizer functions to prevent creation of permission resource - stackTags: # Optional CF stack tags - key: value +``` + +### Docker image deployments in ECR + +Configure [deployment via Docker images](./functions.md#referencing-container-image-as-a-target): + +```yaml +provider: + ecr: + scanOnPush: true + # Definitions of images that later can be referenced by key in `function.image` + images: + baseimage: + # URI of an existing Docker image in ECR + uri: 000000000000.dkr.ecr.us-east-1.amazonaws.com/test-image@sha256:6bb600b4d6e1d7cf521097177d111111ea373edb91984a505333be8ac9455d38 + anotherimage: + # Path to the Docker context that will be used when building that image locally (default: '.') + path: ./image/ + # Dockerfile that will be used when building the image locally (default: 'Dockerfile') + file: Dockerfile.dev + buildArgs: + STAGE: ${sls:stage} + cacheFrom: + - my-image:latest +``` + +### CloudFront + +Configure the CloudFront distribution used for [CloudFront Lambda@Edge events](../events/cloudfront.md): + +```yml +provider: + cloudFront: + cachePolicies: + # Used as a reference in function.events[].cloudfront.cachePolicy.name + myCachePolicy1: + DefaultTTL: 60 + MinTTL: 30 + MaxTTL: 3600 + Comment: my brand new cloudfront cache policy # optional + ParametersInCacheKeyAndForwardedToOrigin: + CookiesConfig: + # Possible values are 'none', 'whitelist', 'allExcept' and 'all' + CookieBehavior: whitelist + Cookies: + - my-public-cookie + EnableAcceptEncodingBrotli: true # optional + EnableAcceptEncodingGzip: true + HeadersConfig: + # Possible values are 'none' and 'whitelist' + HeaderBehavior: whitelist + Headers: + - authorization + - content-type + QueryStringsConfig: + # Possible values are 'none', 'whitelist', 'allExcept' and 'all' + QueryStringBehavior: allExcept + QueryStrings: + - not-cached-query-string +``` + +### IAM permissions + +Configure IAM roles and permissions applied to Lambda functions ([complete documentation](./iam.md)): + +```yml +provider: iam: - # Overwrite the default IAM role which is used for all functions + # Instruct Serverless to use an existing IAM role for all Lambda functions role: arn:aws:iam::XXXXXX:role/role - # .. OR configure logical role + # OR configure the role that will be created by Serverless (simplest): role: - name: your-custom-name-role # Optional custom name for default IAM role - managedPolicies: # Optional IAM Managed Policies, which allows to include the policies into IAM Role - - arn:aws:iam:*****:policy/some-managed-policy - permissionsBoundary: arn:aws:iam::XXXXXX:policy/policy # ARN of an Permissions Boundary for the role. - statements: # IAM role statements so that services can be accessed in the AWS account - - Effect: 'Allow' + # Add statements to the IAM role to give permissions to Lambda functions + statements: + - Effect: Allow Action: - 's3:ListBucket' Resource: @@ -220,10 +453,23 @@ provider: - '' - - 'arn:aws:s3:::' - Ref: ServerlessDeploymentBucket + # Optional custom name for default IAM role + name: your-custom-name-role + # Optional custom path for default IAM role + path: /your-custom-path/ + # Optional IAM Managed Policies to include into the IAM Role + managedPolicies: + - arn:aws:iam:*****:policy/some-managed-policy + # ARN of a Permissions Boundary for the role + permissionsBoundary: arn:aws:iam::XXXXXX:policy/policy + # CloudFormation tags tags: key: value - deploymentRole: arn:aws:iam::XXXXXX:role/role # ARN of an IAM role for CloudFormation service. If specified, CloudFormation uses the role's credentials - stackPolicy: # Optional CF stack policy. The example below allows updates to all resources except deleting/replacing EC2 instances (use with caution!) + # ARN of an IAM role for CloudFormation service. If specified, CloudFormation uses the role's credentials + deploymentRole: arn:aws:iam::XXXXXX:role/role + # Optional CF stack policy to restrict which resources can be updated/deleted on deployment + # The example below allows updating all resources in the service except deleting/replacing EC2 instances (use with caution!) + stackPolicy: - Effect: Allow Principal: '*' Action: 'Update:*' @@ -238,167 +484,342 @@ provider: StringEquals: ResourceType: - AWS::EC2::Instance - vpc: # Optional VPC. But if you use VPC then both subproperties (securityGroupIds and subnetIds) are required +``` + +### VPC + +Configure the Lambda functions to run inside a VPC ([complete documentation](./functions.md#vpc-configuration)): + +```yml +provider: + # Optional VPC settings + # If you use VPC then both securityGroupIds and subnetIds are required + vpc: securityGroupIds: - securityGroupId1 - securityGroupId2 subnetIds: - subnetId1 - subnetId2 - notificationArns: # List of existing Amazon SNS topics in the same region where notifications about stack events are sent. - - 'arn:aws:sns:us-east-1:XXXXXX:mytopic' - stackParameters: - - ParameterKey: 'Keyname' - ParameterValue: 'Value' - rollbackConfiguration: - MonitoringTimeInMinutes: 20 - RollbackTriggers: - - Arn: arn:aws:cloudwatch:us-east-1:000000000000:alarm:health - Type: AWS::CloudWatch::Alarm - - Arn: arn:aws:cloudwatch:us-east-1:000000000000:alarm:latency - Type: AWS::CloudWatch::Alarm - tags: # Optional service wide function tags - foo: bar - baz: qux - tracing: - apiGateway: true # Can only be true if API Gateway is inside a stack. - lambda: true # Optional, can be true (true equals 'Active'), 'Active' or 'PassThrough' +``` + +### Logs + +Configure logs for the deployed resources: + +```yml +provider: logs: - restApi: # Optional configuration which specifies if API Gateway logs are used. This can either be set to `true` to use defaults, or configured via subproperties. Can only be configured if API Gateway is inside a stack. - accessLogging: true # Optional configuration which enables or disables access logging. Defaults to true. - format: 'requestId: $context.requestId' # Optional configuration which specifies the log format to use for access logging. - executionLogging: true # Optional configuration which enables or disables execution logging. Defaults to true. - level: INFO # Optional configuration which specifies the log level to use for execution logging. May be set to either INFO or ERROR. - fullExecutionData: true # Optional configuration which specifies whether or not to log full requests/responses for execution logging. Defaults to true. - role: arn:aws:iam::123456:role # Existing IAM role for ApiGateway to use when managing CloudWatch Logs. If 'role' is not configured, a new role is automatically created. - roleManagedExternally: false # Specifies whether the ApiGateway CloudWatch Logs role setting is not managed by Serverless. Defaults to false. - websocket: # Optional configuration which specifies if Websocket logs are used. This can either be set to `true` to use defaults, or configured via subproperties. - level: INFO # Optional configuration which specifies the log level to use for execution logging. May be set to either INFO or ERROR. - httpApi: # Optional configuration which specifies if HTTP API logs are used. This can either be set to `true` (to use defaults as below) or specific log format configuration can be provided + # Enable HTTP API logs + # This can either be set to `httpApi: true` to use defaults, or configured via subproperties + # Can only be configured if the API is created by Serverless Framework + httpApi: format: '{ "requestId":"$context.requestId", "ip": "$context.identity.sourceIp", "requestTime":"$context.requestTime", "httpMethod":"$context.httpMethod","routeKey":"$context.routeKey", "status":"$context.status","protocol":"$context.protocol", "responseLength":"$context.responseLength" }' - frameworkLambda: true # Optional, whether to write CloudWatch logs for custom resource lambdas as added by the framework + # Enable REST API logs + # This can either be set to `restApi: true` to use defaults, or configured via subproperties + # Can only be configured if the API is created by Serverless Framework + restApi: + # Enables HTTP access logs (default: true) + accessLogging: true + # Log format to use for access logs + format: 'requestId: $context.requestId' + # Enable execution logging (default: true) + executionLogging: true + # Log level to use for execution logging: INFO or ERROR + level: INFO + # Log full requests/responses for execution logging (default: true) + fullExecutionData: true + # Existing IAM role to use for API Gateway when writing CloudWatch Logs (default: automatically created) + role: arn:aws:iam::123456:role + # Whether the API Gateway CloudWatch Logs role setting is not managed by Serverless (default: false) + roleManagedExternally: false + + # Enable Websocket API logs + # This can either be set to `websocket: true` to use defaults, or configured via subproperties. + websocket: + # Log level to use for execution logging: INFO or ERROR. + level: INFO + + # Optional, whether to write CloudWatch logs for custom resource lambdas as added by the framework + frameworkLambda: true +``` + +### S3 buckets + +Configure the S3 buckets created for [S3 Lambda events](../events/s3.md): + +```yml +provider: + # If you need to configure the bucket itself, you'll need to add s3 resources to the provider configuration + s3: + # Eventual additional properties in camel case + bucketOne: + # Supported properties are the same ones as supported by CF resource for S3 bucket + # See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket.html + name: my-custom-bucket-name + versioningConfiguration: + Status: Enabled +``` + +## Package -package: # Optional deployment packaging configuration - patterns: # Specify the directories and files which should be included in the deployment package +The `serverless package` or `serverless deploy` commands [package the code of all functions into zip files](./packaging.md). +These zip files are then used for deployments. + +```yml +# serverless.yml + +# Optional deployment packaging configuration +package: + # Directories and files to include in the deployed package + patterns: - src/** - handler.js - '!.git/**' - '!.travis.yml' - excludeDevDependencies: false # Config if Serverless should automatically exclude dev dependencies in the deployment package. Defaults to true - artifact: path/to/my-artifact.zip # Own package that should be used. You must provide this file. - individually: true # Enables individual packaging for each function. If true you must provide package for each function. Defaults to false + # Package each function as an individual artifact (default: false) + individually: true + # Explicitly set the package artifact to deploy (overrides native packaging behavior) + artifact: path/to/my-artifact.zip + # Automatically exclude NPM dev dependencies from the deployed package (default: true) + excludeDevDependencies: false +``` + +## Functions + +Configure the Lambda functions to deploy ([complete documentation](./functions.md)): + +```yml +# serverless.yml functions: - usersCreate: # A Function - handler: users.create # The file and module for this specific function. Cannot be used when `image` is defined. - image: baseimage # Image to be used by function, cannot be used when `handler` is defined. It can be configured as concrete uri of Docker image in ECR or as a reference to image defined in `provider.ecr.images` - name: ${sls:stage}-lambdaName # optional, Deployed Lambda name - description: My function # The description of your function. - memorySize: 512 # memorySize for this specific function. - reservedConcurrency: 5 # optional, reserved concurrency limit for this function. By default, AWS uses account concurrency limit - provisionedConcurrency: 3 # optional, Count of provisioned lambda instances - runtime: nodejs12.x # Runtime for this specific function. Overrides the default which is set on the provider level - timeout: 10 # Timeout for this specific function. Overrides the default set above. - role: arn:aws:iam::XXXXXX:role/role # IAM role which will be used for this function - onError: arn:aws:sns:us-east-1:XXXXXX:sns-topic # Optional SNS topic / SQS arn (Ref, Fn::GetAtt and Fn::ImportValue are supported as well) which will be used for the DeadLetterConfig - kmsKeyArn: arn:aws:kms:us-east-1:XXXXXX:key/some-hash # Optional KMS key arn which will be used for encryption (overwrites the one defined on the provider level) - disableLogs: false # Disables creation of CloudWatch Log Group - environment: # Function level environment variables - functionEnvVar: 12345678 + # A function + hello: + # The file and module for this specific function. Cannot be used with 'image'. + handler: users.create + # Container image to use. Cannot be used with 'handler'. + # Can be the URI of an image in ECR, or the name of an image defined in 'provider.ecr.images' + image: baseimage + runtime: nodejs14.x + # Memory size (default: 1024MB) + memorySize: 512 + # Timeout (default: 6 seconds) + # Note: API Gateway has a maximum timeout of 30 seconds + timeout: 10 + # Function environment variables + environment: + APP_ENV_VARIABLE: FOOBAR + # Override the Lambda function name + name: ${sls:stage}-lambdaName + description: My function + # Processor architecture: 'x86_64' or 'arm64' via Graviton2 (default: x86_64) + architecture: x86_64 + # Reserve a maximum number of concurrent instances (default: account limit) + reservedConcurrency: 5 + # Provision a minimum number of concurrent instances (default: 0) + provisionedConcurrency: 3 + # Override the IAM role to use for this function + role: arn:aws:iam::XXXXXX:role/role + # SNS topic or SQS ARN to use for the DeadLetterConfig (failed executions) + onError: arn:aws:sns:us-east-1:XXXXXX:sns-topic + # KMS key ARN to use for encryption for this function + kmsKeyArn: arn:aws:kms:us-east-1:XXXXXX:key/some-hash + # Disable the creation of the CloudWatch log group + disableLogs: false tags: # Function specific tags foo: bar - vpc: # Optional VPC. But if you use VPC then both subproperties (securityGroupIds and subnetIds) are required + # VPC settings for this function + # If you use VPC then both subproperties (securityGroupIds and subnetIds) are required + # Can be set to '~' to disable the use of a VPC + vpc: securityGroupIds: - securityGroupId1 - securityGroupId2 subnetIds: - subnetId1 - subnetId2 + # Packaging rules specific to this function package: - patterns: # Specify the directories and files which should be included in the deployment package for this specific function. + # Directories and files to include in the deployed package + patterns: - src/** - handler.js - '!.git/**' - '!.travis.yml' - artifact: path/to/my-artifact.zip # Own package that should be use for this specific function. You must provide this file. - individually: true # Enables individual packaging for specific function. If true you must provide package for each function. Defaults to false - layers: # An optional list Lambda Layers to use - - arn:aws:lambda:region:XXXXXX:layer:LayerName:Y # Layer Version ARN - tracing: Active # optional, can be 'Active' or 'PassThrough' (overwrites the one defined on the provider level) - condition: SomeCondition # optional, adds 'Condition' clause - dependsOn: # optional, appends these additional resources to the 'DependsOn' list + # Explicitly set the package artifact to deploy (overrides native packaging behavior) + artifact: path/to/my-artifact.zip + # Package this function as an individual artifact (default: false) + individually: true + # ARN of Lambda layers to use + layers: + - arn:aws:lambda:region:XXXXXX:layer:LayerName:Y + # Overrides the provider setting. Can be 'Active' or 'PassThrough' + tracing: Active + # Conditionally deploy the function + condition: SomeCondition + # CloudFormation 'DependsOn' option + dependsOn: - MyThing - MyOtherThing - destinations: # optional, destinations for async invocations - onSuccess: functionName # function name or ARN of a target (externally managed lambda, EventBridge event bus, SQS queue or SNS topic) - onFailure: xxx:xxx:target # function name or ARN of a target (externally managed lambda, EventBridge event bus, SQS queue or SNS topic) + # Lambda destination settings + destinations: + # Function name or ARN of target (EventBridge/SQS/SNS topic) + onSuccess: functionName + # Function name or ARN of target (EventBridge/SQS/SNS topic) + onFailure: xxx:xxx:target + # Mount an EFS filesystem fileSystemConfig: - arn: arn:aws:elasticfilesystem:us-east-1:111111111111:access-point/fsap-a1a1a1a1a1a1a1a1a # ARN of EFS Access Point - localMountPath: /mnt/example # path under which EFS will be mounted and accessible by Lambda function - events: # The Events that trigger this Function - - http: # This creates an API Gateway HTTP endpoint which can be used to trigger this function. Learn more in "events/apigateway" - path: users/create # Path for this endpoint - method: get # HTTP method for this endpoint - cors: true # Turn on CORS for this endpoint, but don't forget to return the right header in your response - private: true # Requires clients to add API keys values in the `x-api-key` header of their request - authorizer: # An AWS API Gateway custom authorizer function - name: authorizerFunc # The name of the authorizer function (must be in this service) - arn: xxx:xxx:Lambda-Name # Can be used instead of name to reference a function outside of service + # ARN of EFS Access Point + arn: arn:aws:elasticfilesystem:us-east-1:11111111:access-point/fsap-a1a1a1 + # Path under which EFS will be mounted and accessible in Lambda + localMountPath: /mnt/example +``` + +## Lambda events + +Reference of [Lambda events](./events.md) that trigger functions: + +### API Gateway v2 HTTP API + +[API Gateway v2 HTTP API events](../events/http-api.md): + +```yaml +functions: + hello: + # ... + events: + # HTTP API endpoint (API Gateway v2) + - httpApi: + method: GET + path: /some-get-path/{param} + authorizer: # Optional + # Name of an authorizer defined in 'provider.httpApi.authorizers' + name: someJwtAuthorizer + scopes: # Optional + - user.id + - user.email +``` + +### API Gateway v1 REST API + +[API Gateway v1 REST API events](../events/apigateway.md): + +```yaml +functions: + hello: + # ... + events: + # REST API endpoint (API Gateway v1) + - http: + # Path for this endpoint + path: users/create + # HTTP method for this endpoint + method: get + # Enable CORS. Don't forget to return the right header in your response + cors: true + # Requires clients to add API keys values in the `x-api-key` header of their request + private: true + # An AWS API Gateway custom authorizer function + authorizer: + # Name of the authorizer function (must be in this service) + name: authorizerFunc + # Can be used instead of a name to reference a function outside of service + arn: xxx:xxx:Lambda-Name resultTtlInSeconds: 0 identitySource: method.request.header.Authorization identityValidationExpression: someRegex - type: token # token or request. Determines input to the authorizer function, called with the auth token or the entire request event. Defaults to token - request: # configure method request and integration request settings - uri: http://url/{paramName} # Define http endpoint URL and map path parameters for HTTP and HTTP_PROXY requests - parameters: # Optional request parameter configuration + # Input of the authorizer function: auth token ('token') or the entire request event ('request') (default: token) + type: token + # Configure method request and integration request settings + request: + # HTTP endpoint URL and map path parameters for HTTP and HTTP_PROXY requests + uri: http://url/{paramName} + # Optional request parameter configuration + parameters: paths: paramName: true # mark path parameter as required headers: - headerName: true # mark header required - custom-header: # Optional add a new header to the request + headerName: true # mark header as required + custom-header: required: true - mappedValue: context.requestId # map the header to a static value or integration request variable + # Map the header to a static value or integration request variable + mappedValue: context.requestId querystrings: paramName: true # mark query string - schema: # Optional request schema validation; mapped by content type - application/json: ${file(create_request.json)} # define the valid JSON Schema for a content-type - template: # Optional custom request mapping templates that overwrite default templates + # Request schema validation mapped by content type + schema: + # Define the valid JSON Schema for this content-type + application/json: ${file(create_request.json)} + application/json+abc: + # Name of the API Gateway model + name: ModelName + description: 'Some description' + schema: ${file(model_schema.json)} + # Custom request mapping templates that overwrite default templates + template: application/json: '{ "httpMethod" : "$context.httpMethod" }' - passThrough: NEVER # Optional define pass through behavior when content-type does not match any of the specified mapping templates - schemas: # Optional request schema validation, mapped by content type - application/json: - name: ModelName # Optional: Name of the API Gateway model - description: "Some description" # Optional: Description of the API Gateway model - schema: ${file(model_schema.json)} # Schema for selected content type - - httpApi: # HTTP API endpoint - method: GET - path: /some-get-path/{param} - authorizer: # Optional - name: someJwtAuthorizer # References by name authorizer defined in provider.httpApi.authorizers section - scopes: # Optional - - user.id - - user.email + # Optional define pass through behavior when content-type does not match any of the specified mapping templates + passThrough: NEVER +``` + +### Websocket API + +[API Gateway websocket events](../events/websocket.md): + +```yaml +functions: + hello: + # ... + events: - websocket: route: $connect - routeResponseSelectionExpression: $default # optional, setting this enables callbacks on websocket requests for two-way communication + # Optional, setting this enables callbacks on websocket requests for two-way communication + routeResponseSelectionExpression: $default authorizer: - # name: auth NOTE: you can either use "name" or arn" properties + # Use either "name" or arn" properties + name: auth arn: arn:aws:lambda:us-east-1:1234567890:function:auth identitySource: - 'route.request.header.Auth' - 'route.request.querystring.Auth' +``` + +### S3 + +[S3 events](../events/s3.md): + +```yaml +functions: + hello: + # ... + events: - s3: bucket: photos event: s3:ObjectCreated:* rules: - prefix: uploads/ - suffix: .jpg - existing: true # optional, if you're using an existing Bucket + # Set to 'true' when using an existing bucket + # Else the bucket will be automatically created + existing: true +``` + +### Schedule + +[Schedule events](../events/schedule.md): + +```yaml +functions: + hello: + # ... + events: - schedule: name: my scheduled event description: a description of my scheduled event's purpose + # Can also be an array of rate/cron expressions rate: rate(10 minutes) + # (default: true) enabled: false # Note, you can use only one of input, inputPath, or inputTransformer input: @@ -411,6 +832,17 @@ functions: inputPathsMap: eventTime: '$.time' inputTemplate: '{"time": , "key1": "value1"}' +``` + +### SNS + +[SNS events](../events/sns.md): + +```yaml +functions: + hello: + # ... + events: - sns: topicName: aggregate displayName: Data aggregation pipeline @@ -419,44 +851,210 @@ functions: - dog - cat redrivePolicy: - # (1) ARN - deadLetterTargetArn: arn:aws:sqs:us-east-1:11111111111:myDLQ - # (2) Ref (resource defined in same CF stack) - deadLetterTargetRef: myDLQ - # (3) Import (resource defined in outer CF stack) - deadLetterTargetImport: - arn: MyShared-DLQArn - url: MyShared-DLQUrl + # (1) ARN + deadLetterTargetArn: arn:aws:sqs:us-east-1:11111111111:myDLQ + # (2) Ref (resource defined in same CF stack) + deadLetterTargetRef: myDLQ + # (3) Import (resource defined in outer CF stack) + deadLetterTargetImport: + arn: MyShared-DLQArn + url: MyShared-DLQUrl +``` + +### SQS + +[SQS events](../events/sqs.md): + +```yaml +functions: + hello: + # ... + events: - sqs: arn: arn:aws:sqs:region:XXXXXX:myQueue + # Optional batchSize: 10 - maximumBatchingWindow: 10 # optional, minimum is 0 and the maximum is 300 (seconds) - enabled: true + # Optional, minimum is 0 and the maximum is 300 (seconds) + maximumBatchingWindow: 10 + # (default: true) + enabled: false + functionResponseType: ReportBatchItemFailures + filterPatterns: + - a: [1, 2] +``` + +### Streams + +[Stream events](../events/streams.md): + +```yaml +functions: + hello: + # ... + events: - stream: arn: arn:aws:kinesis:region:XXXXXX:stream/foo batchSize: 100 maximumRecordAgeInSeconds: 120 startingPosition: LATEST - enabled: true + # (default: true) + enabled: false functionResponseType: ReportBatchItemFailures + filterPatterns: + - partitionKey: [1] +``` + +### MSK + +[MSK events](../events/msk.md): + +```yaml +functions: + hello: + # ... + events: - msk: - arn: arn:aws:kafka:us-east-1:111111111111:cluster/ClusterName/a1a1a1a1a1a1a1a1a # ARN of MSK Cluster - topic: kafkaTopic # name of Kafka topic to consume from - batchSize: 100 # optional, must be in 1-10000 range - startingPosition: LATEST # optional, can be set to LATEST or TRIM_HORIZON - enabled: true # optional, true by default, can be used to disable event without deleting resource + # ARN of MSK Cluster + arn: arn:aws:kafka:us-east-1:111111111:cluster/ClusterName/a1a1a1a1a + # name of Kafka topic to consume from + topic: kafkaTopic + # Optional, must be in 1-10000 range + batchSize: 100 + # Optional, must be in 0-300 range (seconds) + maximumBatchingWindow: 30 + # Optional, can be set to LATEST or TRIM_HORIZON + startingPosition: LATEST + # (default: true) + enabled: false +``` + +### ActiveMQ + +[ActiveMQ events](../events/activemq.md): + +```yaml +functions: + hello: + # ... + events: + - activemq: + # ARN of ActiveMQ Broker + arn: arn:aws:mq:us-east-1:0000:broker:ExampleMQBroker:b-xxx-xxx + # Name of ActiveMQ queue consume from + queue: queue-name + # Secrets Manager ARN for basic auth credentials + basicAuthArn: arn:aws:secretsmanager:us-east-1:01234567890:secret:MySecret + # Optional, must be in 1-10000 range + batchSize: 100 + # Optional, must be in 0-300 range (seconds) + maximumBatchingWindow: 30 + # Optional, can be set to LATEST or TRIM_HORIZON + startingPosition: LATEST + # (default: true) + enabled: false +``` + +### Kafka + +[Kakfa events](../events/kafka.md): + +```yaml +functions: + hello: + # ... + events: + - kafka: + # See main kafka documentation for various access configuration settings + accessConfigurations: + # ... + # An array of bootstrap server addresses + bootstrapServers: + - abc3.xyz.com:9092 + - abc2.xyz.com:9092 + # name of Kafka topic to consume from + topic: MySelfManagedKafkaTopic + # Optional, must be in 1-10000 range + batchSize: 100 + # Optional, must be in 0-300 range (seconds) + maximumBatchingWindow: 30 + # Optional, can be set to LATEST or TRIM_HORIZON + startingPosition: LATEST + # (default: true) + enabled: false +``` + +### RabbitMQ + +[RabbitMQ events](../events/rabbitmq.md): + +```yaml +functions: + hello: + # ... + events: + - rabbitmq: + # ARN of RabbitMQ Broker + arn: arn:aws:mq:us-east-1:0000:broker:ExampleMQBroker:b-xxx-xxx + # Name of RabbitMQ queue consume from + queue: queue-name + # Secrets Manager ARN for basic auth credentials + basicAuthArn: arn:aws:secretsmanager:us-east-1:01234567890:secret:MySecret + # Optional, must be in 1-10000 range + batchSize: 100 + # Optional, must be in 0-300 range (seconds) + maximumBatchingWindow: 30 + # Optional, can be set to LATEST or TRIM_HORIZON + startingPosition: LATEST + # (default: true) + enabled: false +``` + +### Alexa + +[Alexa Skill events](../events/alexa-skill.md) and [Alexa Smart Home events](../events/alexa-smart-home.md): + +```yaml +functions: + hello: + # ... + events: - alexaSkill: appId: amzn1.ask.skill.xx-xx-xx-xx - enabled: true + # (default: true) + enabled: false - alexaSmartHome: appId: amzn1.ask.skill.xx-xx-xx-xx - enabled: true + # (default: true) + enabled: false +``` + +### IOT + +[IoT events](../events/iot.md): + +```yaml +functions: + hello: + # ... + events: - iot: name: myIoTEvent description: An IoT event - enabled: true sql: "SELECT * FROM 'some_topic'" sqlVersion: beta + # (default: true) + enabled: false +``` + +### CloudWatch + +[CloudWatch events](../events/cloudwatch-event.md) and [CloudWatch logs events](../events/cloudwatch-log.md): + +```yaml +functions: + hello: + # ... + events: - cloudwatchEvent: event: source: @@ -480,18 +1078,44 @@ functions: - cloudwatchLog: logGroup: '/aws/lambda/hello' filter: '{$.userIdentity.type = Root}' +``` + +### Cognito + +[Cognito User Pool events](../events/cognito-user-pool.md): + +```yaml +functions: + hello: + # ... + events: - cognitoUserPool: pool: MyUserPool trigger: PreSignUp - existing: true # optional, if you're referencing an existing User Pool + # Optional, if you're referencing an existing User Pool + existing: true + # Optional, for forcing deployment of triggers on existing User Pools + forceDeploy: true +``` + +### ALB + +[Application Load Balancer events](../events/alb.md): + +```yaml +functions: + hello: + # ... + events: - alb: - listenerArn: arn:aws:elasticloadbalancing:us-east-1:12345:listener/app/my-load-balancer/50dc6c495c0c9188/ + listenerArn: arn:aws:elasticloadbalancing:us-east-1:12345:listener/app/my-load-balancer/50dcc0c9188/ priority: 1 targetGroupName: helloTargetGroup # optional conditions: host: example.com path: /hello - healthCheck: # optional, can also be set using a boolean value + # Optional, can also be set using a boolean value + healthCheck: path: / # optional intervalSeconds: 35 # optional timeoutSeconds: 30 # optional @@ -499,15 +1123,28 @@ functions: unhealthyThresholdCount: 5 # optional matcher: # optional httpCode: '200' +``` + +### EventBridge + +[EventBridge events](../events/event-bridge.md): + +```yaml +functions: + hello: + # ... + events: + # Use the default AWS event bus - eventBridge: - # using the default AWS event bus schedule: rate(10 minutes) - # creating an event bus + # Create a custom event bus + - eventBridge: eventBus: custom-saas-events pattern: source: - saas.external - # re-using an existing event bus + # Re-use an existing event bus + - eventBridge: eventBus: arn:aws:events:us-east-1:12345:event-bus/custom-private-events pattern: source: @@ -516,7 +1153,8 @@ functions: inputPathsMap: eventTime: '$.time' inputTemplate: '{"time": , "key1": "value1"}' - # using `inputs` + # Using 'inputs' + - eventBridge: pattern: source: - 'aws.ec2' @@ -530,7 +1168,8 @@ functions: key2: value2 stageParams: stage: dev - # using `inputPath` + # Using 'inputPath' + - eventBridge: pattern: source: - 'aws.ec2' @@ -540,7 +1179,8 @@ functions: state: - pending inputPath: '$.stageVariables' - # using `inputTransformer` + # Using 'inputTransformer' + - eventBridge: pattern: source: - 'aws.ec2' @@ -553,33 +1193,78 @@ functions: inputPathsMap: eventTime: '$.time' inputTemplate: '{"time": , "key1": "value1"}' + retryPolicy: + maximumEventAge: 3600 + maximumRetryAttempts: 3 + deadLetterQueueArn: !GetAtt QueueName.Arn +``` + +### CloudFront + +[CloudFront Lambda@Edge events](../events/cloudfront.md): + +```yaml +functions: + hello: + # ... + events: - cloudFront: eventType: viewer-response includeBody: true pathPattern: /docs* cachePolicy: - # Note, you can use only one of name or id - name: myCachePolicy1 # Refers to a Cache Policy defined in provider.cloudFront.cachePolicies - id: 658327ea-f89d-4fab-a63d-7e88639e58f6 # Refers to any external Cache Policy id + # Use either name or id + # Refers to a Cache Policy defined in 'provider.cloudFront.cachePolicies' + name: myCachePolicy1 + # Refers to any external Cache Policy ID + id: 658327ea-f89d-4fab-a63d-7e88639e58f6 origin: DomainName: serverless.com OriginPath: /framework CustomOriginConfig: OriginProtocolPolicy: match-viewer +``` + +## Function layers + +Deploy [Lambda function layers](./layers.md): + +```yml +# serverless.yml layers: - hello: # A Lambda layer - path: layer-dir # required, path to layer contents on disk - name: ${sls:stage}-layerName # optional, Deployed Lambda layer name - description: Description of what the lambda layer does # optional, Description to publish to AWS - compatibleRuntimes: # optional, a list of runtimes this layer is compatible with + # A Lambda layer + hello: + # required, path to layer contents on disk + path: layer-dir + # optional, Deployed Lambda layer name + name: ${sls:stage}-layerName + # optional, Description to publish to AWS + description: Description of what the lambda layer does + # optional, a list of runtimes this layer is compatible with + compatibleRuntimes: - python3.8 - licenseInfo: GPLv3 # optional, a string specifying license information - allowedAccounts: # optional, a list of AWS account IDs allowed to access this layer. + # optional, a list of architectures this layer is compatible with + compatibleArchitectures: + - x86_64 + - arm64 + # optional, a string specifying license information + licenseInfo: GPLv3 + # optional, a list of AWS account IDs allowed to access this layer. + allowedAccounts: - '*' - retain: false # optional, false by default. If true, layer versions are not deleted as new ones are created + # optional, false by default. If true, layer versions are not deleted as new ones are created + retain: false +``` + +## AWS Resources + +[Customize the CloudFormation template](./services.md#serverlessyml), for example to deploy extra CloudFormation resource: -# The "Resources" your "Functions" use. Raw AWS CloudFormation goes in here. +```yml +# serverless.yml + +# Insert raw CloudFormation (resources, outputs…) in the deployed template resources: Resources: usersTable: @@ -595,6 +1280,7 @@ resources: ProvisionedThroughput: ReadCapacityUnits: 1 WriteCapacityUnits: 1 + extensions: # override Properties or other attributes of Framework-created resources. # See https://serverless.com/framework/docs/providers/aws/guide/resources#override-aws-cloudformation-resource for more details @@ -606,8 +1292,9 @@ resources: Outputs: UsersTableArn: Description: The ARN for the User's Table - Value: - 'Fn::GetAtt': [usersTable, Arn] + Value: !GetAtt usersTable.Arn Export: - Name: ${self:service}:${opt:stage}:UsersTableArn # see Fn::ImportValue to use in other services and http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html for documentation on use. + # see Fn::ImportValue to use in other services + # and http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html for documentation on use. + Name: ${self:service}:${sls:stage}:UsersTableArn ``` diff --git a/docs/providers/aws/guide/services.md b/docs/providers/aws/guide/services.md index 3e243ae4d03..4bce2d54b4d 100644 --- a/docs/providers/aws/guide/services.md +++ b/docs/providers/aws/guide/services.md @@ -24,18 +24,22 @@ In the beginning of an application, many people use a single Service to define a ```bash myService/ - serverless.yml # Contains all functions and infrastructure resources + # Contains all functions and infrastructure resources + serverless.yml ``` However, as your application grows, you can break it out into multiple services. A lot of people organize their services by workflows or data models, and group the functions related to those workflows and data models together in the service. ```bash users/ - serverless.yml # Contains 4 functions that do Users CRUD operations and the Users database + # Contains 4 functions that do Users CRUD operations and the Users database + serverless.yml posts/ - serverless.yml # Contains 4 functions that do Posts CRUD operations and the Posts database + # Contains 4 functions that do Posts CRUD operations and the Posts database + serverless.yml comments/ - serverless.yml # Contains 4 functions that do Comments CRUD operations and the Comments database + # Contains 4 functions that do Comments CRUD operations and the Comments database + serverless.yml ``` This makes sense since related functions usually use common infrastructure resources, and you want to keep those functions and resources together as a single unit of deployment, for better organization and separation of concerns. @@ -141,11 +145,11 @@ functions: usersCreate: # A Function handler: users.create events: # The Events that trigger this Function - - http: post users/create + - httpApi: 'POST /users/create' usersDelete: # A Function handler: users.delete events: # The Events that trigger this Function - - http: delete users/delete + - httpApi: 'DELETE /users/delete' # The "Resources" your "Functions" use. Raw AWS CloudFormation goes in here. resources: diff --git a/docs/providers/aws/guide/variables.md b/docs/providers/aws/guide/variables.md index 60e6b2afd6a..012c370fc4f 100644 --- a/docs/providers/aws/guide/variables.md +++ b/docs/providers/aws/guide/variables.md @@ -18,9 +18,6 @@ Variables allow users to dynamically replace config values in `serverless.yml` c They are especially useful when providing secrets for your service to use and when you are working with multiple stages. -If `unresolvedVariablesNotificationMode` is set to `error`, references to variables that cannot be resolved will result in an error being thrown. -This will become the default behaviour in the next major version. - ## Syntax To use variables, you will need to reference values enclosed in `${}` brackets. @@ -38,20 +35,19 @@ You can define your own variable syntax (regex) if it conflicts with CloudFormat ## Current variable sources: +- [Other properties defined in `serverless.yml`](#reference-properties-in-serverlessyml) - [Serverless Core variables](#referencing-serverless-core-variables) - [Environment variables](#referencing-environment-variables) +- [Parameters](#referencing-parameters) - [CLI options](#referencing-cli-options) -- [Other properties defined in `serverless.yml`](#reference-properties-in-serverlessyml) -- [External YAML/JSON files](#reference-variables-in-other-files) +- [External YAML/JSON files](#reference-properties-in-other-files) - [Variables from S3](#referencing-s3-objects) - [Variables from AWS SSM Parameter Store](#reference-variables-using-the-ssm-parameter-store) - [Variables from AWS Secrets Manager](#reference-variables-using-aws-secrets-manager) - [CloudFormation stack outputs](#reference-cloudformation-outputs) - [Properties exported from Javascript files (sync or async)](#reference-variables-in-javascript-files) -- [Pseudo Parameters Reference](#pseudo-parameters-reference) - [Read String Variable Values as Boolean Values](#read-string-variable-values-as-boolean-values) - -## Casting string variables to boolean values +- [Pseudo Parameters Reference](#aws-cloudformation-pseudo-parameters-and-intrinsic-functions) ## Recursively reference properties @@ -160,9 +156,23 @@ functions: In the above example you're dynamically adding a prefix to the function names by referencing the `FUNC_PREFIX` env var. So you can easily change that prefix for all functions by changing the `FUNC_PREFIX` env var. +## Referencing Parameters + +Parameters can be defined in `serverless.yml` under the `params` key, or in [Serverless Dashboard](https://www.serverless.com/secrets). + +To reference parameters, use the `${param:XXX}` syntax in `serverless.yml`. + +```yaml +provider: + environment: + APP_DOMAIN: ${param:domain} +``` + +Read all about parameters in the [Parameters documentation](../../../guides/parameters.md). + ## Referencing CLI Options -To reference CLI options that you passed, use the `${opt:some_option}` syntax in your `serverless.yml` configuration file. It is valid to use the empty string in place of `some_option`. This looks like "`${opt:}`" and the result of declaring this in your `serverless.yml` is to embed the complete `options` object (i.e. all the command line options from your `serverless` command). +To reference CLI options that you passed, use the `${opt: