User Tools

Site Tools


using_terraform

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
using_terraform [2017/08/05 13:52] – [Terraform Apply] walkeradminusing_terraform [2023/03/09 22:35] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Using Terraform ====== ====== Using Terraform ======
 <color darkorange>Aug 2017</color> <color darkorange>Aug 2017</color>
 +\\ 
 +\\ 
 +{{:terraform_logo.jpg?100|}}  |  {{:amazonwebservices_logo.svg.png?75|}}
 \\  \\ 
 \\  \\ 
  
 ---- ----
 +
 Now that we have our simple Terraform script, we can start to use Terraform. First we need to test the script for any errors, then we can launch our EC2 Instance by running the script. Now that we have our simple Terraform script, we can start to use Terraform. First we need to test the script for any errors, then we can launch our EC2 Instance by running the script.
 \\  \\ 
Line 151: Line 155:
 \\  \\ 
 \\  \\ 
-Initially you will see a status of 'Initialising' but this will quickly change to+Initially you will see a status of 'Pending' but this will quickly change to 'Running'
 \\  \\ 
 \\  \\ 
-{{ :terraformaws_006.jpg?850 |}}+{{ :terraformaws_006.jpg?900 |}} 
 +\\  
 +We can see the following information has been populated according to our Script: 
 +\\  
 +  * Name:                   terraform0Instance 
 +  * Instance Type           t2.micro 
 +  * Availability Zone:      eu-west-2a (yes we only specify eu-west-2, the a/b/c suffix is automatic) 
 +  * Key-Name                TestSvr 
 +\\  
 +The EC2 Instance is now running and using  your key-pair and SSH you should be able to login and start using your virtual machine. 
 +\\ 
 \\  \\ 
  
 +----
 +==== Terraform Destroy ====
 +\\ 
 +\\ 
 +Terraform Destroy does exactly that, using the script file you created, it undoes all of your settings. When Terraform applied your settings it stored the state of your EC2 Instance, so it already knows what settings have been applied.
 +\\ 
 +\\ 
 +To use enter the following:
 +\\ 
 +    terraform destroy
 +\\ 
 +Below is an example output of a terraform destroy command.
 +\\ 
 +\\ 
 +Before the destroy action is taken, there is a confirmation request.
 +<file>
 +Do you really want to destroy?
 +  Terraform will delete all your managed infrastructure.
 +  There is no undo. Only 'yes' will be accepted to confirm.
 +
 +  Enter a value:
 +</file>
 +\\ 
 +You have to enter <color #ed1c24>yes</color> to start the destroy.
 +\\ 
 +\\ 
 +Terraform will then issue the command to AWS, depending on the complexity of your EC2 Instance, and what it is doing, the command will take a varying amount of time to complete.
 +\\ 
 +<file>
 +aws_instance.example: Refreshing state... (ID: i-0781af6ecb9c0f2f5)
 +aws_instance.example: Destroying... (ID: i-0781af6ecb9c0f2f5)
 +aws_instance.example: Still destroying... (ID: i-0781af6ecb9c0f2f5, 10s elapsed)
 +
 +aws_instance.example: Still destroying... (ID: i-0781af6ecb9c0f2f5, 20s elapsed)
 +
 +aws_instance.example: Still destroying... (ID: i-0781af6ecb9c0f2f5, 30s elapsed)
 +
 +aws_instance.example: Destruction complete
 +
 +Destroy complete! Resources: 1 destroyed.
 +</file>
 +\\ 
 +Now you can check your Running Instances to see what has happened.
 +\\ 
 +\\ 
 +{{ :terraformaws_008.jpg?900 |}}
 +\\ 
 +The Instance State will first change to Shutting Down, then to Terminated. Terminated Instances take one or two hours to finally disappear from your Running Instance page.
 +\\ 
 +\\ 
using_terraform.1501937533.txt.gz · Last modified: 2023/03/09 22:35 (external edit)