Coder Social home page Coder Social logo

Comments (4)

mattlawnz avatar mattlawnz commented on September 4, 2024

To add to this, I think the SSH API is broken generally.

When trying to add a tfe_ssh_key

  name         = "bitbucket-ssh-key"
  organization = "twl"
  key          = "mtkeyhere"
}

I get the following (debug output) - and obviously the key has been changed :)

2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: 2019/11/20 11:00:23 [DEBUG] Create new SSH key for organization: twl
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: 2019/11/20 11:00:23 [DEBUG] TFE API Request Details:
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: ---[ REQUEST ]---------------------------------------
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: POST /api/v2/organizations/twl/ssh-keys HTTP/1.1
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: Host: app.terraform.io
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: User-Agent: go-tfe
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: Content-Length: 91
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: Accept: application/vnd.api+json
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: Authorization: Bearer XXXXXXXXXXX
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: Content-Type: application/vnd.api+json
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: Accept-Encoding: gzip
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: {
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:  "data": {
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:   "type": "ssh-keys",
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:   "attributes": {
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:    "name": "bitbucket-ssh-key",
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:    "value": "mtkeyhere"
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:   }
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:  }
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: }
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:
2019-11-20T11:00:23.334+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: -----------------------------------------------------
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: 2019/11/20 11:00:23 [DEBUG] TFE API Response Details:
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: ---[ RESPONSE ]--------------------------------------
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: HTTP/2.0 404 Not Found
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: Content-Length: 49
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: Cache-Control: no-cache
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: Content-Type: application/vnd.api+json; charset=utf-8
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: Date: Tue, 19 Nov 2019 22:00:23 GMT
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: Vary: Accept-Encoding
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: Vary: Origin
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: X-Content-Type-Options: nosniff
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: X-Frame-Options: SAMEORIGIN
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: X-Ratelimit-Limit: 30
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: X-Ratelimit-Remaining: 28
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: X-Ratelimit-Reset: 0.48
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: X-Request-Id: e690272e-0dc3-eaf6-addc-6093a0635fed
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: X-Xss-Protection: 1; mode=block
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: {
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:  "errors": [
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:   {
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:    "status": "404",
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:    "title": "not found"
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:   }
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4:  ]
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: }
2019-11-20T11:00:23.626+1300 [DEBUG] plugin.terraform-provider-tfe_v0.11.1_x4: -----------------------------------------------------
2019/11/20 11:00:23 [DEBUG] tfe_ssh_key.bitbucket: apply errored, but we're indicating that via the Error pointer rather than returning it: Error creating SSH key bitbucket-ssh-key for organization twl: resource not found
2019/11/20 11:00:23 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2019/11/20 11:00:23 [TRACE] EvalMaybeTainted: tfe_ssh_key.bitbucket encountered an error during creation, so it is now marked as tainted
2019/11/20 11:00:23 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: Error creating SSH key bitbucket-ssh-key for organization twl: resource not found
2019/11/20 11:00:23 [ERROR] <root>: eval: *terraform.EvalSequence, err: Error creating SSH key bitbucket-ssh-key for organization twl: resource not found

from terraform-provider-tfe.

johncblandii avatar johncblandii commented on September 4, 2024

Note: This endpoint cannot be accessed with organization tokens. You must access it with a user token or team token.

https://www.terraform.io/docs/cloud/api/ssh-keys.html

Just hit this with using data to pull the SSH key id. Just use a team or user token.

from terraform-provider-tfe.

chrisarcand avatar chrisarcand commented on September 4, 2024

johncblandii is correct, the token is likely actually unauthorized. Closing this, but if it's still a problem please feel free to reopen. Thanks!

from terraform-provider-tfe.

nahueloyha avatar nahueloyha commented on September 4, 2024

Hi! Re opening as I'm having the same issue while creating a new SSH key with the TFE provider:
Screen Shot 2023-01-20 at 16 57 40

Something similar happens when trying to assign to a workspace an existing SSH key:
Screen Shot 2023-01-20 at 17 18 30

And even while using the data source trying to retrieve an existing key from the CLI:
fd

-> UPDATE: nevermind, it seems all is related to using an "Organization" level token, that can't manage SSH keys. A bit paradoxical if you ask me as it's the recommended one for managing workspaces but the docs clearly says it so switched to a "Team" level and worked OK.

from terraform-provider-tfe.

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.