Last active
March 13, 2020 13:11
-
-
Save timolinn/ee57e395e22dcf937c8b25ef99165647 to your computer and use it in GitHub Desktop.
Connect to Azure Firewall rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"github.com/Azure/azure-sdk-for-go/sdk/to" | |
"github.com/Azure/azure-sdk-for-go/services/preview/postgresql/mgmt/2017-12-01-preview/postgresql" | |
"github.com/Azure/go-autorest/autorest/azure/auth" | |
) | |
func main() { | |
// create a firewall client | |
pgfirewall := postgresql.NewFirewallRulesClient(<add-your-subscription-id-here>) | |
// create an authorizer from env vars or Azure Managed Service Idenity | |
authorizer, err := auth.NewAuthorizerFromCLI() | |
if err != nil { | |
panic(err) | |
} | |
pgfirewall.Authorizer = authorizer | |
_, err = pgfirewall.CreateOrUpdate( | |
context.Background(), | |
"databricks", | |
"test-for-logs", | |
"allow 0.0.0.0", | |
postgresql.FirewallRule{ | |
FirewallRuleProperties: &postgresql.FirewallRuleProperties{ | |
StartIPAddress: to.StringPtr("0.0.0.0"), | |
EndIPAddress: to.StringPtr("0.0.0.0"), | |
}, | |
}, | |
) | |
if err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment