Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.


Add question

You must login to ask a question.

Login

Register Now

Lorem ipsum dolor sit amet, consectetur adipiscing elit.Morbi adipiscing gravdio, sit amet suscipit risus ultrices eu.Fusce viverra neque at purus laoreet consequa.Vivamus vulputate posuere nisl quis consequat.

AWS CLI script that creates an AWS Lambda function:

AWS CLI script that creates an AWS Lambda function:

Here is an AWS CLI script that creates an AWS Lambda function:

First we need to create IAM Role to attach Lambda Function


AWS CLI script to create AWS IAM Role
aws iam create-role --role-name Lambda_Role --assume-role-policy-document '{"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Principal": {"Service": "lambda.amazonaws.com"}, "Action": "sts:AssumeRole"}]}' --query "Role.Arn"

Output

"arn:aws:iam::xxxxxxxxxxxx:role/Lambda_Role"

Lambda Function AWS CLI Script

aws lambda create-function \
  --function-name Lambda_function \
  --runtime nodejs12.x \
  --role arn:aws:iam::xxxxxxxxxxx:role/Lambda_Role \
  --handler "index.handler" \
  --zip-file fileb://function.zip \
  --region us-east-1

Output

{
    "FunctionName": "Lambda_function",
    "FunctionArn": "arn:aws:lambda:us-east-1:xxxxxxxxxxx:function:Lambda_function",
    "Runtime": "nodejs12.x",
    "Role": "arn:aws:iam::xxxxxxxxxxx:role/Lambda_Role",
    "Handler": "index.handler",
    "CodeSize": 20272963,
    "Description": "",
    "Timeout": 3,
    "MemorySize": 128,
    "LastModified": "2023-02-11T14:51:04.540+0000",
    "CodeSha256": "w+RpB/YhWdBZIzquIRNkem48Z0sJ1KG47unN69C2nIU=",
    "Version": "$LATEST",
    "TracingConfig": {
        "Mode": "PassThrough"
    },
    "RevisionId": "85bcd9fd-3aa8-4038-8da4-5789ff4ea0f6",
    "State": "Pending",
    "StateReason": "The function is being created.",
    "StateReasonCode": "Creating",
    "PackageType": "Zip",
    "Architectures": [
        "x86_64"
    ],
    "EphemeralStorage": {
        "Size": 512
    },
    "SnapStart": {
        "ApplyOn": "None",
        "OptimizationStatus": "Off"
    }
}
ALSO READ  Updating AWS EKS Kubeconfig: Secure Access to your Kubernetes Cluster

About Abhay Singh

I'm Abhay Singh, an Architect with 9 Years of It experience. AWS Certified Solutions Architect.

Follow Me

Leave a reply