https://www.cloudbees.com/blog/setting-jenkins-ec2-slaves http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-ebs.html
750 hours per month of t2.micro instance usage. Need to use this carefully. Make sure to stop instances to avoid payment. A stopped instance will "loose" its IP address. You can pay for elastic IP addresses to fix this.
-
Reserved instances
Provides significant discount compared to on-demand instance pricing.
-
Scheduled instances
Capacity is reserved ahead of time.
-
Spot instances
Specify maximum price you are willing to pay per hour of instance. You must be prepared for interruptions. EC2 can interrupt your instance when spot pricing rises above your bid. You cannot start and start an Amazon EBS-backed instance if it is a Spot instance. You can only reboot or terminate the instance.
-
Instance lifecycle
Amazon charges a full instance hour each time you transition an instance from stopped to running. Rebooting doesn't start a new billing hour. Stopping the instance may erase instance store volumes and disassociate IP addresses.
-
Storage for root device
All AMIs are either backed by Amazon EBS or backed by instance store. EBS is fast, instance (S3) is slow. Instance store-backed cannot be stopped.
-
Configuring instances
Use yum update and other package manager commands to keep instance current.
See here for detailed information.
-
Install AWS CLI using pip:
pip install awscli --user
, configure usingaws configure
-
Create security group, key pair, and role for EC2 instance
-
Launch and connect to the instance
AMI (Amazon Machine Image) ID needed for this step. Use the LaunchInstanceWizard to find the correct ID.
Red Hat Enterprise Linux version 7.3 (HVM), EBS General Purpose (SSD) Volume Type:
ami-e69ebc86
Use
run-instances
command to run the instance:$ aws ec2 run-instances --image-id ami-29ebb519 --security-group-ids sg-b018ced5 --count 1 --instance-type t2.micro --key-name devenv-key --query 'Instances[0].InstanceId'
Obtain public IP address using
describe-instances
:$ aws ec2 describe-instances --instance-ids i-ec3e1e2k --query 'Reservations[0].Instances[0].PublicIpAddress'
Connect to instance using ssh and your private key:
$ ssh -i devenv-key.pem ubuntu@54.183.22.255
See here for detailed information.
-
Create IAM policy for your user account, use IAM console.
-
Install the SSM Agent
mkdir /tmp/ssm curl https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm -o /tmp/ssm/amazon-ssm-agent.rpm sudo yum install -y /tmp/ssm/amazon-ssm-agent.rpm sudo systemctl status amazon-ssm-agent sudo systemctl start amazon-ssm-agent sudo systemctl status amazon-ssm-agent
-
Send command using AWS CLI
Make sure AWS CLI is installed and configured.
aws configure # input required information
aws ssm send-command --document-name "AWS-RunShellScript" --comment "listing services" --instance-ids "Instance-ID" --parameters commands="service --status-all" --region us-west-2 --output text
To view output of previous command:
aws ssm list-command-invocations --command-id "command ID" --details
See this tutorial for details.
TODO: Look for information specific to RHEL7.
- Create separate security group called NFS Services. See above tutorial for specific ports.
- Install NFS service
- Update /etc/exports
- Reload NFS service
- Connect to NFS service, mount volumes