# Day 34: Create a Lambda Function Using CLI

Welcome from Day 34. Today we will learn how to create a lambda function using cli. In this lab you just need to create a Lambda function using cli not from AWS management console.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767341170780/eddca8aa-3178-4fcc-a52c-86c0fa76843b.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767341739207/32650d71-05aa-46e0-94c5-9284a0865c5d.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767341805826/ca1ed6d9-3ff3-4516-a123-e94efa76f058.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767341890943/1a8e6de2-933e-479f-9627-7e9643e717dc.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767341976584/d3f42b39-af36-4dc7-b8e2-5164ad303d11.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767342049885/77b367e2-0456-44b9-919b-a35fc8b023a3.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767342076770/19d586ac-c10e-4e90-9452-009f49217eb2.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1767342092363/08d6ad2e-fc08-40bd-8046-063f162f58ef.png align="center")

```bash
vi lambda_function.py

def lambda_handler(event, context):
    return {
        "statusCode": 200,
        "body": "Welcome to KKE AWS Labs!"
    }
```

```bash
zip function.zip lambda_function.py
```

```bash
aws iam get-role --role-name lambda_execution_role
```

```bash
aws lambda create-function --function-name xfusion-lambda-cli --runtime python3.9 --role arn:aws:iam::123456789012:role/lambda_execution_role --handler lambda_function.lambda_handler --zip-file fileb://function.zip
```

```bash
aws lambda invoke --function-name xfusion-lambda-cli response.json
```

Congratulations you did it. It looks good. This lab was successfully completed without any errors. See you in day 35. If you have any issues please let me know I will be happy to assist you. Stay tuned and learn together. If you find my article useful, please kindly like and share it.
