Contents
In the previous post, I showed you what is terraform cloud and how to sign a terraform cloud account.
in this post, I will show you how to create a terraform cloud organization and workspace.
Create an Organization
Let me first explain what is terraform cloud organization. Organizations are a shared space for teams to collaborate on workspaces in Terraform Cloud.
Terraform Cloud will prompt you to create a new organization after you sign in for the first time. You need to have at least one organization to start using terraform cloud.
You can give whatever name you like just make sure to follow the naming convention . In our case, the organization name is andrew-programming-tc-study and the email address should be your email address accordingly.
For more information about organization creation, refer to the Terraform Documentation: Creating Organizations.
After creating organization, we will be navigated to create workspace page.
Create a Workspace
Workspaces are how Terraform Cloud organizes infrastructure.
Workspace Contents
Traditionally if we use terraform , we need a local directory to hold our code as well as other content. By using terraform cloud we don’t need local directory anymore but we still need a place to hold these things, terraform cloud workspace is the solution.
Terraform Cloud workspaces and local working directories serve the same purpose, but they store their data differently:
Component | Local Terraform | Terraform Cloud |
---|---|---|
Terraform configuration | On disk | In linked version control repository, or periodically uploaded via API/CLI |
Variable values | As .tfvars files, as CLI arguments, or in shell environment | In workspace |
State | On disk or in remote backend | In workspace |
Credentials and secrets | In shell environment or entered at prompts | In workspace, stored as sensitive variables |
Continue Create Workspace
So let’s continue if we create the organization , the next step is to create a workspace, we can connect to a version control provider or not.
Here I choose to connect to Github.com since my code is located here. Of course, you can choose other VCS based on your actual situation.
Follow the Set up provider instructions to set up the OAuth authentication between Github.com and your terraform cloud workspace.
Fulfill these fields based on the highlighted code:
Click “Register application” button and you will see a page like below:
Copy Client ID and Client Secret value and paste to below fields accordingly.
Finally, click Connect and continue button and you will be navigated to this page and click Authorize AndrewProgramming and continue.
Leave this behind, we don’t need enter SSH keypair unless you do need to do so. Click the skip and finish button on the bottom left.
Next, we can explore the project in Github.com and choose a repository for the workspace.
Click Create workspace button then you will have a newly created workspace called tfc-guide-example.