Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for bastion developer create #8366

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
space-separated ip addresses for network acls
  • Loading branch information
Jacques Zhang committed Dec 17, 2024
commit b58040cbffe0c6296368444c211f7f239fa9459d
14 changes: 7 additions & 7 deletions src/bastion/azext_bastion/aaz/latest/network/bastion/_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Create(AAZCommand):
az network bastion create --name MyBastion --resource-group MyResourceGroup --sku Developer --vnet-name MyVnet

:example: Create Developer SKU Bastion with Network ACLs IP rules
az network bastion create --name MyBastion --resource-group MyResourceGroup --sku Developer --vnet-name MyVnet --network-acls-ips '[{"addressPrefix":"1.1.1.1/16"},{"addressPrefix":"100.64.0.0/10"}]'
az network bastion create --name MyBastion --resource-group MyResourceGroup --sku Developer --vnet-name MyVnet --network-acls-ips "1.1.1.1/16 100.64.0.0/10"
"""

_aaz_info = {
Expand Down Expand Up @@ -151,8 +151,8 @@ def _build_arguments_schema(cls, *args, **kwargs):
arg_group="Properties",
help="IP configuration of the Bastion Host resource.",
)
_args_schema.network_acls_ips = AAZListArg(
options=["--network-acls-ips"],
_args_schema.network_acls = AAZListArg(
options=["--network-acls"],
arg_group="Properties",
help="[Supported in Developer SKU only] The Network ACLs IP rules.",
)
Expand Down Expand Up @@ -201,10 +201,10 @@ def _build_arguments_schema(cls, *args, **kwargs):
)
cls._build_args_sub_resource_create(_element.subnet)

network_acls_ips = cls._args_schema.network_acls_ips
network_acls_ips.Element = AAZObjectArg()
network_acls = cls._args_schema.network_acls
network_acls.Element = AAZObjectArg()

_element = cls._args_schema.network_acls_ips.Element
_element = cls._args_schema.network_acls.Element
_element.address_prefix = AAZStrArg(
options=["address-prefix"],
help="Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed.",
Expand Down Expand Up @@ -375,7 +375,7 @@ def content(self):

network_acls = _builder.get(".properties.networkAcls")
if network_acls is not None:
network_acls.set_prop("ipRules", AAZListType, ".network_acls_ips")
network_acls.set_prop("ipRules", AAZListType, ".network_acls")

ip_rules = _builder.get(".properties.networkAcls.ipRules")
if ip_rules is not None:
Expand Down
12 changes: 11 additions & 1 deletion src/bastion/azext_bastion/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,16 @@ def _build_arguments_schema(cls, *args, **kwargs):
"For all SKUs but Developer SKU, this virtual network must have a subnet called AzureBastionSubnet.",
required=True,
)
args_schema.network_acls_ips = AAZStrArg(
options=["--network-acls-ips"],
arg_group="Properties",
help="[Supported in Developer SKU only] Network ACLs IP rules. Space-separated list of IP addresses.",
required=False,
)
# filter arguments
args_schema.ip_configurations._registered = False
args_schema.virtual_network._registered = False
args_schema.network_acls._registered = False
return args_schema

def pre_operations(self):
Expand All @@ -82,7 +89,10 @@ def pre_operations(self):
args.virtual_network = {
"id": vnet_id
}


if args.network_acls_ips is not None:
addresses = str(args.network_acls_ips).split()
args.network_acls = [{"addressPrefix": address} for address in addresses]

SSH_EXTENSION_NAME = "ssh"
SSH_EXTENSION_MODULE = "azext_ssh.custom"
Expand Down
Loading