Certopolis

AWS Certified Developer – Associate

Lambda invocation vs execution errors: DVA-C03 troubleshooting

The Lambda Developer Guide separates two kinds of problem. Invocation errors happen before your code runs, for example missing permissions, throttling, a missing bootstrap file or an Init phase timeout, and they use 400 and 500-series status codes. Execution errors come from your code and return 200 with an X-Amz-Function-Error header.

What goes wrong before the handler runs?

Lambda validates the request and checks scaling capacity before it sends the event to the function. A direct caller sees invocation errors in the response. The caller needs lambda:InvokeFunction, and another service or account needs a statement in the function's resource-based policy.

Sandbox.Timedout with Task timed out after 3.00 seconds can be an Init phase timeout. Lambda runs Init again when the next request arrives, which is called a suppressed init. With a short timeout that second Init can time out again, or leave too little time for the Invoke phase. The fixes are a longer timeout, more memory (which also gives more CPU) or less initialization work.

Runtime.InvalidEntrypoint with Couldn't find valid bootstrap(s) usually means the root of the deployment package has no executable file named bootstrap. For a provided.al2023 function deployed as a .zip file, bootstrap must be at the root of the archive, not in a directory.

How does concurrency cause or stop invocations?

If one function uses all available concurrency, other functions are throttled. Reserved concurrency divides the account's concurrency into pools: the function can always scale to its reserved amount and never beyond it.

A function that writes to the same S3 bucket that triggers it can invoke itself in a loop. The first step is to reduce its available concurrency to zero, which throttles all future invocations. Setting reserved concurrency to 0 does this, and the function processes no events until you remove the limit. Then fix the code path, for example by writing to a different prefix or suffix from the one the trigger matches.

Provisioned concurrency has its own symptoms. It cannot be configured on $LATEST, so a trigger that invokes $LATEST gets cold starts. A non-zero ProvisionedConcurrencySpilloverInvocations metric means all provisioned concurrency was in use. During alias routing, traffic is split by a probabilistic model, and AWS advises a higher provisioned concurrency setting while routing is active.

What goes wrong during execution?

To see which version ran, read the function's logs. The version that was invoked is always shown on the START log line. Invocations that name no version or alias go to $LATEST.

If logs or traces do not appear, the execution role needs AWSLambdaBasicExecutionRole for CloudWatch Logs and AWSXRayDaemonWriteAccess for X-Ray. After adding permissions, make a trivial update to the function's code or configuration. That replaces running instances, which still hold outdated credentials. Logs can take 5 to 10 minutes to show up.

If only some logs are missing, look at volume. When a function writes logs faster than Lambda can send them, Lambda drops logs so that the function is not slowed down. Expect this above 2 MB/s for a single log stream. With JSON formatted logs, Lambda tries to write a logsDropped event. CloudWatch Logs quotas such as the PutLogEvents throttle limit can also throttle logging.

Where the exam catches people

  • Believing an error thrown by your code returns a 4xx or 5xx status: Lambda returns 200 with the X-Amz-Function-Error header. The 400 and 500 series are for invocation errors.
  • Believing that attaching a logging policy fixes running environments at once: they keep outdated credentials until a trivial code or configuration update replaces them.
  • Believing bootstrap can sit in a subdirectory of the .zip file: for provided.al2023 it must be an executable at the root.
  • Believing a looping function is stopped by changing retry settings: the documented step is to reduce concurrency to zero, which reserved concurrency of 0 does.
  • Believing missing log lines always mean missing permissions: above about 2 MB/s on one log stream, Lambda drops logs.

Written from these sources

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. An AWS Lambda function is invoked by object-created event notifications from an Amazon S3 bucket, and it writes a resized copy of each object back to the same bucket. After a deployment, the function invokes itself in a continuous loop and its costs climb quickly. The developer must stop every further invocation immediately while the cause is investigated. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Troubleshooting and Optimization building.

    Not that one: C is right. In the game your Troubleshooting and Optimization building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Setting reserved concurrency to 0 is how that is done. With the loop halted, the developer can find the code path or configuration that caused it; the lasting fixes are writing to a different bucket, or to a prefix or suffix that the notification does not match.

    Written from docs.aws.amazon.com/lambda/latest/dg/troubleshooting-invocation.html

  2. A developer builds a Go application for an AWS Lambda function that uses the provided.al2023 runtime. The build writes an executable named orders-api into a directory named build, and the developer uploads a .zip file of that directory. Every invocation fails with Runtime.InvalidEntrypoint. The function must start, and it must keep the provided.al2023 runtime. Which combination of steps should the developer take to meet these requirements? (Select TWO.)

    Right. In the game that’s Renown for your Troubleshooting and Optimization building.

    Not that one: B,D is right. In the game your Troubleshooting and Optimization building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    This package fails both conditions, so both changes are needed: the executable must be named bootstrap, and it must sit at the root of the .zip file. Either one alone still leaves no bootstrap at the root.

    Written from docs.aws.amazon.com/lambda/latest/dg/troubleshooting-invocation.html

  3. A developer publishes version 7 of an AWS Lambda function and points the function's live alias to it. Another team reports that its calls still behave like the old code. The developer must use the function's log streams in Amazon CloudWatch Logs to find out which version of the function each of the team's invocations ran. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Troubleshooting and Optimization building.

    Not that one: C is right. In the game your Troubleshooting and Optimization building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Lambda writes a START line at the beginning of every invocation, so each of the team's invocations can be matched to the version it ran.

    Written from docs.aws.amazon.com/lambda/latest/dg/troubleshooting-execution.html

Ask for something