test api coverage
regions/images/keys/records working. actions not yet implemented. droplets not working yet.
This commit is contained in:
parent
cdccc88297
commit
194a21da7e
199
main.tf
199
main.tf
|
@ -1,20 +1,179 @@
|
|||
terraform {
|
||||
|
||||
cloud {
|
||||
hostname = "app.terraform.io" # Optional; defaults to app.terraform.io
|
||||
organization = "bij1"
|
||||
workspaces {
|
||||
name = "infra"
|
||||
}
|
||||
}
|
||||
|
||||
required_providers {
|
||||
digitalocean = {
|
||||
source = "digitalocean/digitalocean"
|
||||
version = "~> 2.0"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
provider "digitalocean" {}
|
||||
terraform {
|
||||
|
||||
backend "local" {}
|
||||
|
||||
# cloud {
|
||||
# hostname = "app.terraform.io" # Optional; defaults to app.terraform.io
|
||||
# organization = "bij1"
|
||||
# workspaces {
|
||||
# name = "infra"
|
||||
# }
|
||||
# }
|
||||
|
||||
required_providers {
|
||||
digitalocean = {
|
||||
# https://registry.terraform.io/providers/digitalocean/digitalocean/
|
||||
source = "digitalocean/digitalocean"
|
||||
# source = "bij1/greenhost"
|
||||
version = "~> 2.21.0"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Set the variable value in *.tfvars file
|
||||
# or using -var="do_token=..." CLI option
|
||||
variable "do_token" {}
|
||||
|
||||
# Configure the DigitalOcean Provider
|
||||
provider "digitalocean" {
|
||||
api_endpoint = "https://service.greenhost.net/api/"
|
||||
token = var.do_token
|
||||
}
|
||||
|
||||
###### REGIONS
|
||||
|
||||
data "digitalocean_regions" "available" {
|
||||
# filter {
|
||||
# key = "available"
|
||||
# values = ["true"]
|
||||
# }
|
||||
# filter {
|
||||
# key = "features"
|
||||
# values = ["private_networking"]
|
||||
# }
|
||||
sort {
|
||||
key = "name"
|
||||
direction = "desc"
|
||||
}
|
||||
}
|
||||
|
||||
###### IMAGES
|
||||
|
||||
data "digitalocean_images" "available" {
|
||||
# filter {
|
||||
# key = "distribution"
|
||||
# values = ["Ubuntu"]
|
||||
# }
|
||||
# filter {
|
||||
# key = "regions"
|
||||
# values = ["nyc3"]
|
||||
# }
|
||||
sort {
|
||||
key = "created"
|
||||
direction = "desc"
|
||||
}
|
||||
}
|
||||
|
||||
###### SSH KEYS
|
||||
|
||||
data "digitalocean_ssh_keys" "keys" {
|
||||
# filter {
|
||||
# key = "name"
|
||||
# values = ["laptop", "desktop"]
|
||||
# }
|
||||
sort {
|
||||
key = "name"
|
||||
direction = "asc"
|
||||
}
|
||||
}
|
||||
|
||||
data "digitalocean_ssh_key" "kiara" {
|
||||
name = "kiara"
|
||||
}
|
||||
|
||||
# # Create a new SSH key
|
||||
# resource "digitalocean_ssh_key" "key_kiara" {
|
||||
# name = "kiara's key"
|
||||
# public_key = file("/home/kiara/.ssh/id_rsa.pub")
|
||||
# }
|
||||
|
||||
###### DROPLETS
|
||||
|
||||
# data "digitalocean_droplets" "droplets" {
|
||||
# # filter {
|
||||
# # key = "size"
|
||||
# # values = ["s-1vcpu-1gb"]
|
||||
# # }
|
||||
# # filter {
|
||||
# # key = "backups"
|
||||
# # values = ["true"]
|
||||
# # }
|
||||
# sort {
|
||||
# key = "created_at"
|
||||
# direction = "desc"
|
||||
# }
|
||||
# }
|
||||
|
||||
# data "digitalocean_droplet" "cloud" {
|
||||
# id = "8864"
|
||||
# # name = "cloud.bij1.org"
|
||||
# }
|
||||
|
||||
# # Create a new Droplet using the SSH key
|
||||
# resource "digitalocean_droplet" "web" {
|
||||
# image = "ubuntu-18-04-x64"
|
||||
# name = "web-1"
|
||||
# region = "nyc3"
|
||||
# size = "s-1vcpu-1gb"
|
||||
# ssh_keys = [digitalocean_ssh_key.default.fingerprint]
|
||||
# }
|
||||
|
||||
# # Create a new Web Droplet in the nyc2 region
|
||||
# resource "digitalocean_droplet" "web" {
|
||||
# image = "ubuntu-18-04-x64"
|
||||
# name = "web-1"
|
||||
# region = "nyc2"
|
||||
# size = "s-1vcpu-1gb"
|
||||
# backups = false
|
||||
# monitoring = false
|
||||
# ipv6 = false
|
||||
# # vpc_uuid = ""
|
||||
# # ssh_keys = [] # change = recreate!
|
||||
# # resize_disk = true
|
||||
# # tags = []
|
||||
# # user_data = ""
|
||||
# # volume_ids = []
|
||||
# # droplet_agent = bool
|
||||
# # graceful_shutdown = false
|
||||
# }
|
||||
|
||||
###### DNS RECORDS
|
||||
|
||||
data "digitalocean_records" "records" { # records_bij1_net
|
||||
domain = "bij1.net"
|
||||
# filter {
|
||||
# key = "type"
|
||||
# values = ["MX"]
|
||||
# }
|
||||
sort {
|
||||
key = "name"
|
||||
direction = "asc"
|
||||
}
|
||||
}
|
||||
|
||||
# data "digitalocean_records" "records_bij1_org" {
|
||||
# domain = "bij1.org"
|
||||
# # filter {
|
||||
# # key = "type"
|
||||
# # values = ["MX"]
|
||||
# # }
|
||||
# sort {
|
||||
# key = "name"
|
||||
# direction = "asc"
|
||||
# }
|
||||
# }
|
||||
|
||||
data "digitalocean_record" "static" {
|
||||
domain = "bij1.net"
|
||||
name = "static"
|
||||
}
|
||||
|
||||
# # Add an A record to the domain.
|
||||
# resource "digitalocean_record" "foo" {
|
||||
# domain = "bij1.org"
|
||||
# type = "A"
|
||||
# name = "foo"
|
||||
# value = "192.168.0.11"
|
||||
# ttl = 86400
|
||||
# }
|
||||
|
|
35
outputs.tf
35
outputs.tf
|
@ -0,0 +1,35 @@
|
|||
output "regions_output" {
|
||||
value = data.digitalocean_regions.available.regions
|
||||
}
|
||||
|
||||
output "images_output" {
|
||||
value = data.digitalocean_images.available
|
||||
}
|
||||
|
||||
output "keys_output" {
|
||||
value = data.digitalocean_ssh_keys.keys
|
||||
}
|
||||
|
||||
output "key_output" {
|
||||
value = data.digitalocean_ssh_key.kiara.public_key
|
||||
}
|
||||
|
||||
# output "droplets_output" {
|
||||
# value = data.digitalocean_droplets.droplets
|
||||
# }
|
||||
|
||||
# output "droplet_output" {
|
||||
# value = data.digitalocean_droplet.example.ipv4_address
|
||||
# }
|
||||
|
||||
output "records_output" {
|
||||
value = data.digitalocean_records.records
|
||||
}
|
||||
|
||||
output "record_type" {
|
||||
value = data.digitalocean_record.static.type
|
||||
}
|
||||
|
||||
# output "fqdn" {
|
||||
# value = digitalocean_record.foo.fqdn
|
||||
# }
|
Loading…
Reference in New Issue