Question 406 of 1,746
Design for New SolutionshardMultiple ChoiceObjective-mapped

SAP-C02 kms:ViaService condition Practice Question

This SAP-C02 practice question tests your understanding of design for new solutions. The scenario asks you to isolate a root cause — eliminate options that address a different problem before choosing. A key principle to apply: kms:ViaService condition. 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",
      "Principal": {
        "AWS": "arn:aws:iam::123456789012:role/MyAppRole"
      },
      "Action": "kms:Decrypt",
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "kms:ViaService": "s3.us-east-1.amazonaws.com",
          "kms:EncryptionContext:aws:s3:arn": "arn:aws:s3:::my-bucket/*"
        }
      }
    }
  ]
}

Refer to the exhibit. A solutions architect has attached this key policy to an AWS KMS key. The IAM role MyAppRole is used by an application running on an EC2 instance in us-east-1. The application tries to decrypt an object stored in the S3 bucket my-bucket using server-side encryption with AWS KMS (SSE-KMS). What will happen?

Exhibit

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::123456789012:role/MyAppRole"
      },
      "Action": "kms:Decrypt",
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "kms:ViaService": "s3.us-east-1.amazonaws.com",
          "kms:EncryptionContext:aws:s3:arn": "arn:aws:s3:::my-bucket/*"
        }
      }
    }
  ]
}

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 decryption fails if the application calls KMS Decrypt directly instead of letting S3 decrypt.

Option C is correct because the key policy includes a condition that limits the `kms:Decrypt` permission to only be allowed when the request comes from Amazon S3 (using `kms:ViaService`). When the application calls KMS Decrypt directly, the request does not come from S3, so the condition is not satisfied, and the decryption fails. The IAM role MyAppRole does not have an IAM policy granting `kms:Decrypt`, and the key policy does not grant it directly to the role. Options A, B, and D are incorrect because the decryption fails only when calling KMS directly, not because of the role's permissions or encryption context.

Key principle: kms:ViaService condition

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 decryption fails because the key policy does not grant decrypt to the role.

    Why it's wrong here

    The key policy does grant decrypt, but with conditions.

  • The decryption succeeds because the role has permissions via this key policy.

    Why it's wrong here

    The condition restricts the permission to requests coming via S3 service.

  • The decryption fails if the application calls KMS Decrypt directly instead of letting S3 decrypt.

    Why this is correct

    The condition kms:ViaService requires the request to come from S3, not direct SDK call.

    Related concept

    kms:ViaService condition

  • The decryption succeeds only if the object was uploaded with the correct encryption context.

    Why it's wrong here

    Even with correct context, the viaService condition must be met.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap is that candidates may assume the key policy's kms:Decrypt permission granted to the root account with a condition automatically allows any IAM role to call KMS Decrypt directly. In reality, the condition restricts the permission to requests made via S3 (kms:ViaService), so direct KMS calls are denied unless the role has an explicit IAM policy granting kms:Decrypt or is listed as a principal in the key policy without the restrictive condition.

Detailed technical explanation

How to think about this question

AWS KMS key policies can grant permissions to the root account, which then allows IAM users/roles to access the key via IAM policies. However, when an application makes a direct KMS API call (e.g., `Decrypt`), the key policy must explicitly allow the IAM principal or the root account must have a policy that delegates via IAM. In this scenario, the key policy only allows `kms:Decrypt` to the root account with a condition on encryption context, but MyAppRole is not listed as a principal, so direct KMS calls fail. S3, when decrypting on behalf of the application, uses the root account's permissions, bypassing the need for explicit role permissions in the key policy.

KKey Concepts to Remember

  • kms:ViaService condition
  • Key policy vs IAM policy

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

kms:ViaService condition

Real-world example

How this comes up in practice

A media company stores terabytes of video archives that are accessed once a year for audit purposes. Moving these objects to a cold storage tier (Azure Archive, S3 Glacier, or Google Nearline) costs a fraction of hot storage. Questions like this test whether you understand storage tiers, access frequency tradeoffs, and retrieval latency requirements.

Quick reference

AWS S3 Storage Class Comparison

Storage ClassMin DurationRetrievalUse Case
S3 StandardNoneImmediateFrequently accessed data
S3 Standard-IA30 daysImmediateInfrequent access, rapid retrieval
S3 One Zone-IA30 daysImmediateNon-critical infrequent data
S3 Intelligent-TieringNoneImmediate–hoursUnknown or changing access patterns
S3 Glacier Instant90 daysMillisecondsArchive with instant retrieval
S3 Glacier Flexible90 daysMinutes–hoursArchive, flexible retrieval
S3 Glacier Deep Archive180 daysHoursLong-term compliance archive

What to study next

Got this wrong? Here's your next step.

Review kms:ViaService condition, then practise related SAP-C02 questions on the same topic to reinforce the concept.

Related practice questions

Related SAP-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 SAP-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 SAP-C02 question test?

Design for New Solutions — This question tests Design for New Solutions — kms:ViaService condition.

What is the correct answer to this question?

The correct answer is: The decryption fails if the application calls KMS Decrypt directly instead of letting S3 decrypt. — Option C is correct because the key policy includes a condition that limits the `kms:Decrypt` permission to only be allowed when the request comes from Amazon S3 (using `kms:ViaService`). When the application calls KMS Decrypt directly, the request does not come from S3, so the condition is not satisfied, and the decryption fails. The IAM role MyAppRole does not have an IAM policy granting `kms:Decrypt`, and the key policy does not grant it directly to the role. Options A, B, and D are incorrect because the decryption fails only when calling KMS directly, not because of the role's permissions or encryption context.

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

Review kms:ViaService condition, then practise related SAP-C02 questions on the same topic to reinforce the concept.

What is the key concept behind this question?

kms:ViaService condition

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

Keep practising

More SAP-C02 practice questions

Last reviewed: Jul 4, 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 SAP-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 SAP-C02 exam.