diff --git a/lib/config/configuration.go b/lib/config/configuration.go index d4f68c4afce53..10a6705e4f96c 100644 --- a/lib/config/configuration.go +++ b/lib/config/configuration.go @@ -1545,16 +1545,18 @@ func applyDiscoveryConfig(fc *FileConfig, cfg *servicecfg.Config) error { for _, matcher := range fc.Discovery.AzureMatchers { var installerParams *types.InstallerParams - if matcher.InstallParams != nil { + if slices.Contains(matcher.Types, types.AzureMatcherVM) { installerParams = &types.InstallerParams{ - JoinMethod: matcher.InstallParams.JoinParams.Method, - JoinToken: matcher.InstallParams.JoinParams.TokenName, - ScriptName: matcher.InstallParams.ScriptName, PublicProxyAddr: getInstallerProxyAddr(matcher.InstallParams, fc), } - if matcher.InstallParams.Azure != nil { - installerParams.Azure = &types.AzureInstallerParams{ - ClientID: matcher.InstallParams.Azure.ClientID, + if matcher.InstallParams != nil { + installerParams.JoinMethod = matcher.InstallParams.JoinParams.Method + installerParams.JoinToken = matcher.InstallParams.JoinParams.TokenName + installerParams.ScriptName = matcher.InstallParams.ScriptName + if matcher.InstallParams.Azure != nil { + installerParams.Azure = &types.AzureInstallerParams{ + ClientID: matcher.InstallParams.Azure.ClientID, + } } } } @@ -1576,14 +1578,17 @@ func applyDiscoveryConfig(fc *FileConfig, cfg *servicecfg.Config) error { for _, matcher := range fc.Discovery.GCPMatchers { var installerParams *types.InstallerParams - if matcher.InstallParams != nil { + if slices.Contains(matcher.Types, types.GCPMatcherCompute) { installerParams = &types.InstallerParams{ - JoinMethod: matcher.InstallParams.JoinParams.Method, - JoinToken: matcher.InstallParams.JoinParams.TokenName, - ScriptName: matcher.InstallParams.ScriptName, PublicProxyAddr: getInstallerProxyAddr(matcher.InstallParams, fc), } + if matcher.InstallParams != nil { + installerParams.JoinMethod = matcher.InstallParams.JoinParams.Method + installerParams.JoinToken = matcher.InstallParams.JoinParams.TokenName + installerParams.ScriptName = matcher.InstallParams.ScriptName + } } + serviceMatcher := types.GCPMatcher{ Types: matcher.Types, Locations: matcher.Locations, diff --git a/lib/config/configuration_test.go b/lib/config/configuration_test.go index f8d82390718dd..6c343d025fac0 100644 --- a/lib/config/configuration_test.go +++ b/lib/config/configuration_test.go @@ -4304,6 +4304,11 @@ func TestDiscoveryConfig(t *testing.T) { "service_accounts": []string{"a@example.com", "b@example.com"}, }, } + cfg["version"] = "v3" + cfg["teleport"].(cfgMap)["proxy_server"] = "example.com" + cfg["proxy_service"] = cfgMap{ + "enabled": "no", + } }, expectedGCPMatchers: []types.GCPMatcher{{ Types: []string{"gce"}, @@ -4317,9 +4322,10 @@ func TestDiscoveryConfig(t *testing.T) { ProjectIDs: []string{"p1", "p2"}, ServiceAccounts: []string{"a@example.com", "b@example.com"}, Params: &types.InstallerParams{ - JoinMethod: types.JoinMethodGCP, - JoinToken: types.GCPInviteTokenName, - ScriptName: installers.InstallerScriptName, + JoinMethod: types.JoinMethodGCP, + JoinToken: types.GCPInviteTokenName, + ScriptName: installers.InstallerScriptName, + PublicProxyAddr: "example.com", }, }}, }, @@ -4632,6 +4638,11 @@ func TestDiscoveryConfig(t *testing.T) { }, }, } + cfg["version"] = "v3" + cfg["teleport"].(cfgMap)["proxy_server"] = "example.com" + cfg["proxy_service"] = cfgMap{ + "enabled": "no", + } }, expectedAzureMatchers: []types.AzureMatcher{{ Types: []string{"vm"}, @@ -4642,10 +4653,11 @@ func TestDiscoveryConfig(t *testing.T) { "discover_teleport": []string{"yes"}, }, Params: &types.InstallerParams{ - JoinMethod: "azure", - JoinToken: "azure-discovery-token", - ScriptName: "default-installer", - Azure: &types.AzureInstallerParams{}, + JoinMethod: "azure", + JoinToken: "azure-discovery-token", + ScriptName: "default-installer", + PublicProxyAddr: "example.com", + Azure: &types.AzureInstallerParams{}, }, }}, },