Courseiva
SDLC AutomationhardMultiple ChoiceObjective-mapped

DOP-C02 SDLC Automation Practice Question

Exhibit

Refer to the exhibit.

Resources:
  MyEC2Instance:
    Type: AWS::EC2::Instance
    Properties:
      ImageId: ami-0abcdef1234567890
      InstanceType: t2.micro
      UserData:
        Fn::Base64: !Sub |
          #!/bin/bash
          yum install -y httpd
          systemctl start httpd
          systemctl enable httpd
      Tags:
        - Key: Name
          Value: MyInstance

Refer to the exhibit. A DevOps engineer deploys this CloudFormation template. The EC2 instance launches, but the httpd service does not start. The engineer connects to the instance and finds that the user data script did not run. What is the most likely cause?

⚠ Common exam trap

Many candidates assume the issue is with base64 encoding or the init system, but the real problem is a mismatch between the package manager used in the UserData script and the one available on the AMI.

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 AMI does not have yum installed

The most likely cause is that the AMI does not have yum installed. The CloudFormation template's UserData script uses yum to install httpd, but if the AMI is based on a distribution that does not use yum (e.g., Amazon Linux 2023 uses dnf, or Ubuntu uses apt), the script will fail silently or not execute as intended. Since the script itself is valid and the instance launched, the failure is due to the package manager not being available, preventing the httpd service from starting.

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 UserData is not base64 encoded correctly

    Why it's wrong here

    CloudFormation's `UserData` property accepts plain text and automatically base64-encodes it when creating the EC2 instance, unless you explicitly use `Fn::Base64`. Even if the script were not encoded correctly, the instance would still fail to execute it, but the error message would typically indicate a decoding or execution failure, not a missing `yum` command. In this scenario, the script is executing and reaching the `yum` command, so encoding is not the root cause.

  • The AMI does not have yum installed

    Why this is correct

    The `yum` command is specific to RPM-based distributions that use YUM as the package manager, such as older Amazon Linux (AL1/AL2) or CentOS 7. If the AMI is based on Amazon Linux 2023, which uses `dnf`, or on Ubuntu/Debian, which uses `apt`, the `yum` binary will not be present. When the UserData script runs `yum` on such an AMI, the shell returns a 'command not found' error, preventing the installation and causing the deployment to fail.

  • The tags prevent user data from executing

    Why it's wrong here

    EC2 instance tags are metadata key-value pairs that can be used for organization, billing, or automation, but they have no effect on whether UserData scripts execute. AWS documentation and behavior confirm that UserData scripts run during the first boot of the instance, regardless of any tags applied. The only factors that can block UserData execution are cloud-init misconfiguration, AMI-specific settings, or the script itself failing; tags are not one of them.

  • The AMI uses a different init system than systemd

    Why it's wrong here

    The AMI's init system (systemd vs. SysVinit vs. Upstart) governs how services are started and managed, but it does not control the availability of the `yum` command. While a non-systemd init system might prevent cloud-init from properly executing as a service, the failure described—where the `yum` command itself cannot be found—is a package-manager absence issue, not an init-system incompatibility. The error would occur regardless of the init system if the underlying OS uses a different package manager.

About these practice questions

This DOP-C02 question is part of Courseiva's 251-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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 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.