more terraform boilerplates

This commit is contained in:
Christian
2022-03-04 17:45:04 +01:00
parent cda48ece9d
commit e4fa5990f4
8 changed files with 67 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
data "civo_ssh_key" "sshkey" {
name = "your-ssh-key-name"
}
resource "civo_instance" "server" {
hostname = "servername"
size = "g3.small"
disk_image = "ubuntu-focal"
# (optional):
# ---
# tags = ["python", "nginx"]
# notes = "this is a note for the server"
# initial_user = "user"
# sshkey_id = data.civo_ssh_key.sshkey.id
}

View File

@@ -0,0 +1,9 @@
variable "zone_id" {}
resource "cloudflare_record" "server" {
zone_id = var.zone_id
name = "your-dns-name"
value = civo_instance.server.public_ip
type = "A"
proxied = false
}

View File

@@ -0,0 +1,40 @@
# General Terraform Settings
# ---
terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 3.0"
}
civo = {
source = "civo/civo"
}
}
}
# Declare Variables
# ---
# TODO: Create a yourfile.auto.tfvars file in the project directory and add your variables in it.
# Example:
# cloudflare_email = "youremail@yourmail.com"
# cloudflare_api_key = "your-api-key"
# civo_token = "your-token"
variable "cloudflare_email" {}
variable "cloudflare_api_key" {}
variable "civo_token" {}
# Set Default Provider Settings
# ---
provider "cloudflare" {
email = var.cloudflare_email
api_key = var.cloudflare_api_key
}
provider "civo" {
token = var.civo_token
# (optional) change the defaullt region
# region = "FRA1"
}

View File

@@ -0,0 +1,24 @@
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "~> 2.13.0"
}
}
}
provider "docker" {}
resource "docker_image" "nginx" {
name = "nginx:latest"
keep_locally = false
}
resource "docker_container" "nginx" {
image = docker_image.nginx.latest
name = "tutorial"
ports {
internal = 80
external = 8000
}
}