diff --git a/.gitignore b/.gitignore index 32dd4d5..88eb2fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,33 @@ -# ---> Ansible -*.retry +# ---> Terraform +# Local .terraform directories +**/.terraform/* -# ---> Linux -*~ +# .tfstate files +*.tfstate +*.tfstate.* -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* +# .terraform.lock.hcl +**/.terraform.lock.hcl -# KDE directory preferences -.directory +# Crash log files +crash.log -# Linux trash folder which might appear on any partition or disk -.Trash-* +# Ignore any .tfvars files that are generated automatically for each Terraform run. Most +# .tfvars files are managed as part of configuration and so should be included in +# version control. +# +# example.tfvars -# .nfs files are created when an open file is removed but is still being accessed -.nfs* +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# +# !example_override.tf # ---> Windows # Windows thumbnail cache files @@ -69,12 +82,20 @@ Network Trash Folder Temporary Items .apdisk -# ---> VisualStudioCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json +# ---> Linux +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* # ---> Vim # Swap @@ -95,3 +116,10 @@ tags # Persistent undo [._]*.un~ +# ---> VisualStudioCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6cd23a2 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +.PHONY: all +all: init fmt validate + +.PHONY: init +init: + terraform init -upgrade=false + +.PHONY: initupgrade +initupgrade: + terraform init -upgrade=true + +.PHONY: fmt +fmt: init + terraform fmt + +.PHONY: validate +validate: init fmt + terraform validate + +.PHONY: clean +clean: + $(RM) -r .terraform .terraform.lock.hcl + diff --git a/output.instance.tf b/output.instance.tf new file mode 100644 index 0000000..ede68e4 --- /dev/null +++ b/output.instance.tf @@ -0,0 +1,4 @@ +output "instance" { + value = linode_instance.this +} + diff --git a/resoucce.linode_instance.this.tf b/resoucce.linode_instance.this.tf new file mode 100644 index 0000000..749c8a2 --- /dev/null +++ b/resoucce.linode_instance.this.tf @@ -0,0 +1,11 @@ +resource "linode_instance" "this" { + authorized_keys = var.authorized_keys + backups_enabled = true + booted = true + label = "${var.host_name}.${var.domain_name}" + image = var.image + private_ip = true + tags = var.tags + type = var.type + region = var.region +} diff --git a/terraform.tf b/terraform.tf new file mode 100644 index 0000000..2be7012 --- /dev/null +++ b/terraform.tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + linode = { + source = "linode/linode" + version = ">= 1.27.1" + } + } + required_version = ">= 1.1.9" +} diff --git a/variable.authorized_keys.tf b/variable.authorized_keys.tf new file mode 100644 index 0000000..7a4fae1 --- /dev/null +++ b/variable.authorized_keys.tf @@ -0,0 +1,4 @@ +variable "authorized_keys" { + default = [] + type = list(string) +} diff --git a/variable.domain_name.tf b/variable.domain_name.tf new file mode 100644 index 0000000..274cfb8 --- /dev/null +++ b/variable.domain_name.tf @@ -0,0 +1,4 @@ +variable "domain_name" { + default = "example.com" + type = string +} diff --git a/variable.host_name.tf b/variable.host_name.tf new file mode 100644 index 0000000..6a2e1cc --- /dev/null +++ b/variable.host_name.tf @@ -0,0 +1,4 @@ +variable "host_name" { + default = "hello-world" + type = string +} diff --git a/variable.image.tf b/variable.image.tf new file mode 100644 index 0000000..28ca7a5 --- /dev/null +++ b/variable.image.tf @@ -0,0 +1,4 @@ +variable "image" { + default = "linode/fedora35" + type = string +} diff --git a/variable.region.tf b/variable.region.tf new file mode 100644 index 0000000..5f97528 --- /dev/null +++ b/variable.region.tf @@ -0,0 +1,4 @@ +variable "region" { + default = "us-central" + type = string +} diff --git a/variable.tags.tf b/variable.tags.tf new file mode 100644 index 0000000..a14b03c --- /dev/null +++ b/variable.tags.tf @@ -0,0 +1,4 @@ +variable "tags" { + default = [] + type = list(string) +} diff --git a/variable.type.tf b/variable.type.tf new file mode 100644 index 0000000..6f557e9 --- /dev/null +++ b/variable.type.tf @@ -0,0 +1,4 @@ +variable "type" { + default = "g6-nanode-1" + type = string +}