What can you use to run a script at startup on an Amazon EC2 Linux instance?
Jenkins is an open-source automation server that integrates with a number of AWS Services, including: AWS CodeCommit, AWS CodeDeploy, Amazon EC2 Spot, and Amazon EC2 Fleet. You can use Amazon Elastic Compute Cloud (Amazon EC2) to deploy a Jenkins application on AWS. Show
This tutorial walks you through the process of deploying a Jenkins application. You will launch an EC2 instance, install Jenkins on that instance, and configure Jenkins to automatically spin up Jenkins agents if build abilities need to be augmented on the instance. In this tutorial, you will perform the following steps:
Prerequisites
Creating a key pairCreating a key pair helps ensure that the correct form of authentication is used when you install Jenkins. To create your key pair:
If you do not set these permissions, you cannot connect to your instance using this key pair. For more information, refer to Error: Unprotected private key file. Creating a security groupA security group acts as a firewall that controls the traffic allowed to reach one or more EC2 instances. When you launch an instance, you can assign it one or more security groups. You add rules that control the traffic allowed to reach the instances in each security group. You can modify a security group’s rules any time, and the new rules take effect immediately. For this tutorial, you will create a security group and add the following rules:
To create and configure your security group:
For more information, refer to Security Groups in the Amazon EC2 User Guide for Linux Instances. Launching an Amazon EC2 instanceNow that you have configured a key pair and security group, you can launch an EC2 instance. To launch an EC2 instance:
Installing and configuring JenkinsNow that the Amazon EC2 instance has been launched, Jenkins can be installed properly. In this step you will deploy Jenkins on your EC2 instance by completing the following tasks:
Connecting to your Linux instanceAfter you launch your instance, you can connect to it and use it the same way as your local machine. Before you connect to your instance, get the public DNS name of the instance using the Amazon EC2 console.
If your instance doesn’t have a public DNS name, open the VPC console, select the VPC, and check the Summary tab. If either DNS resolution or DNS hostnames is no, select Edit and change the value to yes. PrerequisitesThe tool that you use to connect to your Linux instance depends on your operating system.
These tools require the use of your key pair. Be sure that you have created your key pair as described in Creating a key pair. Using PuTTY to connect to your instance
Using SSH to connect to your instance
Downloading and installing JenkinsCompleting the previous steps enables you to download and install Jenkins on AWS. To download and install Jenkins:
You can check the status of the Jenkins service using the command: 2Configuring JenkinsJenkins is now installed and running on your EC2 instance. To configure Jenkins:
You are now ready to use EC2 instances as Jenkins agents. Cleaning upAfter completing this tutorial, be sure to delete the AWS resources that you created so you do not continue to accrue charges. Which feature of ec2 allows you to provide commands that the instance will run at startup?AWS userdata is the set of commands/data you can provide to a instance at launch time. For example if you are launching an ec2 instance and want to have docker installed on the newly launched ec2, than you can provide set of bash commands in the userdata field of aws ec2 config page.
What tool can be run from the AWS management Console that to execute the script on all target ec2 instances?Run Command allows you to automate common administrative tasks and perform one-time configuration changes at scale. You can use Run Command from the AWS Management Console, the AWS Command Line Interface (AWS CLI), AWS Tools for Windows PowerShell, or the AWS SDKs.
What command is used to launch ec2 instances?To launch an Amazon EC2 instance using the AMI you selected, use the aws ec2 run-instances command. You can launch the instance into a virtual private cloud (VPC).
What is scripting tool for AWS?The AWS Tools for PowerShell lets you perform many of the same actions available in the AWS SDK for . NET. You can use it from the command line for quick tasks, like controlling your Amazon EC2 instances. The PowerShell scripting language lets you compose scripts to automate your AWS service management.
|