diff --git a/bundle/deploy/terraform/init.go b/bundle/deploy/terraform/init.go index 02d840bc60..64c00adc00 100644 --- a/bundle/deploy/terraform/init.go +++ b/bundle/deploy/terraform/init.go @@ -167,12 +167,19 @@ func inheritEnvVars(ctx context.Context, environ map[string]string) error { } // If there's SYSTEM_ACCESSTOKEN set, we need to pass the value of the environment variable to Terraform. - // This is necessary to ensure that Terraform can use the same access token as the CLI. + // This is necessary to ensure that Terraform can use the same access token as the CLI for Azure DevOps OIDC auth. systemAccessToken, ok := env.Lookup(ctx, "SYSTEM_ACCESSTOKEN") if ok { environ["SYSTEM_ACCESSTOKEN"] = systemAccessToken } + // If there's SYSTEM_TEAMFOUNDATIONCOLLECTIONURI set, we need to pass the value of the environment variable to Terraform. + // This is necessary for Azure DevOps OIDC auth to work properly. + systemCollectionUri, ok := env.Lookup(ctx, "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI") + if ok { + environ["SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"] = systemCollectionUri + } + // Map $DATABRICKS_TF_CLI_CONFIG_FILE to $TF_CLI_CONFIG_FILE // VSCode extension provides a file with the "provider_installation.filesystem_mirror" configuration. // We only use it if the provider version matches the currently used version, diff --git a/bundle/deploy/terraform/init_test.go b/bundle/deploy/terraform/init_test.go index e2036bad0d..f0ddbcc652 100644 --- a/bundle/deploy/terraform/init_test.go +++ b/bundle/deploy/terraform/init_test.go @@ -291,6 +291,16 @@ func TestInheritSystemAccessToken(t *testing.T) { assert.Equal(t, "foobar", env["SYSTEM_ACCESSTOKEN"]) } +func TestInheritSystemTeamFoundationCollectionUri(t *testing.T) { + t.Setenv("SYSTEM_TEAMFOUNDATIONCOLLECTIONURI", "foobar") + + ctx := context.Background() + env := map[string]string{} + err := inheritEnvVars(ctx, env) + require.NoError(t, err) + assert.Equal(t, "foobar", env["SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"]) +} + func TestSetUserProfileFromInheritEnvVars(t *testing.T) { t.Setenv("USERPROFILE", "c:\\foo\\c")