尝试在 localstack 上使用 serverless-localstack 部署 lambda 时,代码已上传到 s3 存储桶,但未部署 lambda,尽管它们不是日志中的错误。
我运行命令
sls deploy --stage local --verbose
并没有看到任何错误。输出是:
Serverless: config
.options_stage: local
Serverless: serverless.service.custom.stage: undefined
Serverless: serverless.service.provider.stage: dev
Serverless: config.stage: local
Serverless: Using serverless-localstack
Serverless: Reconfiguring service apigateway to use http://localhost:4567
Serverless: Reconfiguring service cloudformation to use
http://localhost:4581
Serverless: Reconfiguring service cloudwatch to use http://localhost:4582
Serverless: Reconfiguring service lambda to use http://localhost:4574
Serverless: Reconfiguring service dynamodb to use http://localhost:4569
Serverless: Reconfiguring service kinesis to use http://localhost:4568
Serverless: Reconfiguring service route53 to use http://localhost:4580
Serverless: Reconfiguring service firehose to use http://localhost:4573
Serverless: Reconfiguring service stepfunctions to use http://localhost:4585
Serverless: Reconfiguring service es to use http://localhost:4578
Serverless: Reconfiguring service s3 to use http://localhost:4572
Serverless: Reconfiguring service ses to use http://localhost:4579
Serverless: Reconfiguring service sns to use http://localhost:4575
Serverless: Reconfiguring service sqs to use http://localhost:4576
Serverless: Reconfiguring service sts to use http://localhost:4592
Serverless: Reconfiguring service iam to use http://localhost:4593
Serverless: Generated requirements from /root/lambda_detect/requirements.txt in /root/lambda_detect/.serverless/requirements.txt...
Serverless: Installing requirements from /root/lambda_detect/.serverless/requirements/requirements.txt ...
Serverless: Running ...
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Injecting required Python packages to package...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service detector.zip file to S3 (971.78 KB)...
Serverless: Validating template...
Serverless: Skipping template validation: Unsupported in Localstack
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
CloudFormation - UPDATE_IN_PROGRESS - AWS::CloudFormation::Stack - detector-local
CloudFormation - UPDATE_COMPLETE - AWS::CloudFormation::Stack - detector-local
Serverless: Stack update finished...
Service Information
service: detector
stage: local
region: us-east-1
stack: detector-local
resources: 3
api keys:
None
endpoints:
None
functions:
detectfile: detector-local-detectfile
layers:
None
Stack Outputs
ServerlessDeploymentBucketName: detector-local-ServerlessDeploymentBucket-A-Z978A-Z005A-Z489
我的 serverless.yaml 文件是:
service: detector
provider:
name: aws
runtime: python3.6
region: us-east-1
plugins:
- serverless-python-requirements
- serverless-localstack
custom:
pythonRequirements:
dockerizePip: false
localstack:
host: http://localhost
debug: true
stages:
- local
autostart: true
functions:
detectfile:
handler: lambda_function.lambda_handler
Role: 'arn:aws:iam::000000000001:role/e2e_lambda_role'
Events:
-s3:
Bucket:
Ref: Bucket1
event: 's3:ObjectCreated:*'
filter:
S3Key:
Rules:
- Name: prefix
Value: fmts/
Bucket1:
Type: 'AWS::S3::Bucket'
environment:
bucket: e2e-test
部署后,我运行awslocal lambda list-functions
但看不到他们的 lambda