diff --git a/lwgenerate/azure/azure.go b/lwgenerate/azure/azure.go index 74a109109..0a2159924 100644 --- a/lwgenerate/azure/azure.go +++ b/lwgenerate/azure/azure.go @@ -3,9 +3,7 @@ package azure import ( "fmt" - "io" "net" - "net/http" "strings" "github.com/hashicorp/hcl/v2/hclwrite" @@ -126,39 +124,6 @@ func IsIpv4(ip string) bool { return parsedIP != nil && parsedIP.To4() != nil } -// getCurrentPublicIP retrieves the current public IP address of the machine -func getCurrentPublicIP() (string, error) { - // use reliable IP detection services - urls := []string{ - "https://api.ipify.org", - "https://ifconfig.me", - "https://ipinfo.io/ip", - } - - for _, url := range urls { - resp, err := http.Get(url) - if err != nil { - continue - } - defer resp.Body.Close() - - if resp.StatusCode == http.StatusOK { - body, err := io.ReadAll(resp.Body) - if err != nil { - continue - } - ip := strings.TrimSpace(string(body)) - // Validate if the IP is a valid IPv4 address - if !IsIpv4(ip) { - continue - } - return ip, nil - } - } - - return "", fmt.Errorf("failed to get public IP") -} - // Ensure all combinations of inputs are valid for supported spec func (args *GenerateAzureTfConfigurationArgs) validate() error { // Validate one of config, agentless or activity log was enabled; otherwise error out @@ -743,14 +708,7 @@ func createActivityLog(args *GenerateAzureTfConfigurationArgs) ([]*hclwrite.Bloc if args.UseStorageAccountNetworkRules && !args.ExistingStorageAccount { attributes["use_storage_account_network_rules"] = args.UseStorageAccountNetworkRules - // if no IP rules are provided, automatically detect the current public IP - if len(args.StorageAccountNetworkRuleIpRules) == 0 { - currentIP, err := getCurrentPublicIP() - if err != nil { - return nil, err - } - attributes["storage_account_network_rule_ip_rules"] = []string{currentIP} - } else { + if len(args.StorageAccountNetworkRuleIpRules) > 0 { attributes["storage_account_network_rule_ip_rules"] = args.StorageAccountNetworkRuleIpRules } }