This project aims to provision instances on Linode with the help of Terraform.
Linode charges you for the use of VMs even if they are in a powered off state and this can cause a huge cost issue for some people. So you can never forget to destroy your instances after some testing.
Note
It is necessary to get credentials for Terraform execution.
-
Create a Linode Personal Access Token.
-
Add two variables to your
.bashrcor.zshrcfile:
export TF_VAR_LINODE_CLI_TOKEN=<your-personal-access-token>
export TF_VAR_public_key_path=$(cat /home/your-username/.ssh/id_rsa.pub)- Clone this repo.
- By default an instance with Debian 12 with
g6-nanode-1will be provisioned, if you want another OS or machine modify themodules/linode/variables.tffiles if you wish. - Run
terraform init,terraform plan -out= name-of-the-planandterraform apply. At the end,terraform destroy.
Tip
If you receive the following error when connecting to your instance:
Received disconnect from 45.xx.xx.xx port 22:2: Too many authentication failures
Disconnected from 45.xx.xx.xx port 22
Run the following command to access:
ssh -o IdentitiesOnly=yes [email protected] -i .ssh/id_rsa.pubYou can also apply post-installation scripts to your Linode instance through Stackscripts. This project counts as example scripts for nginx provisioning provided by Ansible Galaxy.
You can create your own script and upload it to the instance via the .sh file that will be called on line 12 of the modules/linode/resources.tf file.
To work with these settings uncomment line 10 in the modules/linode/instance.tf file.
By default this block will be commented. Uncomment if you use it.
You must manually create a bucket in Object Storage and create Access Keys for it.
Linode Object Storage supports S3-compatible applications, so the aws cli is supported for file handling with Linode.
- Install
aws cli. - Run the command
aws configure --profile linodefor configuration. - When prompted, enter the
access_key_idandsecret_access_keyprovided values obtained earlier. The region field can be left blank. - Add the same variables to your
.bashrcor.zshrcfile by filling them in with the Access Keys values obtained earlier:
export TF_VAR_access_key_id=<your credentials>
export TF_VAR_secret_access_key=<your credentials>- Uncomment lines
8to13of thevariables.tffile. - Uncomment and edit lines
11,17and19of themain.tffile with the information about your bucket and the region in which it was created.