コンテンツにスキップ
アカウント作成/サインイン
Stripe ドキュメントのロゴ
/
AI に質問
アカウントを作成サインイン
導入方法
決済管理
売上管理
プラットフォームとマーケットプレイス
資金管理
開発者向けリソース
API & SDKヘルプ
概要
バージョン管理
変更ログ
API バージョンのアップグレード
SDK バージョンをアップグレードする
Essentials
SDK
API
テスト
Stripe CLI
サンプルプロジェクト
ツール
Stripe ダッシュボード
ワークベンチ
開発者ダッシュボード
Stripe Shell
Visual Studio Code をご利用の場合
Terraform
    概要
    Install the Stripe Terraform provider
    Supported resources
機能
ワークフロー
イベントの送信先
Stripe 健全性アラートファイルのアップロード
AI ソリューション
エージェントツールキット
モデルコンテキストプロトコルエージェントを使用した AI SaaS 請求ワークフローの構築
セキュリティとプライバシー
セキュリティ
Stripebot ウェブクローラー
Stripe を拡張する
Stripe Appsを構築する
Stripe アプリを使用する
パートナー
Partner Ecosystem
パートナー認定
アメリカ
日本語
ホーム開発者向けリソースTerraform

メモ

このページはまだ日本語ではご利用いただけません。より多くの言語で文書が閲覧できるように現在取り組んでいます。準備が整い次第、翻訳版を提供いたしますので、もう少しお待ちください。

Install the Stripe Terraform provider

Set up the provider for local development.

The Stripe Terraform Provider enables you to manage Stripe resources using infrastructure as code. Configure products, prices, billing meters, and complex pricing plans with declarative Terraform syntax. Your Stripe infrastructure becomes version controlled, reproducible, and auditable. For API information, see the Stripe API reference.

Sample Workflow

Follow this workflow to create a product with a recurring price and webhook endpoint to receive events.

Create a new Terraform file, main.tf:

terraform { required_providers { stripe = { source = "stripe/stripe" version = "0.1.3" } } } provider "stripe" { # API key is read from STRIPE_API_KEY environment variable # Alternatively, set it explicitly (not recommended for production) # api_key = "sk_test_..." } # Define a product resource "stripe_product" "pro_plan" { name = "Pro Plan" description = "Professional tier with advanced features" } # Create a recurring price for the product resource "stripe_price" "pro_monthly" { product = stripe_product.pro_plan.id currency = "usd" unit_amount = 2900 recurring { interval = "month" } } # Set up a webhook endpoint for payment events resource "stripe_webhook_endpoint" "payments" { url = "https://api.example.com/webhooks/stripe" enabled_events = [ "payment_intent.succeeded", "payment_intent.payment_failed", "customer.subscription.created", "customer.subscription.deleted", ] } output "price_id" { value = stripe_price.pro_monthly.id }

Set your API Key:

Command Line
export STRIPE_API_KEY=
"sk_test_BQokikJOvBiI2HlWgH4olfQ2"

Preview and apply changes:

Command Line
terraform plan terraform apply terraform output

Supported resources

This section provides a quick reference of available resources. For detailed documentation and all configurable parameters, see Supported resources.

Product catalog

ResourceDescription
stripe_productProduct definitions
stripe_pricePricing configurations
stripe_couponDiscount coupons
stripe_shipping_rateShipping rate configurations
stripe_tax_rateTax rate definitions
stripe_entitlements_featureFeature flags for entitlements

Core resources

ResourceDescription
stripe_customerCustomer records
stripe_webhook_endpointWebhook endpoint configurations
stripe_billing_meterUsage tracking meters

Advanced usage-based billing Private preview

These resources are part of the Billing v2 API and require access to the private preview.

ResourceDescription
stripe_v2_billing_pricing_planPricing plan containers
stripe_v2_billing_pricing_plan_componentPlan components
stripe_v2_billing_licensed_itemLicensed access items
stripe_v2_billing_license_feeSubscription fees
stripe_v2_billing_metered_itemUsage-based billable items
stripe_v2_billing_rate_cardPricing containers
stripe_v2_billing_rate_card_rateIndividual rates
stripe_v2_billing_service_actionCredits and adjustments

Data sources

Data SourceDescription
stripe_billing_meterLook up existing billing meters

Manage multiple environments with workspaces

Terraform workspaces let you manage separate Stripe environments (sandbox versus livemode) with isolated state files. This prevents accidental changes to production resources when working in test mode.

Set up workspaces

Create workspaces for a sandbox (test mode) and live mode:

Command Line
# Create workspaces terraform workspace new sandbox terraform workspace new livemode # List available workspaces terraform workspace list

Switch between environments

Each workspace maintains its own state file. Switch workspaces and set the corresponding API key:

Command Line
# Work in sandbox (test mode) terraform workspace select sandbox export STRIPE_API_KEY=
sk_test_BQokikJOvBiI2HlWgH4olfQ2
terraform plan terraform apply
# Work in livemode (production) terraform workspace select livemode export STRIPE_API_KEY="sk_live_..." terraform plan terraform apply
このページはお役に立ちましたか。
はいいいえ
  • お困りのことがございましたら 、サポートにお問い合わせください。
  • 変更ログをご覧ください。
  • ご不明な点がございましたら、お問い合わせください。
  • LLM は llms.txt を参照してください。
  • Powered by Markdoc