@@ -11,6 +11,7 @@ import (
1111
1212 "github.com/hashicorp/terraform-plugin-framework/datasource"
1313 "github.com/hashicorp/terraform-plugin-framework/function"
14+ "github.com/hashicorp/terraform-plugin-framework/path"
1415 "github.com/hashicorp/terraform-plugin-framework/provider"
1516 "github.com/hashicorp/terraform-plugin-framework/provider/schema"
1617 "github.com/hashicorp/terraform-plugin-framework/resource"
@@ -55,9 +56,8 @@ We recommend that you create a custom user with the [permissions required](https
5556 Description : "Provider for the Venafi TLS Protect Cloud Platform" ,
5657 Attributes : map [string ]schema.Attribute {
5758 "apikey" : schema.StringAttribute {
58- MarkdownDescription : "API Key" ,
59- Optional : false ,
60- Required : true ,
59+ MarkdownDescription : "API Key. Required unless specified by setting the environment variable `TLSPC_APIKEY`" ,
60+ Optional : true ,
6161 },
6262 "endpoint" : schema.StringAttribute {
6363 MarkdownDescription : "TLSPC API Endpoint" ,
@@ -81,9 +81,19 @@ func (p *tlspcProvider) Configure(ctx context.Context, req provider.ConfigureReq
8181 if ! config .ApiKey .IsNull () {
8282 apikey = config .ApiKey .ValueString ()
8383 }
84+ if apikey == "" {
85+ resp .Diagnostics .AddAttributeError (
86+ path .Root ("apikey" ),
87+ "API Key not provided" ,
88+ "The provider cannot create the TLSPC API client as the API Key has not been provided" ,
89+ )
90+ }
8491 if ! config .Endpoint .IsNull () {
8592 endpoint = config .Endpoint .ValueString ()
8693 }
94+ if resp .Diagnostics .HasError () {
95+ return
96+ }
8797
8898 client , _ := tlspc .NewClient (apikey , endpoint , p .version )
8999
0 commit comments