Lambda And CloudFormation

Create a lambda function using CloudFormation

Inline

  • Use Code.ZipFile propertyPasted image 20221011155338.png
  • Cannot include function dependencies, suitable for short code

Through S3

Pasted image 20221011155552.png

  • Store the lambda function zip in S3.
  • Must provide
    • S3Bucket: name of the bucket
    • S3Key: full path to zip
    • S3ObjectVersion: if the bucket is versioned.
  • Note: if you update the code in S3 but doesn't update S3Bucket, S3Key, or S3ObjectVersion.
    • CloudFormation won't update your function

For multiple account

  • Use Execution Role in CloudFormation level or Bucket Policy in S3 level
    Pasted image 20221011155857.png