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

Update Pulumi resource ordering #1536

23 changes: 23 additions & 0 deletions data_safe_haven/pulumi/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from .enums import NetworkingPriorities
from .transformations import (
get_available_ips_from_subnet,
get_id_from_rg,
get_id_from_subnet,
get_ip_address_from_container_group,
get_ip_addresses_from_private_endpoint,
get_name_from_rg,
get_name_from_subnet,
get_name_from_vnet,
)

__all__ = [
"get_available_ips_from_subnet",
"get_id_from_rg",
"get_id_from_subnet",
"get_ip_address_from_container_group",
"get_ip_addresses_from_private_endpoint",
"get_name_from_rg",
"get_name_from_subnet",
"get_name_from_vnet",
"NetworkingPriorities",
]
8 changes: 4 additions & 4 deletions data_safe_haven/pulumi/components/automation_dsc_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(
opts: ResourceOptions | None = None,
) -> None:
super().__init__("dsh:common:AutomationDscNode", name, {}, opts)
child_opts = ResourceOptions.merge(ResourceOptions(parent=self), opts)
child_opts = ResourceOptions.merge(opts, ResourceOptions(parent=self))

# Upload the primary domain controller DSC
dsc = automation.DscConfiguration(
Expand All @@ -77,10 +77,10 @@ def __init__(
),
),
opts=ResourceOptions.merge(
child_opts,
ResourceOptions(
delete_before_replace=True, replace_on_changes=["source.hash"]
),
child_opts,
),
)
dsc_compiled = CompiledDsc(
Expand All @@ -97,7 +97,7 @@ def __init__(
required_modules=props.dsc_required_modules,
subscription_name=props.subscription_name,
),
opts=ResourceOptions.merge(ResourceOptions(depends_on=[dsc]), child_opts),
opts=ResourceOptions.merge(child_opts, ResourceOptions(depends_on=[dsc])),
)
compute.VirtualMachineExtension(
f"{self._name}_dsc_extension",
Expand Down Expand Up @@ -130,7 +130,7 @@ def __init__(
vm_name=props.vm_name,
vm_extension_name="Microsoft.Powershell.DSC",
opts=ResourceOptions.merge(
ResourceOptions(depends_on=[dsc_compiled]),
child_opts,
ResourceOptions(depends_on=[dsc_compiled]),
),
)
2 changes: 1 addition & 1 deletion data_safe_haven/pulumi/components/shm_bastion.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(
opts: ResourceOptions | None = None,
) -> None:
super().__init__("dsh:shm:BastionComponent", name, {}, opts)
child_opts = ResourceOptions.merge(ResourceOptions(parent=self), opts)
child_opts = ResourceOptions.merge(opts, ResourceOptions(parent=self))

# Deploy IP address
public_ip = network.PublicIPAddress(
Expand Down
2 changes: 1 addition & 1 deletion data_safe_haven/pulumi/components/shm_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(
opts: ResourceOptions | None = None,
) -> None:
super().__init__("dsh:shm:DataComponent", name, {}, opts)
child_opts = ResourceOptions.merge(ResourceOptions(parent=self), opts)
child_opts = ResourceOptions.merge(opts, ResourceOptions(parent=self))

# Deploy resource group
resource_group = resources.ResourceGroup(
Expand Down
8 changes: 4 additions & 4 deletions data_safe_haven/pulumi/components/shm_domain_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pulumi import ComponentResource, Input, Output, ResourceOptions
from pulumi_azure_native import network, resources

from data_safe_haven.pulumi.common.transformations import get_name_from_subnet
from data_safe_haven.pulumi.common import get_name_from_subnet
from data_safe_haven.pulumi.dynamic.remote_powershell import (
RemoteScript,
RemoteScriptProps,
Expand Down Expand Up @@ -87,7 +87,7 @@ def __init__(
opts: ResourceOptions | None = None,
) -> None:
super().__init__("dsh:shm:DomainControllersComponent", name, {}, opts)
child_opts = ResourceOptions.merge(ResourceOptions(parent=self), opts)
child_opts = ResourceOptions.merge(opts, ResourceOptions(parent=self))
resources_path = pathlib.Path(__file__).parent.parent.parent / "resources"

# Deploy resource group
Expand Down Expand Up @@ -157,8 +157,8 @@ def __init__(
vm_resource_group_name=resource_group.name,
),
opts=ResourceOptions.merge(
ResourceOptions(depends_on=[primary_domain_controller]),
child_opts,
ResourceOptions(depends_on=[primary_domain_controller]),
),
)
# Extract the domain SID
Expand All @@ -177,13 +177,13 @@ def __init__(
vm_resource_group_name=resource_group.name,
),
opts=ResourceOptions.merge(
child_opts,
ResourceOptions(
depends_on=[
primary_domain_controller,
primary_domain_controller_dsc_node,
]
),
child_opts,
),
)

Expand Down
4 changes: 2 additions & 2 deletions data_safe_haven/pulumi/components/shm_firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pulumi import ComponentResource, Input, Output, ResourceOptions
from pulumi_azure_native import network

from data_safe_haven.pulumi.common.transformations import get_id_from_subnet
from data_safe_haven.pulumi.common import get_id_from_subnet


class SHMFirewallProps:
Expand Down Expand Up @@ -46,7 +46,7 @@ def __init__(
opts: ResourceOptions | None = None,
) -> None:
super().__init__("dsh:shm:FirewallComponent", name, {}, opts)
child_opts = ResourceOptions.merge(ResourceOptions(parent=self), opts)
child_opts = ResourceOptions.merge(opts, ResourceOptions(parent=self))

# Important IP addresses
# https://docs.microsoft.com/en-us/azure/virtual-network/what-is-ip-address-168-63-129-16
Expand Down
10 changes: 5 additions & 5 deletions data_safe_haven/pulumi/components/shm_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
replace_separators,
time_as_string,
)
from data_safe_haven.pulumi.common.transformations import get_id_from_subnet
from data_safe_haven.pulumi.common import get_id_from_subnet


class SHMMonitoringProps:
Expand Down Expand Up @@ -48,7 +48,7 @@ def __init__(
opts: ResourceOptions | None = None,
) -> None:
super().__init__("dsh:shm:MonitoringComponent", name, {}, opts)
child_opts = ResourceOptions.merge(ResourceOptions(parent=self), opts)
child_opts = ResourceOptions.merge(opts, ResourceOptions(parent=self))

# Deploy resource group
resource_group = resources.ResourceGroup(
Expand Down Expand Up @@ -285,8 +285,8 @@ def __init__(
),
),
opts=ResourceOptions.merge(
ResourceOptions(ignore_changes=["schedule_info"]),
child_opts,
ResourceOptions(ignore_changes=["schedule_info"]),
),
)
# Create Windows VM system update schedule: daily at 02:02
Expand Down Expand Up @@ -333,13 +333,13 @@ def __init__(
),
),
opts=ResourceOptions.merge(
child_opts,
ResourceOptions(
ignore_changes=[
"schedule_info", # options are added after deployment
"updateConfiguration.windows.included_package_classifications", # ordering might change
]
),
child_opts,
),
)
# Create Linux VM system update schedule: daily at 02:02
Expand Down Expand Up @@ -383,13 +383,13 @@ def __init__(
),
),
opts=ResourceOptions.merge(
child_opts,
ResourceOptions(
ignore_changes=[
"schedule_info", # options are added after deployment
"updateConfiguration.linux.included_package_classifications", # ordering might change
]
),
child_opts,
),
)

Expand Down
8 changes: 4 additions & 4 deletions data_safe_haven/pulumi/components/shm_networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from data_safe_haven.external import AzureIPv4Range
from data_safe_haven.functions import ordered_private_dns_zones
from data_safe_haven.pulumi.common.enums import NetworkingPriorities
from data_safe_haven.pulumi.common import NetworkingPriorities


class SHMNetworkingProps:
Expand Down Expand Up @@ -47,7 +47,7 @@ def __init__(
opts: ResourceOptions | None = None,
) -> None:
super().__init__("dsh:shm:NetworkingComponent", name, {}, opts)
child_opts = ResourceOptions.merge(ResourceOptions(parent=self), opts)
child_opts = ResourceOptions.merge(opts, ResourceOptions(parent=self))

# Deploy resource group
resource_group = resources.ResourceGroup(
Expand Down Expand Up @@ -325,10 +325,10 @@ def __init__(
route_table_name=f"{stack_name}-route",
routes=[],
opts=ResourceOptions.merge(
child_opts,
ResourceOptions(
ignore_changes=["routes"]
), # allow routes to be created outside this definition
child_opts,
),
)

Expand Down Expand Up @@ -392,10 +392,10 @@ def __init__(
virtual_network_name=f"{stack_name}-vnet",
virtual_network_peerings=[],
opts=ResourceOptions.merge(
child_opts,
ResourceOptions(
ignore_changes=["virtual_network_peerings"]
), # allow SRE virtual networks to peer to this
child_opts,
),
)

Expand Down
4 changes: 2 additions & 2 deletions data_safe_haven/pulumi/components/shm_update_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pulumi_azure_native import network

from data_safe_haven.functions import b64encode
from data_safe_haven.pulumi.common.transformations import (
from data_safe_haven.pulumi.common import (
get_available_ips_from_subnet,
get_name_from_subnet,
)
Expand Down Expand Up @@ -53,7 +53,7 @@ def __init__(
opts: ResourceOptions | None = None,
) -> None:
super().__init__("dsh:shm:UpdateServersComponent", name, {}, opts)
child_opts = ResourceOptions.merge(ResourceOptions(parent=self), opts)
child_opts = ResourceOptions.merge(opts, ResourceOptions(parent=self))

# Load cloud-init file
b64cloudinit = self.read_cloudinit()
Expand Down
4 changes: 2 additions & 2 deletions data_safe_haven/pulumi/components/sre_application_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pulumi import ComponentResource, Input, Output, ResourceOptions
from pulumi_azure_native import managedidentity, network, resources

from data_safe_haven.pulumi.common.transformations import (
from data_safe_haven.pulumi.common import (
get_available_ips_from_subnet,
get_id_from_rg,
get_id_from_subnet,
Expand Down Expand Up @@ -55,7 +55,7 @@ def __init__(
opts: ResourceOptions | None = None,
) -> None:
super().__init__("dsh:sre:ApplicationGatewayComponent", name, {}, opts)
child_opts = ResourceOptions.merge(ResourceOptions(parent=self), opts)
child_opts = ResourceOptions.merge(opts, ResourceOptions(parent=self))

# Define public IP address
public_ip = network.PublicIPAddress(
Expand Down
Loading