Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in AWS by (19.1k points)

I am trying to use environment variables for my lambda but when I run the following Lambda AWS CLI create-function command from a Gradle task that runs a shell script,

aws $PROFILESTR lambda create-function \

--region us-east-1 \

--function-name MyLambda \

--zip-file fileb://$ZIP \

--role arn:aws:iam::$AWS_ACCT_ID:role/my_lambda \

--handler com.test.MyLambda::handleRequest \

--runtime java8 \

--description "Lambda description..." \

--memory-size 256 \

--timeout 45 \

--environment Variables={DEV_URL=dev,PROD_URL=prod}

it gives me this message and doesn't create the lambda function

:my-lambda:createLambda

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]

To see help text, you can run:

  aws help

  aws <command> help

  aws <command> <subcommand> help

Unknown options: Variables=PROD_URL=prod

:my-lambda:createLambda FAILED

If I remove the second variable (declare only one env variable), it creates the function just fine.

From the lambda create-function cli documentation, the environment option accepts multiple variables:

--environment (structure)

The parent object that contains your environment's configuration settings. Shorthand Syntax:

Variables={KeyName1=string,KeyName2=string}

I should be able to create the lambda through a script and not through AWS console (release should be automated).

What am I missing here or what am I doing wrong?

1 Answer

+1 vote
by (44.3k points)

Try it with this:

Variables="{KeyName1=string,KeyName2=string}"

by (110 points)
Thanks, It worked.

Related questions

Browse Categories

...