#Create new Instance in AWS GUI #Create new security group with open ports 22 and 80 #Connect to Newly created EC2 Instance ssh i ~/.aws/aws_test.pem ec2 user@52.74.47.51 #Update EC2 instance with latest security patches and application updated sudo yum y update #Install nginx webserver sudo yum y install nginx #Add nginx web server to start with EC2 instance boot sudo /sbin/chkconfig levels 235 nginx on #Start nginx sudo /etc/init.d/nginx start #check if nginx is running ps ef grep nginx #Create New User in IAM aws_tst in GUI #Add credentials for AWS console for newly created IAM aws_tst user mkdir ~/.aws && vim ~/.aws/credentials [default] aws_access_key_id=xxxxxxxxxxxxxxxxxxxx aws_secret_access_key=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy region=ap southeast 1 output=json #Create 2 new groups 1. Read only IAM 2. Full access EC2 and S3 #Add users to the groups #List existing users aws iam list users #List groups aws iam list groups #List existing Volumes aws ec2 describe volumes output table #Create New 1G volume aws ec2 create volume size 1 availability zone ap southeast 1a volume type standard
#List Instance ID and Volume ID aws ec2 describe instances grep InstanceId aws ec2 describe volumes grep VolumeId #Attache volume to newly created instance aws ec2 attach volume volume id vol 81a1be94 instance id i 343d86f8 device /dev/xvdf #Check on volume attachment lsblk ; sudo file s /dev/xvdf # format volume ext4 jfs sudo mkfs t ext4 /dev/xvdf && sudo file s /dev/xvdf #Backup nginx web root folder tar cvpzf nginx_html_backup.tar.gz /usr/share/nginx/html/ #Backup fstab sudo cp /etc/fstab /etc/fstab.orig #mount 1G volume as /usr/share/nginx/html/ sudo mount /def/xvdf /usr/share/nginx/html/ #add automount during boot sudo vim /etc/fstab #Add below entry to the end of the file /dev/xvdf /usr/share/nginx/html ext4 defaults,nofail 0 2 #Check mounted partitions mount #Create new index.html file sudo vim /usr/share/nginx/html/index.html #Add below into the file <!DOCTYPE html> <html> <body> <h1 style="font family:courier; font size:40px; background color:white; font color:black; text align:center">hello AWS World</h1> </body> </html> #Test html curl localhost v #Create S3 new bucket aws s3api list buckets aws s3api create bucket create bucket configuration LocationConstraint=ap southeast 1 bucket=awstst aws s3 ls #or
aws s3api list buckets #Add bucket policy # create policy file vim policy.json { "Version":"2008 10 17", "Id":"http referer policy example", "Statement":[ { "Sid":"readonly policy", "Effect":"Allow", "Principal":"*", "Action":"s3:GetObject", "Resource":"arn:aws:s3:::awstst/*" } ] } #apply policy aws s3api put bucket policy bucket awstst policy file://policy.json #Take required screenshots #Uploda 3 screenshots to S3 awstst bucket #Change permissions for uploaded screenshots files to allow everybody read only access #Upload addition Screenshots Ex. Route 53 DNS config # List S3 objects in bucket awstst aws s3api list objects bucket awstst #or aws s3api list objects bucket awstst # copy cfg files to S3 bucket awstst aws s3 cp /etc/fstab s3://awstst/ aws s3 cp /etc/nginx/nginx.conf s3://awstst/
#Final index.html <!DOCTYPE html> <html> <body> <h1 style="font family:courier; font size:40px; background color:white; font color:black; text align:center">hello AWS World</h1> <p style="font family:courier; font size:20px; background color:white; font color:black; text align:center">the mounted EBS volume</p> <center><img src="https://s3 ap southeast 1.amazonaws.com/awstst/screen shot1.png" width="770" height="158" align="middle"></img></center> <p style="font family:courier; font size:20px; background color:white; font color:black; text align:center">the index.html file resides within EBS</p> <center><img src="https://s3 ap southeast 1.amazonaws.com/awstst/screen shot2.png" style="width:548px;height:171px;border:0"></img></center> <p style="font family:courier; font size:20px; background color:white; font color:black; text align:center">the web server has been configured to serve index.html from the EBS volume</p> <center><img src="https://s3 ap southeast 1.amazonaws.com/awstst/screen shot3.png" width="780" height="633"></img></center> <a href="https://s3 ap southeast 1.amazonaws.com/awstst/Route53_DNS_Config.png">Route 53 config</a> <a href="https://s3 ap southeast 1.amazonaws.com/awstst/fstab">fstab config</a> <a href="https://s3 ap southeast 1.amazonaws.com/awstst/nginx.conf">nginx WEB server config</a> <a href="https://s3 ap southeast 1.amazonaws.com/awstst/Work_Book.pdf">Steps in setting up the enviroment</a> </body> </html>
http://www.mudrii.com/ > Direct IP Address http://mudrii.com/ > Load Balancer http://awstst 403626838.ap southeast 1.elb.amazonaws.com/ http://52.74.47.51/ #Additional configuration for shell to make life easier vim.bashrc #.bashrc # Source global definitions if [ f /etc/bashrc ]; then. /etc/bashrc fi # User specific aliases and functions [ z "$PS1" ] && return PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[m\] \[\e[1;32m\]\$ \[\e[m\]\[\e[1;37m\] ' export EDITOR=vim set o noclobber shopt s histappend export HISTSIZE=1000 export HISTFILESIZE=1000 export HISTTIMEFORMAT='%F %T ' PROMPT_COMMAND="history a;$prompt_command" HISTCONTROL=ignoreboth eval `dircolors b` export GREP_COLOR="1;33" alias ls='ls color=auto' alias grep='grep color=auto' alias ll="ls lh" alias la="ls a" alias mv='mv i' alias rm='rm i' alias cp='cp i' alias exit="clear ; exit" export LESS_TERMCAP_mb=$'\E[01;31m' export LESS_TERMCAP_md=$'\E[01;31m' export LESS_TERMCAP_me=$'\E[0m' export LESS_TERMCAP_se=$'\E[0m' export LESS_TERMCAP_so=$'\E[01;44;33m' export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_us=$'\E[01;32m' echo ne "Hello, $USER! Today is $(date).\n\n" cal
echo ne "System Info: $(uptime)\n\n" cat.nanorc set autoindent include "/usr/share/nano/c.nanorc" include "/usr/share/nano/perl.nanorc" unset backup set nonewlines set tabsize 4 set nowrap cat.inputrc "\eoa": history search backward "\e[a": history search backward "\eob": history search forward "\e[b": history search forward "\eoc": forward char "\e[c": forward char "\eod": backward char "\e[d": backward char "\C x\c r": re read init file set match hidden files off set page completions off set completion query items 350 set show all if ambiguous on set bell style none sudo file s /dev/xvdf df h pwd ; ls ltrah aws iam get account summary