-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1417 from jemrobinson/1414-shm-bastion
Add SHM bastion
- Loading branch information
Showing
21 changed files
with
457 additions
and
127 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from enum import Enum | ||
|
||
|
||
class NetworkingPriorities(int, Enum): | ||
"""Priorities for network security group rules.""" | ||
|
||
# Azure services: 0 - 999 | ||
AZURE_CLOUD = 100 | ||
AZURE_GATEWAY_MANAGER = 200 | ||
AZURE_LOAD_BALANCER = 300 | ||
# Internal connections: 1000-1999 | ||
INTERNAL_SELF = 1000 | ||
INTERNAL_SHM_BASTION = 1100 | ||
INTERNAL_SHM_LDAP_TCP = 1200 | ||
INTERNAL_SHM_LDAP_UDP = 1250 | ||
INTERNAL_SHM_MONITORING_TOOLS = 1300 | ||
INTERNAL_SHM_UPDATE_SERVERS = 1400 | ||
INTERNAL_SRE_REMOTE_DESKTOP = 1500 | ||
INTERNAL_DSH_VIRTUAL_NETWORK = 1999 | ||
# Authorised external IPs: 2000-2999 | ||
AUTHORISED_EXTERNAL_ADMIN_IPS = 2000 | ||
AUTHORISED_EXTERNAL_USER_IPS = 2100 | ||
# Wider internet: 3000-3999 | ||
EXTERNAL_LINUX_UPDATES = 3600 | ||
EXTERNAL_INTERNET = 3999 | ||
# Deny all other: 4096 | ||
ALL_OTHER = 4096 |
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"""Pulumi component for SHM monitoring""" | ||
# Standard library import | ||
from typing import Optional | ||
|
||
# Third party imports | ||
from pulumi import ComponentResource, Input, Output, ResourceOptions | ||
from pulumi_azure_native import network | ||
|
||
# Local imports | ||
from data_safe_haven.helpers.functions import time_as_string | ||
|
||
|
||
class SHMBastionProps: | ||
"""Properties for SHMBastionComponent""" | ||
|
||
def __init__( | ||
self, | ||
location: Input[str], | ||
resource_group_name: Input[str], | ||
subnet: Input[network.GetSubnetResult], | ||
) -> None: | ||
# self.automation_account_name = automation_account_name | ||
self.location = location | ||
self.resource_group_name = resource_group_name | ||
self.subnet_id = Output.from_input(subnet).apply(lambda s: s.id) | ||
|
||
|
||
class SHMBastionComponent(ComponentResource): | ||
"""Deploy SHM bastion with Pulumi""" | ||
|
||
def __init__( | ||
self, | ||
name: str, | ||
stack_name: str, | ||
shm_name: str, | ||
props: SHMBastionProps, | ||
opts: Optional[ResourceOptions] = None, | ||
): | ||
super().__init__("dsh:shm:SHMBastionComponent", name, {}, opts) | ||
child_opts = ResourceOptions.merge(ResourceOptions(parent=self), opts) | ||
|
||
# Deploy IP address | ||
public_ip = network.PublicIPAddress( | ||
f"{self._name}_pip_bastion", | ||
public_ip_address_name=f"{stack_name}-pip-bastion", | ||
public_ip_allocation_method=network.IPAllocationMethod.STATIC, | ||
resource_group_name=props.resource_group_name, | ||
sku=network.PublicIPAddressSkuArgs( | ||
name=network.PublicIPAddressSkuName.STANDARD | ||
), | ||
opts=child_opts, | ||
) | ||
|
||
# Deploy bastion host | ||
bastion_host = network.BastionHost( | ||
f"{self._name}_bastion_host", | ||
bastion_host_name=f"{stack_name}-bas", | ||
ip_configurations=[ | ||
network.BastionHostIPConfigurationArgs( | ||
public_ip_address=network.SubResourceArgs(id=public_ip.id), | ||
subnet=network.SubResourceArgs(id=props.subnet_id), | ||
name=f"{stack_name}-bas-ipcfg", | ||
private_ip_allocation_method=network.IPAllocationMethod.DYNAMIC, | ||
) | ||
], | ||
resource_group_name=props.resource_group_name, | ||
) | ||
|
||
# Register outputs | ||
self.bastion_host = bastion_host |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.