Documentation ¶
Index ¶
- func CreateDenyOutRule(ctx context.Context, nsgName string) (rule network.SecurityRule, err error)
- func CreateHTTPRule(ctx context.Context, nsgName string) (rule network.SecurityRule, err error)
- func CreateLoadBalancer(ctx context.Context, lbName, pipName string) (lb network.LoadBalancer, err error)
- func CreateNIC(ctx context.Context, vnetName, subnetName, nsgName, ipName, nicName string) (nic network.Interface, err error)
- func CreateNICWithLoadBalancer(ctx context.Context, lbName, vnetName, subnetName, nicName string, natRule int) (nic network.Interface, err error)
- func CreateNetworkSecurityGroup(ctx context.Context, nsgName string) (nsg network.SecurityGroup, err error)
- func CreatePublicIP(ctx context.Context, ipName string) (ip network.PublicIPAddress, err error)
- func CreateSQLRule(ctx context.Context, nsgName, frontEndAddressPrefix string) (rule network.SecurityRule, err error)
- func CreateSSHRule(ctx context.Context, nsgName string) (rule network.SecurityRule, err error)
- func CreateSimpleNetworkSecurityGroup(ctx context.Context, nsgName string) (nsg network.SecurityGroup, err error)
- func CreateSubnetWithNetworkSecurityGroup(ctx context.Context, vnetName, subnetName, addressPrefix, nsgName string) (subnet network.Subnet, err error)
- func CreateVirtualNetwork(ctx context.Context, vnetName string) (vnet network.VirtualNetwork, err error)
- func CreateVirtualNetworkAndSubnets(ctx context.Context, vnetName, subnet1Name, subnet2Name string) (vnet network.VirtualNetwork, err error)
- func CreateVirtualNetworkSubnet(ctx context.Context, vnetName, subnetName string) (subnet network.Subnet, err error)
- func DeleteNetworkSecurityGroup(ctx context.Context, nsgName string) (result network.SecurityGroupsDeleteFuture, err error)
- func DeleteNic(ctx context.Context, nic string) (result network.InterfacesDeleteFuture, err error)
- func DeletePublicIP(ctx context.Context, ipName string) (result network.PublicIPAddressesDeleteFuture, err error)
- func DeleteVirtualNetwork(ctx context.Context, vnetName string) (result network.VirtualNetworksDeleteFuture, err error)
- func DeleteVirtualNetworkSubnet()
- func GetLoadBalancer(ctx context.Context, lbName string) (network.LoadBalancer, error)
- func GetNetworkSecurityGroup(ctx context.Context, nsgName string) (network.SecurityGroup, error)
- func GetNic(ctx context.Context, nicName string) (network.Interface, error)
- func GetPublicIP(ctx context.Context, ipName string) (network.PublicIPAddress, error)
- func GetVirtualNetworkSubnet(ctx context.Context, vnetName string, subnetName string) (network.Subnet, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDenyOutRule ¶
CreateDenyOutRule creates an network security rule that denies outbound traffic
func CreateHTTPRule ¶
CreateHTTPRule creates an inbound network security rule that allows using port 80
func CreateLoadBalancer ¶
func CreateLoadBalancer(ctx context.Context, lbName, pipName string) (lb network.LoadBalancer, err error)
CreateLoadBalancer creates a load balancer with 2 inbound NAT rules.
func CreateNIC ¶
func CreateNIC(ctx context.Context, vnetName, subnetName, nsgName, ipName, nicName string) (nic network.Interface, err error)
CreateNIC creates a new network interface. The Network Security Group is not a required parameter
Example ¶
groupName := config.GenerateGroupName("CreateNIC") config.SetGroupName(groupName) // TODO: don't use globals ctx, cancel := context.WithTimeout(context.Background(), 300*time.Second) defer cancel() defer resources.Cleanup(ctx) _, err := resources.CreateGroup(ctx, config.GroupName()) if err != nil { util.LogAndPanic(err) } _, err = CreateVirtualNetworkAndSubnets(ctx, virtualNetworkName, subnet1Name, subnet2Name) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("created vnet and 2 subnets") _, err = CreateNetworkSecurityGroup(ctx, nsgName) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("created network security group") _, err = CreatePublicIP(ctx, ipName) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("created public IP") _, err = CreateNIC(ctx, virtualNetworkName, subnet1Name, nsgName, ipName, nicName) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("created nic")
Output: created vnet and 2 subnets created network security group created public IP created nic
func CreateNICWithLoadBalancer ¶
func CreateNICWithLoadBalancer(ctx context.Context, lbName, vnetName, subnetName, nicName string, natRule int) (nic network.Interface, err error)
CreateNICWithLoadBalancer creats a network interface, wich is set up with a loadbalancer's NAT rule
func CreateNetworkSecurityGroup ¶
func CreateNetworkSecurityGroup(ctx context.Context, nsgName string) (nsg network.SecurityGroup, err error)
CreateNetworkSecurityGroup creates a new network security group with rules set for allowing SSH and HTTPS use
Example ¶
groupName := config.GenerateGroupName("CreateNSG") config.SetGroupName(groupName) // TODO: don't use globals ctx, cancel := context.WithTimeout(context.Background(), 300*time.Second) defer cancel() defer resources.Cleanup(ctx) _, err := resources.CreateGroup(ctx, config.GroupName()) if err != nil { util.LogAndPanic(err) } _, err = CreateVirtualNetwork(ctx, virtualNetworkName) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("created vnet") frontNSGName := "frontend" backNSGName := "backend" _, err = CreateNetworkSecurityGroup(ctx, frontNSGName) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("created frontend network security group") _, err = CreateNetworkSecurityGroup(ctx, backNSGName) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("created backend network security group") frontEndAddressPrefix := "10.0.0.0/16" _, err = CreateSubnetWithNetworkSecurityGroup(ctx, virtualNetworkName, "frontend", frontEndAddressPrefix, frontNSGName) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("created subnet with frontend network security group") _, err = CreateSubnetWithNetworkSecurityGroup(ctx, virtualNetworkName, "backend", "10.1.0.0/16", backNSGName) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("created subnet with backend network security group") _, err = CreateSSHRule(ctx, frontNSGName) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("created frontend SSH security rule") _, err = CreateHTTPRule(ctx, frontNSGName) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("created frontend HTTP security rule") _, err = CreateSQLRule(ctx, frontNSGName, frontEndAddressPrefix) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("created frontend SQL security rule") _, err = CreateDenyOutRule(ctx, backNSGName) if err != nil { util.LogAndPanic(err) } util.PrintAndLog("created backend deny out security rule")
Output: created vnet created frontend network security group created backend network security group created subnet with frontend network security group created subnet with backend network security group created frontend SSH security rule created frontend HTTP security rule created frontend SQL security rule created backend deny out security rule
func CreatePublicIP ¶
CreatePublicIP creates a new public IP
func CreateSQLRule ¶
func CreateSQLRule(ctx context.Context, nsgName, frontEndAddressPrefix string) (rule network.SecurityRule, err error)
CreateSQLRule creates an inbound network security rule that allows using port 1433
func CreateSSHRule ¶
CreateSSHRule creates an inbound network security rule that allows using port 22
func CreateSimpleNetworkSecurityGroup ¶
func CreateSimpleNetworkSecurityGroup(ctx context.Context, nsgName string) (nsg network.SecurityGroup, err error)
CreateSimpleNetworkSecurityGroup creates a new network security group, without rules (rules can be set later)
func CreateSubnetWithNetworkSecurityGroup ¶
func CreateSubnetWithNetworkSecurityGroup(ctx context.Context, vnetName, subnetName, addressPrefix, nsgName string) (subnet network.Subnet, err error)
CreateSubnetWithNetworkSecurityGroup create a subnet referencing a network security group
func CreateVirtualNetwork ¶
func CreateVirtualNetwork(ctx context.Context, vnetName string) (vnet network.VirtualNetwork, err error)
CreateVirtualNetwork creates a virtual network
func CreateVirtualNetworkAndSubnets ¶
func CreateVirtualNetworkAndSubnets(ctx context.Context, vnetName, subnet1Name, subnet2Name string) (vnet network.VirtualNetwork, err error)
CreateVirtualNetworkAndSubnets creates a virtual network with two subnets
func CreateVirtualNetworkSubnet ¶
func CreateVirtualNetworkSubnet(ctx context.Context, vnetName, subnetName string) (subnet network.Subnet, err error)
CreateVirtualNetworkSubnet creates a subnet in an existing vnet
func DeleteNetworkSecurityGroup ¶
func DeleteNetworkSecurityGroup(ctx context.Context, nsgName string) (result network.SecurityGroupsDeleteFuture, err error)
DeleteNetworkSecurityGroup deletes an existing network security group
func DeletePublicIP ¶
func DeletePublicIP(ctx context.Context, ipName string) (result network.PublicIPAddressesDeleteFuture, err error)
DeletePublicIP deletes an existing public IP
func DeleteVirtualNetwork ¶
func DeleteVirtualNetwork(ctx context.Context, vnetName string) (result network.VirtualNetworksDeleteFuture, err error)
DeleteVirtualNetwork deletes a virtual network given an existing virtual network
func DeleteVirtualNetworkSubnet ¶
func DeleteVirtualNetworkSubnet()
DeleteVirtualNetworkSubnet deletes a subnet
func GetLoadBalancer ¶
GetLoadBalancer gets info on a loadbalancer
func GetNetworkSecurityGroup ¶
GetNetworkSecurityGroup returns an existing network security group
func GetPublicIP ¶
GetPublicIP returns an existing public IP
Types ¶
This section is empty.