Terraform: Difference between revisions

1,098 bytes removed ,  5 years ago
Line 89: Line 89:
=== Initializing Terraform ===
=== Initializing Terraform ===


To ensure we have credentials and such set up correctly, we can initialize Terraform in our workspace and check the configuration we have so far. With the provider definition in a file called, for example, <code>nodes.tf</code>, we first run <code>terraform init</code>:
To ensure we have the provider set up correctly, initialize Terraform and check the configuration so far. With the provider definition in a file called, for example, <code>nodes.tf</code>, run <code>terraform init</code>:


<source lang="shell">$ terraform init
<source lang="shell">$ terraform init
Line 119: Line 119:
commands will detect it and remind you to do so if necessary.</source>
commands will detect it and remind you to do so if necessary.</source>
This shows success in initializing Terraform and downloading the OpenStack provider plugin so the OpenStack stanzas will be handled correctly. This does not test out the credentials we’ve configured because this doesn’t actually try to connect to the defined provider.
This shows success in initializing Terraform and downloading the OpenStack provider plugin so the OpenStack stanzas will be handled correctly. This does not test out the credentials we’ve configured because this doesn’t actually try to connect to the defined provider.
We can’t test that out until we’ve got something in our definition which attempts to manage a resource. Until then, Terraform doesn’t have any defined resources for which to check state, and so <code>terraform plan</code> succeeds, but it’s an empty victory.
<source lang="shell">$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
------------------------------------------------------------------------
No changes. Infrastructure is up-to-date.
This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.</source>
The command <code>terraform plan</code> compiles the Terraform definition and attempts to determine how to reconcile the resulting desired state with the actual state on the cloud, and produces a plan of what it would if the changes were applied. We’ll see that shortly.


== Defining a VM ==
== Defining a VM ==
cc_staff
44

edits