User Tools

Site Tools


launch_a_simple_aws_ec2_instance

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
launch_a_simple_aws_ec2_instance [2017/08/04 18:27] walkeradminlaunch_a_simple_aws_ec2_instance [2017/08/05 09:00] (current) – removed walkeradmin
Line 1: Line 1:
-====== Launch a Simple AWS EC2 Instance ====== 
-<color darkorange>Aug 2017</color> 
-\\  
-\\  
-\\  
-\\  
-===== Introduction ===== 
-\\  
-By Simple I mean the very basic EC2 instance that you can have, a single EC2 Instance with basic storage and a DHCP IP Address (so no Elastic IP), and no S3 Buckets etc. 
-\\  
-\\  
-The idea is that using a free AWS account, you should be able to play with the information on this page and not incur any costs (<color #ed1c24>I'm not guaranteeing that by the way</color>). I am only concerned at this point in creating a Terroform script that will launch the EC2 Instance, I am not going to be installing any software on my EC2 Instance at this point. 
-\\  
-\\  
-If you have not created an EC2 Instance manually, then you possibly will not understand this process, so I suggest you check this page out first [[creating_an_amazon_aws_ec2_instance|Creating an Amazon AWS EC2 Instance]] 
- 
----- 
-==== The Script ==== 
-\\  
-Below is the script we will be using, I want to discuss a few of the elements first so that we understand a little of what changes to the script you might need to make to suit your purposes. (Ignore the line numbers) 
-\\  
-\\  
-<sxh> 
-provider "aws" { 
-        access_key = "JLJBK63HMPBC7DC150PA" 
-        secret_key = "K7H2g33xPj6F7zBNcFGTeL5SlbjTsDNA/9nA2caa" 
-        region = "eu-west-2" 
-} 
- 
-resource "aws_instance" "example" { 
-        ami = "ami-40a8bf24" 
-        instance_type = "t2.micro" 
-        key_name = "TestWebSvr" 
-        security_groups= ["launch-wizard-1"] 
-        tags { 
-        Name = "terraform-instance" 
-        } 
-} 
-</sxh> 
-\\  
- 
----- 
- 
-==== Access Key ==== 
-This is not the same as your key pair, if you have created an EC2 instance manually, you will have created a key pair for SSH access, but the credentials here are not the same. 
-\\  
-<sxh> 
-provider "aws" { 
-        access_key = "JLJBK63HMPBC7DC150PA" 
-        secret_key = "K7H2g33xPj6F7zBNcFGTeL5SlbjTsDNA/9nA2caa" 
- 
-</sxh> 
-\\  
-We will look at how to create the 'access' and 'secret' keys further down. Please note that these keys in the above example are complete fabrications, please do not try to use them, you will totally waste your time. 
-\\  
-\\  
- 
----- 
- 
-==== Region  ==== 
-This really caught me out to begin with. If I look at the region I am running my instance in then it is reported as <color #ed1c24>eu-west-2a</color>. The region I am using (London) has two availability zones, <color #ed1c24>eu-west-2a</color> and <color #ed1c24>eu-west-2b</color> However you don't chose which one of these you use, it's automatic, so when you pick your region, you only specify the main region like this <color #ed1c24>eu-west-2</color> 
-\\  
-<sxh> 
-        region = "eu-west-2" 
-</sxh> 
-\\  
-\\  
- 
----- 
-==== Instance AMI ==== 
-The next section is where we setup our AMI (Amazon Machine Image) The AMI is what OS you wish to use (Linux, Winodws etc) and if Linux what version of Linux (Red Had, Debian etc). 
-\\  
-<sxh> 
-        ami = "ami-40a8bf24" 
-</sxh> 
-\\  
-In the above example we have specified ami = "ami-40a8bf24". To find this you need to log in to your AWS account and select 'Launch Instance'. You will see the page of AMI options and their associated AMI names. 
-\\  
-\\  
-{{ :aws_ami_names.jpg?900 |}} 
-\\  
-Please be aware that AMI names vary across AZ availability zones. So the AMI name of Red Hat will differ between London and US. 
-\\  
-\\  
- 
----- 
-==== Instance Type ==== 
-The Instance Type is really the type of Virtual Server. This dictates how many vCPUs you have, the amount of RAM etc.  
-\\  
-<sxh> 
-        instance_type = "t2.micro" 
-</sxh> 
-\\  
-In this example we are using the t2.micro, as this falls in to the free tier category (as long as you are still in your free tier period.) 
-\\  
-\\  
- 
----- 
-==== EC2 Names  ==== 
-Key name is simply a name to identify the EC2 Instance as. 
-\\  
-<sxh> 
-        key_name = "TestWebSvr" 
-        Name = "terraform-instance" 
-</sxh> 
-\\  
-The Name = terraform-instance is another label to identify this by. 
-\\  
-\\  
- 
----- 
-==== Security Groups ==== 
-There are security groups that can be set in the Terraform script. You can create your own security groups or use the default one (default one that is created with a new EC2 Instance.) 
-\\  
-<sxh> 
-        security_groups= ["launch-wizard-1"] 
-</sxh> 
-\\  
-The security groups "launch-wizard-1" is the default security group and has the default inbound settings of <color #ed1c24>SSH, TCP, 22, 0.0.0.0/0</color> which allows for SSH access. 
-\\  
-\\  
- 
----- 
  
launch_a_simple_aws_ec2_instance.1501871236.txt.gz · Last modified: (external edit)