franckverrot / terraform-provider-stripe

A Terraform Provider for Stripe
https://registry.terraform.io/providers/franckverrot/stripe/latest
Mozilla Public License 2.0
242 stars 51 forks source link

Having trouble using Stripe provider resources within a module #47

Closed sarmadsaleem closed 2 years ago

sarmadsaleem commented 3 years ago

First up, thanks a lot for putting in the effort to create this provider, much needed IaC way of dealing with Stripe 🙏

I am having an issue trying to use this provider when I try to put Stripe resources within a module, not sure what am I missing here. When I keep everything within the same file (no modules) and do terraform init and terraform plan, everything works perfectly fine. However when I try to move the Stripe resources to a module and do terraform init, I get the following error:

Initializing modules...

Initializing the backend...

Initializing provider plugins...
- Using previously-installed franckverrot/stripe v1.8.0
- Using previously-installed hashicorp/aws v3.34.0
- Finding latest version of hashicorp/stripe...

Error: Failed to install provider

Error while installing hashicorp/stripe: provider registry
registry.terraform.io does not have a provider named
registry.terraform.io/hashicorp/stripe

I have tried explicitly passing the provider alias to the module as well but to no avail. Would appreciate if anyone can point me in the right direction. Haven't been able to find much through googling, README or issues on the repo.

Additional info

Example of working config ✅

# main.tf
terraform {
  required_providers {
    stripe = {
      source = "franckverrot/stripe"
      version = "1.8.0"
    }
  }
}

provider "stripe" {
  api_token = var.stripe_api_token
}

resource "stripe_webhook_endpoint" "webhook" {
  url = "https://example.com"

  enabled_events = [
    "checkout.session.completed"
  ]
}

Example of failing config 🛑

# main.tf
terraform {
  required_providers {
    stripe = {
      source = "franckverrot/stripe"
      version = "1.8.0"
    }
  }
}

provider "stripe" {
  api_token = var.stripe_api_token
}

module "stripe" {
  source = <path-to-source>
}

# module/main.tf
resource "stripe_webhook_endpoint" "webhook" {
  url = "https://example.com"

  enabled_events = [
    "checkout.session.completed"
  ]
}
franckverrot commented 2 years ago

Hi there! Have you looked at occurences of hashicorp/stripe somewhere else in your repo?