Courseiva

SOA-C02 Deployment, Provisioning, and Automation Practice Question

Exhibit

Refer to the exhibit.

user_data_script:
  Fn::Base64: !Sub |
    #!/bin/bash
    yum update -y
    yum install -y httpd
    systemctl start httpd
    systemctl enable httpd
    echo "<?php phpinfo(); ?>" > /var/www/html/index.php

A CloudFormation template launches an EC2 instance with the user data script shown. The instance launches successfully but the web server does not serve PHP pages. What is the MOST likely reason?

⚠ Common exam trap

SOA-C02 often tests whether candidates confuse user data execution mechanics (root, auto base64, cloud-init) with actual application configuration gaps — the script ran fine, it just didn't install PHP.

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 script does not install PHP.

The user data script installs Apache (httpd) and starts the service but never installs PHP or the PHP module for Apache. Without PHP installed, Apache cannot serve .php files — it will either download them as plain text or return a 500 error. This makes option A the most likely reason.

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 script does not install PHP.

    Why this is correct

    The script does not install PHP. The user data script likely installs and starts the Apache HTTP server, but it omits the installation of the PHP package (or the Apache PHP module). Without the PHP package, Apache cannot interpret and execute PHP files; it will either serve them as plain text or offer them for download, resulting in the PHP page not rendering correctly. The correct fix is to add a command that installs PHP, such as `yum install php` or `apt install php`, and then restart the Apache service so the module loads.

  • ✗

    The script does not have execute permissions.

    Why it's wrong here

    The script does not have execute permissions. User data scripts are executed by cloud-init, which runs as the root user and passes the script to a shell interpreter such as `/bin/sh`. Because the script is interpreted, not executed as a standalone binary, the executable bit on the file is irrelevant; cloud-init invokes the script using a command like `sh -x`, and the root user has full read and write access to the script. Therefore, missing execute permissions would not prevent the script from running, and this is not the cause of the PHP page failing.

  • ✗

    The CloudFormation template is missing a DependsOn clause for the instance.

    Why it's wrong here

    The CloudFormation template is missing a DependsOn clause for the instance. DependsOn controls the explicit creation order of resources in a CloudFormation stack; it ensures that one resource is created only after another is complete. User data scripts execute as part of the EC2 instance's initialization during first boot, not as a separate resource that depends on other stack resources. Therefore, adding a DependsOn clause to the instance would not affect whether the script runs, and in fact, an unnecessary DependsOn can create circular dependencies or slow down stack creation without any benefit.

  • ✗

    The user data script is not base64 encoded correctly.

    Why it's wrong here

    The user data script is not base64 encoded correctly. When you specify the UserData property in a CloudFormation template, CloudFormation automatically base64-encodes the script if you provide it as a plain-text string. You can also explicitly use the Fn::Base64 intrinsic function, but either way, the script is correctly encoded and processed by the instance's user data mechanism. A base64 encoding issue would cause the script to fail entirely or produce a decoding error, but the problem here is that Apache is installed and running, while PHP is missing—so the script clearly executed and the encoding was not the problem.

About these practice questions

This SOA-C02 question is part of Courseiva's 1,169-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 and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Amazon Web Services exam blueprint

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