AWS Certified Solutions Architect Associate · Free Practice Question Easy

Question 36

A systems administration team has a requirement to run certain custom scripts only once during the launch of the Amazon Elastic Compute Cloud (Amazon EC2) instances that host their application.

Which of the following represents the best way of configuring a solution for this requirement with minimal effort?

  • A

    Run the custom scripts as instance metadata scripts on the Amazon EC2 instances

  • B

    Use AWS CLI to run the user data scripts only once while launching the instance

  • C

    Update Amazon EC2 instance configuration to ensure that the custom scripts, added as user data scripts, are run only during the boot process

  • D

    Run the custom scripts as user data scripts on the Amazon EC2 instances

Reveal correct answer

Correct answer: D

Explanation

Correct option:

Run the custom scripts as user data scripts on the Amazon EC2 instances

When you launch an instance in Amazon EC2, you have the option of passing user data to the instance that can be used to perform common automated configuration tasks and even run scripts after the instance starts. You can pass two types of user data to Amazon EC2: shell scripts and cloud-init directives.

By default, user data scripts and cloud-init directives run only during the boot cycle when you first launch an instance. Hence, no extra configuration is needed, apart from including the custom scripts in user data scripts.

Incorrect options:

Update Amazon EC2 instance configuration to ensure that the custom scripts, added as user data scripts, are run only during the boot process - You can update your configuration to ensure that your user data scripts and cloud-init directives run every time you restart your instance. By default, the scripts are run, only once during the boot process while first launching the instance.

Run the custom scripts as instance metadata scripts on the Amazon EC2 instances- Instance metadata is data about your instance that you can use to configure or manage the running instance. Metadata cannot be used to run custom scripts.

Use AWS CLI to run the user data scripts only once while launching the instance - This statement is incorrect and used only as a distractor.

References:

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need