This module provisions "resources" to a fictitious cloud provider, using the "Fake Web Services" Terraform provider.
These resources are purely for demonstration purposes and are created in Terraform Cloud using an API token.
Important
This guide assume that you have already created an Organization in Terraform Cloud and that you have access to a Version Control System (VCS) repository that contains Terraform configuration.
Terraform Cloud provides first-class support for VCS integration. This allows VCS repositories to contain all of the policies and configuration needed to manage Terraform at scale.
- Connect a VCS Provider to Terraform Cloud
- Create a repository in your VCS provider that contains a copy of the example Terraform configuration
- Clone the source repository to a local directory (optional)
To view your settings, click your user icon and select User settings. Your Profile page appears, showing your username, email address, and avatar.
Create a new token:
- Click Create an API token. The Create API token box appears.
- Enter a Description that explains what the token is for and click Create API token.
- Copy your token from the box and save it in a secure location. Terraform Cloud only displays the token once, right after you create it. If you lose it, you must revoke the old token and create a new one.
To view your workspaces, Click Workspaces in the top navigation bar. Terraform Cloud shows a list of all workspaces in the current organization.
Note
The workspace creation process varies depending on the workflow you choose. The following steps assume that you will connect a Terraform Cloud workspace to a version control system (VCS) repository that contains Terraform configuration
Create a workspace:
- Click Workspaces in the top navigation bar to view a list of the workspaces within your organization.
- Click + New Workspace. The Create a new Workspace page appears.
- Choose Version control as the workflow type.
- Choose an existing version control provider or configure a new one. Refer to Connecting VCS Providers for more details.
- Choose the repository that you created in the VCS Settings section of this guide. The Configure settings page appears.
- Enter a Workspace Name. This defaults to the repository name, if applicable.
- Add an optional Description that will appear at the top of the workspace in the Terraform Cloud UI.
- Open Advanced options to optionally configure the following settings:
- Click Create workspace.
To view and manage the workspace's variables, go to the workspace and click the Variables tab.
Add a server_count variable:
- Go to the workspace Variables page and click + Add variable in the Workspace Variables section.
- Choose the Terraform variable category, and enter
server_count
as the Key, and4
as the Value - Click Save variable. The variable now appears in the list of the workspace's variables
Add a fake_token variable:
- Go to the workspace Variables page and click + Add variable in the Workspace Variables section.
- Choose the Environment variable category, and enter
fake_token
as the Key, and yourAPI token
as the Value. - Mark the variable as sensitive and click Save variable.
Add a fws_hostname variable:
- Go to the workspace Variables page and click + Add variable in the Workspace Variables section.
- Choose the Environment variable category, and enter
fws_hostname
as the Key, andapp.terraform.io
as the Value. - Mark the variable as sensitive and click Save variable.
- Getting Started with Terraform Cloud
- Configuring Version Control Access
- Workspaces
- Viewing and Managing Runs
- The UI/VCS-driven Run Workflow
main.tf
// Providers
terraform {
required_providers {
fakewebservices = {
source = "hashicorp/fakewebservices"
version = "0.2.3"
}
}
}
provider "fakewebservices" {
hostname = var.fws_hostname
token = var.fake_token
}
// Variables
variable "fws_hostname" {
type = string
description = "The Terraform Cloud/Enterprise hostname that will be used in the provider configuration block."
}
variable "fake_token" {
type = string
sensitive = true
description = "The Terraform Cloud/Enterprise user/team token that will be used in the provider configuration block."
}
variable "server_count" {
description = "The number of fakewebservices_server resources that will get provisioned."
}
// Main
module "stack" {
source = "aqitio/stack/fakewebservices"
version = "0.0.6"
stack_prefix = "ENV"
server_count = var.server_count
server_type = "t2.micro"
database_size = 256
vpc_cidr_block = "0.0.0.0/1"
}