Comments (6)
@ip1981 I started a patch for consolidating security groups for both vpc and ec2-classic a while back. We did some groundwork for this in 1.3 release. Let me see if I can dig up the patch, and commit it in the next week or so.
from nixops-aws.
that would be great!
from nixops-aws.
I'm facing this issue as well (and #78) :) Have there been any changes related to this?
from nixops-aws.
is there a workaround to this? or #78?
from nixops-aws.
Is it fixed? NixOS/nixops@1a71a2e
from nixops-aws.
@ip1981 thanks for linking that, works for me!
let
region = "us-west-2";
accessKeyId = "myid"; # symbolic name looked up in ~/.ec2-keys or a ~/.aws/credentials profile name
# We must declare an AWS Subnet for each Availability Zone
# because Subnets cannot span AZs.
subnets = [
{ name = "nixops-vpc-subnet-a"; cidr = "10.0.0.0/19"; zone = "${region}a"; }
{ name = "nixops-vpc-subnet-b"; cidr = "10.0.32.0/19"; zone = "${region}b"; }
{ name = "nixops-vpc-subnet-c"; cidr = "10.0.64.0/19"; zone = "${region}c"; }
{ name = "nixops-vpc-subnet-d"; cidr = "10.0.96.0/19"; zone = "${region}d"; }
];
domain = "example.com";
ec2 = { resources, ... }: {
deployment.targetEnv = "ec2";
deployment.ec2.accessKeyId = accessKeyId;
deployment.ec2.region = region;
deployment.ec2.subnetId = resources.vpcSubnets.nixops-vpc-subnet-c;
deployment.ec2.instanceType = "t2.micro";
deployment.ec2.keyPair = resources.ec2KeyPairs.my-key-pair;
deployment.ec2.associatePublicIpAddress = true;
deployment.ec2.ebsBoot = true;
deployment.ec2.ebsInitialRootDiskSize = 20;
/* deployment.ec2.securityGroupIds = [
resources.ec2SecurityGroups.allow-ssh.name
resources.ec2SecurityGroups.allow-http.name
]; */
deployment.ec2.securityGroupIds = [ "allow-ssh" "allow-http" ];
/* deployment.route53.hostName = domain; */
};
lib = (import <nixpkgs> {}).lib;
in
{
mlflow-server = ec2;
resources = {
# Provision an EC2 key pair.
ec2KeyPairs.my-key-pair =
{ inherit region accessKeyId; };
# create security groups
ec2SecurityGroups.allow-ssh = { resources, ... }: {
inherit region accessKeyId;
name = "allow-ssh";
description = "allow-ssh";
vpcId = resources.vpc.nixops-vpc;
rules = [
{ fromPort = 22; toPort = 22; sourceIp = "0.0.0.0/0"; }
];
};
ec2SecurityGroups.allow-http = { resources, ... }: {
inherit region accessKeyId;
name = "allow-http";
description = "allow-http";
vpcId = resources.vpc.nixops-vpc;
rules = [
{ fromPort = 80; toPort = 80; sourceIp = "0.0.0.0/0"; }
{ fromPort = 443; toPort = 443; sourceIp = "0.0.0.0/0"; }
];
};
# configure VPC
vpc.nixops-vpc = {
inherit region accessKeyId;
instanceTenancy = "default";
enableDnsSupport = true;
enableDnsHostnames = true;
cidrBlock = "10.0.0.0/16";
tags.Source = "NixOps";
};
vpcSubnets =
let
makeSubnet = {cidr, zone}:
{ resources, ... }: {
inherit region zone accessKeyId;
vpcId = resources.vpc.nixops-vpc;
cidrBlock = cidr;
mapPublicIpOnLaunch = true;
tags.Source = "NixOps";
};
in
builtins.listToAttrs
(map
({ name, cidr, zone }: lib.nameValuePair name (makeSubnet { inherit cidr zone; }) )
subnets
);
vpcRouteTables = {
route-table = { resources, ... }: {
inherit accessKeyId region;
vpcId = resources.vpc.nixops-vpc;
};
};
vpcRoutes = {
igw-route = { resources, ... }: {
inherit region accessKeyId;
routeTableId = resources.vpcRouteTables.route-table;
destinationCidrBlock = "0.0.0.0/0";
gatewayId = resources.vpcInternetGateways.nixops-igw;
};
};
vpcRouteTableAssociations =
let
association = subnetName: { resources, ... }: {
inherit accessKeyId region;
subnetId = resources.vpcSubnets."${subnetName}";
routeTableId = resources.vpcRouteTables.route-table;
};
in
builtins.listToAttrs
(map
({ name, ... }: lib.nameValuePair "association-${name}" (association name) )
subnets
);
vpcInternetGateways.nixops-igw = { resources, ... }: {
inherit accessKeyId region;
vpcId = resources.vpc.nixops-vpc;
};
elasticIPs.eip = {
inherit region accessKeyId;
vpc = true;
};
/* resources.vpcNatGateways.nat = { resources, ... }: {
inherit region accessKeyId;
allocationId = elasticIPs.eip;
subnetId = vpcSubnets.nixops-vpc-subnet-f;
}; */
};
}
from nixops-aws.
Related Issues (20)
- Port to python3
- Failure to provision hosts on spot market HOT 1
- Root volume is considered as 'detached' using nixpkgs 20.03 HOT 6
- Record on route53 is not being created. HOT 17
- Route53RecordSet pointing at an elasticIP address fails to be created
- AWS c6g.large instance type is not supported
- Where are the docs? HOT 2
- [feature] Manage RDS passwords
- Add support for gp3 disk type HOT 2
- Stop/Start an RDS DB instance HOT 2
- invalid EC2 region ‘eu-south-1’ HOT 1
- Retirement of EC2-Classic
- [flakes] NIX_PATH impurity HOT 1
- Automatically generate python types HOT 1
- aarch64 instance support
- gatewayId can be null which fails in python
- Initial nix-build fails to build
- `KeyError: 'Ebs'` when deploying EC2 instance with `ebsBoot` HOT 1
- How do you use the s3 remote backend? HOT 7
- Status of the repository? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nixops-aws.