spotinst / terraform-provider-spotinst

Terraform Spotinst provider.
https://registry.terraform.io/providers/spotinst/spotinst/latest/docs
Mozilla Public License 2.0
63 stars 56 forks source link

Abilitiy to disable provider authentication check #253

Closed Nuru closed 8 months ago

Nuru commented 3 years ago

Terraform Version

1.0.10

Description

I would like the ability to disable the Spotinst Terraform Provider's check that results in a No valid credentials found for Spotinst Provider error. When I have code that optionally provisions Spotinst resources, and it is given a configuration that does not have any Spotinst resources to deploy/manage, it should be OK that I do not provide valid credentials.

Use Cases

I would like to create reusable Terraform code which can optionally provision Spotinst oceans. Presently, Terraform does not allow conditional creation or enabling of providers, so if I might need to use the provider, it has to be instantiated whether I use it or not. Without the feature I am requesting, I have to include the Spotinst provider and valid Spotinst credentials even when I do not want to use Spotinst. I would like the Spotinst provider to not complain about invalid credentials if there are no resources for it to manage.

Potential Terraform Configuration

 provider "spotinst" {
   enabled = local.spotinst_enabled
   token   = local.spotinst_enabled ? local.spotinst_token : null
   account = local.spotinst_enabled ? local.spotinst_account : null
 }

Community Note

sobhanagit commented 8 months ago

@Nuru , we have released the fix for provider authenticate check as suggested by @hedenface . We have tested below scenarios works fine

provider "spotinst" { enabled = false token = spotinst_token account = spotinst_account } 1) enabled = false , only spotist resource exist - it cancelling the resource creation 2) enabled = true , only spotinst resource exist - it will create the resource 3) no entry enabled field (default it takes true) , only spotinst resource exist - it will create the resource 4) enabled = true , aws and spotinst resource exist - it will create both the resource 5) no entry enabled field (default it takes true) , aws and spotinst resource exist - it will create both the resource 6) enabled = false , aws and spotinst resource exist - it is cancelling all the resource creation