This Expensify provider allows Terraform to add users to the Expensify policies, read users of the Expensify policies, update users in the Expensify policies, remove users from the Expensify policies, create a new policy, read a policy details.
- Go >= 1.16 (To build the provider plugin)
- Terraform >= 0.13.x
- Account: Expensify(Required a Verified Domain and an Expensify Policy with Control/Collect Plan)
- API Documentation
Generate credentials from account which is domain and policy admin
- To authenticate API, we need a pair of credentials: partnerUserID and partnerUserSecret.
- For this, go to https://www.expensify.com/tools/integrations/ and generate the credentials.
- A pair of credentials: partnerUserID and partnerUserSecret will be generated and shown on the page.
For Windows using Command Prompt
- Clone the repository, add all the dependencies, create a vendor directory that contains all dependencies and generate a binary. For this, run the following commands:
git clone https://github.com/shubhambjadhavar/terraform-provider-expensify.git
cd terraform-provider-expensify
go mod init terraform-provider-expensify
go mod tidy
go mod vendor
go build -o terraform-provider-expensify.exe
- Move the generated binary to
%APPDATA%/terraform.d/plugins/${host_name}/${namespace}/${type}/${version}/${OS_ARCH}
. For this, run the following commands:
mkdir -p %APPDATA%/terraform.d/plugins/expensify.com/employee/expensify/1.0.0/windows_amd64
move terraform-provider-expensify.exe %APPDATA%\terraform.d\plugins\expensify.com\employee\expensify\1.0.0\windows_amd64
For Windows Manually
- Download the latest compiled binary from GitHub releases and unzip/untar the archive.
- Move the binary to
%APPDATA%/terraform.d/plugins/${host_name}/${namespace}/${type}/${version}/${OS_ARCH}
.
Create your Terraform configurations as shown in example usage and run terraform init
. This will find plugin locally.
- Update the fields
manager_email
,approves_to
,over_limit_approver
, andapproval_limit
only if Approval Mode for policy is Advanced Approval. - API not allow overwriting manually set values for
first_name
andlast_name
in their Expensify account. - The fields
first_name
andlast_name
are set at account level. - Once the value of any attribute is set, it cannot be set back to null through provider. But, you can set it to null via UI.
terraform{
required_providers {
expensify = {
version = "1.0.0"
source = "expensify.com/employee/expensify"
}
}
}
provider "expensify" {
partner_user_id = "_REPLACE_PARTNER_USER_ID_"
partner_user_secret = "_REPLACE_PARTNER_USER_SECRET_"
}
resource "expensify_policy" "policy"{
policy_name = "demo"
plan = "corporate"
}
data "expensify_policy" "policy" {
policy_id = "22E95AFCD33ABE2BB8"
}
resource "expensify_employee" "employee"{
employee_email = "[email protected]"
manager_email = "[email protected]"
policy_id = "22E95AFCD33ABE2BB8"
employee_id = "1"
first_name = "Dummy"
last_name = "Employee"
approves_to = "[email protected]"
approval_limit = 5
over_limit_approver = "[email protected]"
}
data "expensify_employee" "employee" {
policy_id = "22E95AFCD33ABE2BB8"
employee_email = "[email protected]"
}