Knowee
Questions
Features
Study Tools

Write a Bash script to perform these instruction:1. Infrastructure Setup 1.1. EC2 Instance Launch Proper launch of EC2 instances with Amazon Linux, Ubuntu, and CentOS.Configuration of instance attributes such as instance type, security groups, and key pairs.1.2. Security Measures Appropriate configuration of security groups to ensure optimal security measures.Proper setup of key pairs for secure remote access.2. Remote Execution and Deployment (30 points):2.1. Script Upload (10 points):Successful upload of the enhanced script to a centralised server.Secure handling of the script to prevent unauthorizedaccess.2.2. Remote Execution (10 points):Proper execution of the script on each instance remotelyHandling of dependencies and adjustments for different distributions.2.3. Apache Deployment (5 points):Successful deployment of the Apache web server oneach instance.Verification of the Apache service status.2.4. Sample Web Application Deployment (5 points):Successful deployment of a sample web application oneach instance.Verification of web application accessibility.

Question

Write a Bash script to perform these instruction:1. Infrastructure Setup 1.1. EC2 Instance Launch Proper launch of EC2 instances with Amazon Linux, Ubuntu, and CentOS.Configuration of instance attributes such as instance type, security groups, and key pairs.1.2. Security Measures Appropriate configuration of security groups to ensure optimal security measures.Proper setup of key pairs for secure remote access.2. Remote Execution and Deployment (30 points):2.1. Script Upload (10 points):Successful upload of the enhanced script to a centralised server.Secure handling of the script to prevent unauthorizedaccess.2.2. Remote Execution (10 points):Proper execution of the script on each instance remotelyHandling of dependencies and adjustments for different distributions.2.3. Apache Deployment (5 points):Successful deployment of the Apache web server oneach instance.Verification of the Apache service status.2.4. Sample Web Application Deployment (5 points):Successful deployment of a sample web application oneach instance.Verification of web application accessibility.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a basic example of a Bash script that could be used to perform the tasks you've described. Please note that this is a simplified version and you may need to adjust it according to your specific needs.

#!/bin/bash

# 1. Infrastructure Setup
# 1.1. EC2 Instance Launch
aws ec2 run-instances --image-id ami-abc12345 --count 1 --instance-type t2.micro --key-name MyKeyPair --security-groups MySecurityGroup

# 1.2. Security Measures
aws ec2 create-security-group --group-name MySecurityGroup --description "My security group"
aws ec2 authorize-security-group-ingress --group-name MySecurityGroup --protocol tcp --port 22 --cidr 0.0.0.0/0

# 2. Remote Execution and Deployment
# 2.1. Script Upload
scp -i MyKeyPair.pem MyScript.sh [email protected]:~

# 2.2. Remote Execution
ssh -i MyKeyPair.pem [email protected] 'bash -s' < MyScript.sh

# 2.3. Apache Deployment
ssh -i MyKeyPair.pem [email protected] 'sudo yum install -y httpd; sudo service httpd start; sudo chkconfig httpd on'

# 2.4. Sample Web Application Deployment
scp -i MyKeyPair.pem MyWebApp.zip [email protected]:~
ssh -i MyKeyPair.pem [email protected] 'unzip MyWebApp.zip -d /var/www/html/'

This script assumes that you have the AWS CLI installed and configured, and that you have a key pair and security group set up. It also assumes that you have a script (MyScript.sh) and a web application (MyWebApp.zip) in your current directory.

Please replace ami-abc12345, MyKeyPair, MySecurityGroup, ec2-1-2-3-4.compute-1.amazonaws.com, MyScript.sh, and MyWebApp.zip with your actual values.

This problem has been solved

Similar Questions

A company's flagship application runs on a fleet of Amazon Elastic Compute Cloud (Amazon EC2) instances. As per the new policies, the system administrators are looking for the best way to provide secure shell access to Amazon Elastic Compute Cloud (Amazon EC2) instances without opening new ports or using public IP addresses. Which tool/service will help you achieve this requirement?

Which AWS service can be used to automate code deployment to Amazon Elastic Compute Cloud (Amazon EC2) instances as well as on-premises instances?Question 45Answera.AWS CloudFormationb.AWS CodePipelinec.AWS CodeCommitd.AWS CodeDeploy

Which of the following can you use to run a bootstrap script while launching an Amazon Elastic Compute Cloud (Amazon EC2) instance?Question 5Answera.Amazon EC2 instance metadatab.Amazon EC2 instance configuration datac.Amazon EC2 instance AMI datad.Amazon EC2 instance user data

A developer would like to automate operations on his on-premises environment using Chef and Puppet. Which AWS service can help with this task?Question 11Answera.AWS CodeDeployb.AWS Batchc.AWS CloudFormationd.AWS OpsWorks

A company wants to improve its security and audit posture by limiting Amazon EC2 inbound access.What should the company use to access instances remotely instead of opening inbound SSH ports and managing SSH keys?Network ACLsEC2 key pairsAWS Identity and Access Management (IAM)AWS Systems Manager Session Manager

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.