EMD Blog

tfe Provider로 OAuth Client 구성 시 Provider 수동 연결 이슈 본문

IaC/Terraform

tfe Provider로 OAuth Client 구성 시 Provider 수동 연결 이슈

EmaDam 2022. 9. 4. 07:46

tfe provider를 사용해서 Organization을 구성 할 때 OAuth Client도 함께 구성 할 수 있다. 아래 Resource 참고

https://registry.terraform.io/providers/hashicorp/tfe/latest/docs/resources/oauth_client

위 리소스를 사용하면 이미 연결된 VCS Provider에 대해서 oauth_client_id 값을 받아 올 수 있다. 문제는 이 리소스의 경우 id를 받아오는 용도로 밖에 사용 할 수 없다는 것인데, 결국에는 Organization을 먼저 생성하고 수동으로 VCS 연결 후 다시 Terraform 코드를 Apply해줘야 한다.

 

이러면 굳이 저 리소스를 안쓰고 Client ID를 따로 관리하는 게 편해보이는데, 뭔가 다른 방법이 있는 것인지 확인 해볼 필요 있겠음.

Hashicorp에서 답변을 받았으나 UI 및 API를 사용하는 방법밖에 없는 것으로 확인 되었음.

============

Thank you for contacting HashiCorp Support.

When creating a VCS connection to a Terraform Cloud (TFC) Organization, configuring authentication for that VCS connection usually requires OAuth access and the process takes place within the TFC UI.

However, when creating a VCS connection through either "tfe" provider or TFC API you have to authenticate with a Personal Access Token (PAT) instead as a value for the oauth_token argument of the tfe_oauth_client resource.

You can read the following documentation on how to generate PAT for each of the VCS providers listed below:

GitHub and GitHub EnterpriseGitLab, GitLab Community Edition, and GitLab Enterprise EditionAzure DevOps Services and Azure DevOps Server

Note that for the "oauth_token" value, you needed to pass a PAT that has the appropriate permissions.

For example for GitHub:
- repo:status
- admin:org_hook

You can also find useful the following KB describing the steps required to create a VCS connection using a PAT.