GithubHelp home page GithubHelp logo

upcloudltd / terraform-provider-upcloud Goto Github PK

View Code? Open in Web Editor NEW
59.0 14.0 28.0 30.9 MB

Terraform provider for UpCloud

Home Page: https://registry.terraform.io/providers/UpCloudLtd/upcloud

License: MIT License

Makefile 0.29% Go 99.03% Shell 0.41% Dockerfile 0.26%
terraform terraform-provider upcloud golang infrastructure-as-code

terraform-provider-upcloud's Introduction

terraform-provider-upcloud's People

Contributors

aakso avatar abamaxa avatar alienhaxor avatar cancerballs avatar darep avatar dependabot[bot] avatar derkgort avatar github-actions[bot] avatar iler avatar johannestegner avatar joliver avatar jpjarven avatar ka-myl avatar kaminek avatar kangasta avatar meafmira avatar mlackman avatar moitias avatar nate-droid avatar peknur avatar poposensei avatar rossigee avatar scop avatar szepeviktor avatar thevilledev avatar trentrosenbaum avatar villevsv-upcloud avatar yoink00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terraform-provider-upcloud's Issues

Configurable public networking, like private_networking

Looking at the Upcloud API documentation it's possible to configure public and private networking separately for VMs.

Based on https://github.com/UpCloudLtd/terraform-provider-upcloud/tree/master/examples it seems there is an option "private_networking" true/false which sounds like it configures if there's a private network for the VM or not. I need similar configuration option for public networks/IPs..

So it'd be nice to have an option "public_networking" true/false to choose if the VM should get public IP or not..

Basicly I need to be able to provision 3 different kinds of VMs:

  • Both the public and private IP.
  • Only public IP.
  • Only private IP.

Thoughts?

IDE default even though address is set to virtio

Create a server:

resource "upcloud_server" "swarm_manager_nl_pbp1" {
  count = 3

  zone = "nl-pbp1"
  hostname = "nl-pbp1-swarm-manager-${format("%02d", count.index + 1)}.example.com"

  cpu = "6"
  mem = "8192"

  ipv6 = false

  storage_devices = [
    {
      // Root partition
      action = "clone"
      size = 10
      address = "virtio:0"
      tier = "maxiops"
      storage = "01e3dbaf-c236-448a-bf03-5b43ad626140"
    },
    {
      // Data partition
      action = "create"
      size = 50
      address = "virtio:1"
      tier = "maxiops"
    },
  ]
}

Now we want to attach a new disk

resource "upcloud_server" "swarm_manager_nl_pbp1" {
  count = 3

  zone = "nl-pbp1"
  hostname = "nl-pbp1-swarm-manager-${format("%02d", count.index + 1)}.example.com"

  cpu = "6"
  mem = "8192"

  ipv6 = false

  storage_devices = [
    {
      // Root partition
      action = "clone"
      size = 10
      address = "virtio:0"
      tier = "maxiops"
      storage = "01e3dbaf-c236-448a-bf03-5b43ad626140"
    },
    {
      // Data partition
      action = "create"
      size = 50
      address = "virtio:1"
      tier = "maxiops"
    },
    {
      // Swap
      action = "create"
      size = 10
      address = "virtio:2"
      tier = "maxiops"
    }
  ]
}

After running terraform apply

The second disk will be created as IDE:0:0 which will render the machine not bootable, even though the original plan says that it will be created with virtio

  ~ upcloud_server.swarm_manager_nl_pbp1[0]
      storage_devices.#:         "2" => "3"
      storage_devices.2.action:  "" => "create"
      storage_devices.2.address: "" => "virtio:2"
      storage_devices.2.size:    "" => "24"
      storage_devices.2.tier:    "" => "maxiops"

Running terraform apply again will correct the issue

upcloud_server.swarm_manager_nl_pbp1[1]: Modifying... (ID: 0033790c-15b4-4862-a490-a63d88f48a38)
  storage_devices.2.address: "ide:0:0" => "virtio:2"
upcloud_server.swarm_manager_nl_pbp1[3]: Modifying... (ID: 00a6d58e-2d8a-4ad8-b47c-624ef39b6395)
  storage_devices.2.address: "ide:0:0" => "virtio:2"
upcloud_server.swarm_manager_nl_pbp1[2]: Modifying... (ID: 001f7688-d9e1-4bf8-94af-bb3b26132582)
  storage_devices.2.address: "ide:0:0" => "virtio:2"

Add data source for images

Create a separate datasource for filtering images through UpCloud API. This could be then used like this:

data "upcloud_image" "centos" {
  name         = "CentOS 7.0"
}

resource "upcloud_server" "test_server" {
  image = "${data.upcloud_image.centos.id}"
}

The ID used by the image resource should be the image UUID, so if user wants to define raw UUIDs to upcloud_server parameters then it would still be possible.

Whenever I import a running upcloud_server instance, storage devices do not get imported

I am trying to import the current Upcloud infrastructure to a terraform state file. That server, webServerA, has 3 storage devices attached to it.
This is the terraform resource block for that upcloud_server

resource "upcloud_server" "webserver" {
  zone     = "nl-ams1"
  hostname = "webServerA"
}

I am executing terraform import upcloud_server.webServerA <server_id>.

It gets imported successfully however without the information regarding the storage devices and their backup rules.

terraform state show upcloud_server.webServerA output:

# upcloud_server.webServerA:
resource "upcloud_server" "webServerA" {
    cpu                  = 6
    hostname             = "webServerA"
    id                   = <server_id>
    ipv4_address         = <server_ip>
    ipv4_address_private = <<server_ip_private>
    mem                  = 8192
    title                = "webServerA (managed by terraform)"
    zone                 = "nl-ams1"
}

This is obviously not the correct resource.

Now the problem is that when I am trying to execute terraform plan, it tries to recreate the storage devices because they do not exist in the state file.

The operation is not allowed while the server is in state 'maintenance'. (SERVER_STATE_ILLEGAL)

The operation is not allowed while the server 00ee80de-d95d-4ed5-89e7-875d7a317c7d is in state 'maintenance'. (SERVER_STATE_ILLEGAL)
The server was already up and running but it gave me that error. It occurs every now and than.

Error: Error applying plan:

1 error(s) occurred:

* upcloud_server.test (destroy): 1 error(s) occurred:

* upcloud_server.test: The operation is not allowed while the server 00ee80de-d95d-4ed5-89e7-875d7a317c7d is in state 'maintenance'. (SERVER_STATE_ILLEGAL)

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure

I tried to ran the plan again and it was a successfully

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  - upcloud_server.test


Plan: 0 to add, 0 to change, 1 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

upcloud_server.test: Destroying... (ID: 00ee80de-d95d-4ed5-89e7-875d7a317c7d)
upcloud_server.test: Still destroying... (ID: 00ee80de-d95d-4ed5-89e7-875d7a317c7d, 10s elapsed)
upcloud_server.test: Destruction complete after 18s

Apply complete! Resources: 0 added, 0 changed, 1 destroyed.

I just changed the count from 1 to 0

resource "upcloud_server" "test" {
  count    = 0
  zone     = "nl-lia1"
  hostname = "nikoh-timeout-testing-${format("%04d", count.index + 1)}"

  cpu      = "2"
  mem      = "1024"

  # Login details
  login {
    user = "tf"

    keys = [
      "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCZNKVSnDL5B+0DwqO04aQLmPKSy55kZ4vDNsKl2/YrI4qroICjWT0Hum89FuHv5HdEmpjWKRpyn06WLIi28C22LO5xDWUbnbsoNSiaNSC/CgKwZ/hu5fmScb0dAf+Va+KS42FEOGcSbAd36R2htRHnaLg4cgN2RjjQw8p5lfiVPl4zDtZr8+mZZKKPs6pxHY54mM5oTt+mqzfncwvnfF4tS498VY5kC4stqZAO1/A3rdP2YI7uIXP2bvQ4MSKohI9eoePTbuOCCZC7E20NA4uKxCeimGCciAusolp+1TrkDBmARF7ew/AI/X/R9d+tlZhcJ1QSx+oM9xhEuGEL6bxJ [email protected]",
    ]

    create_password   = false
    password_delivery = "email"
  }

  storage_devices = [
    {
      # You can use both storage template names and UUIDs
      size    = 10
      action  = "clone"
      tier    = "maxiops"
      storage = "01000000-0000-4000-8000-000020040100"
    }
  ]
}

Reprovisioning server forces destroy/create

When re-provisioning an already existing server the id field (which then is "server_id" => "<computed>") counts as changed and forces a destroy + create instead of update.
I would think that one possible solution is to add the server ID parameter to the resource_upcloud_server.go Schema, something like:

"id": {
        Type:     schema.TypeString,
	Computed: true,
},

Submitting non valid values as updates succeeds

Example:


  storage_devices = [
    {
      size    = 70
      action  = "clone"
      storage = "Ubuntu Server 16.04 LTS (Xenial Xerus)"
      title   = "Storage 1"
      tier    = "asdsds"
    },
  ]

Results correctly in:

Error: Error applying plan:

1 error(s) occurred:

* upcloud_server.test: 1 error(s) occurred:

* upcloud_server.test: The attribute tier has an invalid value. (TIER_INVALID)

But after creating this resource successfully and then updating with the incorrect

tier = "asdsds"

Results in an apparent success(no error messages).

Login ssh keys can't be empty

If there's a custom image in use there's no need for additional keys since those can be added by the packer. I wouldn't like to drop out the login since it's nice to have root passwords just in case ๐Ÿ˜„
It seems that the Terraform plan is impossible to run successfully if the login's ssh key option is empty.

Actually I think it's by the design that it's not possible to manage ssh keys by that login option with the custom images?

Snippet from the server.tf file:

  # Login details
  login {
    user              = "${var.user}"
    keys              = "${var.keys}" <-- In here it would be nice to have an empty value option
    create_password   = "${var.create_password}"
    password_delivery = "${var.password_delivery}"
  }

I have used the custom connection block so the solution has been to add the "terraform" user public key into that keys variable.

Storage image update failed

There's no effect if the storage id is changed afterwards.
The problem occurs if the original image is tried to change e.g. from Debian GNU/Linux 9.5 (Stretch) to a custom image (e.g. created by the packer)

Example from the Terraform plan:

$ terraform plan
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  ~ module.upcloud_server.instance
      storage_devices.0.storage: "01000000-0000-4000-8000-000020040100" => "xxxxxxx-xxxx-xxx-xxx-xxxxxxx"

Plan: 0 to add, 1 to change, 0 to destroy.

I think that instead of the update process (update in-place) provider should destroy the current instance and then create a replacement instance with the updated image (-/+ destroy and then create replacement)

The result of the terraform plan would look like Plan: 1 to add, 0 to change, 1 to destroy.

Add firewall as resource

It seems the only "resource" in UpCloud that can currently be managed is a server, firewalls are not yet included in this provider? I think this is one of the use cases for using Terraform in the first place since firewall rules can be large and complex and they are very important to get right.

Support more than one login block

It does not currently appear to be possible to specify more than one login block.

For example, if you try calling terraform plan using the following definition:

variable "users" {
  type = list
  default = ["root", "user1"] 
}

resource "upcloud_server" "server1" {

  ...

  dynamic "login" {
    for_each = var.users
    content {
      user = login.value
      keys = [
        file(var.public_key_path),
      ]
      create_password = var.set_password
      password_delivery = "email"
    }
  }

...it gives the error:
image

Is there any reason for this limitation and, if not, can it be disabled?

Error: Pulumi Terraform Bridge Provider for UpCloud

I am trying to create a Pulumi Terraform Bridge Provider for UpCloud, code is in Pulumi-upcloud repo

By following README steps, finally running build with make command I got this:

upcloud Package
BUILD:

go install -ldflags "-X github.com/pulumi/pulumi-upcloud/pkg/version.Version=v0.0.1-dev.1582803188+g9ddff78" github.com/pulumi/pulumi-upcloud/cmd/pulumi-tfgen-upcloud
# github.com/pulumi/pulumi-upcloud
./resources.go:90:25: invalid type assertion: "github.com/UpCloudLtd/terraform-provider-upcloud/upcloud".Provider().(*"github.com/hashicorp/terraform-plugin-sdk/helper/schema".Provider) (non-interface type *"github.com/hashicorp/terraform/helper/schema".Provider on left)
make: *** [tfgen] Error 2

Any idea or suggestion about how to solve it would be very helpful ?

custom image cloning via terraform

I'm trying to clone custom server created by doing a snapshot. The resource is created, but the next resource that I create destroys previously created server and replaces with the new one. Also it creates server name in upcloud dashboad that equals to hostname set in .tf file and is forbidding to set the 'title' field within. Since this functionality is working via upcloud dashboard, I would expect this to work via terraform. Or is there another way to do it?

Firewall rule `position` required but not caught in `plan`

When creating a new firewall rule through the API the position argument is optional (in the documentation that is), the same seems to apply for the terraform plan command but not for the terraform apply command.

The position field is used when querying for the rules upon removal or updates, which makes it understandable that they require it, but it would be great if the plan command threw errors too!

Shutting down the machines when creating a backup policy

Is it possible to set the backup policies without shutting down the server ?
Currently whenever I need to add a backup policy the plugin shut downs the servers in question

Also from the UI looks like it's impossible to set different retention period for disks.

  1. Disk0 is the root disk backup daily and keep 1 backup
  2. Disk1 is the data disk and backup daily and keep for 1 week

But from the terraform plugin it's possible, will this break some functionality, should I be even doing this then?

Add support for defining VNC configs

Add VNC related config parameters to server schema. Allow modification through update method without power cycling the hosts (since the API can do that without disruption).

Is this project still active?

I am trying out upcloud, and the terraform provider is important to me. However, it seems to be inactive, recent terraform versions are not supported and several PRs are open. In fact, this year not a single issue has been answered by the mantainers.
Are there any plans for this project?

Same tags for different plans

When you have created a upcloud_tag resource with a given name, and have more than one environment (say stage and prod) you might want to re-use the same tags that is created for one env on the other env too.

Example:
I tag my servers which runs Ubuntu with ubuntu and 1604lts. I want both the machines in the production and staging environment to use the same tags, but my production and staging envs does not share the terraform state files.
So when first creating a tag for the production servers:

resource upcloud_tag {
  name = "ubuntu"
  servers = ["id", "id2"]
}

And then move on to my stage:

resource upcloud_tag {
  name = "ubuntu"
  servers = ["id3", "id4"]
}

terraform fails.

Not too strange really, the resource exists with its given name and a set of servers already, but I would love to merge them.


I think a way of fixing this would be to add a property to the Tag schema, say merge = true/false, and if it's set to true, the provider will first fetch the current server list, then merge the lists and use that list as the actual resource. That way the tag resource is updated with all the servers.

Would this be a wanted feature? I will gladly take a hit on fixing it, but wouldn't want to do it if it's not something that is wanted!

Issue when installing UpCloud provider plugin from source

Based on your tutorial at https://upcloud.com/community/tutorials/get-started-terraform/, I tried to install the plugin but something is making it fail.

$ go get github.com/UpCloudLtd/terraform-provider-upcloud                                                                                                                        
# github.com/hashicorp/terraform/helper/plugin
hashicorp/terraform/helper/plugin/grpc_provisioner.go:173:6: b.Cap undefined (type strings.Builder has no field or method Cap)

Terraform version is Terraform v0.12.20. This is blocking me and I guess other users from managing Upcloud Infrastructure with Terraform. Please can you fix that?

source_ip_filtering always stuck to true

Upcloud terraform provider does not let source_ip_filtering to be set to false.

Steps to reproduce:

Apply the following terraform file:

terraform {
  required_providers {
    upcloud = {
      source = "UpCloudLtd/upcloud"
      version = "1.0.0"
    }
  }
}

provider "upcloud" {
}

resource "upcloud_network" "network" {
  name = "my private network"
  zone = "fi-hel1"

  ip_network {
    address = "10.201.0.0/24"
    dhcp = false
    dhcp_default_route = false
    family = "IPv4"
    gateway = "10.201.0.1"
  }
}

resource "upcloud_server" "server" {
  zone = "fi-hel1"
  hostname = "server"
  plan = "1xCPU-1GB"

  storage_devices {
    size = 10
    action = "clone"
    tier = "maxiops"
    title = "boot disk"
    storage = "Debian GNU/Linux 10 (Buster)"
  }

  network_interface {
    type = "private"
    network = upcloud_network.network.id
    source_ip_filtering = false
  }
}

output "source_ip_filtering" {
  value = upcloud_server.server.network_interface[0].source_ip_filtering
}

Expected behaviour:

Should output source_ip_filtering = false.

Actual behaviour:

Incorrectly outputs source_ip_filtering = true, which also causes recreation of new instance if another terraform apply is made subsequently. Possibly calls to POST /1.3/server/{uuid}/networking/interface are not made at all, which also prevents use of static ip addresses.

Documentation is incomplete even for testing

The documentation in both the root directory (https://github.com/vtorhonen/terraform-provider-upcloud/blob/master/README.md) and examples diretory (https://github.com/vtorhonen/terraform-provider-upcloud/blob/master/examples/README.md) is incomplete and conflicting even for testing the provider. If one follows the instructions for installing in the provider in the root directory and tries to run terraform init it ends up with the following error:

Initializing provider plugins...
- Checking for available provider plugins on https://releases.hashicorp.com...

Provider "upcloud" not available for installation.

A provider named "upcloud" could not be found in the official repository.

This may result from mistyping the provider name, or the given provider may
be a third-party provider that cannot be installed automatically.

In the latter case, the plugin must be installed manually by locating and
downloading a suitable distribution package and placing the plugin's executable
file in the following directory:
    terraform.d/plugins/darwin_amd64

Terraform detects necessary plugins by inspecting the configuration and state.
To view the provider versions requested by each module, run
"terraform providers".

enable API seems only be possible in old dashboard

The upcloud terraform provider depends on the upcloud API being enabled. The only way I've found to enable the API is via the "old" upcloud dashboard:

image

Does the new upcloud dashboard support a way to enable API integration?

Terraform timeout problem

Hi,

I was trying to create 10 instances (by using the count indexes) at once but the Terraform gave me this kinds of errors:

* upcloud_server.instance.2: Timeout reached while waiting for server to enter state "started"

Based on that it would be nice to have a timeout feature into the upcloud_server resource which makes possible to manage timeouts and functionality in different use cases (delete, update, recreate etc.).

Or is it possible to use connection block inside of the resource like it can be used with the provisioners?

CIDR block inputs

Update: We think this can be treated as a documentation issue, where the source_address_start = cidrhost(var.cidr, "1") and source_address_end = cidrhost(var.cidr, "-1") examples are included in the Terraform registry docs for upcloud_network as well as the github docs.

For the same reasons/motivation as in issue #65 : to reuse terraform code across cloud vendors it helps to pass network ranges a cidr blocks instead of:

      source_address_end = "192.168.1.255"
      source_address_start = "192.168.1.1"

Right now we have to re-write all our resources that abstract away cloud provider specifics, to use different inputs.
This also makes it more costly/difficult to integrate UpCloud when other providers consume ["172.19.48.0/20", "172.19.64.0/20", "172.19.80.0/20",].

A workaround might be to provide two helper functions that takes as input a CIDR block and outputs either the start IP or end IP.

Resizing a disk succeeds when it should fail

If you have a disk that is 24GB and you put 8GB in the definition it says it's success but it should fail, as it's not possible to downsize a disk.

Latest terraform plugin (built from master today)

Shouldn't this throw an error?

    {
      action  = "create"
      size    = 24
      address = "virtio:1"
      tier    = "maxiops"
    },

And then after creation change to

    {
      action  = "create"
      size    = 8
      address = "virtio:1"
      tier    = "maxiops"
    },

This will succeed sometimes, and sometimes it will give a timeout.
But the disk will remain 24GB.

Removing it from the tf file and then re-adding it with the correct size works properly

Cannot pass username and password in as non-environment variables

I'm currently using the plugin upcloud provider with terraform 0.13. I do not want to set the username and password as an environment variable, since running it with sudo would require me to type UPCLOUD_USERNAME=<username> UPCLOUD_PASSWORD=<password> sudo -E terraform apply every time.

As per 0.13, the plugin is properly built and linked in $HOME/.terraform.d/upcloud.com/upcloud/upcloud/1.0/linux_amd64 and works correctly when initializing, but when running terraform plan I get the following error:

Error: Missing required argument

The argument "password" is required, but was not set.


Error: Missing required argument

The argument "username" is required, but was not set.

the terraform configuration in the main.tf looks like this

terraform {
  required_providers {
    upcloud = {
        source = "upcloud.com/upcloud/upcloud"
        username = <username>
        password = <password>
    }
  }
}

I've explored the provider.go file and it seemd to indicate a "username" and "password" field as valid options, but so far nothing seems to work.

Output the IP of a created server resource

Currently when creating a server resource with this provider it only outputs the ID of the server when it's created, but no information that would allow connecting to the created resource. I think it would be good to output the needed information after the creation so that one does not have to still have to open the UpCloud UI to get information like the IP of the created server. Outputting this info allows for automation where terraform apply could be run in a script that captures the IP and continues the configuration automatically. The example documentation here https://github.com/vtorhonen/terraform-provider-upcloud/blob/master/examples/README.md suggests this would happen. When testing the tool this part never showed up:

Outputs:

ip = <SOME IP ADDRESS>

File provisioner reports ssh: handshake failed

Using the following terraform config:

resource "upcloud_server" "app4" {
  zone     = "uk-lon1"
  hostname = "app4.upcloud.mydomain.com"

  cpu      = "2"
  mem      = "4096"

  # Login details
  login {
    user = "root"

    keys = [
      "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvEEM09rqCFaiv0u0vg8c2FHRPZpOlQ1DzXWLcgnH/2APUElHk6KtYPQZeaIMQRHBUsABrqwBimBlJAss4k8Wf3y/eqsCyNBezZoSoslJPuKpVxzLs3j4pdvKO3FuJy7792CgMLyvVrJ9bA/PYfb4BAkzAeXrwyZFvoib1+SHAz6QH/VWtIpzZYR9GbETg5nd8AXYAVVMnLW+jn5PMyZBrAU70gy/ga3jAj8lvNj+Kq3HdEu/0QA5M3cfnJpRWBLpEghX1GbkjR+sA6gYBgvt3HMyjI+fFNAJg2JtMV1rXzWQQWDIbRjkQIfnC/yJ/CousoZ+c/VpirhiFImh0emF5"
    ]
  }

  storage_devices = [
    {
      # You can use both storage template names and UUIDs
      size    = 25
      action  = "clone"
      tier    = "maxiops"
      storage = "Ubuntu Server 18.04 LTS (Bionic Beaver)"

      backup_rule = {
        interval = "daily"
        time = "0100"
        retention = 8
      }
    }
  ]

  # Run a script to install Docker
  provisioner "file" {
    source = "scripts/provision-app-host.sh"
    destination = "/tmp/provision-app-host.sh"
  }
  provisioner "remote-exec" {
    inline = [
      "chmod +x /tmp/provision-app-host.sh",
      "/tmp/provision-app-host.sh",
    ]
  }

When run, I get:

upcloud_server.app4: Creating...
  cpu:                                     "" => "2"
  hostname:                                "" => "app4.upcloud.mydomain.com"
  ipv4:                                    "" => "true"
  ipv4_address:                            "" => "<computed>"
  ipv4_address_private:                    "" => "<computed>"
  ipv6:                                    "" => "true"
  ipv6_address:                            "" => "<computed>"
  login.#:                                 "" => "1"
  login.2905545760.create_password:        "" => "false"
  login.2905545760.keys.#:                 "" => "1"
  login.2905545760.keys.0:                 "" => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvEEM09rqCFaiv0u0vg8c2FHRPZpOlQ1DzXWLcgnH/2APUElHk6KtYPQZeaIMQRHBUsABrqwBimBlJAss4k8Wf3y/eqsCyNBezZoSoslJPuKpVxzLs3j4pdvKO3FuJy7792CgMLyvVrJ9bA/PYfb4BAkzAeXrwyZFvoib1+SHAz6QH/VWtIpzZYR9GbETg5nd8AXYAVVMnLW+jn5PMyZBrAU70gy/ga3jAj8lvNj+Kq3HdEu/0QA5M3cfnJpRWBLpEghX1GbkjR+sA6gYBgvt3HMyjI+fFNAJg2JtMV1rXzWQQWDIbRjkQIfnC/yJ/CousoZ+c/VpirhiFImh0emF5"
  login.2905545760.password_delivery:      "" => "none"
  login.2905545760.user:                   "" => "root"
  mem:                                     "" => "4096"
  private_networking:                      "" => "true"
  storage_devices.#:                       "" => "1"
  storage_devices.0.action:                "" => "clone"
  storage_devices.0.address:               "" => "<computed>"
  storage_devices.0.backup_rule.%:         "" => "3"
  storage_devices.0.backup_rule.interval:  "" => "daily"
  storage_devices.0.backup_rule.retention: "" => "8"
  storage_devices.0.backup_rule.time:      "" => "0100"
  storage_devices.0.id:                    "" => "<computed>"
  storage_devices.0.size:                  "" => "25"
  storage_devices.0.storage:               "" => "Ubuntu Server 18.04 LTS (Bionic Beaver)"
  storage_devices.0.tier:                  "" => "maxiops"
  storage_devices.0.title:                 "" => "<computed>"
  title:                                   "" => "<computed>"
  zone:                                    "" => "uk-lon1"
upcloud_server.app4: Still creating... (10s elapsed)
upcloud_server.app4: Still creating... (20s elapsed)
upcloud_server.app4: Still creating... (30s elapsed)
upcloud_server.app4: Still creating... (40s elapsed)
upcloud_server.app4: Still creating... (50s elapsed)
upcloud_server.app4: Still creating... (1m0s elapsed)
upcloud_server.app4: Still creating... (1m10s elapsed)
upcloud_server.app4: Still creating... (1m20s elapsed)
upcloud_server.app4: Still creating... (1m30s elapsed)
upcloud_server.app4: Still creating... (1m40s elapsed)
upcloud_server.app4: Still creating... (1m50s elapsed)
upcloud_server.app4: Still creating... (2m0s elapsed)
upcloud_server.app4: Still creating... (2m10s elapsed)
upcloud_server.app4: Still creating... (2m20s elapsed)
upcloud_server.app4: Still creating... (2m30s elapsed)
upcloud_server.app4: Still creating... (2m40s elapsed)
upcloud_server.app4: Still creating... (2m50s elapsed)
upcloud_server.app4: Still creating... (3m0s elapsed)
upcloud_server.app4: Still creating... (3m10s elapsed)
upcloud_server.app4: Provisioning with 'file'...
upcloud_server.app4: Still creating... (3m20s elapsed)
upcloud_server.app4: Still creating... (3m30s elapsed)
upcloud_server.app4: Still creating... (3m40s elapsed)
upcloud_server.app4: Still creating... (3m50s elapsed)
upcloud_server.app4: Still creating... (4m0s elapsed)
upcloud_server.app4: Still creating... (4m10s elapsed)
upcloud_server.app4: Still creating... (4m20s elapsed)
upcloud_server.app4: Still creating... (4m30s elapsed)
upcloud_server.app4: Still creating... (4m40s elapsed)
upcloud_server.app4: Still creating... (4m50s elapsed)

upcloud_server.app4: Still creating... (5m0s elapsed)
upcloud_server.app4: Still creating... (5m10s elapsed)
upcloud_server.app4: Still creating... (5m20s elapsed)
upcloud_server.app4: Still creating... (5m30s elapsed)
upcloud_server.app4: Still creating... (5m40s elapsed)
upcloud_server.app4: Still creating... (5m50s elapsed)
upcloud_server.app4: Still creating... (6m0s elapsed)
upcloud_server.app4: Still creating... (6m10s elapsed)
upcloud_server.app4: Still creating... (6m20s elapsed)
upcloud_server.app4: Still creating... (6m30s elapsed)
upcloud_server.app4: Still creating... (6m40s elapsed)
upcloud_server.app4: Still creating... (6m50s elapsed)
upcloud_server.app4: Still creating... (7m0s elapsed)
upcloud_server.app4: Still creating... (7m10s elapsed)
upcloud_server.app4: Still creating... (7m20s elapsed)
upcloud_server.app4: Still creating... (7m30s elapsed)
upcloud_server.app4: Still creating... (7m40s elapsed)
upcloud_server.app4: Still creating... (7m50s elapsed)
upcloud_server.app4: Still creating... (8m0s elapsed)
upcloud_server.app4: Still creating... (8m10s elapsed)

Error: Error applying plan:

1 error(s) occurred:

* upcloud_server.app4: timeout - last error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [publickey none], no supported methods remain

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Any ideas why it's timing out?

Add support for defining login credentials

CreateServerRequest takes LoginUser struct as an argument. Allow implementation to define either

  • SSH keys
  • Auto-generated password, which is delivered by none/sms/e-mail

An additional resource type should be created, so the same user account can be used in different Terraform configs.

Allow default incoming/outgoing firewall rules to be specified for a server

Currently it does not appear to be possible to specify whether the default incoming and outgoing firewall rules for a server should be ACCEPT or DROP and this needs to be specified via the UI, i.e.:

image

It also does not appear to be possible to auto-add the default firewall rules for DNS traffic, i.e.:

image

Provider validation failure

provider "upcloud" {
  # Your UpCloud credentials are read from the environment variables
  # export UPCLOUD_USERNAME="Username for Upcloud API user"
  # export UPCLOUD_PASSWORD="Password for Upcloud API user"
}

image

Tagging feature doesn't work

I have the following tf file, and am running into issues while using the tagging feature. Used latest version of provider

$ terraform --version
Terraform v0.11.7
+ provider.upcloud (unversioned)

resource.tf


resource "upcloud_server" "s2s" {

  zone = "nl-pbp1"
  hostname = "s2s.example.com"

  cpu = "2"
  mem = "4096"

  ipv6 = false

  storage_devices = [
    {
      action = "clone"
      size = 10
      address = "virtio:0"
      storage = "01e3dbaf-c236-448a-bf03-5b43ad626140"
      tier = "maxiops"
    }
  ]

}

resource "upcloud_tag" "core" {
  description = "Core functionality"
  name = "core"
  servers = {
    server = [
     "${upcloud_server.s2s.id}"
   ]
  }
  depends_on = [
    "upcloud_server.s2s",
  ]
}

I get the following error when I try to do apply or see the plan

$ terraform plan

Error: upcloud_tag.core: servers: unexpected map value type: map[string]*schema.Schema{"server":*schema.Schema{Type:5, Optional:false, Required:true, DiffSuppressFunc:(schema.SchemaDiffSuppressFunc)(nil), Default:interface {}(nil), DefaultFunc:(schema.SchemaDefaultFunc)(nil), Description:"", InputDefault:"", Computed:false, ForceNew:false, StateFunc:(schema.SchemaStateFunc)(nil), Elem:4, MaxItems:0, MinItems:0, PromoteSingle:false, Set:(schema.SchemaSetFunc)(nil), ComputedWhen:[]string(nil), ConflictsWith:[]string(nil), Deprecated:"", Removed:"", ValidateFunc:(schema.SchemaValidateFunc)(nil), Sensitive:false}}

Build fails

$ make build
==> Checking that code complies with gofmt requirements...
dep ensure
go install
can't load package: package github.com/UpCloudLtd/terraform-provider-upcloud: code in directory /Users/xxx/go/src/github.com/UpCloudLtd/terraform-provider-upcloud expects import "github.com/vtorhonen/terraform-provider-upcloud"
make: *** [build] Error 1

Invite to publish to the Terraform Registry

๐Ÿ‘‹ Hi there! We noticed this provider is on our list of community providers, however it has not yet been published to the newly-released Terraform Registry for Providers (registry.terraform.io). We'd like to invite you to get it published, since it makes using and installing it much easier for anyone using Terraform 0.13! Instructions for doing so are available here. Please note that we will soon be redirecting the community listing page to registry.terraform.io.

Thanks for your contributions and we look forward to seeing this provider listed soon!

Thanks,
Team Terraform @ HashiCorp

Creating server with backup rule does not work

Adding backup rule to server creation causes server to be created without disk image. Server can not boot because of that.

Workaround is to create server without the backup and modify the plan after first deployment.

Terraform Error: net/http: TLS handshake timeout

Hi,

I got the following error when executing Terraform, below Terraform the output

To perform exactly these actions, run the following command to apply:
    terraform apply "tfplan"

upcloud_server.benchmark: Creating...
upcloud_server.benchmark: Still creating... [10s elapsed]
upcloud_server.benchmark: Still creating... [20s elapsed]
upcloud_server.benchmark: Still creating... [30s elapsed]

Error: Get https://api.upcloud.com/1.2/server/00a66a70-8915-4f35-9b4a-eb99d1623423: net/http: TLS handshake timeout

Terraform version

$ terraform --version
Terraform v0.12.17

Here is my Terraform configurations

template.tf

provider "upcloud" {
    username = var.username
    password = var.password
}

resource "upcloud_server" "resource_name" {
    hostname = var.hostname
    zone     = var.zones[var.zone]
    plan     = var.plans[var.plan]
    
    storage_devices {
        size    = lookup(var.storages, var.plans[var.plan])
        tier    = "maxiops"
        storage = var.templates[var.template]
        action  = "clone"
    }

    login {
        user = "root"
        keys = [
            var.ssh_public_key
        ]
    }

    connection {
        host        = self.ipv4_address
        type        = "ssh"
        user        = "root"
        private_key = file(var.ssh_private_key_path)
    }
}

terraform.tfvars

username    = "myuser"
password    = "********"
hostname    = "lemper.eslabs.id"
plan        = "5USD"
zone        = "sanjose1"
template    = "ubuntu-18.04"

my custom variables.tf

variable plans {
    type = map
    default = {
        "5USD"      = "1xCPU-1GB"
        "10USD"     = "1xCPU-2GB"
        "20USD"     = "2xCPU-4GB"
        "40USD"     = "4xCPU-8GB"
        "80USD"     = "6xCPU-16GB"
        "160USD"    = "8xCPU-32GB"
        "240USD"    = "12xCPU-48GB"
        "320USD"    = "16xCPU-64GB"
        "480USD"    = "20xCPU-96GB"
        "640USD"    = "20xCPU-128GB"
    }
}

variable storages {
    type = map
    default = {
        "1xCPU-1GB"     = "25"
        "1xCPU-2GB"     = "50"
        "2xCPU-4GB"     = "100"
        "4xCPU-8GB"     = "160"
        "6xCPU-16GB"    = "320"
        "8xCPU-32GB"    = "640"
        "12xCPU-48GB"   = "960"
        "16xCPU-64GB"   = "1280"
        "20xCPU-96GB"   = "1920"
        "20xCPU-128GB"  = "2048"
    }
}

variable zones {
    type = map
    default = {
        "amsterdam1"    = "nl-ams1"
        "london1"       = "uk-lon1"
        "frankfurt1"    = "de-fra1"
        "helsinki1"     = "fi-hel1"
        "helsinki2"     = "fi-hel2"
        "chicago1"      = "us-chi1"
        "sanjose1"      = "us-sjo1"
        "singapore1"    = "sg-sin1"
    }
}

variable templates {
    type = map
    default = {
        "centos-6"       = "01000000-0000-4000-8000-000050010200" 
        "centos-7"       = "01000000-0000-4000-8000-000050010300"
        "centos-8"       = "01000000-0000-4000-8000-000050010400"
        "coreos"         = "01000000-0000-4000-8000-000080010200"
        "debian-8"       = "01000000-0000-4000-8000-000020030100"
        "debian-9"       = "01000000-0000-4000-8000-000020040100"
        "debian-10"      = "01000000-0000-4000-8000-000020050100"
        "ubuntu-16.04"   = "01000000-0000-4000-8000-000030060200"
        "ubuntu-18.04"   = "01000000-0000-4000-8000-000030080200"
        "windows-2012"   = "01000000-0000-4000-8000-000010050300"
        "windows-2012dc" = "01000000-0000-4000-8000-000010050200"
        "windows-2016"   = "01000000-0000-4000-8000-000010060300"
        "winsows-2016dc" = "01000000-0000-4000-8000-000010060200"
        "windows-2019"   = "01000000-0000-4000-8000-000010070300"
        "windows-2019dc" = "01000000-0000-4000-8000-000010070200"
    }
}

variable hostname {
    default = "template"
}

variable plan {
    default = "5USD"
}

variable zone {
    default = "sanjose1"
}

variable template {
    default = "ubuntu-18.04"
}

variable username {
    default = "username"
}

variable password {
    default = "password"
}

variable ssh_private_key_path {
    default = ""
}

variable ssh_public_key {
    default = ""
}

This configuration is working fine before I upgraded Terraform to the latest version

Not able to set firewall rules when a server is in maintenance -state

Not able to define firewall rules before server instances have been deployed and running (cannot be applied when a server is in maintenance state),

can be replicated by running the example (https://github.com/UpCloudLtd/terraform-provider-upcloud/blob/master/examples/01_server.tf) with firewall block

resource "upcloud_firewall_rules" "firewall" {
  server_id = upcloud_server.test.id
  firewall_rule {
    action                 = "accept"
    direction              = "in"
    family                 = "IPv4"
  }
}

Proposed fix: ping for running before applying firewall rules

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.