Creating lambda function using cloudformation stack



This video show you creating lambda function using cloudformation stack.

—————————- Template Using code inside cloudformation stack ——————————-

{
“AWSTemplateFormatVersion”: “2010-09-09”,
“Description”: “A template is for creating lambda “,
“Resources”: {
“LambdaFunResource”: {
“Type”: “AWS::Lambda::Function”,
“Properties”: {
“FunctionName”: “SurajLambdaCFT”,

“Code”: {
“ZipFile”: {
“Fn::Join”: [
“n”,
[

“def lambda_handler(event, context):”,
” print(‘THIS IS LAMBDA CREATED FROM CloudFormation’)”,
” return ‘success'”
]
]
}
},
“Description”: “Used to run job”,
“Handler”: “index.lambda_handler”,
“Role”: “arn:aws:iam::13015229333333455024:role/lambda_basic_execution”,
“Runtime”: “python3.6”,
“Timeout”: 120
}
}
}
}

——————- Template Using code (your lambda python code file) stored S3 Bucket ———————

{
“AWSTemplateFormatVersion”: “2010-09-09”,
“Description”: “A template is for creating lambda from s3 buckets”,
“Resources”: {
“LambdaFunResource”: {
“Type”: “AWS::Lambda::Function”,
“Properties”: {
“FunctionName”: “SurajLambdaCFT”,

“Code”: {
“S3Bucket” : “surajyt”,
“S3Key” : “index.zip”
},
“Description”: “Used to run job”,
“Handler”: “index.lambda_handler”,
“Role”: “arn:aws:iam::13015229333333455024:role/lambda_basic_execution”,
“Runtime”: “python3.6”,
“Timeout”: 120
}
}
}
}

source

12 thoughts on “Creating lambda function using cloudformation stack”
  1. I'm getting a roll back, please how do I fix this? Error The following resource failed to create: [LamdaFunResource].

  2. Can we create multiple lambda functions within one JSON? Can you please share the sample JSON

  3. Can you explain where you got the value for the Role? I didn't quite understand in the video.

  4. Could you please do videos on deploying resources through any other tools(like HashiCop Packer) instead of doing from UI?

  5. Can I have the same for RDS creation, Backup and Restore with SQLSERVER_BACKUP_RESTORE option

Leave a Reply

Your email address will not be published.

Captcha loading...