serverless로 배포하려다보면 아래같은 에러를 만날 수 있다
Serverless Error ---------------------------------------
An error occurred: S3BucketBucketName - bucket-name-image already exists.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
OS: darwin
Node Version: 12.22.6
Serverless Version: 1.44.1
그리고 나의 yml 파일 상태는 아래와 같았다.
parking:
handler: handler
name: Fn-${self:provider.stage}-name
events:
- s3:
bucket: ${env:BUCKET-NAME-IMAGE}
event: s3:ObjectCreated:*
rules:
- prefix: prefix/
- suffix: .jpg
existing: true
environment:
이미 있는 Bucket을 생성하고 있기는 하지만 existing: true 명령을 통해 이미 있는 Bucket은 다시 생성하지 않도록 만들어주었는데 무엇이 문제인지 serverless document에 들어가보았다.
해답은 아래에 있었다.
Sometimes you might want to attach Lambda functions to existing S3 buckets. In that case you just need to set the existing event configuration property to true. All the other config parameters can also be used on existing buckets:
IMPORTANT: You can only attach 1 existing S3 bucket per function.
NOTE: Using the existing config will add an additional Lambda function and IAM Role to your stack. The Lambda function backs-up the Custom S3 Resource which is used to support existing S3 buckets.
NOTE: This property was added in version 1.47.0. Older versions don't support this feature.
Serverless Framework - AWS Lambda Events - S3
serverless 버전이 문제였다.
document에 써져 있는 것처럼 1.47.0 이전 버전은 지원하지 않았고 2.69.1 버전으로 업데이트 한 후 에러는 사라졌다.
후.. 내 두시간.. ( ¯⌓¯)
serverless document는 볼 때마다 굉장히 잘 되어 있는 것 같다.
에러가 나면 document좀 먼저 보기로 하자!