@@ -31,6 +31,8 @@ import (
3131 "github.com/hashicorp/terraform-provider-hcp/internal/provider/waypoint"
3232 "github.com/hashicorp/terraform-provider-hcp/internal/provider/webhook"
3333 "github.com/hashicorp/terraform-provider-hcp/internal/statuspage"
34+
35+ "github.com/hashicorp/terraform-plugin-log/tflog"
3436)
3537
3638// This is an implementation using the Provider framework
@@ -48,6 +50,7 @@ type ProviderFrameworkModel struct {
4850 ProjectID types.String `tfsdk:"project_id"`
4951 WorkloadIdentity types.List `tfsdk:"workload_identity"`
5052 SkipStatusCheck types.Bool `tfsdk:"skip_status_check"`
53+ Geography types.String `tfsdk:"geography"`
5154}
5255
5356type WorkloadIdentityFrameworkModel struct {
@@ -62,6 +65,7 @@ func (p *ProviderFramework) Metadata(ctx context.Context, req provider.MetadataR
6265}
6366
6467func (p * ProviderFramework ) Schema (ctx context.Context , req provider.SchemaRequest , resp * provider.SchemaResponse ) {
68+ tflog .Info (ctx , "Configuring hcp schema" )
6569 resp .Schema = schema.Schema {
6670 Attributes : map [string ]schema.Attribute {
6771 "client_id" : schema.StringAttribute {
@@ -98,6 +102,13 @@ func (p *ProviderFramework) Schema(ctx context.Context, req provider.SchemaReque
98102 Optional : true ,
99103 Description : "When set to true, the provider will skip checking the HCP status page for service outages or returning warnings." ,
100104 },
105+ "geography" : schema.StringAttribute {
106+ Optional : true ,
107+ Description : "The geography in which resources should be created." ,
108+ Validators : []validator.String {
109+ stringvalidator .OneOf (clients .GeographyUS , clients .GeographyEU ),
110+ },
111+ },
101112 },
102113 Blocks : map [string ]schema.Block {
103114 // TODO migrate to SingleNestedAttribute once the providersdkv2 is
@@ -235,6 +246,8 @@ func NewFrameworkProvider(version string) func() provider.Provider {
235246}
236247
237248func (p * ProviderFramework ) Configure (ctx context.Context , req provider.ConfigureRequest , resp * provider.ConfigureResponse ) {
249+ tflog .Info (ctx , "Configuring hcp provider" )
250+
238251 // Sets up HCP SDK client.
239252 var data ProviderFrameworkModel
240253 resp .Diagnostics .Append (req .Config .Get (ctx , & data )... )
@@ -271,6 +284,14 @@ func (p *ProviderFramework) Configure(ctx context.Context, req provider.Configur
271284 }
272285 }
273286
287+ if data .Geography .IsNull () {
288+ tflog .Info (ctx , "Geography is null; using default" )
289+ } else {
290+ clientConfig .Geography = data .Geography .ValueString ()
291+ }
292+ tflog .Info (ctx , "Configure creating a new client" , map [string ]interface {}{
293+ "geography" : clientConfig .Geography ,
294+ })
274295 client , err := clients .NewClient (clientConfig )
275296 if err != nil {
276297 resp .Diagnostics .AddError (fmt .Sprintf ("unable to create HCP api client: %v" , err ), "" )
0 commit comments