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
.bashrc
or.zshrc
file:
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-1
will be provisioned, if you want another OS or machine, modify thevariables.tf
files if you wish. - Run
terraform init
,terraform plan -out= name-of-the-plan
andterraform apply
. At the end,terraform destroy
You 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 send it into the instance via the bash <(curl -sk URL)
line in the resources.tf
file.
To work with these settings, uncomment line 10
in the 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 linode
for configuration. - When prompted, enter the
access_key_id
andsecret_access_key
provided values obtained earlier. The region field can be left blank. - Add the same variables to your
.bashrc
or.zshrc
file 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
8
to13
of thevariables.tf
file. - Edit lines
11
,17
and19
of themain.tf
file with the information about your bucket and the region in which it was created.
If you like this work, give me it a star on GitHub, and consider supporting it buying me a coffee: