using_terraform
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
using_terraform [2017/08/05 11:47] – [Terraform Apply] walkeradmin | using_terraform [2017/08/05 14:06] – [Terraform] walkeradmin | ||
---|---|---|---|
Line 85: | Line 85: | ||
\\ | \\ | ||
\\ | \\ | ||
- | {{ : | + | {{ : |
\\ | \\ | ||
- | In the above example we can see that there is nothing | + | In the above example we can see that there is no EC2 Instance |
\\ | \\ | ||
+ | \\ | ||
+ | If we select Running Instances, then this will be empty (unless you have manually created some.) | ||
+ | \\ | ||
+ | \\ | ||
+ | {{ : | ||
+ | \\ | ||
+ | Now we can run our Terraform Script. | ||
+ | \\ | ||
+ | \\ | ||
+ | In the command window where you ran Terraform Plan, you can now use: | ||
+ | \\ | ||
+ | terraform.exe apply | ||
+ | \\ | ||
+ | If you don't have any errors, then you will see an output similar to below: | ||
+ | \\ | ||
+ | < | ||
+ | aws_instance.example: | ||
+ | ami: "" | ||
+ | associate_public_ip_address: | ||
+ | availability_zone: | ||
+ | ebs_block_device.#: | ||
+ | ephemeral_block_device.#: | ||
+ | instance_state: | ||
+ | instance_type: | ||
+ | ipv6_address_count: | ||
+ | ipv6_addresses.#: | ||
+ | key_name: | ||
+ | network_interface.#: | ||
+ | network_interface_id: | ||
+ | placement_group: | ||
+ | primary_network_interface_id: | ||
+ | private_dns: | ||
+ | private_ip: | ||
+ | public_dns: | ||
+ | public_ip: | ||
+ | root_block_device.#: | ||
+ | security_groups.#: | ||
+ | security_groups.2525401260: | ||
+ | source_dest_check: | ||
+ | subnet_id: | ||
+ | tags.%: | ||
+ | tags.Name: | ||
+ | tenancy: | ||
+ | volume_tags.%: | ||
+ | vpc_security_group_ids.#: | ||
+ | aws_instance.example: | ||
+ | aws_instance.example: | ||
+ | aws_instance.example: | ||
+ | |||
+ | Apply complete! Resources: 1 added, 0 changed, 0 destroyed. | ||
+ | |||
+ | The state of your infrastructure has been saved to the path | ||
+ | below. This state is required to modify and destroy your | ||
+ | infrastructure, | ||
+ | use the `terraform show` command. | ||
+ | |||
+ | State path: | ||
+ | </ | ||
+ | \\ | ||
+ | Now we can check the Running Instances page again. | ||
+ | \\ | ||
+ | \\ | ||
+ | Initially you will see a status of ' | ||
+ | \\ | ||
+ | \\ | ||
+ | {{ : | ||
+ | \\ | ||
+ | We can see the following information has been populated according to our Script: | ||
+ | \\ | ||
+ | * Name: | ||
+ | * Instance Type | ||
+ | * Availability Zone: eu-west-2a (yes we only specify eu-west-2, the a/b/c suffix is automatic) | ||
+ | * Key-Name | ||
+ | \\ | ||
+ | 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. | ||
+ | < | ||
+ | Do you really want to destroy? | ||
+ | Terraform will delete all your managed infrastructure. | ||
+ | There is no undo. Only ' | ||
+ | |||
+ | Enter a value: | ||
+ | </ | ||
+ | \\ | ||
+ | You have to enter <color # | ||
+ | \\ | ||
+ | \\ | ||
+ | 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. | ||
+ | \\ | ||
+ | < | ||
+ | aws_instance.example: | ||
+ | aws_instance.example: | ||
+ | aws_instance.example: | ||
+ | |||
+ | aws_instance.example: | ||
+ | |||
+ | aws_instance.example: | ||
+ | |||
+ | aws_instance.example: | ||
+ | |||
+ | Destroy complete! Resources: 1 destroyed. | ||
+ | </ | ||
+ | \\ | ||
+ | Now you can check your Running Instances to see what has happened. | ||
+ | \\ | ||
+ | \\ | ||
+ | {{ : | ||
\\ | \\ | ||
using_terraform.txt · Last modified: 2023/03/09 22:35 by 127.0.0.1