This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AWS = require('aws-sdk'); | |
exports.handler = function(event, context) { | |
var ec2 = new AWS.EC2({region: 'us-east-1'}); | |
ec2.startInstances({InstanceIds : ['i-0114833f8ffc9151c'] },function (err, data) { | |
if (err) console.log(err, err.stack); | |
else console.log(data); | |
context.done(err,data); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum install perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https -y | |
curl http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip -O | |
unzip CloudWatchMonitoringScripts-1.2.1.zip | |
rm CloudWatchMonitoringScripts-1.2.1.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<powershell> | |
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) | |
choco install python -y | |
(new-object net.webclient).DownloadFile('https://s3.amazonaws.com/aws-cli/AWSCLI64.msi','c:\AWSCLI64.msi') | |
msiexec.exe /i 'C:\AWSCLI64.msi' /qn | |
</powershell> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum install -y aws-cli | |
cd /home/ec2-user/ | |
aws s3 cp 's3://aws-codedeploy-us-east-1/latest/codedeploy-agent.noarch.rpm' . --region us-east-1 | |
yum -y install codedeploy-agent.noarch.rpm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws autoscaling put-lifecycle-hook \ | |
--lifecycle-hook-name scale-out-hook \ | |
--auto-scaling-group-name MyASG \ | |
--lifecycle-transition autoscaling:EC2_INSTANCE_LAUNCHING | |
aws autoscaling complete-lifecycle-action \ | |
--lifecycle-action-result CONTINUE \ | |
--instance-id i-0680775fb68bc97a5 \ | |
--lifecycle-hook-name scale-out-hook \ | |
--auto-scaling-group-name MyASG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws elb create-load-balancer \ | |
--load-balancer-name MyELB \ | |
--listeners Protocol=TCP,LoadBalancerPort=80,InstanceProtocol=TCP,InstancePort=80 \ | |
--subnets subnet-46e6506c subnet-57b8010f \ | |
--scheme internet-facing \ | |
--security-groups sg-aec570d4 | |
aws autoscaling create-launch-configuration \ | |
--launch-configuration-name MyLC \ | |
--key-name virginia \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum install httpd -y | |
/sbin/chkconfig --levels 235 httpd on | |
service httpd start | |
instanceId=$(curl http://169.254.169.254/latest/meta-data/instance-id) | |
region=$(curl http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}') | |
echo "<h1>$instanceId</h1>" > /var/www/html/index.html | |
aws ec2 create-tags --resources "$instanceId" --tags Key=Name,Value="PROD-$instanceId" --region "$region" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Configure user 'user' for sudo access and change root password and user password | |
* use passwd command to change passwords for user and root | |
Add user 'user' to sudo | |
* usermod -g wheel user | |
Download chef development kit | |
* go to https://downloads.chef.io/chefdk/1.1.16 and copy url for RHEL - https://packages.chef.io/files/stable/chefdk/1.1.16/el/7/chefdk-1.1.16-1.el7.x86_64.rpm | |
wget the above link in the server to download the software | |
Install using the command - sudo rpm -ivh chefdk-1.1.16-1.el7.x86_64.rpm | |
To verify installation, type 'sudo chef-client --local-mode' (running chef-client in local mode) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Convergence | |
*Pre-convergence - Phase before a node is configured. Lint tests, foodcritic | |
*Convergence - Tests the defined resources to ensure they are in the desired state,"Providers' are what do the work (yum, apt-get etc.,) to enforce the desired configuration | |
*Post-Convergence - Occurs after the Chef convergence - Run tests that verifies a node is in the desired state of configuration/ Unit testing | |
Chef can be run over and over again without changing configurations if configurations are already in place (Idempotency) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@gsmurali1 user]# vim learn.rb | |
[root@gsmurali1 user]# cat learn.rb | |
package 'apache' do | |
end | |
This is the pre-convergence checks; to check ruby syntax and chef syntax | |
------------------------------------------------------------------------ | |
[root@gsmurali1 user]# ruby -c learn.rb | |
Syntax OK |
OlderNewer