Skip to content

[v16] Machine ID: Terraform Cloud joining (#45574)#46049

Merged
timothyb89 merged 7 commits intobranch/v16from
timothyb89/v16/terraform-cloud-joining
Sep 18, 2024
Merged

[v16] Machine ID: Terraform Cloud joining (#45574)#46049
timothyb89 merged 7 commits intobranch/v16from
timothyb89/v16/terraform-cloud-joining

Conversation

@timothyb89
Copy link
Copy Markdown
Contributor

@timothyb89 timothyb89 commented Aug 30, 2024

Backport of #45574 for branch/v16

changelog: Add new terraform_cloud joining method to enable secretless authentication on HCP Terraform jobs for the Teleport Terraform provider


  • Machine ID: Terraform Cloud joining

This adds a new terraform join method, which uses Terraform Cloud's Workload Identity OIDC provider to provide delegated joining support for Machine ID bots. As the Terraform provider now embeds tbot, this means - with some light modifications - that the Terraform provider can now join using this join method, and without any secrets.

  • Address some review feedback, add first batch of tests

This addresses a few feedback items, defaulting the audience to the Teleport cluster name and requiring allow rules specify an organization + at least one other parameter.

Also, adds a first batch of tests.

  • Update autogenerated CRD docs

  • Add tests for RegisterUsingToken and provisioning token init

  • Fix imports

  • Fix CRD docs

  • Update tfschema

  • Update tf docs

  • Update docstring to make it clear that Audience is optional

  • Update manifests

  • Update CRD docs

  • Code review feedback; docstring fixes

  • Rename lib/terraform to lib/terraformcloud

  • Rename terraform -> terraform_cloud

Renames the new join method to terraform_cloud to make it clear that it won't work for TF running elsewhere (where other join methods should be used)

  • Fix tests and docs lints

  • Update api/proto/teleport/legacy/types/types.proto

  • Update proto artifacts


Backport of #45574 for branch/v16

---

* Machine ID: Terraform Cloud joining

This adds a new `terraform` join method, which uses Terraform Cloud's
Workload Identity OIDC provider to provide delegated joining support
for Machine ID bots. As the Terraform provider now embeds tbot, this
means - with some light modifications - that the Terraform provider
can now join using this join method, and without any secrets.

* Address some review feedback, add first batch of tests

This addresses a few feedback items, defaulting the audience to the
Teleport cluster name and requiring allow rules specify an
organization + at least one other parameter.

Also, adds a first batch of tests.

* Update autogenerated CRD docs

* Add tests for RegisterUsingToken and provisioning token init

* Fix imports

* Fix CRD docs

* Update tfschema

* Update tf docs

* Update docstring to make it clear that `Audience` is optional

* Update manifests

* Update CRD docs

* Code review feedback; docstring fixes

* Rename lib/terraform to lib/terraformcloud

* Rename terraform -> terraform_cloud

Renames the new join method to terraform_cloud to make it clear that
it won't work for TF running elsewhere (where other join methods
should be used)

* Fix tests and docs lints

* Update api/proto/teleport/legacy/types/types.proto

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>

* Update proto artifacts

---------

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>
@github-actions
Copy link
Copy Markdown
Contributor

🤖 Vercel preview here: https://docs-bz640x8vn-goteleport.vercel.app/docs/ver/preview

@timothyb89 timothyb89 changed the title Machine ID: Terraform Cloud joining (#45574) [v16] Machine ID: Terraform Cloud joining (#45574) Aug 30, 2024
timothyb89 and others added 3 commits September 12, 2024 17:55
This adds support for hostname/issuer overrides, needed to support
on-prem Terraform Enterprise installs. When the new `hostname` field
is unset, behavior is changed, but when set, the JWT is validated
against it instead of `app.terraform.io`.

Additionally, this renames `join_terraform.go` to
`join_terraformcloud.go`, since that was missed during the rename
in #45574.
* Terraform Cloud joining: Support Terraform Enterprise issuers

This adds support for hostname/issuer overrides, needed to support
on-prem Terraform Enterprise installs. When the new `hostname` field
is unset, behavior is changed, but when set, the JWT is validated
against it instead of `app.terraform.io`.

Additionally, this renames `join_terraform.go` to
`join_terraformcloud.go`, since that was missed during the rename
in #45574.

* Enable Terraform Cloud joining for Teleport Community Edition

This enables Terraform Cloud joining for Community Edition when
using the public HCP Terraform SaaS. Teleport Enterprise is still
required for use with self-hosted Terraform Enterprise.

changelog: Enable Terraform Cloud joining for Teleport Community Edition when using HCP Terraform

* Fix unit tests

* Update lib/auth/join_terraformcloud.go

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>

* Fix linter

---------

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>
@github-actions
Copy link
Copy Markdown
Contributor

🤖 Vercel preview here: https://docs-ckn0xc3cx-goteleport.vercel.app/docs/ver/preview

@github-actions
Copy link
Copy Markdown
Contributor

🤖 Vercel preview here: https://docs-qzvq3ales-goteleport.vercel.app/docs/ver/preview

@timothyb89 timothyb89 marked this pull request as ready for review September 17, 2024 18:30
@public-teleport-github-review-bot
Copy link
Copy Markdown

@timothyb89 - this PR will require admin approval to merge due to its size. Consider breaking it up into a series smaller changes.

@github-actions
Copy link
Copy Markdown
Contributor

The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with changelog: followed by the changelog entries for the PR.

@timothyb89
Copy link
Copy Markdown
Contributor Author

timothyb89 commented Sep 17, 2024

I published a dev build with this change, 17.0.0-dev.timothyb89.2 and was able to successfully test it on a staging Teleport Cloud tenant. The Terraform provider publishing is broken for dev builds unfortunately, but the artifacts are downloadable:

These can be used alongside the public docs and my gist to configure a local Terraform Cloud project to use on-disk binaries.

@github-actions
Copy link
Copy Markdown
Contributor

🤖 Vercel preview here: https://docs-jzi584llm-goteleport.vercel.app/docs/ver/preview

@timothyb89 timothyb89 added this pull request to the merge queue Sep 18, 2024
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Sep 18, 2024
@timothyb89 timothyb89 added this pull request to the merge queue Sep 18, 2024
@timothyb89 timothyb89 removed this pull request from the merge queue due to a manual request Sep 18, 2024
@github-actions
Copy link
Copy Markdown
Contributor

🤖 Vercel preview here: https://docs-3g6xuxlb3-goteleport.vercel.app/docs/ver/preview

@timothyb89 timothyb89 added this pull request to the merge queue Sep 18, 2024
Merged via the queue into branch/v16 with commit 5dad937 Sep 18, 2024
@timothyb89 timothyb89 deleted the timothyb89/v16/terraform-cloud-joining branch September 18, 2024 19:45
@fheinecke fheinecke mentioned this pull request Apr 9, 2025
@fheinecke fheinecke mentioned this pull request Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants