Guest User

Untitled

a guest
Oct 21st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. let
  2. region = "us-east-1";
  3. zone = "us-east-1a";
  4. accessKeyId = "default";
  5. in {
  6. resources.ebsVolumes.cntr-disk = {
  7. accessKeyId = accessKeyId;
  8. tags.Name = "cntr-disk";
  9. inherit region;
  10. zone = zone;
  11. size = 100;
  12. volumeType = "gp2";
  13. };
  14.  
  15. cntr-machine = { resources, config, lib, ... }: {
  16. deployment.targetEnv = "ec2";
  17. deployment.ec2.accessKeyId = accessKeyId;
  18. deployment.ec2.region = region;
  19. deployment.ec2.zone = zone;
  20. deployment.ec2.instanceType = "m4.xlarge";
  21. deployment.ec2.associatePublicIpAddress = true;
  22. deployment.ec2.keyPair = resources.ec2KeyPairs.cntr-key-pair;
  23. deployment.ec2.elasticIPv4 = resources.elasticIPs.cntr-ip;
  24. deployment.ec2.ebsInitialRootDiskSize = 30;
  25. deployment.ec2.subnetId = resources.vpcSubnets.cntr-subnet;
  26. deployment.ec2.securityGroupIds = [ resources.ec2SecurityGroups.cntr-security-group.name ];
  27.  
  28.  
  29. fileSystems."/scratch" = {
  30. autoFormat = true;
  31. fsType = "ext4";
  32. device = "/dev/xvdj";
  33. ec2.disk = resources.ebsVolumes.cntr-disk;
  34. };
  35. };
  36.  
  37. resources.ec2KeyPairs.cntr-key-pair = { inherit region accessKeyId; };
  38.  
  39. resources.ec2SecurityGroups.cntr-security-group = { resources, ... }: {
  40. inherit region accessKeyId;
  41. vpcId = resources.vpc.cntr-vpc;
  42. rules = [{ protocol = "-1"; fromPort = 0; toPort = 65535; sourceIp = "0.0.0.0/0"; }];
  43. };
  44.  
  45. resources.vpc.cntr-vpc = {
  46. inherit region accessKeyId;
  47. instanceTenancy = "default";
  48. enableDnsSupport = true;
  49. enableDnsHostnames = true;
  50. cidrBlock = "192.168.56.0/24";
  51. };
  52.  
  53. resources.vpcSubnets.cntr-subnet = { resources, ... }: {
  54. inherit region zone accessKeyId;
  55. vpcId = resources.vpc.cntr-vpc;
  56. cidrBlock = "192.168.56.0/25";
  57. mapPublicIpOnLaunch = true;
  58. tags.Source = "NixOps";
  59. };
  60.  
  61. resources.elasticIPs.cntr-ip = {
  62. inherit region accessKeyId;
  63. vpc = true;
  64. };
  65.  
  66. resources.vpcInternetGateways.cntr-igw = { resources, ... }: {
  67. inherit region accessKeyId;
  68. vpcId = resources.vpc.cntr-vpc;
  69. };
  70.  
  71. resources.vpcRouteTables.cntr-route-table = { resources, ... }: {
  72. inherit region accessKeyId;
  73. vpcId = resources.vpc.cntr-vpc;
  74. };
  75.  
  76. resources.vpcRouteTableAssociations.cntr-association = { resources, ... }: {
  77. inherit region accessKeyId;
  78. subnetId = resources.vpcSubnets.cntr-subnet;
  79. routeTableId = resources.vpcRouteTables.cntr-route-table;
  80. };
  81.  
  82. resources.vpcRoutes.cntr-igw-route = { resources, ... }: {
  83. inherit region accessKeyId;
  84. routeTableId = resources.vpcRouteTables.cntr-route-table;
  85. destinationCidrBlock = "0.0.0.0/0";
  86. gatewayId = resources.vpcInternetGateways.cntr-igw;
  87. };
  88. }
Add Comment
Please, Sign In to add comment