diff --git a/mmv1/third_party/terraform/fwtransport/framework_config.go.tmpl b/mmv1/third_party/terraform/fwtransport/framework_config.go.tmpl index c43ba36f7939..e6ca30d01038 100644 --- a/mmv1/third_party/terraform/fwtransport/framework_config.go.tmpl +++ b/mmv1/third_party/terraform/fwtransport/framework_config.go.tmpl @@ -57,6 +57,7 @@ type FrameworkProviderConfig struct { DefaultLabels types.Map // paths for client setup + IAMCredentialsBasePath string // TODO: This will be removed once we resove the muxing issues {{- range $product := $.Products }} {{ $product.Name }}BasePath string {{- end }} @@ -99,6 +100,7 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context, // Setup Base Paths for clients // Generated products + p.IAMCredentialsBasePath = data.IamCredentialsCustomEndpoint.ValueString() // TODO: This will be removed once we resove the muxing issues {{- range $product := $.Products }} p.{{ $product.Name }}BasePath = data.{{ $product.Name }}CustomEndpoint.ValueString() {{- end }} diff --git a/mmv1/third_party/terraform/fwtransport/framework_provider_clients.go.tmpl b/mmv1/third_party/terraform/fwtransport/framework_provider_clients.go.tmpl index 1001fa557202..87e7c83b2b04 100644 --- a/mmv1/third_party/terraform/fwtransport/framework_provider_clients.go.tmpl +++ b/mmv1/third_party/terraform/fwtransport/framework_provider_clients.go.tmpl @@ -2,6 +2,7 @@ package fwtransport import ( "fmt" + "log" "strings" "google.golang.org/api/dns/v1" @@ -9,6 +10,7 @@ import ( firebase "google.golang.org/api/firebase/v1beta1" {{- end }} "google.golang.org/api/option" + iamcredentials "google.golang.org/api/iamcredentials/v1" "github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -37,6 +39,20 @@ func (p *FrameworkProviderConfig) NewDnsClient(userAgent string, diags *diag.Dia return clientDns } +func (p *FrameworkProviderConfig) NewIamCredentialsClient(userAgent string) *iamcredentials.Service { + iamCredentialsClientBasePath := transport_tpg.RemoveBasePathVersion(p.IAMCredentialsBasePath) + log.Printf("[INFO] Instantiating Google Cloud IAMCredentials client for path %s", iamCredentialsClientBasePath) + clientIamCredentials, err := iamcredentials.NewService(p.Context, option.WithHTTPClient(p.Client)) + if err != nil { + log.Printf("[WARN] Error creating client iam credentials: %s", err) + return nil + } + clientIamCredentials.UserAgent = userAgent + clientIamCredentials.BasePath = iamCredentialsClientBasePath + + return clientIamCredentials +} + {{ if ne $.TargetVersionName `ga` -}} func (p *FrameworkProviderConfig) NewFirebaseClient(userAgent string, diags *diag.Diagnostics) *firebase.Service { firebaseClientBasePath := transport_tpg.RemoveBasePathVersion(p.FirebaseBasePath)