Introduction
This article describes how to change the password for a Terraform Enterprise admin account using the Admin API.
Expected Outcome
You will successfully change the password for the Terraform Enterprise admin account.
Prerequisites
- A user token for the admin account.
- The hostname of your Terraform Enterprise instance.
Procedure
Follow these steps to change the admin password using the API.
-
Create a user token.
Generate a user token from the Tokens tab on the user settings page. For detailed instructions, refer to the API Tokens documentation.
-
Prepare the request body.
Create a JSON file named
adminpassword.jsonwith the following content. Replace the placeholder values with your current password and your new password.{ "data": { "type": "users", "attributes": { "current_password": "<CURRENT_PASSWORD>", "password": "<NEW_PASSWORD>", "password_confirmation": "<NEW_PASSWORD>" } } } -
Make the API request.
Execute the following
curlcommand to submit the password change request. Replace<TFE_HOSTNAME>with your Terraform Enterprise instance's hostname and$TOKENwith the user token you created.$ curl \ --header "Authorization: Bearer $TOKEN" \ --header "Content-Type: application/vnd.api+json" \ --request PATCH \ --data @adminpassword.json \ https://<TFE_HOSTNAME>/api/v2/account/password
Alternative Method: Using the Rails Console
The recommended approach is to use the Admin API, as it provides a more secure and streamlined process. However, you can also reset the Terraform Enterprise administrator password directly via the Rails console by following the procedure in this guide: How to Reset Terraform Enterprise Administrator Password via Rails.
Additional Information
- For more details on the API endpoint used, refer to the Account API documentation.