Integrate with Terraform Cloud
Support level: Community
What is Terraform Cloud
Terraform Cloud is a managed SaaS platform by HashiCorp that enables teams to collaborate on infrastructure-as-code by running, storing state, enforcing policies, and automating workflows for Terraform configurations.
Preparation
The following placeholders are used in this guide:
authentik.companyis the FQDN of the authentik installation.
This documentation lists only the settings that you need to change from their default values. Be aware that any changes other than those explicitly mentioned in this guide could cause issues accessing your application.
authentik configuration
To support the integration of Terraform with authentik, you need to create an application/provider pair in authentik.
Create an application and provider in authentik
-
Log in to authentik as an administrator and open the authentik Admin interface.
-
Navigate to Applications > Applications and click Create with Provider to create an application and provider pair. (Alternatively you can first create a provider separately, then create the application and connect it with the provider.)
- Application: provide a descriptive name, an optional group for the type of application, the policy engine mode, and optional UI settings.
- Choose a Provider type: select SAML Provider as the provider type.
- Configure the Provider: provide a name (or accept the auto-provided name), the authorization flow to use for this provider, and the following required configurations:
- Set the ACS URL to
https://temporary.domain. - Set the Issuer to
https://authentik.company. - Set the Service Provider Binding to
Post. - Set the Audience to
https://temporary.domain. - Under Advanced protocol settings, select an available Signing Certificate.
- Set the ACS URL to
- Configure Bindings (optional): you can create a binding (policy, group, or user) to manage the listing and access to applications on a user's My applications page.
-
Click Submit to save the new application and provider.
Copy the metadata URL
- Log in to authentik as an administrator and open the authentik Admin interface.
- Navigate to Applications > Providers and click the provider that you created in the previous step.
- Under Related objects, click Copy download URL and take note of the URL as it will be used in the next step.
Terraform Cloud configuration
- Log in to Terraform Cloud as an administrator.
- Select your organization from the dropdown menu in the top left, then click Settings > SSO.
- Click Setup SSO, click SAML, then Next, and set the Metadata URL to the URL copied in the previous step.
- Click Save Settings.
- Under HCP Terraform, take note of the Entity ID (Audience) and Assertion Consumer URL values. Do not close this window.
Configure the remaining information in authentik
- Log in to authentik as an administrator and open the authentik Admin interface.
- Navigate to Applications > Providers and provider that you created in the previous step.
- Click Edit.
- Under Protocol settings, set the value of the ACS URL to the Assertion Consumer URL value from the previous step. Then, set the value of the Audience to the Entity ID (Audience) value from the previous step.
- Click Update.
Enabling Terraform Cloud SSO
- In Terraform Cloud, under Settings > SSO, click Test. Successfully authenticating will result in a green checkmark and Successful appearing. Then, to enable SSO, click Enable.
- Read the warning message that appears and click Enable SAML.
Configuration verification
To verify that authentik is correctly integrated with Terraform Cloud, first log out of Terrafom Cloud. Open the Terraform Cloud login page and click Sign in with Terraform SSO. Enter the name of your organization, click Next, and you'll be redirected to authentik. Once authenticated, you will be signed into Terraform Cloud.