Onelogin Terraform Provider
Prerequisites
1) Install Golang
2) Install Terraform v0.12.24 or later
3) Install code dependencies
Getting Started
If you are sideloading this provider (i.e. not getting this via the Terraform store) You must clone this repository to run the following commands.
-
In the ./terraform-provider-onelogin directory run:
make sideload
If you are using Terraform v0.13.x or later you can use following Terraform configuration for sideloaded version of this provider:
terraform { required_providers { onelogin = { source = "onelogin.com/onelogin/onelogin" version = "0.1.0" } } } provider "onelogin" { # Configuration options }
-
You'll need admin access to a OneLogin account where you can create API credentials. Create a set of API credentials with manage all permission. For applying the credentials, there are 2 ways
- Export these credentials to your environment and the provider will read them in from there
export ONELOGIN_CLIENT_ID=<your client id> export ONELOGIN_CLIENT_SECRET=<your client secret> export ONELOGIN_OAPI_URL=<the api url for your region>
-
You are ready to use the provider, just follow the terraform commands!
Managing App Resources
Refer to creating an App On create, omitted fields are ignored and set to their empty or default values.
On update, omitted fields are treated as if the intent is to clear the field and
an empty or zero value is sent to the API to clear the field. E.G. creating an app with
a description, then removing the description field in your HCL file, will result in
setting the description to ""
App Fields
Required fields are, well, required. Computed fields are set by the API and cannot be set via Terraform
- name [string] required
- connector_id [int] required
- description [string]
- notes [string]
- visible [bool] - Defaults to
true
- allow_assumed_signin [bool] - Defaults to
false
- parameters [set no limit] - see below
- configuration [set limit 1] - see below
- provisioning [set limit 1] - see below
- auth_method computed
- icon_url computed
- policy_id computed
- tab_id computed
- updated_at computed
- created_at computed
Parameter Sub Field
Known Issue - Parameters are tracked as completely separate entities in the OneLogin API. Currently only adding new/additional parameters permitted is permitted here as their lifecycle methods Have not yet been implemented. Removing or Changing a parameter will NOT affect the state of the App resource as of v0.0.1.
- param_key_name [string] required
- param_id [int] computed
- label [string]
- user_attribute_mappings [string]
- user_attribute_macros [string]
- attributes_transformations [string]
- default_values [string]
- skip_if_blank [bool] - Defaults to
false
- values [string]
- provisioned_entitlements [bool] - Defaults to
false
- safe_entitlements_enabled [bool] - Defaults to
false
Provisioning Sub Field
- Enabled [bool] - Defaults to
false
App Type Specific Sub Fields
Configuration and SSO depends on they app's authentication type e.g. SAML or OIDC and has different fields.
SAML Configuration
- certificate_id computed
- provider_arn [string]
- signature_algorithm [string] required - one of
SHA-1
,SHA-256
,SHA-348
,SHA-512
SAML SSO
- acs_url [string] computed
- metadata_url [string] computed
- issuer [string] computed
- certificate [set limit 1]
- name [string] computed
- id [string]computed
- value [string] computed
- sls_url [string] computed
OIDC Configuration
- redirect_uri [string]
- refresh_token_expiration_minutes [int] - defaults to 1 minute
- login_url [string]
- oidc_application_type [int] - one of
0
(Web) or1
(Native/Mobile) - token_endpoint_auth_method [int] - one of
0
(Basic)1
(POST)2
(Nonce/PKCE) - access_token_expiration_minutes [int] - defaults to 1 minute
OIDC SSO
- client_id [string] computed
- client_secret [string] computed
Terraform
Install:
brew install terraform
Initialize:
terraform init
Plan:
terraform plan
Apply:
terraform apply
Dependency Management
We use go mod for dependency management.
To add a package:
go get -u "package-name"
To re-install dependencies for this project:
rm go.sum
go mod download
To update dependencies for this project:
go mod -u ./...
Running Tests
Standard Go Way:
go test ./... -v -cover
Including Terraform Acceptance Tests
TF_ACC=1 go test ./... -v -cover