 write a bash script (for bootstrapping) for my EC2 instance (Amazon Linux 2) that does the ff:

1. Update all software packages on the system

2. Install the Apache web server

3. Enable automatically starting Apache every boot and also immediately start the web server now

4. Create a simple HTML index file in the web root containing this: `<h1>Heading Main</h1>` 

5. Create an app1 subdirectory and HTML file within it.

6. Fetch and save the EC2 instance metadata to a metadata.html file in the app1 folder.
system
 write a bash script (for bootstrapping) for my EC2 instance (Amazon Linux 2) that does the ff:

1. Update all software packages on the system

2. Install the Apache web server

3. Enable automatically starting Apache every boot and also immediately start the web server now

4. Create a simple HTML index file in the web root containing this: `<h1>Heading Main</h1>` 

5. Create an app1 subdirectory and HTML file within it.

6. Fetch and save the EC2 instance metadata to a metadata.html file in the app1 folder.
user
Sure! Here is a user data script that bootstraps your EC2 instance as you specified:

```
#! /bin/bash

sudo yum update -y
sudo yum install -y httpd
sudo systemctl enable httpd
sudo service httpd start

sudo echo '<h1>Heading Main</h1>' | sudo tee /var/www/html/index.html
sudo mkdir /var/www/html/app1
sudo echo '<h1>APP-1</h1>' | sudo tee /var/www/html/app1/index.html
sudo curl http://169.254.169.254/latest/dynamic/instance-identity/document -o /var/www/html/app1/metadata.html
```

This will perform all the steps you mentioned, provided that it is selected as the EC2 instance's user data script. Let me know if you have any other questions or requests!
assistant
<|system|>
</s>
<|user|>
 write a bash script (for bootstrapping) for my EC2 instance (Amazon Linux 2) that does the ff:

1. Update all software packages on the system

2. Install the Apache web server

3. Enable automatically starting Apache every boot and also immediately start the web server now

4. Create a simple HTML index file in the web root containing this: `<h1>Heading Main</h1>` 

5. Create an app1 subdirectory and HTML file within it.

6. Fetch and save the EC2 instance metadata to a metadata.html file in the app1 folder.</s>
<|assistant|>
Sure! Here is a user data script that bootstraps your EC2 instance as you specified:

```
#! /bin/bash

sudo yum update -y
sudo yum install -y httpd
sudo systemctl enable httpd
sudo service httpd start

sudo echo '<h1>Heading Main</h1>' | sudo tee /var/www/html/index.html
sudo mkdir /var/www/html/app1
sudo echo '<h1>APP-1</h1>' | sudo tee /var/www/html/app1/index.html
sudo curl http://169.254.169.254/latest/dynamic/instance-identity/document -o /var/www/html/app1/metadata.html
```

This will perform all the steps you mentioned, provided that it is selected as the EC2 instance's user data script. Let me know if you have any other questions or requests!</s>
