A Decade of Wisdom: Mastering AWS CloudFormation for Effortless Deployment of Basic AWS Lambda Functions
Introduction :-
The provided AWS CloudFormation (CF) template represents a foundational piece of infrastructure as code (IaC) that defines the configuration for deploying an AWS Lambda function. AWS CloudFormation is a powerful service that allows users to automate the creation, modification, and deletion of AWS resources by defining them in a template format. In this specific template, we are orchestrating the deployment of a serverless AWS Lambda function, which is a compute service that enables you to run code without provisioning or managing servers.
Pre-requesties:-
- An AWS Account with Proper permissions
Step 1: Log in to AWS Console
Ensure you are logged in to your AWS account in the AWS Management Console.
Step 2: Access CloudFormation
In the AWS Management Console, navigate to the “Services” menu and select “Management & Governance.”
Click on “CloudFormation” under the “Management & Governance” section.
In the CloudFormation dashboard, click the “Create stack” button.
In the “Specify template” section, select “Upload a template file.”
“Choose file” and select the YAML template file you have, which is the one you provided.
6. Click “Next.”
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
EnvironmentName:
Description: Environment name for the application
Type: String
Default: dev
ApplicationName:
Description: Application Name
Type: String
Default: mahiratechnology-lambda
Mappings: {}
Conditions: {}
Resources:
Lambda:
Type: AWS::Serverless::Function
Properties:
PackageType: Zip
Handler: index.handler
MemorySize: 128
Runtime: nodejs16.x
Timeout: 30
FunctionName: !Sub ${EnvironmentName}-${ApplicationName}
Environment:
Variables:
NODE_ENV: !Ref EnvironmentName
Policies:
- AWSLambdaVPCAccessExecutionRole
- Version: '2012-10-17'
Statement:
- Action: '*'
Resource: '*'
Effect: Allow
Outputs:
LambdaFunctionConsoleUrl:
Description: Console URL for the Lambda Function.
Value: !Sub 'https://${AWS::Region}.console.aws.amazon.com/lambda/home?region=${AWS::Region}#/functions/${Lambda}'
2.7 You can configure advanced options like tags, permissions, and more if needed.
2.8 Review the stack configuration to ensure everything is correct.
2.9 Create Stack
2.10 After reviewing, click the “Create stack” button to start the stack creation process.
2.11 The CloudFormation stack creation will take some time. You can monitor the progress on the CloudFormation dashboard.
Conclusion:-
In summary, this AWS CloudFormation template simplifies the provisioning of an AWS Lambda function by encapsulating its configuration in a structured, reusable format. Users can create CloudFormation stacks based on this template, providing the necessary parameters such as environment and application names. This automation reduces manual configuration efforts and ensures consistent and reliable Lambda function deployments. By leveraging AWS CloudFormation, developers and system administrators can efficiently manage and maintain their AWS resources as code, further enhancing the agility and scalability of their applications hosted on the AWS cloud platform.
#Aws #lambda #cloudformation #template #Devops #Best Practices ##AWS #CloudFormation #AWSLambda #InfrastructureAsCode #Serverless #DevOps #CloudComputing #AWSAutomation #TechTutorial #AWSInfrastructure #LambdaFunction #InfrastructureManagement #CloudDevelopment #AWSBestPractices #TechHowTo #AWSArchitecture #ServerlessComputing #AWSBeginner #Coding #CloudDeployment