{"id":2207,"date":"2024-01-03T19:04:20","date_gmt":"2024-01-03T19:04:20","guid":{"rendered":"https:\/\/www.maghilda.com\/staging\/9669\/?p=2207"},"modified":"2024-01-08T00:09:19","modified_gmt":"2024-01-08T00:09:19","slug":"aws-cloudformation-and-aws-cli-to-invoke-lambda","status":"publish","type":"post","link":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/","title":{"rendered":"HOWTO: AWS CloudFormation and AWS CLI to build Lambda"},"content":{"rendered":"\n<p>In the <a href=\"https:\/\/www.maghilda.com\/staging\/9669\/lambda-with-s3-trigger-using-aws-sdk-and-python\/\">previous tutorial<\/a>, I showed how to use AWS SDK and Python to deploy an existing Lambda function and configure a trigger for an Amazon S3 bucket. In this tutorial, we will repeat the same steps but using AWS CloudFormation template instead of AWS SDK and Python. Every time we add an object to the Amazon S3 bucket, Lambda function runs and outputs the object type to Amazon CloudWatch Logs.<\/p>\n\n\n\n<p>We will re-use the same Python file for the Lambda function and upload the zip file to our S3 bucket. We could have also defined an in-line Lambda function within CloudFormation template but for real world production workloads, defining the functions in a separate Python file is highly recommended for reusability and readability.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">AWS Services Used<\/h3>\n\n\n\n<ul class=\"wp-block-list\" style=\"padding-right:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--50)\">\n<li>AWS CLI<\/li>\n\n\n\n<li>AWS Management Console<\/li>\n\n\n\n<li>Amazon CloudWatch Logs<\/li>\n\n\n\n<li>Amazon S3<\/li>\n\n\n\n<li>AWS CloudFormation<\/li>\n\n\n\n<li>AWS Lambda<\/li>\n\n\n\n<li>AWS IAM<\/li>\n<\/ul>\n\n\n\n<p>To complete this tutorial, the steps are almost the same as in the previous tutorial but this time using a template file:<\/p>\n\n\n\n<ul class=\"wp-block-list\" style=\"padding-right:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--50)\">\n<li>Create IAM permissions policy<\/li>\n\n\n\n<li>Create IAM execution role for the Lambda function<\/li>\n\n\n\n<li>Deploy the Lambda function<\/li>\n\n\n\n<li>Create the S3 trigger<\/li>\n\n\n\n<li>Define Lambda permissions to allow S3 to invoke the Lambda function<\/li>\n\n\n\n<li>Create the Stack by uploading the template file<\/li>\n\n\n\n<li>Test the S3 trigger by uploading a file in the S3 bucket<\/li>\n\n\n\n<li>Verify CloudWatch logs to see if the Lambda function executed successfully<\/li>\n\n\n\n<li>Delete the stack to tear down all the resources&nbsp;<\/li>\n<\/ul>\n\n\n\n<p>A template contains the configuration information about the AWS resources you want to create in the stack. The template is stored as a text file whose format complies with the JavaScript Object Notation (JSON) or YAML standard. Because they are text files, you can create and edit them in any text editor and manage them in your source control system with the rest of your source code. For this tutorial, I am using YAML format and have created and edited the template in Visual Studio Code.<\/p>\n\n\n\n<p>I downloaded the &#8216;YAML Language Support by RedHat\u2019 extension for Visual Studio Code to create well-formed YAML.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Install YAML Language Support by RedHat for Visual Studio Code<\/strong><\/h3>\n\n\n\n<p>You can download, install, and set up the Python for Visual Studio Code through the VS Code Marketplace in your IDE.<\/p>\n\n\n\n<ol class=\"wp-block-list\" style=\"padding-right:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--50)\">\n<li>Click the extensions button on the left navigation bar and then in the Search Extensions in Marketplace, enter YAML.<\/li>\n\n\n\n<li>Choose <strong>Install<\/strong> to begin the installation process.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"589\" src=\"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-1024x589.png\" alt=\"\" class=\"wp-image-2209\" style=\"width:828px;height:auto\" srcset=\"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-1024x589.png 1024w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-300x172.png 300w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-768x441.png 768w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image.png 1136w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>With the right template, you can deploy all the AWS resources at once for an application. The only required top-level object is the <strong>Resources<\/strong> object, which must declare at least one resource.<\/p>\n\n\n\n<p>In this tutorial, you&#8217;ll examine a template that declares the resources for a Lambda function with its required permissions, policy and S3 bucket as a trigger. Once the resources are defined, you can create a stack, monitor the stack creation process, examine the resources on the stack, and then delete the stack. You can use the AWS Management Console or AWS CLI to complete these tasks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<ul class=\"wp-block-list\" style=\"padding-right:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--50)\">\n<li>Set up IAM user in the IAM Identity Center<\/li>\n\n\n\n<li>Create a bucket to host your function file<\/li>\n\n\n\n<li>Upload the function.zip file in the above bucket<\/li>\n<\/ul>\n\n\n\n<p>For instructions, follow the <a href=\"https:\/\/www.maghilda.com\/staging\/9669\/lambda-with-s3-trigger-using-aws-sdk-and-python\/\">previous tutorial<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Create IAM permissions policy<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>SampleManagedPolicy:\n    Type: AWS::IAM::ManagedPolicy\n    Properties:\n      PolicyDocument: \n        Version: '2012-10-17'\n        Statement:\n          - Effect: Allow\n            Action:\n              - logs:PutLogEvents\n              - logs:CreateLogGroup\n              - logs:CreateLogStream\n            Resource: \"arn:aws:logs:*:*:*\"\n          - Effect: Allow\n            Action: \n            - s3:GetObject\n            Resource: \"arn:aws:s3:::*\/*\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Create IAM execution role<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>RootRole:\n    Type: 'AWS::IAM::Role'\n    Properties:\n      AssumeRolePolicyDocument:\n        Version: '2012-10-17'\n        Statement:\n          - Effect: Allow\n            Principal:\n              Service:\n                - lambda.amazonaws.com\n            Action:\n              - 'sts:AssumeRole'\n      ManagedPolicyArns:\n          - !Ref SampleManagedPolicy<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Deploy the Lambda function<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>DeployLambdafn:\n    Type: AWS::Lambda::Function\n    Properties:\n      Runtime: python3.11\n      Role: !GetAtt RootRole.Arn\n      Handler: test.lambda_handler\n      Code:\n        S3Bucket: vibstest  #name of the s3 bucket\n        S3Key: function.zip #zip file in the vibstest bucket containing Lambda function\n      Description: test my lambda function\n      TracingConfig:\n        Mode: Active<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Create the Amazon S3 trigger<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>S3Trigger:\n    Type: AWS::S3::Bucket\n    DependsOn: \n        - LambdaPerms\n    Properties:\n      NotificationConfiguration:\n        LambdaConfigurations:\n          - Event: s3:ObjectCreated:*\n            Function: !GetAtt DeployLambdafn.Arn<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Define Lambda permissions to allow S3 to invoke the lambda function<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>LambdaPerms:\n    Type: AWS::Lambda::Permission\n    Properties:\n      Action: 'lambda:InvokeFunction'\n      FunctionName: !Ref DeployLambdafn\n      Principal: s3.amazonaws.com \n      SourceAccount: !Ref AWS::AccountId  <\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Define the output (optional)<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Outputs:\n  S3BucketName:\n    Description: The name of the bucket created above\n    Value: !Ref S3Trigger<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Complete Template File (yaml)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>AWSTemplateFormatVersion: 2010-09-09\nDescription: Tutorial- How to use CloudFormation Template\nResources:\n  SampleManagedPolicy:\n    Type: AWS::IAM::ManagedPolicy\n    Properties:\n      PolicyDocument: \n        Version: '2012-10-17'\n        Statement:\n          - Effect: Allow\n            Action:\n              - logs:PutLogEvents\n              - logs:CreateLogGroup\n              - logs:CreateLogStream\n            Resource: \"arn:aws:logs:*:*:*\"\n          - Effect: Allow\n            Action: \n            - s3:GetObject\n            Resource: \"arn:aws:s3:::*\/*\"\n  RootRole:\n    Type: 'AWS::IAM::Role'\n    Properties:\n      AssumeRolePolicyDocument:\n        Version: '2012-10-17'\n        Statement:\n          - Effect: Allow\n            Principal:\n              Service:\n                - lambda.amazonaws.com\n            Action:\n              - 'sts:AssumeRole'\n      ManagedPolicyArns:\n          - !Ref SampleManagedPolicy\n  DeployLambdafn:\n    Type: AWS::Lambda::Function\n    Properties:\n      Runtime: python3.11\n      Role: !GetAtt RootRole.Arn\n      Handler: test.lambda_handler\n      Code:\n        S3Bucket: vibstest\n        S3Key: function.zip\n      Description: test my lambda function\n      TracingConfig:\n        Mode: Active\n  S3Trigger:\n    Type: AWS::S3::Bucket\n    #BucketName: !Ref S3BucketName\n    DependsOn: \n        - LambdaPerms\n    Properties:\n      NotificationConfiguration:\n        LambdaConfigurations:\n          - Event: s3:ObjectCreated:*\n            Function: !GetAtt DeployLambdafn.Arn\n  LambdaPerms:\n    Type: AWS::Lambda::Permission\n    Properties:\n      Action: 'lambda:InvokeFunction'\n      FunctionName: !Ref DeployLambdafn\n      Principal: s3.amazonaws.com \n      SourceAccount: !Ref AWS::AccountId   \nOutputs:\n  S3BucketName:\n    Description: The name of the bucket created above\n    Value: !Ref S3Trigger\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Create the Stack<\/strong><\/h3>\n\n\n\n<p>Two ways to create the stack:<br>&#8211; AWS Management Console<br>&#8211; AWS CLI<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Create the stack via AWS Management Console<\/h5>\n\n\n\n<ul class=\"wp-block-list\" style=\"padding-right:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--50)\">\n<li>Sign in to the AWS Management Console and search for CloudFormation.<\/li>\n\n\n\n<li>Click <strong>Create Stack<\/strong><\/li>\n\n\n\n<li>Select the following options: <strong>Template is ready<\/strong>, <strong>Upload a template file<\/strong>, <strong>upload a template file<\/strong><\/li>\n\n\n\n<li>Upload your file, you will see S3 url at the bottom of the screen. This will create a template bucket in S3 with the template file in it.&nbsp;<\/li>\n\n\n\n<li>To validate that your template is valid, you can also open the template in<strong> View in Designer. <\/strong>This is a good option to create and modify your template but that\u2019s a topic for another tutorial. Close and return to the Create Stack page if all looks good.&nbsp;<\/li>\n\n\n\n<li>Provide a <strong>Stack name <\/strong>and click<strong> Next<\/strong><\/li>\n\n\n\n<li>Keep the defaults in <strong>Create stack options<\/strong> and click <strong>Next<\/strong>.<\/li>\n\n\n\n<li>On the <strong>Review stack page<\/strong>, under <strong>Capabilities<\/strong> section, acknowledge as your template will be creating IAM resources and click <strong>Submit<\/strong>.<\/li>\n\n\n\n<li>In the <strong>events<\/strong> tab, you should see creation statuses for all the resources with <strong>CREATE_COMPLETE<\/strong> for your stack<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" width=\"1024\" height=\"820\" src=\"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-1-1024x820.png\" alt=\"\" class=\"wp-image-2212\" style=\"width:922px;height:auto\" srcset=\"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-1-1024x820.png 1024w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-1-300x240.png 300w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-1-768x615.png 768w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-1.png 1075w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" width=\"1024\" height=\"730\" src=\"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-2-1024x730.png\" alt=\"\" class=\"wp-image-2213\" style=\"width:867px;height:auto\" srcset=\"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-2-1024x730.png 1024w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-2-300x214.png 300w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-2-768x548.png 768w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-2.png 1167w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">Create the stack via AWS CLI<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>aws cloudformation create-stack --stack-name <strong>test2stack<\/strong> --template-body <strong>file:\/\/template<\/strong> --capabilities <strong>CAPABILITY_IAM<\/strong><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>OUTPUT:\n{\n    \"StackId\": \"arn:aws:cloudformation:us-east-1:111111222222:stack\/test2stack\/dc025330-a9c7-11ee-9dbb-1222e1fd621b\"\n}<\/code><\/pre>\n\n\n\n<p>To see if the stack was created successfully, run the describe stacks command and notice the output values defined in the template. You may hav to run the command a few times until you see CREATE_COMPLETE status <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws cloudformation describe-stacks<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>OUTPUT:\n{\n    \"Stacks\": &#91;\n        {\n            \"StackId\": \"arn:aws:cloudformation:us-east-1:111111222222:stack\/test2stack\/a0bf92d0-aa4c-11ee-b5e6-0e5e8cfd4ae1\",\n            \"StackName\": \"test2stack\",\n            \"Description\": \"Tutorial- How to use CloudFormation Template\",\n            \"CreationTime\": \"2024-01-03T15:27:38.727000+00:00\",\n            \"RollbackConfiguration\": {\n                \"RollbackTriggers\": &#91;]\n            },\n            \"StackStatus\": \"<strong>CREATE_COMPLETE<\/strong>\",\n            \"DisableRollback\": false,\n            \"NotificationARNs\": &#91;],\n            \"Capabilities\": &#91;\n                \"CAPABILITY_IAM\"\n            ],\n            \"Outputs\": &#91;\n                {\n                    \"OutputKey\": \"S3BucketName\",\n                    \"OutputValue\": \"<strong>test2stack-s3trigger-5mvqtxnybmve<\/strong>\",\n                    \"Description\": \"The name of the bucket created above\"\n                }\n            ],\n            \"Tags\": &#91;],\n            \"EnableTerminationProtection\": false,\n            \"DriftInformation\": {\n                \"StackDriftStatus\": \"NOT_CHECKED\"\n            }\n        }\n    ]\n}<\/code><\/pre>\n\n\n\n<p>To view resources created <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws cloudformation describe-stack-resource --stack-name <strong>test2stack<\/strong> --logical-resource-id <strong>DeployLambdafn<\/strong><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>OUTPUT:\n{\n    \"StackResourceDetail\": {\n        \"StackName\": \"test2stack\",\n        \"StackId\": \"arn:aws:cloudformation:us-east-1:111111222222:stack\/test2stack\/a0bf92d0-aa4c-11ee-b5e6-0e5e8cfd4ae1\",\n        \"LogicalResourceId\": \"DeployLambdafn\",\n        \"PhysicalResourceId\": \"test2stack-DeployLambdafn-h0C0XeNsc2kA\",\n        \"ResourceType\": \"AWS::Lambda::Function\",\n        \"LastUpdatedTimestamp\": \"2024-01-03T15:28:25.364000+00:00\",\n        \"ResourceStatus\": \"<strong>CREATE_COMPLETE<\/strong>\",\n        \"Metadata\": \"{}\",\n        \"DriftInformation\": {\n            \"StackResourceDriftStatus\": \"NOT_CHECKED\"\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<p>To view the Lambda function that was created. Note the function name to later look up the CloudWatch logs after you upload an object into the S3 bucket<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws lambda list-functions<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>OUTPUT:\n{\n    \"Functions\": &#91;\n        {\n            \"FunctionName\": \"<strong>test2stack-DeployLambdafn-h0C0XeNsc2kA<\/strong>\",\n            \"FunctionArn\": \"arn:aws:lambda:us-east-1:111111222222:function:test2stack-DeployLambdafn-h0C0XeNsc2kA\",\n            \"Runtime\": \"python3.11\",\n            \"Role\": \"arn:aws:iam::111111222222:role\/test2stack-RootRole-u8yLyd77vTv2\",\n            \"Handler\": \"test.lambda_handler\",\n            \"CodeSize\": 2942,\n            \"Description\": \"test my lambda function\",\n            \"Timeout\": 3,\n            \"MemorySize\": 128,\n            \"LastModified\": \"2024-01-02T22:43:04.080+0000\",\n            \"CodeSha256\": \"3n2cKsIK42Xi9NH\/\/LP8fp9yz3GQ9U9SDYTg2Y7fDzs=\",\n            \"Version\": \"$LATEST\",\n            \"TracingConfig\": {\n                \"Mode\": \"Active\"\n            },\n            \"RevisionId\": \"3a6fe279-4650-47ff-bd68-12d3ab102545\",\n            \"PackageType\": \"Zip\",\n            \"Architectures\": &#91;\n                \"x86_64\"\n            ],\n            \"EphemeralStorage\": {\n                \"Size\": 512\n            },\n            \"SnapStart\": {\n                \"ApplyOn\": \"None\",\n                \"OptimizationStatus\": \"Off\"\n            },\n            \"LoggingConfig\": {\n                \"LogFormat\": \"Text\",\n                \"LogGroup\": \"\/aws\/lambda\/<strong>test2stack-DeployLambdafn-h0C0XeNsc2kA<\/strong>\"\n            }\n        }\n    ]\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Invoke the Lambda function with the Amazon S3 trigger<\/strong><\/h3>\n\n\n\n<p>Two ways to invoke the Lambda function with the S3 trigger:<br>&#8211; AWS Management Console<br>&#8211; AWS CLI<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Invoke the Lambda function via the AWS Management Console<\/h5>\n\n\n\n<ol class=\"wp-block-list\" style=\"padding-right:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--50)\">\n<li>Sign in to the AWS Management Console and search for S3.<\/li>\n\n\n\n<li>Upload the vacation.jpg file in the newly created bucket &#8216;test2stack-s3trigger-5mvqtxnybmve&#8217;<\/li>\n<\/ol>\n\n\n\n<h5 class=\"wp-block-heading\">Invoke the Lambda function via the AWS CLI<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>aws s3api put-object --bucket <strong>test2stack-s3trigger-5mvqtxnybmve<\/strong> --key <strong>vacation.jpg<\/strong> --body <strong>vacation.jpg<\/strong><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>OUTPUT:\n{\n    \"ETag\": \"\\\"95253d1d6618a616babc6905c57b968f\\\"\",\n    \"ServerSideEncryption\": \"AES256\"\n}<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Verify correct operation using CloudWatch Logs<\/strong><\/h5>\n\n\n\n<p>Two ways to view the CloudWatch logs:<br>&#8211; AWS Management Console<br>&#8211; AWS CLI<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">CloudWatch Logs via the AWS Management Console<\/h5>\n\n\n\n<ul class=\"wp-block-list\" style=\"padding-right:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--50)\">\n<li>Sign in to the AWS Management Console and search for CloudWatch.<\/li>\n\n\n\n<li>Select LogGroups on the left<\/li>\n\n\n\n<li>You will notice one log group was created when you uploaded the file<\/li>\n\n\n\n<li>Click on the Log group and in details section, you will notice the Log streams at the bottom of the page<\/li>\n\n\n\n<li>Click the Log stream and you will see the details showing successful execution of your lambda function<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"988\" height=\"290\" src=\"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-3.png\" alt=\"\" class=\"wp-image-2221\" srcset=\"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-3.png 988w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-3-300x88.png 300w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-3-768x225.png 768w\" sizes=\"(max-width: 988px) 100vw, 988px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"586\" src=\"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-4-1024x586.png\" alt=\"\" class=\"wp-image-2222\" srcset=\"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-4-1024x586.png 1024w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-4-300x172.png 300w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-4-768x439.png 768w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-4.png 1028w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">CloudWatch Logs via the AWS CLI<\/h5>\n\n\n\n<p>View the CloudWatch logs to validate the Lambda function executed successfully. Replace the log_group with your Lambda function name. Note the Content Type<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LOG_GROUP=\/aws\/lambda\/<strong>test2stack-DeployLambdafn-h0C0XeNsc2kA<\/strong>\nLOG_STREAM=`aws logs describe-log-streams --log-group-name $LOG_GROUP --max-items 1 --order-by LastEventTime --descending --query logStreams&#91;].logStreamName --output text | head -n 1`<\/code><\/pre>\n\n\n\n<p>aws logs get-log-events &#8211;log-group-name $LOG_GROUP &#8211;log-stream-name $LOG_STREAM &#8211;query events[].message &#8211;output text<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>OUTPUT:\nINIT_START Runtime Version: python:3.11.v25     Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:a3304f2b48f740276b97ad9c52a9cc36a0bd9b44fecf74d0f1416aafb74e92fc\n        Loading function\n        START RequestId: 690275f5-5413-4b4c-b560-8d0b19d5d11c Version: $LATEST\n        <strong>CONTENT TYPE: image\/jpeg<\/strong>\n        END RequestId: 690275f5-5413-4b4c-b560-8d0b19d5d11c\n        REPORT RequestId: 690275f5-5413-4b4c-b560-8d0b19d5d11c  Duration: 299.11 ms     Billed Duration: 300 ms Memory Size: 128 MB         Max Memory Used: 83 MB  Init Duration: 458.82 ms        \nXRAY TraceId: 1-65949531-68b969ac3a8a0f815a4f03d2       SegmentId: 46d42794126d886c     Sampled: true  \n<\/code><\/pre>\n\n\n\n<p>You can also run the following command for more verbose output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws logs tail $LOG_GROUP \u2014follow<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>OUTPUT:\n2024-01-02T22:58:58.155000+00:00 2024\/01\/02\/&#91;$LATEST]82da857ea9d940bba645911e513a27c8 INIT_START Runtime Version: python:3.11.v25  Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:a3304f2b48f740276b97ad9c52a9cc36a0bd9b44fecf74d0f1416aafb74e92fc\n2024-01-02T22:58:58.448000+00:00 2024\/01\/02\/&#91;$LATEST]82da857ea9d940bba645911e513a27c8 Loading function\n2024-01-02T22:58:58.615000+00:00 2024\/01\/02\/&#91;$LATEST]82da857ea9d940bba645911e513a27c8 START RequestId: 690275f5-5413-4b4c-b560-8d0b19d5d11c Version: $LATEST\n2024-01-02T22:58:58.912000+00:00 2024\/01\/02\/&#91;$LATEST]82da857ea9d940bba645911e513a27c8 <strong>CONTENT TYPE: image\/jpeg<\/strong>\n2024-01-02T22:58:58.914000+00:00 2024\/01\/02\/&#91;$LATEST]82da857ea9d940bba645911e513a27c8 END RequestId: 690275f5-5413-4b4c-b560-8d0b19d5d11c\n2024-01-02T22:58:58.914000+00:00 2024\/01\/02\/&#91;$LATEST]82da857ea9d940bba645911e513a27c8 REPORT RequestId: 690275f5-5413-4b4c-b560-8d0b19d5d11c        Duration: 299.11 ms     Billed Duration: 300 ms Memory Size: 128 MB     Max Memory Used: 83 MB  Init Duration: 458.82 ms\nXRAY TraceId: 1-65949531-68b969ac3a8a0f815a4f03d2       SegmentId: 46d42794126d886c     Sampled: true<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Delete the stack<\/h3>\n\n\n\n<p>Two ways to delete the stack:<br>&#8211; AWS Management Console<br>&#8211; AWS CLI<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Delete the stack via AWS Management Console<\/h5>\n\n\n\n<ul class=\"wp-block-list\" style=\"padding-right:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--50)\">\n<li>In the S3 console, empty the bucket by deleting the files. Deleting files is necessary otherwise the delete stack will fail as it cannot delete the bucket if it has files.<\/li>\n\n\n\n<li>In the CloudFormation console, select the stack and click <strong>Delete<\/strong><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"852\" height=\"936\" src=\"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-5.png\" alt=\"\" class=\"wp-image-2226\" style=\"width:655px;height:auto\" srcset=\"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-5.png 852w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-5-273x300.png 273w, https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-5-768x844.png 768w\" sizes=\"(max-width: 852px) 100vw, 852px\" \/><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">Delete the stack via AWS Management Console<\/h5>\n\n\n\n<ul class=\"wp-block-list\" style=\"padding-right:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--50)\">\n<li>Delete the files in the S3 bucket. Deleting files is necessary otherwise the delete stack will fail as it cannot delete the bucket if it has files.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>aws s3 rm s3:\/\/<strong>test2stack-s3trigger-5mvqtxnybmve\/vacation.jpg<\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\" style=\"padding-right:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--50)\">\n<li>Delete the stack<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>aws cloudformation delete-stack --stack-name <strong>test2stack<\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\" style=\"padding-right:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--50)\">\n<li>Validate if the stack was deleted successfully<\/li>\n<\/ul>\n\n\n\n<p>Deleted stacks don&#8217;t show up in the DescribeStacks operation if the deletion has been completed successfully.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws cloudformation describe-stacks<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>OUTPUT:\n{\n    \"Stacks\": &#91;]\n}<\/code><\/pre>\n\n\n\n<p>When you list the lambda functions, it should show empty<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>aws lambda list-functions<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>OUTPUT:\n{\n    \"Functions\": &#91;]\n}<\/code><\/pre>\n\n\n\n<p>Well that&#8217;s the end of the tutorial. Hope you got something out of it. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">References:<\/h3>\n\n\n\n<ul class=\"wp-block-list\" style=\"padding-right:var(--wp--preset--spacing--50);padding-left:var(--wp--preset--spacing--50)\">\n<li><a href=\"https:\/\/docs.aws.amazon.com\/AWSCloudFormation\/latest\/UserGuide\/gettingstarted.templatebasics.html\">https:\/\/docs.aws.amazon.com\/AWSCloudFormation\/latest\/UserGuide\/gettingstarted.templatebasics.html<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.aws.amazon.com\/AWSCloudFormation\/latest\/UserGuide\/GettingStarted.Walkthrough.html\">https:\/\/docs.aws.amazon.com\/AWSCloudFormation\/latest\/UserGuide\/GettingStarted.Walkthrough.html<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/aws-quickstart.github.io\/templates-examples.html\">https:\/\/aws-quickstart.github.io\/templates-examples.html<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/repost.aws\/knowledge-center\/cloudformation-attach-managed-policy\">https:\/\/repost.aws\/knowledge-center\/cloudformation-attach-managed-policy<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.aws.amazon.com\/AWSCloudFormation\/latest\/UserGuide\/aws-resource-lambda-function.html\">https:\/\/docs.aws.amazon.com\/AWSCloudFormation\/latest\/UserGuide\/aws-resource-lambda-function.html<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.aws.amazon.com\/cli\/latest\/reference\/cloudformation\/#cli-aws-cloudformation\">https:\/\/docs.aws.amazon.com\/cli\/latest\/reference\/cloudformation\/#cli-aws-cloudformation<\/a><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous tutorial, I showed how to use AWS SDK and Python to deploy an existing Lambda function and configure a trigger for an Amazon S3 bucket. In this tutorial, we will repeat the same steps but using AWS CloudFormation template instead of AWS SDK and Python. Every time we add an object to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[12,41,24,25],"tags":[20,43,26,27],"class_list":["post-2207","post","type-post","status-publish","format-standard","hentry","category-aws-tutorial","category-cloudformation","category-lambda","category-s3","tag-cli","tag-cloudformation","tag-lambda","tag-s3"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>HOWTO: AWS CloudFormation and AWS CLI to build Lambda - maghilda<\/title>\n<meta name=\"description\" content=\"AWS CloudFormation to create and delete stacks\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HOWTO: AWS CloudFormation and AWS CLI to build Lambda - maghilda\" \/>\n<meta property=\"og:description\" content=\"AWS CloudFormation to create and delete stacks\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/\" \/>\n<meta property=\"og:site_name\" content=\"maghilda\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-03T19:04:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-08T00:09:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-1024x589.png\" \/>\n<meta name=\"author\" content=\"vibs\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"vibs\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/aws-cloudformation-and-aws-cli-to-invoke-lambda\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/aws-cloudformation-and-aws-cli-to-invoke-lambda\\\/\"},\"author\":{\"name\":\"vibs\",\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/#\\\/schema\\\/person\\\/21009c5e4f1817ea18c81d5004bcec1e\"},\"headline\":\"HOWTO: AWS CloudFormation and AWS CLI to build Lambda\",\"datePublished\":\"2024-01-03T19:04:20+00:00\",\"dateModified\":\"2024-01-08T00:09:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/aws-cloudformation-and-aws-cli-to-invoke-lambda\\\/\"},\"wordCount\":1255,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/aws-cloudformation-and-aws-cli-to-invoke-lambda\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/image-1024x589.png\",\"keywords\":[\"cli\",\"cloudformation\",\"Lambda\",\"S3\"],\"articleSection\":[\"AWS Tutorial\",\"CloudFormation\",\"Lambda\",\"S3\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/aws-cloudformation-and-aws-cli-to-invoke-lambda\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/aws-cloudformation-and-aws-cli-to-invoke-lambda\\\/\",\"url\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/aws-cloudformation-and-aws-cli-to-invoke-lambda\\\/\",\"name\":\"HOWTO: AWS CloudFormation and AWS CLI to build Lambda - maghilda\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/aws-cloudformation-and-aws-cli-to-invoke-lambda\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/aws-cloudformation-and-aws-cli-to-invoke-lambda\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/image-1024x589.png\",\"datePublished\":\"2024-01-03T19:04:20+00:00\",\"dateModified\":\"2024-01-08T00:09:19+00:00\",\"description\":\"AWS CloudFormation to create and delete stacks\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/aws-cloudformation-and-aws-cli-to-invoke-lambda\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/aws-cloudformation-and-aws-cli-to-invoke-lambda\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/aws-cloudformation-and-aws-cli-to-invoke-lambda\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/image.png\",\"contentUrl\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/image.png\",\"width\":1136,\"height\":653},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/aws-cloudformation-and-aws-cli-to-invoke-lambda\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"HOWTO: AWS CloudFormation and AWS CLI to build Lambda\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/#website\",\"url\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/\",\"name\":\"maghilda.com\",\"description\":\"Technology blog focused on cloud computing, emerging technologies, software development and security.\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/#organization\",\"name\":\"maghilda.com\",\"url\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/cropped-logo_red.png\",\"contentUrl\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/cropped-logo_red.png\",\"width\":512,\"height\":512,\"caption\":\"maghilda.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/#\\\/schema\\\/person\\\/21009c5e4f1817ea18c81d5004bcec1e\",\"name\":\"vibs\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/28233c799bf0736fecb2854057b69e52d9bd97b467b55be3406890936003faee?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/28233c799bf0736fecb2854057b69e52d9bd97b467b55be3406890936003faee?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/28233c799bf0736fecb2854057b69e52d9bd97b467b55be3406890936003faee?s=96&d=mm&r=g\",\"caption\":\"vibs\"},\"sameAs\":[\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\"],\"url\":\"https:\\\/\\\/www.maghilda.com\\\/staging\\\/9669\\\/author\\\/obliczte\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"HOWTO: AWS CloudFormation and AWS CLI to build Lambda - maghilda","description":"AWS CloudFormation to create and delete stacks","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/","og_locale":"en_US","og_type":"article","og_title":"HOWTO: AWS CloudFormation and AWS CLI to build Lambda - maghilda","og_description":"AWS CloudFormation to create and delete stacks","og_url":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/","og_site_name":"maghilda","article_published_time":"2024-01-03T19:04:20+00:00","article_modified_time":"2024-01-08T00:09:19+00:00","og_image":[{"url":"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-1024x589.png","type":"","width":"","height":""}],"author":"vibs","twitter_card":"summary_large_image","twitter_misc":{"Written by":"vibs","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/#article","isPartOf":{"@id":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/"},"author":{"name":"vibs","@id":"https:\/\/www.maghilda.com\/staging\/9669\/#\/schema\/person\/21009c5e4f1817ea18c81d5004bcec1e"},"headline":"HOWTO: AWS CloudFormation and AWS CLI to build Lambda","datePublished":"2024-01-03T19:04:20+00:00","dateModified":"2024-01-08T00:09:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/"},"wordCount":1255,"commentCount":0,"publisher":{"@id":"https:\/\/www.maghilda.com\/staging\/9669\/#organization"},"image":{"@id":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/#primaryimage"},"thumbnailUrl":"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-1024x589.png","keywords":["cli","cloudformation","Lambda","S3"],"articleSection":["AWS Tutorial","CloudFormation","Lambda","S3"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/","url":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/","name":"HOWTO: AWS CloudFormation and AWS CLI to build Lambda - maghilda","isPartOf":{"@id":"https:\/\/www.maghilda.com\/staging\/9669\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/#primaryimage"},"image":{"@id":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/#primaryimage"},"thumbnailUrl":"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image-1024x589.png","datePublished":"2024-01-03T19:04:20+00:00","dateModified":"2024-01-08T00:09:19+00:00","description":"AWS CloudFormation to create and delete stacks","breadcrumb":{"@id":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/#primaryimage","url":"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image.png","contentUrl":"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2024\/01\/image.png","width":1136,"height":653},{"@type":"BreadcrumbList","@id":"https:\/\/www.maghilda.com\/staging\/9669\/aws-cloudformation-and-aws-cli-to-invoke-lambda\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.maghilda.com\/staging\/9669\/"},{"@type":"ListItem","position":2,"name":"HOWTO: AWS CloudFormation and AWS CLI to build Lambda"}]},{"@type":"WebSite","@id":"https:\/\/www.maghilda.com\/staging\/9669\/#website","url":"https:\/\/www.maghilda.com\/staging\/9669\/","name":"maghilda.com","description":"Technology blog focused on cloud computing, emerging technologies, software development and security.","publisher":{"@id":"https:\/\/www.maghilda.com\/staging\/9669\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.maghilda.com\/staging\/9669\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.maghilda.com\/staging\/9669\/#organization","name":"maghilda.com","url":"https:\/\/www.maghilda.com\/staging\/9669\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.maghilda.com\/staging\/9669\/#\/schema\/logo\/image\/","url":"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2023\/12\/cropped-logo_red.png","contentUrl":"https:\/\/www.maghilda.com\/staging\/9669\/wp-content\/uploads\/2023\/12\/cropped-logo_red.png","width":512,"height":512,"caption":"maghilda.com"},"image":{"@id":"https:\/\/www.maghilda.com\/staging\/9669\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.maghilda.com\/staging\/9669\/#\/schema\/person\/21009c5e4f1817ea18c81d5004bcec1e","name":"vibs","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/28233c799bf0736fecb2854057b69e52d9bd97b467b55be3406890936003faee?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/28233c799bf0736fecb2854057b69e52d9bd97b467b55be3406890936003faee?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/28233c799bf0736fecb2854057b69e52d9bd97b467b55be3406890936003faee?s=96&d=mm&r=g","caption":"vibs"},"sameAs":["https:\/\/www.maghilda.com\/staging\/9669"],"url":"https:\/\/www.maghilda.com\/staging\/9669\/author\/obliczte\/"}]}},"_links":{"self":[{"href":"https:\/\/www.maghilda.com\/staging\/9669\/wp-json\/wp\/v2\/posts\/2207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.maghilda.com\/staging\/9669\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.maghilda.com\/staging\/9669\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.maghilda.com\/staging\/9669\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.maghilda.com\/staging\/9669\/wp-json\/wp\/v2\/comments?post=2207"}],"version-history":[{"count":4,"href":"https:\/\/www.maghilda.com\/staging\/9669\/wp-json\/wp\/v2\/posts\/2207\/revisions"}],"predecessor-version":[{"id":2375,"href":"https:\/\/www.maghilda.com\/staging\/9669\/wp-json\/wp\/v2\/posts\/2207\/revisions\/2375"}],"wp:attachment":[{"href":"https:\/\/www.maghilda.com\/staging\/9669\/wp-json\/wp\/v2\/media?parent=2207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.maghilda.com\/staging\/9669\/wp-json\/wp\/v2\/categories?post=2207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.maghilda.com\/staging\/9669\/wp-json\/wp\/v2\/tags?post=2207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}