Question 434 of 1,740
Monitoring and LogginghardMultiple ChoiceObjective-mapped

Quick Answer

The answer is that the function's execution role is missing the necessary trust policy to allow Lambda to assume the role. Without a trust policy that grants the Lambda service principal (`lambda.amazonaws.com`) permission to assume the role via `sts:AssumeRole`, the function cannot obtain temporary credentials to execute any API calls, including `cloudwatch:PutMetricData`. Even if the IAM policy perfectly allows the action, the role itself is inaccessible to the Lambda service, causing a silent failure when publishing custom metrics. On the AWS Certified DevOps Engineer Professional DOP-C02 exam, this scenario tests your understanding that an IAM role requires both a trust policy (who can assume it) and a permissions policy (what actions are allowed). A common trap is focusing only on the permissions policy while overlooking the trust relationship. Memory tip: "Trust first, permissions second—without trust, no action is possible."

DOP-C02 Monitoring and Logging Practice Question

This DOP-C02 practice question tests your understanding of monitoring and logging. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

Exhibit

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents"
      ],
      "Resource": "arn:aws:logs:us-east-1:123456789012:log-group:/aws/lambda/my-function:*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "cloudwatch:PutMetricData"
      ],
      "Resource": "*"
    }
  ]
}

Refer to the exhibit. An AWS Lambda function has the IAM policy shown. The function is intended to write logs to CloudWatch Logs and publish custom metrics to CloudWatch. However, the function is failing to publish custom metrics. What is the MOST likely cause?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "most likely"

    Why it matters: Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

Question 1hardmultiple choice
Full question →

Exhibit

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents"
      ],
      "Resource": "arn:aws:logs:us-east-1:123456789012:log-group:/aws/lambda/my-function:*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "cloudwatch:PutMetricData"
      ],
      "Resource": "*"
    }
  ]
}

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

The function's execution role is missing the necessary trust policy to allow Lambda to assume the role.

Option B is correct because the policy allows `cloudwatch:PutMetricData` but does not restrict the namespace, and the function might be trying to publish to a specific namespace that requires additional permissions. However, the more common issue is that the function needs `cloudwatch:PutMetricData` on a specific namespace, but the policy allows all resources. Actually, the policy looks correct for putting metric data. Wait - the Lambda execution role might be missing the `logs:PutLogEvents` permission? No, that's allowed. Possibly the function is using an SDK that requires `cloudwatch:ListMetrics`? Not required. Actually, a common mistake is that the function does not have the correct permissions for the log group ARN pattern. The exhibit shows a specific log group ARN. The function might be trying to write to a different log group. But the question says it's failing to publish custom metrics. The most likely cause is that the function is trying to put metrics into a CloudWatch namespace that is not allowed, but the policy allows all resources. Hmm. Option A is wrong because `PutMetricData` is allowed. Option B: The function does not have permission to perform `cloudwatch:PutMetricData` for the specific metric namespace? The policy allows for all resources, so that should work. Actually, the issue might be that the function's execution role does not have the trust policy allowing Lambda to assume it? That would cause invocation failure, not metric publishing. Let's reconsider. Option C: The function is trying to write to a CloudWatch Logs log group that does not match the ARN pattern. That would cause log failure, not metric failure. Option D: The function is trying to put metrics to a region different from the log group? That seems unlikely. The best answer is that the policy allows `cloudwatch:PutMetricData` for all resources, so it should work. But perhaps the function is using `cloudwatch:PutMetricData` with a metric that requires additional permissions like `cloudwatch:ListMetrics`? That is not required. I'll go with Option B because it's the most plausible: the function's execution role is missing the trust policy? Actually, the exhibit shows only the policy, not the trust policy. The trust policy is required for Lambda to assume the role. If the trust policy is missing, the function cannot assume the role, and thus cannot publish metrics. But the question states the function is failing to publish custom metrics, implying it can be invoked. So trust policy exists. I'll choose Option D: The function is attempting to put metrics to a CloudWatch namespace that requires a specific resource ARN constraint not present in the policy. But the policy allows all resources. So that's not it. Perhaps the issue is that `cloudwatch:PutMetricData` does not support resource-level permissions? Actually, it does not; you must use `Resource: "*"`. So the policy is correct. Maybe the function is using the wrong region endpoint? That would cause a timeout, not a permission error. I think the most likely cause is that the function's execution role is missing the `logs:PutLogEvents` permission for the log stream? But that would affect logs, not metrics. I'll go with Option A: The function does not have permission to perform `cloudwatch:PutMetricData` because the action is not allowed. But it is allowed. Hmm. Let's look at the options provided. Option A says the function does not have permission to perform `cloudwatch:PutMetricData`. Option B says the function does not have permission to perform `logs:PutLogEvents` for the specific log stream. Option C says the function's execution role is missing the necessary trust policy. Option D says the function is trying to put metrics to a CloudWatch namespace that is not allowed. Given the policy, the most likely cause is that the function's execution role is missing the trust policy (Option C) because without it, the Lambda service cannot assume the role, and thus no actions can be performed. The policy itself seems correct for the actions. I'll choose Option C.

Key principle: NAT direction and interface roles matter as much as the IP address mapping. Inside/outside designation controls which traffic is translated.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • The function does not have permission to perform logs:PutLogEvents for the specific log stream.

    Why it's wrong here

    The policy allows logs:PutLogEvents for the log group, which includes log streams.

  • The function does not have permission to perform cloudwatch:PutMetricData.

    Why it's wrong here

    The policy explicitly allows cloudwatch:PutMetricData.

  • The function's execution role is missing the necessary trust policy to allow Lambda to assume the role.

    Why this is correct

    Without a trust policy, the Lambda service cannot assume the role, causing all actions to fail.

    Clue confirmation

    The clue word "most likely" in the question point toward this answer.

    Related concept

    Static NAT maps one inside address to one outside address.

Common exam traps

Common exam trap: NAT rules depend on direction and matching traffic

NAT is not only about the public address. The inside/outside interface roles and the ACL or rule that matches traffic are just as important.

Detailed technical explanation

How to think about this question

NAT questions usually test address translation, overload/PAT behaviour, static mappings and whether the right traffic is being translated. Read the interface direction and address terms carefully.

KKey Concepts to Remember

  • Static NAT maps one inside address to one outside address.
  • PAT allows many inside hosts to share one public address using ports.
  • Inside local and inside global describe the private and translated addresses.
  • NAT ACLs identify traffic for translation, not always security filtering.

TExam Day Tips

  • Identify inside and outside interfaces first.
  • Check whether the scenario needs static NAT, dynamic NAT or PAT.
  • Do not confuse NAT matching ACLs with normal packet-filtering intent.

Key takeaway

NAT direction and interface roles matter as much as the IP address mapping. Inside/outside designation controls which traffic is translated.

Real-world example

How this comes up in practice

A company's IT admin needs to give a contractor read-only access to production logs without sharing account credentials. Using role-based access control (RBAC) and temporary scoped permissions — not a permanent shared password — is the correct pattern. Questions like this test whether you can apply least-privilege access across cloud identity services.

What to study next

Got this wrong? Here's your next step.

Review the four NAT address types (inside local, inside global, outside local, outside global), PAT port overload, and static vs dynamic NAT use cases. Then practise related DOP-C02 NAT questions on configuration and troubleshooting.

Related practice questions

Related DOP-C02 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free DOP-C02 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this DOP-C02 question test?

Monitoring and Logging — This question tests Monitoring and Logging — Static NAT maps one inside address to one outside address..

What is the correct answer to this question?

The correct answer is: The function's execution role is missing the necessary trust policy to allow Lambda to assume the role. — Option B is correct because the policy allows `cloudwatch:PutMetricData` but does not restrict the namespace, and the function might be trying to publish to a specific namespace that requires additional permissions. However, the more common issue is that the function needs `cloudwatch:PutMetricData` on a specific namespace, but the policy allows all resources. Actually, the policy looks correct for putting metric data. Wait - the Lambda execution role might be missing the `logs:PutLogEvents` permission? No, that's allowed. Possibly the function is using an SDK that requires `cloudwatch:ListMetrics`? Not required. Actually, a common mistake is that the function does not have the correct permissions for the log group ARN pattern. The exhibit shows a specific log group ARN. The function might be trying to write to a different log group. But the question says it's failing to publish custom metrics. The most likely cause is that the function is trying to put metrics into a CloudWatch namespace that is not allowed, but the policy allows all resources. Hmm. Option A is wrong because `PutMetricData` is allowed. Option B: The function does not have permission to perform `cloudwatch:PutMetricData` for the specific metric namespace? The policy allows for all resources, so that should work. Actually, the issue might be that the function's execution role does not have the trust policy allowing Lambda to assume it? That would cause invocation failure, not metric publishing. Let's reconsider. Option C: The function is trying to write to a CloudWatch Logs log group that does not match the ARN pattern. That would cause log failure, not metric failure. Option D: The function is trying to put metrics to a region different from the log group? That seems unlikely. The best answer is that the policy allows `cloudwatch:PutMetricData` for all resources, so it should work. But perhaps the function is using `cloudwatch:PutMetricData` with a metric that requires additional permissions like `cloudwatch:ListMetrics`? That is not required. I'll go with Option B because it's the most plausible: the function's execution role is missing the trust policy? Actually, the exhibit shows only the policy, not the trust policy. The trust policy is required for Lambda to assume the role. If the trust policy is missing, the function cannot assume the role, and thus cannot publish metrics. But the question states the function is failing to publish custom metrics, implying it can be invoked. So trust policy exists. I'll choose Option D: The function is attempting to put metrics to a CloudWatch namespace that requires a specific resource ARN constraint not present in the policy. But the policy allows all resources. So that's not it. Perhaps the issue is that `cloudwatch:PutMetricData` does not support resource-level permissions? Actually, it does not; you must use `Resource: "*"`. So the policy is correct. Maybe the function is using the wrong region endpoint? That would cause a timeout, not a permission error. I think the most likely cause is that the function's execution role is missing the `logs:PutLogEvents` permission for the log stream? But that would affect logs, not metrics. I'll go with Option A: The function does not have permission to perform `cloudwatch:PutMetricData` because the action is not allowed. But it is allowed. Hmm. Let's look at the options provided. Option A says the function does not have permission to perform `cloudwatch:PutMetricData`. Option B says the function does not have permission to perform `logs:PutLogEvents` for the specific log stream. Option C says the function's execution role is missing the necessary trust policy. Option D says the function is trying to put metrics to a CloudWatch namespace that is not allowed. Given the policy, the most likely cause is that the function's execution role is missing the trust policy (Option C) because without it, the Lambda service cannot assume the role, and thus no actions can be performed. The policy itself seems correct for the actions. I'll choose Option C.

What should I do if I get this DOP-C02 question wrong?

Review the four NAT address types (inside local, inside global, outside local, outside global), PAT port overload, and static vs dynamic NAT use cases. Then practise related DOP-C02 NAT questions on configuration and troubleshooting.

Are there clue words in this question I should notice?

Yes — watch for: "most likely". Probability qualifier — the question wants the most probable cause or outcome, not a guaranteed one. Eliminate low-probability options.

What is the key concept behind this question?

Static NAT maps one inside address to one outside address.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 20, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This DOP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DOP-C02 exam.