我正在尝试使用无服务器框架部署AWS Lambda,并在
serverless.yaml
中有以下内容
provider:
name: aws
runtime: python3.8
region: us-west-2
stackName: ${self:service}-${self:custom.name}-${opt:stage, 'dev'}
stackTags:
Service: "it"
lambdaHashingVersion: 20201221
memorySize: 128
timeout: 900
logRetentionInDays: 14
disableDefaultOutputExportNames: true
deploymentBucket: ${self:custom.deployment-s3-bucket}
environment:
S3_BUCKET: ${self:custom.bucket}
S3_BUCKET_PATH_PREFIX: ${self:custom.path_prefix}
REDSHIFT_DATABASE: ${self:custom.database}
REDSHIFT_SCHEMA: ${self:custom.schema}
REDSHIFT_TABEL_PREFIX: ${self:custom.table_prefix}
REDSHIFT_USER: ${self:custom.user}
REDSHIFT_PASSWORD: ${self:custom.password}
REDSHIFT_PORT: ${self:custom.port}
REDSHIFT_ENDPOINT: ${self:custom.endpoint}
REDSHIFT_ROLE: ${self:custom.role}
iam:
role:
name: s3-to-redshift-load
statements:
- Effect: Allow
Action:
- s3:GetObject
Resource: "arn:aws:s3:::${self:custom.bucket}/*"
functions:
load:
handler: handler.run
events:
- s3: #https://www.serverless.com/framework/docs/providers/aws/events/s3#using-existing-buckets
bucket: ${self:custom.bucket}
event: s3:ObjectCreated:*
rules:
- prefix: ${self:custom.path_prefix}/
- suffix: .json
existing: true
但是当我部署时出现以下错误
Serverless Error ----------------------------------------
An error occurred: LoadCustomS31 - Received response status [FAILED] from custom resource. Message returned: Configuration is ambiguously defined. Cannot have overlapping suffixes in two rules if the prefixes are overlapping for the same event type. See details in CloudWatch Log: 2021/08/30/[$LATEST]4f4f9ec564544ebb979576ed1b6b2879 (RequestId: 317ecd1c-b699-4799-8060-5168e1947e3c).
知道我在这里做错了什么吗?
在不了解 CloudWatch 日志的详细信息的情况下
2021/08/30/[$LATEST]4f4f9ec564544ebb979576ed1b6b2879 (RequestId: 317ecd1c-b699-4799-8060-5168e1947e3c)
我会说,在您的 AWS 账户中,该存储桶上已经有一个带有前缀 ${self:custom.path_prefix}/
和后缀 .json
的 S3 事件。它可能是因为以前或其他无服务器堆栈而存在,或者是有人手动创建它但尚未删除它。
您能否通过 AWS 控制台检查 S3 上是否没有具有相同配置的其他事件?
当我将一个事件函数替换为具有相同前缀的另一个事件函数时,我遇到了这个问题。我通过在没有该事件的任何函数的情况下部署,然后使用该函数重新部署来删除该函数。 我想我可以手动进入控制台并删除该事件......