Reputation: 1043
I'm trying to create a basic lambda and an S3 bucket using the Serverless Framework. I have cut out a small code snippet from this post: Enable Lambda function to an S3 bucket using cloudformation
# serverless.yml
service: MyTest
provider:
name: aws
runtime: python3.7
resources:
Resources:
Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: MyBucket12345
MyFunc:
Type: AWS::Lambda::Function
Properties:
Handler: handler.MyFunc
# handler.py
def MyFunc(event, context):
print(event)
Output:
Serverless: Packaging service...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
CloudFormation - CREATE_IN_PROGRESS - AWS::CloudFormation::Stack - MyTest-dev
CloudFormation - CREATE_IN_PROGRESS - AWS::S3::Bucket - ServerlessDeploymentBucket
CloudFormation - CREATE_IN_PROGRESS - AWS::S3::Bucket - ServerlessDeploymentBucket
CloudFormation - CREATE_COMPLETE - AWS::S3::Bucket - ServerlessDeploymentBucket
CloudFormation - CREATE_IN_PROGRESS - AWS::S3::BucketPolicy - ServerlessDeploymentBucketPolicy
CloudFormation - CREATE_IN_PROGRESS - AWS::S3::BucketPolicy - ServerlessDeploymentBucketPolicy
CloudFormation - CREATE_COMPLETE - AWS::S3::BucketPolicy - ServerlessDeploymentBucketPolicy
CloudFormation - CREATE_COMPLETE - AWS::CloudFormation::Stack - MyTest-dev
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Type Error ---------------------------------------------
TypeError: Cannot set property 'S3Key' of undefined
Upvotes: 1
Views: 928
Reputation: 238747
Based on the comments.
The link provided in the question showcases a CloudFormation (CFN) template, not serverless framework template. Although there are similarities between the two, they are different.
The code in the question is a mixture of both CFN and serverless templates, which makes it not work in both systems.
Thus to solve the issue, you have to check and find examples for serverless framework templates, not CFN. Then you modify your current template into valid serverless template.
Upvotes: 1