This document provides instructions for deploying a Linux compute instance on Google Cloud that installs the Apache web server using a remote startup script. It describes creating a storage bucket to hold the startup script, creating a compute instance and configuring its metadata to reference the script, opening necessary firewall ports, and testing connectivity to confirm successful installation of Apache. The solution automates this process through a script that handles creating the bucket and uploading the startup script, creating the instance and applying the necessary metadata and firewall configurations, and checking that the startup script executed properly and the instance is accessible over HTTP.
Unblocking The Main Thread Solving ANRs and Frozen Frames
Deploy a compute instance with a remote startup script
1. Deploy a Compute Instance
with a Remote Startup Script
Mahmmoud Mahdi
2. Your challenge
Configure a Linux Google Compute Engine instance that
installs the Apache web server software using a remote
startup script. In order to confirm that a compute
instance Apache has successfully installed, the
Compute Engine instance must be accessible via HTTP
from the internet.
3. Deploy an Instance with a Remote Startup Script
1.Create a Bucket & Upload startup script.
2.Create a Compute Instance & config metadata.
3.Enable Public Access to Instance.
4.Check executing the startup script.
5.Check the URL and address.
5. Requirement Steps
2. Create VM Instance and
configure metadata
1. Create Startup script
and upload to bucket
3. Open firewall port
4. Test Connectivity
11. Tasks
1.Create a Bucket & Upload startup script.
2.Create a Compute Instance & config metadata.
3.Enable Public Access to Instance.
4.Check executing the startup script.
5.Check the URL and address.
12. echo '#!/bin/bash
apt-get update
apt-get install -y apache2' > resource-install-web.sh
Prepare Apache Installation Script
gsutil mb gs://BUCKET_NAME/
gsutil cp resources-install-web.sh gs://BUCKET_NAME
create bucket, Replace BUCKET_NAME with project Id
create script file contains installation commands
copy startup script to bucket
BUCKET_NAME must be the same as first line
13. Create Machine
gcloud compute instances create apache
--zone=us-central1-a
--tags=http-server
--metadata=startup-script-url=gs://$BUCKET_NAME/resource-install-web.sh
Machine name
Machine location
Network tag used to open port later
Script location run once machine start
14. Tasks
1.Create a Bucket & Upload startup script.
2.Create a Compute Instance & config metadata.
3.Enable Public Access to Instance.
4.Check executing the startup script.
5.Check the URL and address.
15. Create Firewall
gcloud compute firewall-rules create default-allow-http
--direction=INGRESS --priority=1000 --network=default
--action=ALLOW --rules=tcp:80
--source-ranges=0.0.0.0/0
--target-tags=http-server
Firewall rule name
Allow http port
From public interent address
Network tag (Same as tag name in create machine command)
16. Tasks
1.Create a Bucket & Upload startup script.
2.Create a Compute Instance & config metadata.
3.Enable Public Access to Instance.
4.Check executing the startup script.
5.Check the URL and address.
18. Tasks
1.Create a Bucket & Upload startup script.
2.Create a Compute Instance & config metadata.
3.Enable Public Access to Instance.
4.Check executing the startup script.
5.Check the URL and address.