-
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.
- Loading branch information
Showing
5 changed files
with
80 additions
and
77 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
2 changes: 2 additions & 0 deletions
2
data_safe_haven/infrastructure/components/wrapped/__init__.py
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
from .log_analytics_workspace import WrappedLogAnalyticsWorkspace | ||
from .nfsv3_storage_account import NFSV3StorageAccount | ||
|
||
__all__ = [ | ||
"NFSV3StorageAccount", | ||
"WrappedLogAnalyticsWorkspace", | ||
] |
68 changes: 68 additions & 0 deletions
68
data_safe_haven/infrastructure/components/wrapped/nfsv3_storage_account.py
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,68 @@ | ||
from collections.abc import Mapping, Sequence | ||
|
||
from pulumi import Input, Output, ResourceOptions | ||
from pulumi_azure_native import storage | ||
|
||
from data_safe_haven.external import AzureIPv4Range | ||
|
||
|
||
class NFSV3StorageAccount(storage.StorageAccount): | ||
encryption_args = storage.EncryptionArgs( | ||
key_source=storage.KeySource.MICROSOFT_STORAGE, | ||
services=storage.EncryptionServicesArgs( | ||
blob=storage.EncryptionServiceArgs( | ||
enabled=True, key_type=storage.KeyType.ACCOUNT | ||
), | ||
file=storage.EncryptionServiceArgs( | ||
enabled=True, key_type=storage.KeyType.ACCOUNT | ||
), | ||
), | ||
) | ||
|
||
def __init__( | ||
self, | ||
resource_name: str, | ||
*, | ||
account_name: Input[str], | ||
allowed_ip_addresses: Input[Sequence[str]], | ||
location: Input[str], | ||
resource_group_name: Input[str], | ||
subnet_id: Input[str], | ||
opts: ResourceOptions, | ||
tags: Input[Mapping[str, Input[str]]], | ||
): | ||
self.resource_group_name_ = Output.from_input(resource_group_name) | ||
super().__init__( | ||
resource_name, | ||
account_name=account_name, | ||
enable_https_traffic_only=True, | ||
enable_nfs_v3=True, | ||
encryption=self.encryption_args, | ||
is_hns_enabled=True, | ||
kind=storage.Kind.BLOCK_BLOB_STORAGE, | ||
location=location, | ||
minimum_tls_version=storage.MinimumTlsVersion.TLS1_2, | ||
network_rule_set=storage.NetworkRuleSetArgs( | ||
bypass=storage.Bypass.AZURE_SERVICES, | ||
default_action=storage.DefaultAction.DENY, | ||
ip_rules=Output.from_input(allowed_ip_addresses).apply( | ||
lambda ip_ranges: [ | ||
storage.IPRuleArgs( | ||
action=storage.Action.ALLOW, | ||
i_p_address_or_range=str(ip_address), | ||
) | ||
for ip_range in sorted(ip_ranges) | ||
for ip_address in AzureIPv4Range.from_cidr(ip_range).all_ips() | ||
] | ||
), | ||
virtual_network_rules=[ | ||
storage.VirtualNetworkRuleArgs( | ||
virtual_network_resource_id=subnet_id, | ||
) | ||
], | ||
), | ||
resource_group_name=resource_group_name, | ||
sku=storage.SkuArgs(name=storage.SkuName.PREMIUM_ZRS), | ||
opts=opts, | ||
tags=tags, | ||
) |
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