Terraform: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 31: Line 31:


<!--T:11-->
<!--T:11-->
There are two ways to provide your OpenStack credentials in a command-line environment: via environment variables or in a configuration file.  We'll need to use one of these methods with Terraform, described in the [[#Defining_OpenStack_provider|next section]].  Regardless of your preferred method, the OpenStack web interface offers a simple way to download credentials: once logged in, click on ''API Access'' in the navigation bar, and on that page is a drop-down menu entitled “Download OpenStack RC File”. From here you may download a <code>clouds.yaml</code> file or an RC file which can be sourced from your shell session.
There are two ways to provide your OpenStack credentials in a command-line environment: via environment variables or in a configuration file.  We'll need to use one of these methods with Terraform, described in the [[#Defining_OpenStack_provider|next section]].  Regardless of your preferred method, the OpenStack web interface offers a simple way to download credentials: once logged in, click on <i>API Access</i> in the navigation bar, and on that page is a drop-down menu entitled “Download OpenStack RC File”. From here you may download a <code>clouds.yaml</code> file or an RC file which can be sourced from your shell session.


<!--T:12-->
<!--T:12-->
Line 65: Line 65:


<!--T:22-->
<!--T:22-->
First, describe the ''provider'': this is where you tell Terraform to use OpenStack, and how. On initialization the most recent version of the OpenStack provider plugin will be installed in the working directory and on subsequent Terraform operations, the included credentials will be used to connect to the specified cloud.
First, describe the <i>provider</i>: this is where you tell Terraform to use OpenStack, and how. On initialization the most recent version of the OpenStack provider plugin will be installed in the working directory and on subsequent Terraform operations, the included credentials will be used to connect to the specified cloud.


<!--T:23-->
<!--T:23-->
Line 162: Line 162:


<!--T:38-->
<!--T:38-->
<blockquote>'''Important''': It is good practice to '''always''' specify flavours and images using their IDs even when Terraform supports using the name. Although the name is more readable, the ID is what actually defines the state of the resource and the ID of a given image or flavour '''will never change'''. It is possible, however, for the '''name''' to change. If a flavour or image is retired, for example, and replaced with another of the same name, the next time you run Terraform, the updated ID will be detected and Terraform will determine that you want to '''rebuild or resize the associated resource'''. This is a destructive (and reconstructive) operation.
<blockquote><b>Important</b>: It is good practice to <b>always</b> specify flavours and images using their IDs even when Terraform supports using the name. Although the name is more readable, the ID is what actually defines the state of the resource and the ID of a given image or flavour <b>will never change</b>. It is possible, however, for the <b>name</b> to change. If a flavour or image is retired, for example, and replaced with another of the same name, the next time you run Terraform, the updated ID will be detected and Terraform will determine that you want to <b>rebuild or resize the associated resource</b>. This is a destructive (and reconstructive) operation.
</blockquote>
</blockquote>
A minimal OpenStack VM may be defined as follows in Terraform:
A minimal OpenStack VM may be defined as follows in Terraform:
Line 180: Line 180:


<!--T:40-->
<!--T:40-->
<blockquote>'''Note''': If you’re following along (please do!), use your own values for <code>image_id</code>, <code>flavor_id</code>, and <code>key_pair</code>, or this will probably fail!
<blockquote><b>Note</b>: If you’re following along (please do!), use your own values for <code>image_id</code>, <code>flavor_id</code>, and <code>key_pair</code>, or this will probably fail!
</blockquote>
</blockquote>
The values for <code>image_id</code> and <code>flavor_id</code> are one reason I like to have a terminal session open running the OpenStack CLI, connected to the cloud I’m targeting with Terraform: I switch over to it and issue <code>flavor list</code> or <code>image list</code>. These list the names and IDs.
The values for <code>image_id</code> and <code>flavor_id</code> are one reason I like to have a terminal session open running the OpenStack CLI, connected to the cloud I’m targeting with Terraform: I switch over to it and issue <code>flavor list</code> or <code>image list</code>. These list the names and IDs.
rsnt_translations
56,420

edits

Navigation menu