0
0
AWScloud~10 mins

Creating a Lambda function in AWS - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the runtime environment for the Lambda function.

AWS
lambda_function = aws.lambda_.Function("MyFunction",
    runtime=aws.lambda_.Runtime.[1],
    handler="index.handler",
    code=aws.lambda_.Code.from_asset("./app")
)
Drag options to blanks, or click blank then click option'
ANODEJS_14_X
BPYTHON_3_8
CJAVA_11
DGO_1_X
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a runtime that does not match the code language.
Using an outdated or unsupported runtime.
2fill in blank
medium

Complete the code to set the Lambda function's handler correctly.

AWS
lambda_function = aws.lambda_.Function("MyFunction",
    runtime=aws.lambda_.Runtime.NODEJS_14_X,
    handler="[1]",
    code=aws.lambda_.Code.from_asset("./app")
)
Drag options to blanks, or click blank then click option'
Amain.handler
Bapp.main
Chandler.index
Dindex.handler
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of file and function names.
Using a handler name that does not exist in the code.
3fill in blank
hard

Fix the error in the code by choosing the correct method to load the Lambda function code from a local folder.

AWS
lambda_function = aws.lambda_.Function("MyFunction",
    runtime=aws.lambda_.Runtime.NODEJS_14_X,
    handler="index.handler",
    code=aws.lambda_.Code.[1]("./app")
)
Drag options to blanks, or click blank then click option'
Afrom_file
Bfrom_directory
Cfrom_asset
Dfrom_path
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like from_file or from_path.
Confusing with other AWS SDK methods.
4fill in blank
hard

Fill both blanks to add environment variables to the Lambda function.

AWS
lambda_function = aws.lambda_.Function("MyFunction",
    runtime=aws.lambda_.Runtime.NODEJS_14_X,
    handler="index.handler",
    code=aws.lambda_.Code.from_asset("./app"),
    environment={
        [1],
        [2]
    }
)
Drag options to blanks, or click blank then click option'
A"STAGE": "prod"
B"ENV": "dev"
C"DEBUG": "true"
D"VERSION": "1.0"
Attempts:
3 left
💡 Hint
Common Mistakes
Passing environment variables as strings instead of dictionaries.
Using invalid JSON syntax.
5fill in blank
hard

Fill all three blanks to create a Lambda function with a timeout, memory size, and description.

AWS
lambda_function = aws.lambda_.Function("MyFunction",
    runtime=aws.lambda_.Runtime.NODEJS_14_X,
    handler="index.handler",
    code=aws.lambda_.Code.from_asset("./app"),
    timeout=[1],
    memory_size=[2],
    description=[3]
)
Drag options to blanks, or click blank then click option'
ADuration.seconds(10)
B128
C"My Lambda function for processing"
DDuration.minutes(5)
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect Duration methods or units.
Setting memory size as string instead of number.
Omitting quotes around description string.