How to deploy Serverless Framework to AWS from Azure Pipeline?

Viewed 23

I'm wanting to get familiar with Azure DevOps and setting up CI/CD through it. For the backend services, I want to use Serverless Framework (SF). I'm getting stuck trying to add credentials to the CI pipeline for SF.

I'm following the instructions in this documentation page but I'm getting this error in the deploy step.

AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here:

These are the steps to reproduce:

  • Create a SF service, initial a git repo and add it to the Azure project.
sls create -t aws-nodejs-typescript -p api-hello-service
cd api-hello-service
git init
git add .
git commit -m 'initial commit'
git remote add origin <origin>
  • In the Serverless Framework Dashboard, go to org and create an access key (save the key for later) enter image description here

  • In the Azure DevOps GUI, refresh the Repo page and click the "Setup Build" button enter image description here

  • Select the Node.js template as a base. enter image description here

  • Customize the pipeline

# azure-pipelines.yml
trigger:
- main

pool:
  vmImage: ubuntu-latest

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '16.x'
  displayName: 'Install Node.js'

- script: |
    npm install
    npm install -g serverless
    serverless deploy
  displayName: 'npm install and build'
  • Set the variable SERVERLESS_ACCESS_KEY as described in the documentation earlier with the access key create in SF Dashboard earlier. (check "Keep this value secret")
  • Hit save & run

Deploy step fails:

Starting: npm install and build
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.201.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/dec6f028-dba1-4c47-8718-cb65524f31a1.sh
npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated superagent@7.1.6: Please downgrade to v7.1.5 if you need IE/ActiveXObject support OR upgrade to v8.0.0 as we no longer support IE and published an incorrect patch version (see https://github.com/visionmedia/superagent/issues/1731)
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.

added 474 packages, and audited 475 packages in 16s

88 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated superagent@7.1.6: Please downgrade to v7.1.5 if you need IE/ActiveXObject support OR upgrade to v8.0.0 as we no longer support IE and published an incorrect patch version (see https://github.com/visionmedia/superagent/issues/1731)

added 425 packages, and audited 426 packages in 6s

87 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Running "serverless" from node_modules

Deploying api-hello-service to stage dev (us-east-1)

× Stack api-hello-service-dev failed to deploy (0s)
Environment: linux, node 16.17.0, framework 3.22.0 (local) 3.22.0v (global), plugin 6.2.2, SDK 4.3.2
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
AWS provider credentials not found. Learn how to set up AWS provider credentials in our docs here: <http://slss.io/aws-creds-setup>.
##[error]Bash exited with code '1'.
Finishing: npm install and build
0 Answers
Related