I tried deploying a serverless python app through the azure devops pipeline.
serverless.yml
service: ws-serverless
provider:
name: aws
runtime: python3.7
websocketApiName: ws-serverless-api
websocketApiRouteSelectionExpression: $request.body.action
stage: dev
region: ap-northeast-2
iamRoleStatements:
- Effect: "Allow"
Action:
- "execute-api:ManageConnections"
Resource:
- "arn:aws:execute-api:*:*:**/@connections/*"
- Effect: "Allow"
Action:
- "dynamodb:PutItem"
- "dynamodb:GetItem"
- "dynamodb:UpdateItem"
- "dynamodb:DeleteItem"
- "dynamodb:BatchGetItem"
- "dynamodb:BatchWriteItem"
- "dynamodb:Scan"
- "dynamodb:Query"
Resource:
- "arn:aws:dynamodb:ap-northeast-2:*:*"
functions:
connectionManager:
handler: handler.connection_manager
events:
- websocket:
route: $connect
- websocket:
route: $disconnect
defaultMessage:
handler: handler.default_message
events:
- websocket:
route: $default
getRecentMessages:
handler: handler.get_recent_messages
events:
- websocket:
route: getRecentMessages
sendMessage:
handler: handler.send_message
events:
- websocket:
route: sendMessage
ping:
handler: handler.ping
events:
- http:
path: ping
method: get
plugins:
- serverless-python-requirements
custom:
pythonRequirements:
dockerizePip: true
noDeploy: []
azure-pipelines.yml
trigger:
- test
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
displayName: Install Python
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install --no-cache
displayName: 'npm install'
- task: AWSShellScript@1
inputs:
awsCredentials: aws
regionName: 'ap-northeast-2'
scriptType: 'inline'
inlineScript: |
./node_modules/.bin/serverless package --stage dev --region ap-northeast-2 --package /tmp/dev_artifacts/
displayName: Package for Dev Environment
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: /tmp/dev_artifacts
artifactName: dev_artifacts
displayName: Export Dev Artifacts
It failed on Package for Dev Environment
I got this error message
Error: ENOENT: no such file or directory, open '/home/vsts/work/1/s/venv/bin/python'
So i tried installing Python in that path using Virtualenv, but it also failed.
FileExistsError: [Errno 17] File exists: '/opt/hostedtoolcache/Python/3.7.7/x64/bin/python' -> '/home/vsts/work/1/s/venv/bin/python'