Giter VIP home page Giter VIP logo

Comments (8)

danielsreichenbach avatar danielsreichenbach commented on August 30, 2024 1

@gdubicki yes, of course.

resource "digitalocean_droplet" "example" {
  ssh_keys = [
    "${digitalocean_ssh_key.default.fingerprint}",
    "${digitalocean_ssh_key.example.fingerprint}",
  ]

  connection {
    user    = "root"
    type    = "ssh"
    timeout = "60s"
    agent   = true
  }
}

Supplying the connection settings resolved the issue of not updating SSH keys added/changed for me. Previously I only had ssh_keys set. We're using it like this for almost half a year on production systems with no problems.

from terraform-provider-digitalocean.

hashibot avatar hashibot commented on August 30, 2024

This comment was originally opened by @cabbiepete as hashicorp/terraform#2733 (comment). It was migrated here as part of the provider split. The original comment is below.


This is more of a DO thing than a terraform thing. DO only provisions ssh keys when you create droplets it never updates them post this. You can use a provisioner such as remote exec, chef, puppet to ensure the full list of keys is there.

from terraform-provider-digitalocean.

hashibot avatar hashibot commented on August 30, 2024

This comment was originally opened by @apparentlymart as hashicorp/terraform#2733 (comment). It was migrated here as part of the provider split. The original comment is below.


Based @cabbiepete's comment, it sounds like the bug here is that we should have ForceNew set on that attribute so that Terraform knows that it has to create a replacement droplet in order to implement an SSH key change.

from terraform-provider-digitalocean.

hashibot avatar hashibot commented on August 30, 2024

This comment was originally opened by @cabbiepete as hashicorp/terraform#2733 (comment). It was migrated here as part of the provider split. The original comment is below.


@apparentlymart I'd expect that to be an optional setting and default to not. There are other ways to get the new/updated ssh key to the server in less destructive ways which is a better default for anyone that does not quite know all the details of terraform and that particular provider.

from terraform-provider-digitalocean.

hashibot avatar hashibot commented on August 30, 2024

This comment was originally opened by @apparentlymart as hashicorp/terraform#2733 (comment). It was migrated here as part of the provider split. The original comment is below.


@cabbiepete is there something that Terraform could do automatically/programmatically when it detects a diff on this attribute? ForceNew is how Terraform models things that can only be set at creation time and can't be updated later, so that's the right thing to do unless there's something less destructive that Terraform could do instead, to apply an update here.

Your earlier comment suggested that logging in to the machine and manually tweaking the keys was the only path. If so, this is a similar situation to Amazon EC2, where the corresponding attribute (key_pair) is marked as ForceNew as I described.

from terraform-provider-digitalocean.

hashibot avatar hashibot commented on August 30, 2024

This comment was originally opened by @danielsreichenbach as hashicorp/terraform#2733 (comment). It was migrated here as part of the provider split. The original comment is below.


Adding my two cents here. I just did this on an existing droplet, where I needed to extend set of SSH keys deployed.

This is actually working, if you supply a connection object in the droplet configuration, and then add further entries to the SSH configuration.

from terraform-provider-digitalocean.

gdubicki avatar gdubicki commented on August 30, 2024

What you mean by "supplying a connection object", @danielsreichenbach ? Can you share the code that is working for you?

from terraform-provider-digitalocean.

MasonEgger avatar MasonEgger commented on August 30, 2024

Closing this issue. Retroactively adding and removing SSH keys is not something the API allows us to do. I would recommend using a configuration management tool such as Ansible, Salt, or Puppet for managing identity past the initial provisioning step. The connection work around provided appears to work so that is another viable solution.

from terraform-provider-digitalocean.

Related Issues (20)

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.