Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixops
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 235799920cd7
Choose a base ref
...
head repository: NixOS/nixops
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 755dede677f0
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Oct 8, 2018

  1. Enable sourceDestCheck for ec2 deployment

    pixelkind authored and Olaf Miller committed Oct 8, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    acdlite Andrew Clark
    Copy the full SHA
    83197a0 View commit details

Commits on Apr 20, 2019

  1. Merge pull request #1018 from MapCaseGmbH/pr-ec2-source-dest-check

    ec2: Allow configuring source-destination-check on ec2-instances
    AmineChikhaoui authored Apr 20, 2019
    Copy the full SHA
    755dede View commit details
Showing with 16 additions and 0 deletions.
  1. +9 −0 nix/ec2.nix
  2. +7 −0 nixops/backends/ec2.py
9 changes: 9 additions & 0 deletions nix/ec2.nix
Original file line number Diff line number Diff line change
@@ -354,6 +354,15 @@ in
'';
};

deployment.ec2.sourceDestCheck = mkOption {
default = true;
type = types.bool;
description = ''
If instance in a subnet/VPC, whether to enable or disable
source-destination-check.
'';
};

deployment.ec2.placementGroup = mkOption {
default = "";
example = "my-cluster";
7 changes: 7 additions & 0 deletions nixops/backends/ec2.py
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ def __init__(self, xml, config):
self.subnet_id = config["ec2"]["subnetId"]
self.associate_public_ip_address = config["ec2"]["associatePublicIpAddress"]
self.use_private_ip_address = config["ec2"]["usePrivateIpAddress"]
self.source_dest_check = config["ec2"]["sourceDestCheck"]
self.security_group_ids = config["ec2"]["securityGroupIds"]

# convert sd to xvd because they are equal from aws perspective
@@ -95,6 +96,7 @@ def get_type(cls):
private_ipv4 = nixops.util.attr_property("privateIpv4", None)
public_dns_name = nixops.util.attr_property("publicDnsName", None)
use_private_ip_address = nixops.util.attr_property("ec2.usePrivateIpAddress", False, type=bool)
source_dest_check = nixops.util.attr_property("ec2.sourceDestCheck", True, type=bool)
associate_public_ip_address = nixops.util.attr_property("ec2.associatePublicIpAddress", False, type=bool)
elastic_ipv4 = nixops.util.attr_property("ec2.elasticIpv4", None)
access_key_id = nixops.util.attr_property("ec2.accessKeyId", None)
@@ -138,6 +140,7 @@ def _reset_state(self):
self.state = MachineState.MISSING
self.associate_public_ip_address = None
self.use_private_ip_address = None
self.source_dest_check = None
self.vm_id = None
self.public_ipv4 = None
self.private_ipv4 = None
@@ -1078,6 +1081,10 @@ def create(self, defn, check, allow_reboot, allow_recreate):
common_tags['Owners'] = ", ".join(defn.owners)
self.update_tags(self.vm_id, user_tags=common_tags, check=check)

# Reapply sourceDestCheck if it has changed.
if self.source_dest_check != defn.source_dest_check:
instance.modify_attribute("sourceDestCheck", defn.source_dest_check)

# Assign the elastic IP. If necessary, dereference the resource.
elastic_ipv4 = defn.elastic_ipv4
if elastic_ipv4.startswith("res-"):