Courseiva
DeploymenthardMultiple ChoiceObjective-mapped

DVA-C02 Deployment Practice Question

Exhibit

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ec2:DescribeImages",
        "ec2:RunInstances",
        "ec2:TerminateInstances"
      ],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "iam:PassRole"
      ],
      "Resource": "arn:aws:iam::123456789012:role/MyAppRole"
    }
  ]
}

Refer to the exhibit. A developer is trying to deploy an EC2 instance using AWS CloudFormation. The stack creation fails with an 'AccessDenied' error when CloudFormation tries to create the EC2 instance. The developer has the IAM policy above. What is the MOST likely reason for the failure?

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 IAM role specified in the CloudFormation template is not the same as the one in the PassRole resource.

CloudFormation needs permission to pass the IAM role specified in the template. The policy allows PassRole only for a specific role ARN. If the template specifies a different role, CloudFormation cannot pass it, resulting in an AccessDenied error. Option A is incorrect because ec2:DescribeImages is allowed in the policy. Option C is incorrect because ec2:RunInstances is allowed. Option D is incorrect because ec2:TerminateInstances is not called during stack creation, and the policy allows it anyway.

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 policy does not allow ec2:DescribeImages.

    Why it's wrong here

    This is incorrect because the IAM policy shown in the exhibit already grants ec2:DescribeImages, so CloudFormation can freely resolve the AMI ID referenced in the template. The failure occurs later in the deployment sequence, when CloudFormation attempts to call iam:PassRole to assign an instance profile to the EC2 instance. A deny for ec2:DescribeImages would produce an "unauthorized to perform ec2:DescribeImages" error, not the PassRole authorization error you're seeing. Therefore, this option is not the cause of the failure.

  • The IAM role specified in the CloudFormation template is not the same as the one in the PassRole resource.

    Why this is correct

    This is correct. When CloudFormation creates an EC2 instance with an IAM instance profile, the user or role making the API calls must have iam:PassRole permission with a Resource that explicitly includes the ARN of the role being passed. In this case, the template specifies one IAM role (via its instance profile), but the PassRole statement in the policy points to a different role ARN. Because the role ARN in the policy resource does not match the role ARN in the template, CloudFormation is denied the iam:PassRole action, which prevents the instance from launching even though all EC2 actions are allowed. To fix it, either change the template to use the role allowed by the PassRole policy or extend the policy's Resource to include the template's role ARN, using least privilege.

  • The policy does not allow ec2:RunInstances.

    Why it's wrong here

    This is incorrect because the policy explicitly includes ec2:RunInstances, so CloudFormation has the necessary permission to create the instance. The deployment never reaches the point of successfully executing RunInstances because the earlier iam:PassRole call fails. If ec2:RunInstances were missing, the error would name ec2:RunInstances as the unauthorized action, not iam:PassRole. Thus, a lack of RunInstances permission cannot explain the observed failure.

  • The policy does not allow ec2:TerminateInstances.

    Why it's wrong here

    This is incorrect because ec2:TerminateInstances is not called during initial stack creation; it is only needed if CloudFormation must clean up resources during stack deletion or a rollback triggered after a failure. The deployment failed during the create phase at the iam:PassRole authorization check, before any instance was launched and before termination could be relevant. Even if TerminateInstances were denied, that would not cause this error on a fresh deployment, so this option is irrelevant to the question.

About these practice questions

Courseiva writes every DVA-C02 question from scratch — 724 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DVA-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 DVA-C02 exam.