Skip to content

Commit 9177b63

Browse files
authored
Merge pull request #112 from andir/efs_mount_subnet
efs mount targets: allow passing a subnetid as Nix attrset
2 parents 9ff8f18 + 659ff3c commit 9177b63

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

nixops_aws/nix/elastic-file-system-mount-target.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ with import ./lib.nix lib;
2424
};
2525

2626
subnet = mkOption {
27-
type = types.str;
27+
type = types.either types.str (resource "vpc-subnet");
28+
apply = x: if builtins.isString x then x else "res-" + x._name + "." + x._type;
2829
description = "The EC2 subnet in which to create this mount target.";
2930
};
3031

nixops_aws/resources/elastic_file_system_mount_target.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from . import elastic_file_system
1313
import time
1414
from .elastic_file_system import ElasticFileSystemState
15+
from .vpc_subnet import VPCSubnetState
1516

1617
from .types.elastic_file_system_mount_target import ElasticFileSystemMountTargetOptions
1718

@@ -118,6 +119,12 @@ def create(self, defn, check, allow_reboot, allow_recreate):
118119
args["IpAddress"] = defn.config["ipAddress"]
119120

120121
subnetId = defn.config["subnet"]
122+
if subnetId.startswith("res-"):
123+
subnet_res = self.depl.get_typed_resource(
124+
subnetId[4:].split(".")[0], "vpc-subnet", VPCSubnetState
125+
)
126+
subnetId = subnet_res._state["subnetId"]
127+
121128
securityGroups = self.security_groups_to_ids(
122129
region, access_key_id, subnetId, defn.config["securityGroups"]
123130
)

0 commit comments

Comments
 (0)