This terraform provider allows to perform Create ,Read ,Update, Delete and Import stripe Users.
- Create a Stripe account. (https://dashboard.stripe.com/register)
- Sign in to the stripe account (https://dashboard.stripe.com/login)
Go to the Developers -> API Keys -> Standard Keys and select Secret Key.
This app will provide us with the Secret Key which will be needed to configure our provider and make request.
- Clone the repository, add all the dependencies and create a vendor directory that contains all dependencies. For this, run the following commands:
cd terraform-provider-stripe
go mod init terraform-provider-stripe
go mod tidy
go mod vendor
For Windows:
- Run the following command to create a vendor sub-directory (
%APPDATA%/terraform.d/plugins/${host_name}/${namespace}/${type}/${version}/${OS_ARCH}
) which will consist of all terraform plugins.
Command:
mkdir -p %APPDATA%/terraform.d/plugins/hashicorp.com/edu/stripe/0.2.0/windows_amd64
- Run
go build -o terraform-provider-stripe.exe
to generate the binary in present working directory. - Run this command to move this binary file to the appropriate location.
move terraform-provider-stripe.exe %APPDATA%\terraform.d\plugins\hashicorp.com\edu\stripe\0.2.0\windows_amd64
[OR]
- Manually move the file from current directory to destination directory (
%APPDATA%\terraform.d\plugins\hashicorp.com\edu\stripe\0.2.0\windows_amd64
).
- Add
terraform
block andprovider
block as shown in example usage. - Get the credentials: secretkey
- Assign the above credentials to the respective field in the
provider
block.
terraform init
- To initialize a working directory containing Terraform configuration files.terraform plan
- To create an execution plan. Displays the changes to be done.terraform apply
- To execute the actions proposed in a Terraform plan. Apply the changes.
- Add the user data in the respective field in
resource
block as shown in example usage. - Initialize the terraform provider
terraform init
- Check the changes applicable using
terraform plan
and apply usingterraform apply
- You will see that a user has been successfully created.
Update the data of the user in resource
block as show in example usage file and apply using terraform apply
Add data and output blocks as shown in the example usage and run terraform plan
to read user data.
Delete the resource block of the particular user and run terraform apply
.
- Write manually a
resource
configuration block for the user as shown in example usage. Imported user will be mapped to this block. - Run the command
terraform import stripe_user.user1 [EMAIL_ID]
- Check for the attributes in the
.tfstate
file and fill them accordingly in resource block.
terraform {
required_providers{
stripe ={
version ="0.2"
source = "hashicorp.com/edu/stripe"
}
}
}
provider "stripe" {
secretkey = _REPLACE_STRIPE_USER_SECRETKEY"
}
data "stripe_user" "user" {
email = "user@domain.com"
}
output "user" {
value = data.stripe_user.user
}
resource "stripe_user" "user1" {
email = "user@domain.com"
name = "User_Name"
description = "User_Description"
phone = "User_Phone_No"
}
secretkey
(required, string) - The secretkey for stripe user. This may also be set via the "STRIPE_TOKEN" environment variable.email
(required, string) - Email of the user.name
(optional, string) - Name of the User.description
(optional, string) - Description of the User.phone
(optional, string) - Phone No of the User.