How do I use Terraform with Wasabi?

Terraform is an open source tool that allows you to manage your infrastructure as code. Below are the instructions to use Terraform with Wasabi. Note that these examples discuss the use of Wasabi's us-east-1 and us-east-2 storage regions. To use other Wasabi storage regions, please use the appropriate Wasabi service URL as described in this article

1. Download Terraform

2. Install by unzipping the downloaded file and run the executable file

3. Add the terraform directory to the PATH variable

4. Verify by typing the below command in a new terminal

    terraform --version

5. Terraform describes the infrastructure in a .tf configuration file.  Below is a sample config file that connects to Wasabi and uploads the state file to the bucket:

terraform {
required_version = ">= 0.11, < 0.12"
backend "s3" {
skip_requesting_account_id = true
skip_credentials_validation = true
skip_get_ec2_platforms = true
skip_metadata_api_check = true
access_key = "<WASABI-ACCESS-KEY>"
secret_key = "<WASABI-SECRECT-KEY>"
endpoint = "https://s3.wasabisys.com"
region = "us-east-1"
bucket = "<BUCKET>"
key = "<PATH-IN-BUCKET>/terraform.tfstate"
}
}

 

------------------------------------------------------------------------------------------------------------

 

  • The below example shows how to create an S3 Bucket  on Wasabi using Terraform 

 

provider aws {
region = "us-east-2"
access_key = "XXXXXXXX"
secret_key = "XXXXXXXXXXXXXXXX"

endpoints {
sts = "https://sts.wasabisys.com"
iam = "https://iam.wasabisys.com"
s3 = "https://s3.us-east-2.wasabisys.com"
}

s3_force_path_style = true
skip_get_ec2_platforms = true
}

resource aws_s3_bucket pankaj-terraform-us-east-2-testing-1 {
bucket = "pankaj-terraform-us-east-2-testing-1"
acl = "private"
}

 

Steps to execute this file:

1. On the command line, go to this .tf file path and type "Terraform init" to initialize the provider plugins

2. Then run "Terraform plan" to see if any changes are required for your infrastructure

3. Finally run "Terraform apply" to apply the planned action(s)

Note that when you apply the above plan, you may also see a replication and/or tag related error. This error can be ignored, we do not have replication or tags and features like that for now but its build in syntax that's why it shows the error. Irrespective of them, the operation if you see on the console will be successful.

Using this code, we created a bucket named "pankaj-terraform-us-east-2-testing-1" in us-east-2 region as shown in the screenshot below

Screen_Shot_2020-03-27_at_5.20.41_PM.png

 

Have more questions? Submit a request