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
EC2[EBS] Allow assigning existing volume to the resource #1128
Conversation
nixops/resources/ebs_volume.py
Outdated
def get_physical_spec(self): | ||
physical = {} | ||
if self.volume_id: | ||
physical['volumeId'] = self.volume_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea where this can be used ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to use it to to tweak the show-physical-backup function to get it to generate a file to override volumes with snapshots/other volumes
nixops/resources/ebs_volume.py
Outdated
if defn.snapshot: | ||
self.log("creating EBS volume of {0} GiB from snapshot ‘{1}’...".format(defn.size, defn.snapshot)) | ||
if defn.volume_id != "": | ||
vol_id = defn.volume_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about the other volume attributes ? I think it'd be better to implement a _check method that pulls the volume attribute and persist to the state so in case it's an existent volume we run self._check() first
Btw I like the idea in general but sometimes I think it should be implemented at the resource level where we'll have something like |
867b297
to
16e3b15
Compare
nix/ebs-volume.nix
Outdated
@@ -29,6 +29,16 @@ with lib; | |||
description = "The AWS Access Key ID."; | |||
}; | |||
|
|||
volumeId = mkOption { | |||
default = "test123"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there shouldn't be a default value here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup and i missed to remove that since i used it for testing. ty
nix/ebs-volume.nix
Outdated
example = "vol-abc123"; | ||
type = types.str; | ||
description = '' | ||
The volume ID that will be set by nixops or overriden |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent with 2 spaces
nixops/resources/ebs_volume.py
Outdated
self._conn_boto3 = nixops.ec2_utils.connect_ec2_boto3(region, self.access_key_id) | ||
return self._conn_boto3 | ||
|
||
def _check(self, defn): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this won't run during nixops check
as that expects a method _check() that doesn't get any arguments
nixops/resources/ebs_volume.py
Outdated
def _check(self, defn): | ||
self.connect_boto3(defn.region) | ||
try: | ||
_vol = self._conn_boto3.describe_volumes(VolumeIds=[defn.volume_id])['Volumes'][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also what if there is no volume_id in the definition like the old behavior ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function should not run when there is no defined volume_id. the function should not run during a nixops check
so i assume i should change the name if _check
if reserved ?
bbc6df3
to
c93a99b
Compare
also remove xml parsing in the definition and use the defn.config dict instead.
4e0f467
to
fa6348e
Compare
No description provided.