forked from Fediversity/Fediversity
un-track .terraform
This commit is contained in:
parent
1da2e9e497
commit
ce0e8e39f2
75 changed files with 0 additions and 4347 deletions
|
@ -1 +0,0 @@
|
|||
/nix/store/8mh14khb56hqyslxhla0nzdzi2wp6wp7-source
|
|
@ -1 +0,0 @@
|
|||
{"Modules":[{"Key":"","Source":"","Dir":"."},{"Key":"mastodon","Source":"./vm","Dir":"vm"},{"Key":"mastodon.deploy","Source":"file:///nix/store/8mh14khb56hqyslxhla0nzdzi2wp6wp7-source//deploy_nixos","Dir":".terraform/modules/mastodon.deploy/deploy_nixos"},{"Key":"peertube","Source":"./vm","Dir":"vm"},{"Key":"peertube.deploy","Source":"file:///nix/store/8mh14khb56hqyslxhla0nzdzi2wp6wp7-source//deploy_nixos","Dir":".terraform/modules/peertube.deploy/deploy_nixos"},{"Key":"pixelfed","Source":"./vm","Dir":"vm"},{"Key":"pixelfed.deploy","Source":"file:///nix/store/8mh14khb56hqyslxhla0nzdzi2wp6wp7-source//deploy_nixos","Dir":".terraform/modules/pixelfed.deploy/deploy_nixos"}]}
|
|
@ -1,201 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -1,113 +0,0 @@
|
|||
# terraform-nixos
|
||||
|
||||
[](https://builtwithnix.org)
|
||||
|
||||
This repository contains a set of Terraform Modules designed to deploy NixOS
|
||||
machines. These modules are designed to work together and support different
|
||||
deployment scenarios.
|
||||
|
||||
## What is Terraform?
|
||||
|
||||
[Terraform][terraform] is a tool that allows to declare infrastructures as
|
||||
code.
|
||||
|
||||
## What is Nix, nixpkgs and NixOS?
|
||||
|
||||
[Nix][nix] is a build system and package manager that allows to manage whole
|
||||
system configurations as code. nixpkgs is a set of 20k+ packages built with
|
||||
Nix. NixOS is a Linux distribution built on top of nixpkgs.
|
||||
|
||||
## What is a Terraform Module?
|
||||
|
||||
A Terraform Module refers to a self-contained package of Terraform
|
||||
configurations that are managed as a group. This repo contains a collection of
|
||||
Terraform Modules which can be composed together to create useful
|
||||
infrastructure patterns.
|
||||
|
||||
## Terraform + Nix vs NixOps
|
||||
|
||||
NixOps is a great tool for personal deployments. It handles a lot of things
|
||||
like cloud resource creation, machine NixOS bootstrapping and deployment.
|
||||
|
||||
The difficulty is when the cloud resources are not supported by NixOps. It
|
||||
takes a lot of work to map all the cloud APIs. Compared to NixOps, Terraform
|
||||
has become an industry standard and has thousands of people contributing new
|
||||
cloud API mapping all the time.
|
||||
|
||||
Another issue is when sharing the configuration as code with multiple
|
||||
developers. Both NixOps and Terraform maintain a state file of "known applied"
|
||||
configuration. Unlike NixOps, Terraform provides facilities to sync and lock
|
||||
the state file so it's available by other users.
|
||||
|
||||
The approach here is to use Terraform to create all the cloud resources. By
|
||||
using the `google_image_nixos_custom` module it's possible to pre-build images in
|
||||
auto-scaling scenarios. Or use a push model similar to NixOps with the generic
|
||||
`deploy_nixos` module.
|
||||
|
||||
So overall Terraform + Nix is more flexible and scales better. But it's also
|
||||
more cumbersome to use as it requires to learn two languages instead of one
|
||||
and the integration between both is also a bit clunky.
|
||||
|
||||
## Terraform Modules
|
||||
|
||||
The list of modules provided by this project:
|
||||
|
||||
* [deploy_nixos](deploy_nixos#readme) - deploy NixOS onto running NixOS
|
||||
machines
|
||||
* [google_image_nixos](google_image_nixos#readme) - setup an official GCE
|
||||
image into a Google Cloud Project.
|
||||
* [google_image_nixos_custom](google_image_nixos_custom#readme) - build and
|
||||
deploy a custom GCE image into a Google Cloud Project
|
||||
|
||||
## Using these modules from your terraform configuration
|
||||
|
||||
Terraform supports importing [modules](https://www.terraform.io/docs/configuration/modules.html) directly [from a GitHub repository](https://www.terraform.io/docs/modules/sources.html#github).
|
||||
|
||||
For example, to use the [`deploy_nixos`](deploy_nixos#readme) module:
|
||||
|
||||
```
|
||||
module "deploy_nixos" {
|
||||
source = "github.com/tweag/terraform-nixos//deploy_nixos?ref=ced68729b6a0382dda02401c8f663c9b29c29368"
|
||||
|
||||
… module-specific fields …
|
||||
}
|
||||
```
|
||||
|
||||
Beware the double `//`, which separates the github repository url from the
|
||||
subdirectory that contains the module. `?ref=` specifies a specific git ref
|
||||
of the repository, in this case the commit `ced687…`.
|
||||
|
||||
## Examples
|
||||
|
||||
To better understand how these modules can be used together, look into the
|
||||
[./examples](examples) folder.
|
||||
|
||||
## Related projects
|
||||
|
||||
* [terraform-provider-nix](https://github.com/andrewchambers/terraform-provider-nix)
|
||||
|
||||
## Future
|
||||
|
||||
* Support other cloud providers.
|
||||
* Support nixos-infect bootstrapping method.
|
||||
|
||||
Contributions are welcome!
|
||||
|
||||
## Thanks
|
||||
|
||||
Thanks to [Digital Asset][digital-asset] for generously sponsoring this work!
|
||||
|
||||
Thanks to [Tweag][tweag] for enabling this work and the continuous support!
|
||||
|
||||
## License
|
||||
|
||||
This code is released under the Apache 2.0 License. Please see
|
||||
[LICENSE](LICENSE) for more details.
|
||||
|
||||
Copyright © 2018 Tweag I/O.
|
||||
|
||||
|
||||
[digital-asset]: https://www.digitalasset.com/
|
||||
[nix]: https://nixos.org/nix/
|
||||
[terraform]: https://www.terraform.io
|
||||
[tweag]: https://www.tweag.io/
|
|
@ -1,46 +0,0 @@
|
|||
# AWS Collection of NixOS AMIs
|
||||
|
||||
This terraform module provides links to official NixOS AMIs on AWS. The AMIs are
|
||||
released by the NixOS project.
|
||||
|
||||
Since image names are unique, only one instance per version of the module is
|
||||
supported.
|
||||
|
||||
## Example
|
||||
|
||||
provider "aws" {
|
||||
region = "eu-west-1"
|
||||
}
|
||||
|
||||
module "nixos_image_1903" {
|
||||
source = "path/to/aws_image_nixos"
|
||||
release = "19.03"
|
||||
}
|
||||
|
||||
resource "aws_instance" "example" {
|
||||
ami = module.nixos_image_1903.ami
|
||||
instance_type = "t2.micro"
|
||||
|
||||
...
|
||||
}
|
||||
|
||||
## New NixOS releases
|
||||
|
||||
Run the `./update-url-map` script to fetch new image releases.
|
||||
|
||||
<!-- terraform-docs-start -->
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|:----:|:-----:|:-----:|
|
||||
| region | The region to use. If not provided, current provider's region will be used. | string | `` | no |
|
||||
| release | The NixOS version to use. For example, 18.09 | string | `latest` | no |
|
||||
| type | The type of the AMI to use -- hvm-ebs, pv-ebs, or pv-s3. | string | `hvm-ebs` | no |
|
||||
| url\_map | A map of release series to actual releases | map | `<map>` | no |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| ami | NixOS AMI on AWS |
|
||||
<!-- terraform-docs-end -->
|
|
@ -1,34 +0,0 @@
|
|||
variable "release" {
|
||||
type = string
|
||||
default = "latest"
|
||||
description = "The NixOS version to use. For example, 18.09"
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "The region to use. If not provided, current provider's region will be used."
|
||||
}
|
||||
|
||||
variable "type" {
|
||||
type = string
|
||||
default = "hvm-ebs"
|
||||
description = "The type of the AMI to use -- hvm-ebs, pv-ebs, or pv-s3."
|
||||
}
|
||||
|
||||
# ---
|
||||
|
||||
data "aws_region" "current" {}
|
||||
|
||||
locals {
|
||||
key = "${var.release}.${coalesce(var.region, data.aws_region.current.name)}.${var.type}"
|
||||
ami = var.url_map[local.key]
|
||||
}
|
||||
|
||||
# ---
|
||||
|
||||
output "ami" {
|
||||
description = "NixOS AMI on AWS"
|
||||
value = local.ami
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -p python3 -i python
|
||||
# vim: ft=python
|
||||
#
|
||||
# Run this script to update the list of EC2 images
|
||||
#
|
||||
import json
|
||||
import io
|
||||
from subprocess import check_output
|
||||
from textwrap import dedent
|
||||
from os import putenv
|
||||
|
||||
putenv('NIX_PATH', 'nixpkgs=channel:nixpkgs-unstable')
|
||||
|
||||
def render_tf():
|
||||
nix_eval = check_output(['nix-instantiate', '--json', '--strict', '--eval', './url_map.nix'])
|
||||
url_map = json.loads(nix_eval)
|
||||
|
||||
out = io.StringIO()
|
||||
out.write(dedent("""\
|
||||
# DON'T EDIT, run '%s' instead
|
||||
variable "url_map" {
|
||||
type = map(string)
|
||||
|
||||
default = {
|
||||
""" % __file__))
|
||||
|
||||
for version, regions in url_map.items():
|
||||
for region, kinds in regions.items():
|
||||
for kind, ami in kinds.items():
|
||||
out.write(' "%s.%s.%s" = "%s"\n' % (version, region, kind, ami))
|
||||
|
||||
out.write(dedent("""\
|
||||
}
|
||||
|
||||
description = "A map of release series to actual releases"
|
||||
}
|
||||
"""))
|
||||
|
||||
return out.getvalue()
|
||||
|
||||
url_map_tf = render_tf()
|
||||
|
||||
with open("url_map.tf", "w") as f:
|
||||
f.write(url_map_tf)
|
||||
|
||||
print(url_map_tf)
|
||||
|
||||
# Local Variables:
|
||||
# mode: Python
|
||||
# End:
|
|
@ -1,2 +0,0 @@
|
|||
# Indirect link to where the image map is stored
|
||||
import <nixpkgs/nixos/modules/virtualisation/ec2-amis.nix>
|
|
@ -1,353 +0,0 @@
|
|||
# DON'T EDIT, run './update-url-map' instead
|
||||
variable "url_map" {
|
||||
type = map(string)
|
||||
|
||||
default = {
|
||||
"14.04.ap-northeast-1.hvm-ebs" = "ami-71c6f470"
|
||||
"14.04.ap-northeast-1.pv-ebs" = "ami-4dcbf84c"
|
||||
"14.04.ap-northeast-1.pv-s3" = "ami-8fc4f68e"
|
||||
"14.04.ap-southeast-1.hvm-ebs" = "ami-da280888"
|
||||
"14.04.ap-southeast-1.pv-ebs" = "ami-7a9dbc28"
|
||||
"14.04.ap-southeast-1.pv-s3" = "ami-c4290996"
|
||||
"14.04.ap-southeast-2.hvm-ebs" = "ami-ab523e91"
|
||||
"14.04.ap-southeast-2.pv-ebs" = "ami-6769055d"
|
||||
"14.04.ap-southeast-2.pv-s3" = "ami-15533f2f"
|
||||
"14.04.eu-central-1.hvm-ebs" = "ami-ba0234a7"
|
||||
"14.04.eu-west-1.hvm-ebs" = "ami-96cb63e1"
|
||||
"14.04.eu-west-1.pv-ebs" = "ami-b48c25c3"
|
||||
"14.04.eu-west-1.pv-s3" = "ami-06cd6571"
|
||||
"14.04.sa-east-1.hvm-ebs" = "ami-01b90e1c"
|
||||
"14.04.sa-east-1.pv-ebs" = "ami-69e35474"
|
||||
"14.04.sa-east-1.pv-s3" = "ami-61b90e7c"
|
||||
"14.04.us-east-1.hvm-ebs" = "ami-58ba3a30"
|
||||
"14.04.us-east-1.pv-ebs" = "ami-9e0583f6"
|
||||
"14.04.us-east-1.pv-s3" = "ami-9cbe3ef4"
|
||||
"14.04.us-west-1.hvm-ebs" = "ami-0bc3d74e"
|
||||
"14.04.us-west-1.pv-ebs" = "ami-8b1703ce"
|
||||
"14.04.us-west-1.pv-s3" = "ami-27ccd862"
|
||||
"14.04.us-west-2.hvm-ebs" = "ami-3bf1bf0b"
|
||||
"14.04.us-west-2.pv-ebs" = "ami-259bd515"
|
||||
"14.04.us-west-2.pv-s3" = "ami-07094037"
|
||||
"14.12.ap-northeast-1.hvm-ebs" = "ami-24435f25"
|
||||
"14.12.ap-northeast-1.pv-ebs" = "ami-b0425eb1"
|
||||
"14.12.ap-northeast-1.pv-s3" = "ami-fed3c6ff"
|
||||
"14.12.ap-southeast-1.hvm-ebs" = "ami-6c765d3e"
|
||||
"14.12.ap-southeast-1.pv-ebs" = "ami-6a765d38"
|
||||
"14.12.ap-southeast-1.pv-s3" = "ami-d1bf9183"
|
||||
"14.12.ap-southeast-2.hvm-ebs" = "ami-af86f395"
|
||||
"14.12.ap-southeast-2.pv-ebs" = "ami-b386f389"
|
||||
"14.12.ap-southeast-2.pv-s3" = "ami-69c5ae53"
|
||||
"14.12.eu-central-1.hvm-ebs" = "ami-4a497a57"
|
||||
"14.12.eu-central-1.pv-ebs" = "ami-4c497a51"
|
||||
"14.12.eu-central-1.pv-s3" = "ami-60f2c27d"
|
||||
"14.12.eu-west-1.hvm-ebs" = "ami-d126a5a6"
|
||||
"14.12.eu-west-1.pv-ebs" = "ami-0126a576"
|
||||
"14.12.eu-west-1.pv-s3" = "ami-deda5fa9"
|
||||
"14.12.sa-east-1.hvm-ebs" = "ami-2d239e30"
|
||||
"14.12.sa-east-1.pv-ebs" = "ami-35239e28"
|
||||
"14.12.sa-east-1.pv-s3" = "ami-81e3519c"
|
||||
"14.12.us-east-1.hvm-ebs" = "ami-0c463a64"
|
||||
"14.12.us-east-1.pv-ebs" = "ami-ac473bc4"
|
||||
"14.12.us-east-1.pv-s3" = "ami-00e18a68"
|
||||
"14.12.us-west-1.hvm-ebs" = "ami-ca534a8f"
|
||||
"14.12.us-west-1.pv-ebs" = "ami-3e534a7b"
|
||||
"14.12.us-west-1.pv-s3" = "ami-2905196c"
|
||||
"14.12.us-west-2.hvm-ebs" = "ami-fb9dc3cb"
|
||||
"14.12.us-west-2.pv-ebs" = "ami-899dc3b9"
|
||||
"14.12.us-west-2.pv-s3" = "ami-cb7f2dfb"
|
||||
"15.09.ap-northeast-1.hvm-ebs" = "ami-58cac236"
|
||||
"15.09.ap-northeast-1.hvm-s3" = "ami-39c8c057"
|
||||
"15.09.ap-northeast-1.pv-ebs" = "ami-5ac9c134"
|
||||
"15.09.ap-northeast-1.pv-s3" = "ami-03cec66d"
|
||||
"15.09.ap-southeast-1.hvm-ebs" = "ami-2fc2094c"
|
||||
"15.09.ap-southeast-1.hvm-s3" = "ami-9ec308fd"
|
||||
"15.09.ap-southeast-1.pv-ebs" = "ami-95c00bf6"
|
||||
"15.09.ap-southeast-1.pv-s3" = "ami-bfc00bdc"
|
||||
"15.09.ap-southeast-2.hvm-ebs" = "ami-996c4cfa"
|
||||
"15.09.ap-southeast-2.hvm-s3" = "ami-3f6e4e5c"
|
||||
"15.09.ap-southeast-2.pv-ebs" = "ami-066d4d65"
|
||||
"15.09.ap-southeast-2.pv-s3" = "ami-cc6e4eaf"
|
||||
"15.09.eu-central-1.hvm-ebs" = "ami-3f8c6b50"
|
||||
"15.09.eu-central-1.hvm-s3" = "ami-5b836434"
|
||||
"15.09.eu-central-1.pv-ebs" = "ami-118c6b7e"
|
||||
"15.09.eu-central-1.pv-s3" = "ami-2c977043"
|
||||
"15.09.eu-west-1.hvm-ebs" = "ami-9cf04aef"
|
||||
"15.09.eu-west-1.hvm-s3" = "ami-2bea5058"
|
||||
"15.09.eu-west-1.pv-ebs" = "ami-c9e852ba"
|
||||
"15.09.eu-west-1.pv-s3" = "ami-c6f64cb5"
|
||||
"15.09.sa-east-1.hvm-ebs" = "ami-6e52df02"
|
||||
"15.09.sa-east-1.hvm-s3" = "ami-1852df74"
|
||||
"15.09.sa-east-1.pv-ebs" = "ami-4368e52f"
|
||||
"15.09.sa-east-1.pv-s3" = "ami-f15ad79d"
|
||||
"15.09.us-east-1.hvm-ebs" = "ami-84a6a0ee"
|
||||
"15.09.us-east-1.hvm-s3" = "ami-06a7a16c"
|
||||
"15.09.us-east-1.pv-ebs" = "ami-a4a1a7ce"
|
||||
"15.09.us-east-1.pv-s3" = "ami-5ba8ae31"
|
||||
"15.09.us-west-1.hvm-ebs" = "ami-22c8bb42"
|
||||
"15.09.us-west-1.hvm-s3" = "ami-a2ccbfc2"
|
||||
"15.09.us-west-1.pv-ebs" = "ami-10cebd70"
|
||||
"15.09.us-west-1.pv-s3" = "ami-fa30429a"
|
||||
"15.09.us-west-2.hvm-ebs" = "ami-ce57b9ae"
|
||||
"15.09.us-west-2.hvm-s3" = "ami-2956b849"
|
||||
"15.09.us-west-2.pv-ebs" = "ami-005fb160"
|
||||
"15.09.us-west-2.pv-s3" = "ami-cd55bbad"
|
||||
"16.03.ap-northeast-1.hvm-ebs" = "ami-40619d21"
|
||||
"16.03.ap-northeast-1.hvm-s3" = "ami-ce629eaf"
|
||||
"16.03.ap-northeast-1.pv-ebs" = "ami-ef639f8e"
|
||||
"16.03.ap-northeast-1.pv-s3" = "ami-a1609cc0"
|
||||
"16.03.ap-northeast-2.hvm-ebs" = "ami-deca00b0"
|
||||
"16.03.ap-northeast-2.hvm-s3" = "ami-a3b77dcd"
|
||||
"16.03.ap-northeast-2.pv-ebs" = "ami-7bcb0115"
|
||||
"16.03.ap-northeast-2.pv-s3" = "ami-a2b77dcc"
|
||||
"16.03.ap-south-1.hvm-ebs" = "ami-0dff9562"
|
||||
"16.03.ap-south-1.hvm-s3" = "ami-13f69c7c"
|
||||
"16.03.ap-south-1.pv-ebs" = "ami-0ef39961"
|
||||
"16.03.ap-south-1.pv-s3" = "ami-e0c8a28f"
|
||||
"16.03.ap-southeast-1.hvm-ebs" = "ami-5e964a3d"
|
||||
"16.03.ap-southeast-1.hvm-s3" = "ami-4d964a2e"
|
||||
"16.03.ap-southeast-1.pv-ebs" = "ami-ec9b478f"
|
||||
"16.03.ap-southeast-1.pv-s3" = "ami-999b47fa"
|
||||
"16.03.ap-southeast-2.hvm-ebs" = "ami-9f7359fc"
|
||||
"16.03.ap-southeast-2.hvm-s3" = "ami-987359fb"
|
||||
"16.03.ap-southeast-2.pv-ebs" = "ami-a2705ac1"
|
||||
"16.03.ap-southeast-2.pv-s3" = "ami-a3705ac0"
|
||||
"16.03.eu-central-1.hvm-ebs" = "ami-17a45178"
|
||||
"16.03.eu-central-1.hvm-s3" = "ami-f9a55096"
|
||||
"16.03.eu-central-1.pv-ebs" = "ami-c8a550a7"
|
||||
"16.03.eu-central-1.pv-s3" = "ami-6ea45101"
|
||||
"16.03.eu-west-1.hvm-ebs" = "ami-b5b3d5c6"
|
||||
"16.03.eu-west-1.hvm-s3" = "ami-c986e0ba"
|
||||
"16.03.eu-west-1.pv-ebs" = "ami-b083e5c3"
|
||||
"16.03.eu-west-1.pv-s3" = "ami-3c83e54f"
|
||||
"16.03.sa-east-1.hvm-ebs" = "ami-f6eb7f9a"
|
||||
"16.03.sa-east-1.hvm-s3" = "ami-93e773ff"
|
||||
"16.03.sa-east-1.pv-ebs" = "ami-cbb82ca7"
|
||||
"16.03.sa-east-1.pv-s3" = "ami-abb82cc7"
|
||||
"16.03.us-east-1.hvm-ebs" = "ami-c123a3d6"
|
||||
"16.03.us-east-1.hvm-s3" = "ami-bc25a5ab"
|
||||
"16.03.us-east-1.pv-ebs" = "ami-bd25a5aa"
|
||||
"16.03.us-east-1.pv-s3" = "ami-a325a5b4"
|
||||
"16.03.us-west-1.hvm-ebs" = "ami-748bcd14"
|
||||
"16.03.us-west-1.hvm-s3" = "ami-a68dcbc6"
|
||||
"16.03.us-west-1.pv-ebs" = "ami-048acc64"
|
||||
"16.03.us-west-1.pv-s3" = "ami-208dcb40"
|
||||
"16.03.us-west-2.hvm-ebs" = "ami-8263a0e2"
|
||||
"16.03.us-west-2.hvm-s3" = "ami-925c9ff2"
|
||||
"16.03.us-west-2.pv-ebs" = "ami-5e61a23e"
|
||||
"16.03.us-west-2.pv-s3" = "ami-734c8f13"
|
||||
"16.09.ap-northeast-1.hvm-ebs" = "ami-68453b0f"
|
||||
"16.09.ap-northeast-1.hvm-s3" = "ami-f9bec09e"
|
||||
"16.09.ap-northeast-1.pv-ebs" = "ami-254a3442"
|
||||
"16.09.ap-northeast-1.pv-s3" = "ami-ef473988"
|
||||
"16.09.ap-northeast-2.hvm-ebs" = "ami-18ae7f76"
|
||||
"16.09.ap-northeast-2.hvm-s3" = "ami-9eac7df0"
|
||||
"16.09.ap-northeast-2.pv-ebs" = "ami-57aa7b39"
|
||||
"16.09.ap-northeast-2.pv-s3" = "ami-5cae7f32"
|
||||
"16.09.ap-south-1.hvm-ebs" = "ami-b3f98fdc"
|
||||
"16.09.ap-south-1.hvm-s3" = "ami-98e690f7"
|
||||
"16.09.ap-south-1.pv-ebs" = "ami-aef98fc1"
|
||||
"16.09.ap-south-1.pv-s3" = "ami-caf88ea5"
|
||||
"16.09.ap-southeast-1.hvm-ebs" = "ami-80fb51e3"
|
||||
"16.09.ap-southeast-1.hvm-s3" = "ami-2df3594e"
|
||||
"16.09.ap-southeast-1.pv-ebs" = "ami-37f05a54"
|
||||
"16.09.ap-southeast-1.pv-s3" = "ami-27f35944"
|
||||
"16.09.ap-southeast-2.hvm-ebs" = "ami-57ece834"
|
||||
"16.09.ap-southeast-2.hvm-s3" = "ami-87f4f0e4"
|
||||
"16.09.ap-southeast-2.pv-ebs" = "ami-d8ede9bb"
|
||||
"16.09.ap-southeast-2.pv-s3" = "ami-a6ebefc5"
|
||||
"16.09.ca-central-1.hvm-ebs" = "ami-9f863bfb"
|
||||
"16.09.ca-central-1.hvm-s3" = "ami-ea85388e"
|
||||
"16.09.ca-central-1.pv-ebs" = "ami-ce8a37aa"
|
||||
"16.09.ca-central-1.pv-s3" = "ami-448a3720"
|
||||
"16.09.eu-central-1.hvm-ebs" = "ami-1b884774"
|
||||
"16.09.eu-central-1.hvm-s3" = "ami-b08c43df"
|
||||
"16.09.eu-central-1.pv-ebs" = "ami-888946e7"
|
||||
"16.09.eu-central-1.pv-s3" = "ami-06874869"
|
||||
"16.09.eu-west-1.hvm-ebs" = "ami-1ed3e76d"
|
||||
"16.09.eu-west-1.hvm-s3" = "ami-73d1e500"
|
||||
"16.09.eu-west-1.pv-ebs" = "ami-44c0f437"
|
||||
"16.09.eu-west-1.pv-s3" = "ami-f3d8ec80"
|
||||
"16.09.eu-west-2.hvm-ebs" = "ami-2c9c9648"
|
||||
"16.09.eu-west-2.hvm-s3" = "ami-6b9e940f"
|
||||
"16.09.eu-west-2.pv-ebs" = "ami-f1999395"
|
||||
"16.09.eu-west-2.pv-s3" = "ami-bb9f95df"
|
||||
"16.09.sa-east-1.hvm-ebs" = "ami-a11882cd"
|
||||
"16.09.sa-east-1.hvm-s3" = "ami-7726bc1b"
|
||||
"16.09.sa-east-1.pv-ebs" = "ami-9725bffb"
|
||||
"16.09.sa-east-1.pv-s3" = "ami-b027bddc"
|
||||
"16.09.us-east-1.hvm-ebs" = "ami-854ca593"
|
||||
"16.09.us-east-1.hvm-s3" = "ami-2241a834"
|
||||
"16.09.us-east-1.pv-ebs" = "ami-a441a8b2"
|
||||
"16.09.us-east-1.pv-s3" = "ami-e841a8fe"
|
||||
"16.09.us-east-2.hvm-ebs" = "ami-3f41645a"
|
||||
"16.09.us-east-2.hvm-s3" = "ami-804065e5"
|
||||
"16.09.us-east-2.pv-ebs" = "ami-f1466394"
|
||||
"16.09.us-east-2.pv-s3" = "ami-05426760"
|
||||
"16.09.us-west-1.hvm-ebs" = "ami-c2efbca2"
|
||||
"16.09.us-west-1.hvm-s3" = "ami-d71042b7"
|
||||
"16.09.us-west-1.pv-ebs" = "ami-04e8bb64"
|
||||
"16.09.us-west-1.pv-s3" = "ami-31e9ba51"
|
||||
"16.09.us-west-2.hvm-ebs" = "ami-6449f504"
|
||||
"16.09.us-west-2.hvm-s3" = "ami-344af654"
|
||||
"16.09.us-west-2.pv-ebs" = "ami-6d4af60d"
|
||||
"16.09.us-west-2.pv-s3" = "ami-de48f4be"
|
||||
"17.03.ap-northeast-1.hvm-ebs" = "ami-dbd0f7bc"
|
||||
"17.03.ap-northeast-1.hvm-s3" = "ami-7cdff81b"
|
||||
"17.03.ap-northeast-2.hvm-ebs" = "ami-c59a48ab"
|
||||
"17.03.ap-northeast-2.hvm-s3" = "ami-0b944665"
|
||||
"17.03.ap-south-1.hvm-ebs" = "ami-4f413220"
|
||||
"17.03.ap-south-1.hvm-s3" = "ami-864033e9"
|
||||
"17.03.ap-southeast-1.hvm-ebs" = "ami-e08c3383"
|
||||
"17.03.ap-southeast-1.hvm-s3" = "ami-c28f30a1"
|
||||
"17.03.ap-southeast-2.hvm-ebs" = "ami-fca9a69f"
|
||||
"17.03.ap-southeast-2.hvm-s3" = "ami-3daaa55e"
|
||||
"17.03.ca-central-1.hvm-ebs" = "ami-9b00bdff"
|
||||
"17.03.ca-central-1.hvm-s3" = "ami-e800bd8c"
|
||||
"17.03.eu-central-1.hvm-ebs" = "ami-5450803b"
|
||||
"17.03.eu-central-1.hvm-s3" = "ami-6e2efe01"
|
||||
"17.03.eu-west-1.hvm-ebs" = "ami-10754c76"
|
||||
"17.03.eu-west-1.hvm-s3" = "ami-11734a77"
|
||||
"17.03.eu-west-2.hvm-ebs" = "ami-ff1d099b"
|
||||
"17.03.eu-west-2.hvm-s3" = "ami-fe1d099a"
|
||||
"17.03.sa-east-1.hvm-ebs" = "ami-d95d3eb5"
|
||||
"17.03.sa-east-1.hvm-s3" = "ami-fca2c190"
|
||||
"17.03.us-east-1.hvm-ebs" = "ami-0940c61f"
|
||||
"17.03.us-east-1.hvm-s3" = "ami-674fc971"
|
||||
"17.03.us-east-2.hvm-ebs" = "ami-afc2e6ca"
|
||||
"17.03.us-east-2.hvm-s3" = "ami-a1cde9c4"
|
||||
"17.03.us-west-1.hvm-ebs" = "ami-587b2138"
|
||||
"17.03.us-west-1.hvm-s3" = "ami-70411b10"
|
||||
"17.03.us-west-2.hvm-ebs" = "ami-a93daac9"
|
||||
"17.03.us-west-2.hvm-s3" = "ami-5139ae31"
|
||||
"17.09.ap-northeast-1.hvm-ebs" = "ami-89b921ef"
|
||||
"17.09.ap-northeast-2.hvm-ebs" = "ami-179b3b79"
|
||||
"17.09.ap-south-1.hvm-ebs" = "ami-4e376021"
|
||||
"17.09.ap-southeast-1.hvm-ebs" = "ami-84bccff8"
|
||||
"17.09.ap-southeast-2.hvm-ebs" = "ami-0dc5386f"
|
||||
"17.09.ca-central-1.hvm-ebs" = "ami-ca8207ae"
|
||||
"17.09.eu-central-1.hvm-ebs" = "ami-266cfe49"
|
||||
"17.09.eu-west-1.hvm-ebs" = "ami-a30192da"
|
||||
"17.09.eu-west-2.hvm-ebs" = "ami-295a414d"
|
||||
"17.09.eu-west-3.hvm-ebs" = "ami-8c0eb9f1"
|
||||
"17.09.sa-east-1.hvm-ebs" = "ami-4762202b"
|
||||
"17.09.us-east-1.hvm-ebs" = "ami-40bee63a"
|
||||
"17.09.us-east-2.hvm-ebs" = "ami-9d84aff8"
|
||||
"17.09.us-west-1.hvm-ebs" = "ami-d14142b1"
|
||||
"17.09.us-west-2.hvm-ebs" = "ami-3eb40346"
|
||||
"18.03.ap-northeast-1.hvm-ebs" = "ami-456511a8"
|
||||
"18.03.ap-northeast-2.hvm-ebs" = "ami-3366d15d"
|
||||
"18.03.ap-south-1.hvm-ebs" = "ami-6a390b05"
|
||||
"18.03.ap-southeast-1.hvm-ebs" = "ami-aa0b4d40"
|
||||
"18.03.ap-southeast-2.hvm-ebs" = "ami-d0f254b2"
|
||||
"18.03.ca-central-1.hvm-ebs" = "ami-aca72ac8"
|
||||
"18.03.eu-central-1.hvm-ebs" = "ami-09faf9e2"
|
||||
"18.03.eu-west-1.hvm-ebs" = "ami-065c46ec"
|
||||
"18.03.eu-west-2.hvm-ebs" = "ami-64f31903"
|
||||
"18.03.eu-west-3.hvm-ebs" = "ami-5a8d3d27"
|
||||
"18.03.sa-east-1.hvm-ebs" = "ami-163e1f7a"
|
||||
"18.03.us-east-1.hvm-ebs" = "ami-8b3538f4"
|
||||
"18.03.us-east-2.hvm-ebs" = "ami-150b3170"
|
||||
"18.03.us-west-1.hvm-ebs" = "ami-ce06ebad"
|
||||
"18.03.us-west-2.hvm-ebs" = "ami-586c3520"
|
||||
"18.09.ap-northeast-1.hvm-ebs" = "ami-0cdba8e998f076547"
|
||||
"18.09.ap-northeast-2.hvm-ebs" = "ami-0400a698e6a9f4a15"
|
||||
"18.09.ap-south-1.hvm-ebs" = "ami-0880a678d3f555313"
|
||||
"18.09.ap-southeast-1.hvm-ebs" = "ami-0892c7e24ebf2194f"
|
||||
"18.09.ap-southeast-2.hvm-ebs" = "ami-010730f36424b0a2c"
|
||||
"18.09.ca-central-1.hvm-ebs" = "ami-04f66113f76198f6c"
|
||||
"18.09.eu-central-1.hvm-ebs" = "ami-07c9b884e679df4f8"
|
||||
"18.09.eu-west-1.hvm-ebs" = "ami-0f412186fb8a0ec97"
|
||||
"18.09.eu-west-2.hvm-ebs" = "ami-0dada3805ce43c55e"
|
||||
"18.09.eu-west-3.hvm-ebs" = "ami-074df85565f2e02e2"
|
||||
"18.09.sa-east-1.hvm-ebs" = "ami-0e4a8a47fd6db6112"
|
||||
"18.09.us-east-1.hvm-ebs" = "ami-009c9c3f1af480ff3"
|
||||
"18.09.us-east-2.hvm-ebs" = "ami-08199961085ea8bc6"
|
||||
"18.09.us-west-1.hvm-ebs" = "ami-07aa7f56d612ddd38"
|
||||
"18.09.us-west-2.hvm-ebs" = "ami-01c84b7c368ac24d1"
|
||||
"19.03.ap-northeast-1.hvm-ebs" = "ami-00db62688900456a4"
|
||||
"19.03.ap-northeast-2.hvm-ebs" = "ami-0485cdd1a5fdd2117"
|
||||
"19.03.ap-south-1.hvm-ebs" = "ami-0303deb1b5890f878"
|
||||
"19.03.ap-southeast-1.hvm-ebs" = "ami-0cff66114c652c262"
|
||||
"19.03.ap-southeast-2.hvm-ebs" = "ami-054c73a7f8d773ea9"
|
||||
"19.03.ca-central-1.hvm-ebs" = "ami-03f9fd0ef2e035ede"
|
||||
"19.03.eu-central-1.hvm-ebs" = "ami-0022b8ea9efde5de4"
|
||||
"19.03.eu-west-1.hvm-ebs" = "ami-0fe40176548ff0940"
|
||||
"19.03.eu-west-2.hvm-ebs" = "ami-03a40fd3a02fe95ba"
|
||||
"19.03.eu-west-3.hvm-ebs" = "ami-0436f9da0f20a638e"
|
||||
"19.03.sa-east-1.hvm-ebs" = "ami-0c6a43c6e0ad1f4e2"
|
||||
"19.03.us-east-1.hvm-ebs" = "ami-0efc58fb70ae9a217"
|
||||
"19.03.us-east-2.hvm-ebs" = "ami-0abf711b1b34da1af"
|
||||
"19.03.us-west-1.hvm-ebs" = "ami-07d126e8838c40ec5"
|
||||
"19.03.us-west-2.hvm-ebs" = "ami-03f8a737546e47fb0"
|
||||
"19.09.ap-east-1.hvm-ebs" = "ami-055b2348db2827ff1"
|
||||
"19.09.ap-northeast-1.hvm-ebs" = "ami-02a62555ca182fb5b"
|
||||
"19.09.ap-northeast-2.hvm-ebs" = "ami-0219dde0e6b7b7b93"
|
||||
"19.09.ap-south-1.hvm-ebs" = "ami-066f7f2a895c821a1"
|
||||
"19.09.ap-southeast-1.hvm-ebs" = "ami-0f71ae5d4b0b78d95"
|
||||
"19.09.ap-southeast-2.hvm-ebs" = "ami-057bbf2b4bd62d210"
|
||||
"19.09.ca-central-1.hvm-ebs" = "ami-07df50fc76702a36d"
|
||||
"19.09.eu-central-1.hvm-ebs" = "ami-015f8efc2be419b79"
|
||||
"19.09.eu-north-1.hvm-ebs" = "ami-07fc0a32d885e01ed"
|
||||
"19.09.eu-west-1.hvm-ebs" = "ami-071082f0fa035374f"
|
||||
"19.09.eu-west-2.hvm-ebs" = "ami-0d9dc33c54d1dc4c3"
|
||||
"19.09.eu-west-3.hvm-ebs" = "ami-09566799591d1bfed"
|
||||
"19.09.sa-east-1.hvm-ebs" = "ami-018aab68377227e06"
|
||||
"19.09.us-east-1.hvm-ebs" = "ami-03330d8b51287412f"
|
||||
"19.09.us-east-2.hvm-ebs" = "ami-0518b4c84972e967f"
|
||||
"19.09.us-west-1.hvm-ebs" = "ami-06ad07e61a353b4a6"
|
||||
"19.09.us-west-2.hvm-ebs" = "ami-0e31e30925cf3ce4e"
|
||||
"20.03.ap-east-1.hvm-ebs" = "ami-0d18fdd309cdefa86"
|
||||
"20.03.ap-northeast-1.hvm-ebs" = "ami-093d9cc49c191eb6c"
|
||||
"20.03.ap-northeast-2.hvm-ebs" = "ami-0087df91a7b6ebd45"
|
||||
"20.03.ap-south-1.hvm-ebs" = "ami-0a1a6b569af04af9d"
|
||||
"20.03.ap-southeast-1.hvm-ebs" = "ami-0dbf353e168d155f7"
|
||||
"20.03.ap-southeast-2.hvm-ebs" = "ami-04c0f3a75f63daddd"
|
||||
"20.03.ca-central-1.hvm-ebs" = "ami-02365684a173255c7"
|
||||
"20.03.eu-central-1.hvm-ebs" = "ami-0a1a94722dcbff94c"
|
||||
"20.03.eu-north-1.hvm-ebs" = "ami-02699abfacbb6464b"
|
||||
"20.03.eu-west-1.hvm-ebs" = "ami-02c34db5766cc7013"
|
||||
"20.03.eu-west-2.hvm-ebs" = "ami-0e32bd8c7853883f1"
|
||||
"20.03.eu-west-3.hvm-ebs" = "ami-061edb1356c1d69fd"
|
||||
"20.03.sa-east-1.hvm-ebs" = "ami-09859378158ae971d"
|
||||
"20.03.us-east-1.hvm-ebs" = "ami-0c5e7760748b74e85"
|
||||
"20.03.us-east-2.hvm-ebs" = "ami-030296bb256764655"
|
||||
"20.03.us-west-1.hvm-ebs" = "ami-050be818e0266b741"
|
||||
"20.03.us-west-2.hvm-ebs" = "ami-06562f78dca68eda2"
|
||||
"20.09.ap-east-1.hvm-ebs" = "ami-071f49713f86ea965"
|
||||
"20.09.ap-northeast-1.hvm-ebs" = "ami-0beb18d632cf64e5a"
|
||||
"20.09.ap-northeast-2.hvm-ebs" = "ami-0dd0316af578862db"
|
||||
"20.09.ap-south-1.hvm-ebs" = "ami-008d15ced81c88aed"
|
||||
"20.09.ap-southeast-1.hvm-ebs" = "ami-0db0304e23c535b2a"
|
||||
"20.09.ap-southeast-2.hvm-ebs" = "ami-045983c4db7e36447"
|
||||
"20.09.ca-central-1.hvm-ebs" = "ami-06d5ee429f153f856"
|
||||
"20.09.eu-central-1.hvm-ebs" = "ami-01d4a0c2248cbfe38"
|
||||
"20.09.eu-north-1.hvm-ebs" = "ami-0003f54dd99d68e0f"
|
||||
"20.09.eu-west-1.hvm-ebs" = "ami-01a79d5ce435f4db3"
|
||||
"20.09.eu-west-2.hvm-ebs" = "ami-0cbe14f32904e6331"
|
||||
"20.09.eu-west-3.hvm-ebs" = "ami-07f493412d6213de6"
|
||||
"20.09.sa-east-1.hvm-ebs" = "ami-05ded1ae35209b5a8"
|
||||
"20.09.us-east-1.hvm-ebs" = "ami-068a62d478710462d"
|
||||
"20.09.us-east-2.hvm-ebs" = "ami-01ac677ff61399caa"
|
||||
"20.09.us-west-1.hvm-ebs" = "ami-04befdb203b4b17f6"
|
||||
"20.09.us-west-2.hvm-ebs" = "ami-0fb7bd4a43261c6b2"
|
||||
"latest.ap-east-1.hvm-ebs" = "ami-071f49713f86ea965"
|
||||
"latest.ap-northeast-1.hvm-ebs" = "ami-0beb18d632cf64e5a"
|
||||
"latest.ap-northeast-2.hvm-ebs" = "ami-0dd0316af578862db"
|
||||
"latest.ap-south-1.hvm-ebs" = "ami-008d15ced81c88aed"
|
||||
"latest.ap-southeast-1.hvm-ebs" = "ami-0db0304e23c535b2a"
|
||||
"latest.ap-southeast-2.hvm-ebs" = "ami-045983c4db7e36447"
|
||||
"latest.ca-central-1.hvm-ebs" = "ami-06d5ee429f153f856"
|
||||
"latest.eu-central-1.hvm-ebs" = "ami-01d4a0c2248cbfe38"
|
||||
"latest.eu-north-1.hvm-ebs" = "ami-0003f54dd99d68e0f"
|
||||
"latest.eu-west-1.hvm-ebs" = "ami-01a79d5ce435f4db3"
|
||||
"latest.eu-west-2.hvm-ebs" = "ami-0cbe14f32904e6331"
|
||||
"latest.eu-west-3.hvm-ebs" = "ami-07f493412d6213de6"
|
||||
"latest.sa-east-1.hvm-ebs" = "ami-05ded1ae35209b5a8"
|
||||
"latest.us-east-1.hvm-ebs" = "ami-068a62d478710462d"
|
||||
"latest.us-east-2.hvm-ebs" = "ami-01ac677ff61399caa"
|
||||
"latest.us-west-1.hvm-ebs" = "ami-04befdb203b4b17f6"
|
||||
"latest.us-west-2.hvm-ebs" = "ami-0fb7bd4a43261c6b2"
|
||||
}
|
||||
|
||||
description = "A map of release series to actual releases"
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
terraform {
|
||||
required_version = ">= 0.12"
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
# deploy_nixos
|
||||
|
||||
A Terraform module that knows how to deploy NixOS onto a target host.
|
||||
|
||||
This allow to describe an infrastructure as code with Terraform and delegate
|
||||
the machine configuration with NixOS. All directed by Terraform.
|
||||
|
||||
The advantage of this method is that if any of the Nix code changes, the
|
||||
difference will be detected on the next "terraform plan".
|
||||
|
||||
## Usage
|
||||
|
||||
Either pass a "config" which is a dynamic nixos configuration and a
|
||||
"config_pwd", or a "nixos_config", a path to a nixos configuration.nix file.
|
||||
If you have defined your NixOs configuration in a Flake, use "nixos_config"
|
||||
to specify the name of the attribue and set "flake" to true.
|
||||
|
||||
### Secret handling
|
||||
|
||||
Keys can be passed to the "keys" attribute. Each key will be installed under
|
||||
`/var/keys/${key}` with the content as the value.
|
||||
|
||||
For services to access one of the keys, add the service user to the "keys"
|
||||
group.
|
||||
|
||||
The target machine needs `jq` installed prior to the deployment (as part of
|
||||
the base image). If `jq` is not found it will try to use a version from
|
||||
`<nixpkgs>`.
|
||||
|
||||
### Disabling sandboxing
|
||||
|
||||
Unfortunately some time it's required to disable the nix sandboxing. To do so,
|
||||
add `["--option", "sandbox", "false"]` to the "extra_build_args" parameter.
|
||||
|
||||
If that doesn't work, make sure that your user is part of the nix
|
||||
"trusted-users" list.
|
||||
|
||||
### Non-root `target_user`
|
||||
|
||||
It is possible to connect to the target host using a user that is not `root`
|
||||
under certain conditions:
|
||||
|
||||
* sudo needs to be installed on the machine
|
||||
* the user needs password-less sudo access on the machine
|
||||
|
||||
This would typically be provisioned in the base image.
|
||||
|
||||
### Binary cache configuration
|
||||
|
||||
One thing that might be surprising is that the binary caches (aka
|
||||
substituters) are taken from the machine configuration. This implies that the
|
||||
user Nix configuration will be ignored in that regard.
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `bash` 4.0+
|
||||
* `nix`
|
||||
* `openssh`
|
||||
* `readlink` with `-f` (coreutils or busybox)
|
||||
|
||||
## Known limitations
|
||||
|
||||
The deployment machine requires Nix with access to a remote builder with the
|
||||
same system as the target machine.
|
||||
|
||||
Because Nix code is being evaluated at "terraform plan" time, deploying a lot
|
||||
of machine in the same target will require a lot of RAM.
|
||||
|
||||
All the secrets share the same "keys" group.
|
||||
|
||||
When deploying as non-root, it assumes that passwordless `sudo` is available.
|
||||
|
||||
The target host must already have NixOS installed.
|
||||
|
||||
### config including computed values
|
||||
|
||||
The module doesn't work when `<computed>` values from other resources are
|
||||
interpolated with the "config" attribute. Because it happens at evaluation
|
||||
time, terraform will render an empty drvPath.
|
||||
|
||||
see also:
|
||||
* https://github.com/hashicorp/terraform/issues/16380
|
||||
* https://github.com/hashicorp/terraform/issues/16762
|
||||
* https://github.com/hashicorp/terraform/issues/17034
|
||||
|
||||
<!-- terraform-docs-start -->
|
||||
## Requirements
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| terraform | >= 0.12 |
|
||||
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| external | n/a |
|
||||
| null | n/a |
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|:--------:|
|
||||
| NIX\_PATH | Allow to pass custom NIX\_PATH | `string` | `""` | no |
|
||||
| build\_on\_target | Avoid building on the deployer. Must be true or false. Has no effect when deploying from an incompatible system. Unlike remote builders, this does not require the deploying user to be trusted by its host. | `string` | `false` | no |
|
||||
| config | NixOS configuration to be evaluated. This argument is required unless 'nixos\_config' is given | `string` | `""` | no |
|
||||
| config\_pwd | Directory to evaluate the configuration in. This argument is required if 'config' is given | `string` | `""` | no |
|
||||
| extra\_build\_args | List of arguments to pass to the nix builder | `list(string)` | `[]` | no |
|
||||
| extra\_eval\_args | List of arguments to pass to the nix evaluation | `list(string)` | `[]` | no |
|
||||
| hermetic | Treat the provided nixos configuration as a hermetic expression and do not evaluate using the ambient system nixpkgs. Useful if you customize eval-modules or use a pinned nixpkgs. | `bool` | false | no |
|
||||
| flake | Treat the provided nixos_config as the name of the NixOS configuration to use in the flake located in the current directory. Useful if you customize eval-modules or use a pinned nixpkgs. | `bool` | false | no |
|
||||
| keys | A map of filename to content to upload as secrets in /var/keys | `map(string)` | `{}` | no |
|
||||
| nixos\_config | Path to a NixOS configuration | `string` | `""` | no |
|
||||
| ssh\_agent | Whether to use an SSH agent. True if not ssh\_private\_key is passed | `bool` | `null` | no |
|
||||
| ssh\_private\_key | Content of private key used to connect to the target\_host | `string` | `""` | no |
|
||||
| ssh\_private\_key\_file | Path to private key used to connect to the target\_host | `string` | `""` | no |
|
||||
| target\_host | DNS host to deploy to | `string` | n/a | yes |
|
||||
| target\_port | SSH port used to connect to the target\_host | `number` | `22` | no |
|
||||
| target\_system | Nix system string | `string` | `"x86_64-linux"` | no |
|
||||
| target\_user | SSH user used to connect to the target\_host | `string` | `"root"` | no |
|
||||
| triggers | Triggers for deploy | `map(string)` | `{}` | no |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| id | random ID that changes on every nixos deployment |
|
||||
|
||||
<!-- terraform-docs-end -->
|
|
@ -1,221 +0,0 @@
|
|||
variable "target_host" {
|
||||
type = string
|
||||
description = "DNS host to deploy to"
|
||||
}
|
||||
|
||||
variable "target_user" {
|
||||
type = string
|
||||
description = "SSH user used to connect to the target_host"
|
||||
default = "root"
|
||||
}
|
||||
|
||||
variable "target_port" {
|
||||
type = number
|
||||
description = "SSH port used to connect to the target_host"
|
||||
default = 22
|
||||
}
|
||||
|
||||
variable "ssh_private_key" {
|
||||
type = string
|
||||
description = "Content of private key used to connect to the target_host"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "ssh_private_key_file" {
|
||||
type = string
|
||||
description = "Path to private key used to connect to the target_host"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "ssh_agent" {
|
||||
type = bool
|
||||
description = "Whether to use an SSH agent. True if not ssh_private_key is passed"
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "NIX_PATH" {
|
||||
type = string
|
||||
description = "Allow to pass custom NIX_PATH"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "nixos_config" {
|
||||
type = string
|
||||
description = "Path to a NixOS configuration"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "config" {
|
||||
type = string
|
||||
description = "NixOS configuration to be evaluated. This argument is required unless 'nixos_config' is given"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "config_pwd" {
|
||||
type = string
|
||||
description = "Directory to evaluate the configuration in. This argument is required if 'config' is given"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "extra_eval_args" {
|
||||
type = list(string)
|
||||
description = "List of arguments to pass to the nix evaluation"
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "extra_build_args" {
|
||||
type = list(string)
|
||||
description = "List of arguments to pass to the nix builder"
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "build_on_target" {
|
||||
type = string
|
||||
description = "Avoid building on the deployer. Must be true or false. Has no effect when deploying from an incompatible system. Unlike remote builders, this does not require the deploying user to be trusted by its host."
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "triggers" {
|
||||
type = map(string)
|
||||
description = "Triggers for deploy"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "keys" {
|
||||
type = map(string)
|
||||
description = "A map of filename to content to upload as secrets in /var/keys"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "target_system" {
|
||||
type = string
|
||||
description = "Nix system string"
|
||||
default = "x86_64-linux"
|
||||
}
|
||||
|
||||
variable "hermetic" {
|
||||
type = bool
|
||||
description = "Treat the provided nixos configuration as a hermetic expression and do not evaluate using the ambient system nixpkgs. Useful if you customize eval-modules or use a pinned nixpkgs."
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "flake" {
|
||||
type = bool
|
||||
description = "Treat the provided nixos_config as the NixOS configuration to use in the flake located in the current directory"
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "delete_older_than" {
|
||||
type = string
|
||||
description = "Can be a list of generation numbers, the special value old to delete all non-current generations, a value such as 30d to delete all generations older than the specified number of days (except for the generation that was active at that point in time), or a value such as +5 to keep the last 5 generations ignoring any newer than current, e.g., if 30 is the current generation +5 will delete generation 25 and all older generations."
|
||||
default = "+1"
|
||||
}
|
||||
|
||||
variable "deploy_environment" {
|
||||
type = map(string)
|
||||
description = "Extra environment variables to be set during deployment."
|
||||
default = {}
|
||||
}
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
locals {
|
||||
triggers = {
|
||||
deploy_nixos_drv = data.external.nixos-instantiate.result["drv_path"]
|
||||
deploy_nixos_keys = sha256(jsonencode(var.keys))
|
||||
}
|
||||
|
||||
extra_build_args = concat([
|
||||
"--option", "substituters", data.external.nixos-instantiate.result["substituters"],
|
||||
"--option", "trusted-public-keys", data.external.nixos-instantiate.result["trusted-public-keys"],
|
||||
],
|
||||
var.extra_build_args,
|
||||
)
|
||||
ssh_private_key_file = var.ssh_private_key_file == "" ? "-" : var.ssh_private_key_file
|
||||
ssh_private_key = local.ssh_private_key_file == "-" ? var.ssh_private_key : file(local.ssh_private_key_file)
|
||||
ssh_agent = var.ssh_agent == null ? (local.ssh_private_key != "") : var.ssh_agent
|
||||
build_on_target = data.external.nixos-instantiate.result["currentSystem"] != var.target_system ? true : tobool(var.build_on_target)
|
||||
}
|
||||
|
||||
# used to detect changes in the configuration
|
||||
data "external" "nixos-instantiate" {
|
||||
program = concat([
|
||||
"${path.module}/nixos-instantiate.sh",
|
||||
var.NIX_PATH == "" ? "-" : var.NIX_PATH,
|
||||
var.config != "" ? var.config : var.nixos_config,
|
||||
var.config_pwd == "" ? "." : var.config_pwd,
|
||||
var.flake,
|
||||
# end of positional arguments
|
||||
# start of pass-through arguments
|
||||
"--argstr", "system", var.target_system,
|
||||
"--arg", "hermetic", var.hermetic
|
||||
],
|
||||
var.extra_eval_args,
|
||||
)
|
||||
}
|
||||
|
||||
resource "null_resource" "deploy_nixos" {
|
||||
triggers = merge(var.triggers, local.triggers)
|
||||
|
||||
connection {
|
||||
type = "ssh"
|
||||
host = var.target_host
|
||||
port = var.target_port
|
||||
user = var.target_user
|
||||
agent = local.ssh_agent
|
||||
timeout = "100s"
|
||||
private_key = local.ssh_private_key == "-" ? "" : local.ssh_private_key
|
||||
}
|
||||
|
||||
# copy the secret keys to the host
|
||||
provisioner "file" {
|
||||
content = jsonencode(var.keys)
|
||||
destination = "packed-keys.json"
|
||||
}
|
||||
|
||||
# FIXME: move this to nixos-deploy.sh
|
||||
provisioner "file" {
|
||||
source = "${path.module}/unpack-keys.sh"
|
||||
destination = "unpack-keys.sh"
|
||||
}
|
||||
|
||||
# FIXME: move this to nixos-deploy.sh
|
||||
provisioner "file" {
|
||||
source = "${path.module}/maybe-sudo.sh"
|
||||
destination = "maybe-sudo.sh"
|
||||
}
|
||||
|
||||
provisioner "remote-exec" {
|
||||
inline = [
|
||||
"chmod +x unpack-keys.sh maybe-sudo.sh",
|
||||
"./maybe-sudo.sh ./unpack-keys.sh ./packed-keys.json",
|
||||
]
|
||||
}
|
||||
|
||||
# do the actual deployment
|
||||
provisioner "local-exec" {
|
||||
environment = var.deploy_environment
|
||||
interpreter = concat([
|
||||
"${path.module}/nixos-deploy.sh",
|
||||
data.external.nixos-instantiate.result["drv_path"],
|
||||
data.external.nixos-instantiate.result["out_path"],
|
||||
"${var.target_user}@${var.target_host}",
|
||||
var.target_port,
|
||||
local.build_on_target,
|
||||
local.ssh_private_key == "" ? "-" : local.ssh_private_key,
|
||||
"switch",
|
||||
var.delete_older_than,
|
||||
],
|
||||
local.extra_build_args
|
||||
)
|
||||
command = "ignoreme"
|
||||
}
|
||||
}
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
output "id" {
|
||||
description = "random ID that changes on every nixos deployment"
|
||||
value = null_resource.deploy_nixos.id
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Run sudo if required
|
||||
#
|
||||
# Usage: ./maybe-sudo.sh <command> [...args]
|
||||
set -euo pipefail
|
||||
if [[ "$UID" = 0 ]]; then
|
||||
exec -- "$@"
|
||||
else
|
||||
exec sudo -- "$@"
|
||||
fi
|
|
@ -1,133 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# nixos-deploy deploys a nixos-instantiate-generated drvPath to a target host
|
||||
#
|
||||
# Usage: nixos-deploy.sh <drvPath> <host> <switch-action> [<build-opts>] ignoreme
|
||||
set -euo pipefail
|
||||
|
||||
### Defaults ###
|
||||
|
||||
buildArgs=(
|
||||
--option extra-binary-caches https://cache.nixos.org/
|
||||
)
|
||||
profile=/nix/var/nix/profiles/system
|
||||
# will be set later
|
||||
sshOpts=(
|
||||
-o "ControlMaster=auto"
|
||||
-o "ControlPersist=60"
|
||||
# Avoid issues with IP re-use. This disable TOFU security.
|
||||
-o "StrictHostKeyChecking=no"
|
||||
-o "UserKnownHostsFile=/dev/null"
|
||||
-o "GlobalKnownHostsFile=/dev/null"
|
||||
# interactive authentication is not possible
|
||||
-o "BatchMode=yes"
|
||||
# verbose output for easier debugging
|
||||
-v
|
||||
)
|
||||
|
||||
### Argument parsing ###
|
||||
|
||||
drvPath="$1"
|
||||
outPath="$2"
|
||||
targetHost="$3"
|
||||
targetPort="$4"
|
||||
buildOnTarget="$5"
|
||||
sshPrivateKey="$6"
|
||||
action="$7"
|
||||
deleteOlderThan="$8"
|
||||
shift 8
|
||||
|
||||
# remove the last argument
|
||||
set -- "${@:1:$(($# - 1))}"
|
||||
buildArgs+=("$@")
|
||||
|
||||
sshOpts+=( -p "${targetPort}" )
|
||||
|
||||
workDir=$(mktemp -d)
|
||||
trap 'rm -rf "$workDir"' EXIT
|
||||
|
||||
if [[ -n "${sshPrivateKey}" && "${sshPrivateKey}" != "-" ]]; then
|
||||
sshPrivateKeyFile="$workDir/ssh_key"
|
||||
echo "$sshPrivateKey" > "$sshPrivateKeyFile"
|
||||
chmod 0700 "$sshPrivateKeyFile"
|
||||
sshOpts+=( -o "IdentityFile=${sshPrivateKeyFile}" )
|
||||
fi
|
||||
|
||||
### Functions ###
|
||||
|
||||
log() {
|
||||
echo "--- $*" >&2
|
||||
}
|
||||
|
||||
copyToTarget() {
|
||||
NIX_SSHOPTS="${sshOpts[*]}" nix-copy-closure --to "$targetHost" "$@"
|
||||
}
|
||||
|
||||
# assumes that passwordless sudo is enabled on the server
|
||||
targetHostCmd() {
|
||||
# ${*@Q} escapes the arguments losslessly into space-separted quoted strings.
|
||||
# `ssh` did not properly maintain the array nature of the command line,
|
||||
# erroneously splitting arguments with internal spaces, even when using `--`.
|
||||
# Tested with OpenSSH_7.9p1.
|
||||
#
|
||||
# shellcheck disable=SC2029
|
||||
ssh "${sshOpts[@]}" "$targetHost" "./maybe-sudo.sh ${*@Q}"
|
||||
}
|
||||
|
||||
# Setup a temporary ControlPath for this session. This speeds-up the
|
||||
# operations by not re-creating SSH sessions between each command. At the end
|
||||
# of the run, the session is forcefully terminated.
|
||||
setupControlPath() {
|
||||
sshOpts+=(
|
||||
-o "ControlPath=$workDir/ssh_control"
|
||||
)
|
||||
cleanupControlPath() {
|
||||
local ret=$?
|
||||
# Avoid failing during the shutdown
|
||||
set +e
|
||||
# Close ssh multiplex-master process gracefully
|
||||
log "closing persistent ssh-connection"
|
||||
ssh "${sshOpts[@]}" -O stop "$targetHost"
|
||||
rm -rf "$workDir"
|
||||
exit "$ret"
|
||||
}
|
||||
trap cleanupControlPath EXIT
|
||||
}
|
||||
|
||||
### Main ###
|
||||
|
||||
setupControlPath
|
||||
|
||||
if [[ "${buildOnTarget:-false}" == true ]]; then
|
||||
|
||||
# Upload derivation
|
||||
log "uploading derivations"
|
||||
copyToTarget "$drvPath" --gzip --use-substitutes
|
||||
|
||||
# Build remotely
|
||||
log "building on target"
|
||||
set -x
|
||||
targetHostCmd "nix-store" "--realize" "$drvPath" "${buildArgs[@]}"
|
||||
|
||||
else
|
||||
|
||||
# Build derivation
|
||||
log "building on deployer"
|
||||
outPath=$(nix-store --realize "$drvPath" "${buildArgs[@]}")
|
||||
|
||||
# Upload build results
|
||||
log "uploading build results"
|
||||
copyToTarget "$outPath" --gzip --use-substitutes
|
||||
|
||||
fi
|
||||
|
||||
# Activate
|
||||
log "activating configuration"
|
||||
targetHostCmd nix-env --profile "$profile" --set "$outPath"
|
||||
targetHostCmd "$outPath/bin/switch-to-configuration" "$action"
|
||||
|
||||
# Cleanup previous generations
|
||||
log "collecting old nix derivations"
|
||||
# Deliberately not quoting $deleteOlderThan so the user can configure something like "1 2 3"
|
||||
# to keep generations with those numbers
|
||||
targetHostCmd "nix-env" "--profile" "$profile" "--delete-generations" $deleteOlderThan
|
||||
targetHostCmd "nix-store" "--gc"
|
|
@ -1,94 +0,0 @@
|
|||
#! /usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Args
|
||||
nix_path=$1
|
||||
config=$2
|
||||
config_pwd=$3
|
||||
flake=$4
|
||||
shift 4
|
||||
|
||||
|
||||
command=(nix-instantiate --show-trace --expr '
|
||||
{ system, configuration, hermetic ? false, flake ? false, ... }:
|
||||
let
|
||||
importFromFlake = { nixosConfig }:
|
||||
let
|
||||
flake = (import (
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
|
||||
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; }
|
||||
) {
|
||||
src = ./.;
|
||||
}).defaultNix;
|
||||
in
|
||||
builtins.getAttr nixosConfig flake.nixosConfigurations;
|
||||
os =
|
||||
if flake
|
||||
then importFromFlake { nixosConfig = configuration; }
|
||||
else if hermetic
|
||||
then
|
||||
(
|
||||
if builtins.isString configuration
|
||||
# case: nixos_config i.e. file path
|
||||
then import configuration
|
||||
# case: config i.e. the module expression itself
|
||||
else configuration
|
||||
)
|
||||
else
|
||||
import <nixpkgs/nixos> { inherit system configuration; };
|
||||
in {
|
||||
inherit (builtins) currentSystem;
|
||||
|
||||
substituters =
|
||||
builtins.concatStringsSep " " os.config.nix.binaryCaches;
|
||||
|
||||
trusted-public-keys =
|
||||
builtins.concatStringsSep " " os.config.nix.binaryCachePublicKeys;
|
||||
|
||||
drv_path = os.config.system.build.toplevel.drvPath;
|
||||
out_path = os.config.system.build.toplevel;
|
||||
}')
|
||||
|
||||
if readlink --version | grep -q GNU; then
|
||||
readlink="readlink -f"
|
||||
else
|
||||
if command -v greadlink &> /dev/null; then
|
||||
readlink="greadlink -f"
|
||||
else
|
||||
echo "Warning: symlinks not supported because readlink is non GNU" >&2
|
||||
readlink="realpath"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -f "$config" ]]; then
|
||||
config=$($readlink "$config")
|
||||
command+=(--argstr configuration "$config")
|
||||
else
|
||||
if $flake; then
|
||||
command+=(--argstr configuration "$config" --arg flake true)
|
||||
else
|
||||
command+=(--arg configuration "$config")
|
||||
fi
|
||||
fi
|
||||
|
||||
# add all extra CLI args as extra build arguments
|
||||
command+=("$@")
|
||||
|
||||
# Setting the NIX_PATH
|
||||
if [[ -n "$nix_path" && "$nix_path" != "-" ]]; then
|
||||
export NIX_PATH=$nix_path
|
||||
fi
|
||||
|
||||
# Changing directory
|
||||
cd "$($readlink "$config_pwd")"
|
||||
|
||||
# Instantiate
|
||||
echo "running (instantiating): ${NIX_PATH:+NIX_PATH=$NIX_PATH} ${command[*]@Q}" -A out_path >&2
|
||||
"${command[@]}" -A out_path >/dev/null
|
||||
|
||||
# Evaluate some more details,
|
||||
# relying on preceding "Instantiate" command to perform the instantiation,
|
||||
# because `--eval` is required but doesn't instantiate for some reason.
|
||||
echo "running (evaluating): ${NIX_PATH:+NIX_PATH=$NIX_PATH} ${command[*]@Q}" --eval --strict --json >&2
|
||||
"${command[@]}" --eval --strict --json
|
|
@ -1,46 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Unpacks the packed-keys.json into individual keys
|
||||
set -euo pipefail
|
||||
shopt -s nullglob
|
||||
|
||||
keys_file=${1:-packed-keys.json}
|
||||
keys_dir=/var/keys
|
||||
|
||||
if [[ ! -f "$keys_file" ]]; then
|
||||
echo "error: $keys_file not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Fallback if jq is not installed
|
||||
if ! type -p jq &>/dev/null; then
|
||||
jqOut=$(nix-build '<nixpkgs>' -A jq)
|
||||
jq() {
|
||||
"$jqOut/bin/jq" "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
# cleanup
|
||||
mkdir -m 0750 -p "$keys_dir"
|
||||
chown -v root:keys "$keys_dir"
|
||||
chmod -v 0750 "$keys_dir"
|
||||
for key in "$keys_dir"/* ; do
|
||||
rm -v "$key"
|
||||
done
|
||||
|
||||
if [[ $(< "$keys_file") = "{}" ]]; then
|
||||
echo "no keys to unpack"
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "unpacking $keys_file"
|
||||
|
||||
# extract the keys from .packed.json
|
||||
for keyname in $(jq -S -r 'keys[]' "$keys_file"); do
|
||||
echo "unpacking: $keyname"
|
||||
jq -r ".\"$keyname\"" < "$keys_file" > "$keys_dir/$keyname"
|
||||
chmod 0640 "$keys_dir/$keyname"
|
||||
chown root:keys "$keys_dir/$keyname"
|
||||
done
|
||||
|
||||
echo "unpacking done"
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
terraform {
|
||||
required_version = ">= 0.12"
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
# Here we have an example of how a machine can be provisioned with some config
|
||||
# after boot. This is useful in case one doesn't want to unecessarily destroy
|
||||
# and create VMs in a pet scenario.
|
||||
|
||||
data "google_compute_network" "default" {
|
||||
name = "default"
|
||||
}
|
||||
|
||||
resource "google_compute_firewall" "deploy-nixos" {
|
||||
name = "deploy-nixos"
|
||||
network = data.google_compute_network.default.name
|
||||
|
||||
allow {
|
||||
protocol = "icmp"
|
||||
}
|
||||
|
||||
// Allow SSH access
|
||||
allow {
|
||||
protocol = "tcp"
|
||||
ports = ["22"]
|
||||
}
|
||||
|
||||
// To vm tagged with: nixos
|
||||
target_tags = ["nixos"]
|
||||
direction = "INGRESS"
|
||||
|
||||
// From anywhere.
|
||||
source_ranges = ["0.0.0.0/0"]
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "deploy-nixos" {
|
||||
name = "deploy-nixos-example"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
|
||||
// Bind the firewall rules
|
||||
tags = ["nixos"]
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
// Start with an image the deployer can SSH into
|
||||
image = module.nixos_image_custom.self_link
|
||||
size = "20"
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
|
||||
// Give it a public IP
|
||||
access_config {}
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
// No need to re-deploy the machine if the image changed
|
||||
// NixOS is already immutable
|
||||
ignore_changes = [boot_disk]
|
||||
}
|
||||
}
|
||||
|
||||
module "deploy_nixos" {
|
||||
source = "../../deploy_nixos"
|
||||
|
||||
// Deploy the given NixOS configuration. In this case it's the same as the
|
||||
// original image. So if the configuration is changed later it will be
|
||||
// deployed here.
|
||||
nixos_config = "${path.module}/image_nixos_custom.nix"
|
||||
|
||||
target_user = "root"
|
||||
target_host = google_compute_instance.deploy-nixos.network_interface[0].access_config[0].nat_ip
|
||||
|
||||
triggers = {
|
||||
// Also re-deploy whenever the VM is re-created
|
||||
instance_id = google_compute_instance.deploy-nixos.id
|
||||
}
|
||||
|
||||
// Pass some secrets. See the terraform-provider-secret to handle secrets
|
||||
// in Terraform
|
||||
keys = {
|
||||
foo = "bar"
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
# Here is a simple example that instantiates the google image and spins up an
|
||||
# instance
|
||||
|
||||
module "nixos_image_1809" {
|
||||
source = "../../google_image_nixos"
|
||||
nixos_version = "18.09"
|
||||
}
|
||||
|
||||
// This instance is not very useful since it doesn't contain any
|
||||
// configuration. This could be fixed by passing a user metadata script.
|
||||
resource "google_compute_instance" "image-nixos" {
|
||||
name = "image-nixos"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image = module.nixos_image_1809.self_link
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
{ modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
# Make sure to have this in all your configurations
|
||||
"${toString modulesPath}/virtualisation/google-compute-image.nix"
|
||||
];
|
||||
|
||||
# Bake the deploy's SSH key into the image. This is not
|
||||
# kosher Nix.
|
||||
users.users.root.openssh.authorizedKeys.keyFiles = [
|
||||
(/. + builtins.getEnv("HOME") + "/.ssh/id_rsa.pub")
|
||||
];
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
# create a random ID for the bucket
|
||||
resource "random_id" "bucket" {
|
||||
byte_length = 8
|
||||
}
|
||||
|
||||
# create a bucket to upload the image into
|
||||
resource "google_storage_bucket" "nixos-images" {
|
||||
name = "nixos-images-${random_id.bucket.hex}"
|
||||
location = "EU"
|
||||
}
|
||||
|
||||
# create a custom nixos base image the deployer can SSH into
|
||||
#
|
||||
# this could also include much more configuration and be used to feed the
|
||||
# auto-scaler with system images
|
||||
module "nixos_image_custom" {
|
||||
source = "../../google_image_nixos_custom"
|
||||
bucket_name = google_storage_bucket.nixos-images.name
|
||||
|
||||
nixos_config = "${path.module}/image_nixos_custom.nix"
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
provider "google" {
|
||||
project = "tweag-digital-assets"
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
# A simple, hermetic NixOS configuration for an AWS EC2 instance that
|
||||
# uses a nixpkgs pinned to a specific Git revision with an integrity
|
||||
# hash to ensure that we construct a NixOS system as purely as
|
||||
# possible.
|
||||
#
|
||||
# i.e. we explicitly specify which nixpkgs to use instead of relying
|
||||
# on the nixpkgs supplied on the NIX_PATH.
|
||||
#
|
||||
# The primary benefit of this is that it removes deployment surprises
|
||||
# when other developers supply a different nix-channel in the NIX_PATH
|
||||
# of their environment (even if you only add the 20.09 channel,
|
||||
# nix-channel --update can mutate that channel to a 20.09 with
|
||||
# backported changes).
|
||||
#
|
||||
# The secondary benefit is that you guard the `nixpkgs` you use, with
|
||||
# an integrity hash.
|
||||
let
|
||||
nixpkgs =
|
||||
let
|
||||
rev = "cd63096d6d887d689543a0b97743d28995bc9bc3";
|
||||
sha256 = "1wg61h4gndm3vcprdcg7rc4s1v3jkm5xd7lw8r2f67w502y94gcy";
|
||||
in
|
||||
builtins.fetchTarball {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
|
||||
inherit sha256;
|
||||
};
|
||||
|
||||
system = "x86_64-linux";
|
||||
|
||||
configuration = { config, pkgs, ... }: {
|
||||
imports = [
|
||||
"${nixpkgs}/nixos/modules/virtualisation/amazon-image.nix"
|
||||
];
|
||||
|
||||
ec2.hvm = true;
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 22 80 ];
|
||||
|
||||
environment.systemPackages = [
|
||||
pkgs.cloud-utils
|
||||
];
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts = {
|
||||
"_" = {
|
||||
root = pkgs.writeTextDir "html/index.html" ''
|
||||
<html>
|
||||
<body>
|
||||
<h1>This is a hermetic NixOS configuration!</h1>
|
||||
</body>
|
||||
</html>
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
import "${nixpkgs}/nixos" { inherit system configuration; }
|
|
@ -1,27 +0,0 @@
|
|||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
profile = "yourprofile"
|
||||
}
|
||||
|
||||
resource "aws_instance" "hermetic-nixos-system" {
|
||||
count = 1
|
||||
ami = "ami-068a62d478710462d" # NixOS 20.09 AMI
|
||||
|
||||
instance_type = "t2.micro"
|
||||
|
||||
key_name = "yourkeyname"
|
||||
|
||||
tags = {
|
||||
Name = "hermetic-nixos-system-example"
|
||||
Description = "An example of a hermetic NixOS system deployed by Terraform"
|
||||
}
|
||||
}
|
||||
|
||||
module "deploy_nixos" {
|
||||
source = "github.com/awakesecurity/terraform-nixos//deploy_nixos?ref=c4b1ee6d24b54e92fa3439a12bce349a6805bcdd"
|
||||
nixos_config = "${path.module}/configuration.nix"
|
||||
hermetic = true
|
||||
target_user = "root"
|
||||
target_host = aws_instance.hermetic-nixos-system[0].public_ip
|
||||
ssh_private_key_file = pathexpand("~/.ssh/yourkeyname.pem")
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
terraform fmt
|
||||
|
||||
fmt_docs() {
|
||||
./scripts/terraform-docs-updater "$1"
|
||||
}
|
||||
|
||||
fmt_docs deploy_nixos
|
||||
fmt_docs google_image_nixos
|
||||
fmt_docs google_image_nixos_custom
|
||||
|
||||
echo "."
|
|
@ -1,76 +0,0 @@
|
|||
# `google_image_nixos`
|
||||
|
||||
This terraform module creates a new image in the Google Cloud project using a
|
||||
public tarballs of a NixOS release. Those tarballs are released by the NixOS
|
||||
project.
|
||||
|
||||
Since image names are unique, only one instance per version of the module is
|
||||
supported per Google Cloud project.
|
||||
|
||||
## Example
|
||||
|
||||
```hcl
|
||||
module "nixos_image_1809" {
|
||||
source = "github.com/tweag/terraform-nixos/google_image_nixos"
|
||||
nixos_version = "18.09"
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "example" {
|
||||
name = "example"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image = module.nixos_image_1809.self_link
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Default configuration.nix
|
||||
|
||||
A new configuration.nix can be passed trough the userdata. Here is the default
|
||||
configuration to expand upon:
|
||||
|
||||
```nix
|
||||
{ modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
"${toString modulesPath}/virtualisation/google-compute-image.nix"
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
## New NixOS releases
|
||||
|
||||
Run the `./update-url-map` script to fetch new image releases. Please submit a
|
||||
PR as well!
|
||||
|
||||
<!-- terraform-docs-start -->
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| google | n/a |
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|:-----:|
|
||||
| gcp\_project\_id | The ID of the project in which the resource belongs. If it is not provided, the provider project is used. | `string` | `""` | no |
|
||||
| licenses | A list of license URIs to apply to this image. Changing this forces a new resource to be created. | `list(string)` | <pre>[<br> "https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx"<br>]</pre> | no |
|
||||
| nixos\_version | The NixOS version to use. Eg: 18.09 | `string` | `"latest"` | no |
|
||||
| url\_map | A map of release series to actual releases | `map(string)` | <pre>{<br> "14.12": "https://nixos-cloud-images.storage.googleapis.com/nixos-14.12.471.1f09b77-x86_64-linux.raw.tar.gz",<br> "15.09": "https://nixos-cloud-images.storage.googleapis.com/nixos-15.09.425.7870f20-x86_64-linux.raw.tar.gz",<br> "16.03": "https://nixos-cloud-images.storage.googleapis.com/nixos-image-16.03.847.8688c17-x86_64-linux.raw.tar.gz",<br> "17.03": "https://nixos-cloud-images.storage.googleapis.com/nixos-image-17.03.1082.4aab5c5798-x86_64-linux.raw.tar.gz",<br> "18.03": "https://nixos-cloud-images.storage.googleapis.com/nixos-image-18.03.132536.fdb5ba4cdf9-x86_64-linux.raw.tar.gz",<br> "18.09": "https://nixos-cloud-images.storage.googleapis.com/nixos-image-18.09.1228.a4c4cbb613c-x86_64-linux.raw.tar.gz",<br> "20.03": "https://nixos-images.storage.googleapis.com/google-cloud-nixos-20.03.1639.73e73c7d6b5.raw.tar.gz",<br> "latest": "https://nixos-images.storage.googleapis.com/google-cloud-nixos-20.03.1639.73e73c7d6b5.raw.tar.gz"<br>}</pre> | no |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| self\_link | Link to the NixOS Compute Image |
|
||||
|
||||
<!-- terraform-docs-end -->
|
|
@ -1,64 +0,0 @@
|
|||
variable "nixos_version" {
|
||||
type = string
|
||||
default = "latest"
|
||||
description = "The NixOS version to use. Eg: 18.09"
|
||||
}
|
||||
|
||||
variable "gcp_project_id" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "The ID of the project in which the resource belongs. If it is not provided, the provider project is used."
|
||||
}
|
||||
|
||||
variable "labels" {
|
||||
type = map(string)
|
||||
default = {}
|
||||
description = "A map of labels applied to this image."
|
||||
}
|
||||
|
||||
variable "licenses" {
|
||||
type = list(string)
|
||||
|
||||
default = [
|
||||
"https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx",
|
||||
]
|
||||
|
||||
description = "A list of license URIs to apply to this image. Changing this forces a new resource to be created."
|
||||
}
|
||||
|
||||
# ---
|
||||
|
||||
locals {
|
||||
image_url = var.url_map[var.nixos_version]
|
||||
|
||||
# Example: nixos-image-18-09-1228-a4c4cbb613c-x86-64-linux
|
||||
#
|
||||
# Remove a few things so that it matches the required regexp for image names
|
||||
# (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)
|
||||
image_name = replace(
|
||||
replace(basename(local.image_url), ".raw.tar.gz", ""),
|
||||
"/[._]+/",
|
||||
"-",
|
||||
)
|
||||
}
|
||||
|
||||
resource "google_compute_image" "nixos" {
|
||||
name = local.image_name
|
||||
description = "NixOS ${var.nixos_version}"
|
||||
family = "nixos"
|
||||
project = var.gcp_project_id
|
||||
labels = var.labels
|
||||
licenses = var.licenses
|
||||
|
||||
raw_disk {
|
||||
source = local.image_url
|
||||
}
|
||||
}
|
||||
|
||||
# ---
|
||||
|
||||
output "self_link" {
|
||||
description = "Link to the NixOS Compute Image"
|
||||
value = google_compute_image.nixos.self_link
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -p ruby -i ruby
|
||||
# vim: ft=ruby
|
||||
#
|
||||
# Run this script to update the list of GCE images
|
||||
#
|
||||
require "json"
|
||||
require "uri"
|
||||
|
||||
ENV['NIX_PATH'] = "nixpkgs=channel:nixpkgs-unstable"
|
||||
|
||||
def render_tf
|
||||
url_map=JSON.load(`nix-instantiate --json --strict --eval ./url_map.nix`)
|
||||
|
||||
out = <<~HEADER
|
||||
# DON'T EDIT, run $0 instead
|
||||
variable "url_map" {
|
||||
type = map(string)
|
||||
|
||||
default = {
|
||||
HEADER
|
||||
|
||||
url_map.each_pair do |version, gs_url|
|
||||
u = URI.parse(gs_url)
|
||||
# convert the gs:// URL to HTTPS URL for Terraform to consume
|
||||
#
|
||||
# Eg: "gs://nixos-cloud-images/nixos-image-18.09-x86_64-linux.raw.tar.gz"
|
||||
https_url = "https://#{u.host}.storage.googleapis.com#{u.path}"
|
||||
|
||||
out += " %- 8s = %s\n" % [ version.inspect, https_url.inspect]
|
||||
end
|
||||
|
||||
out += <<~FOOTER
|
||||
}
|
||||
|
||||
description = "A map of release series to actual releases"
|
||||
}
|
||||
FOOTER
|
||||
end
|
||||
|
||||
url_map_tf = render_tf
|
||||
|
||||
open("url_map.tf", "w") do |f|
|
||||
f.write(url_map_tf)
|
||||
end
|
||||
|
||||
puts url_map_tf
|
|
@ -1,2 +0,0 @@
|
|||
# Indirect link to where the image map is stored
|
||||
import <nixpkgs/nixos/modules/virtualisation/gce-images.nix>
|
|
@ -1,17 +0,0 @@
|
|||
# DON'T EDIT, run $0 instead
|
||||
variable "url_map" {
|
||||
type = map(string)
|
||||
|
||||
default = {
|
||||
"14.12" = "https://nixos-cloud-images.storage.googleapis.com/nixos-14.12.471.1f09b77-x86_64-linux.raw.tar.gz"
|
||||
"15.09" = "https://nixos-cloud-images.storage.googleapis.com/nixos-15.09.425.7870f20-x86_64-linux.raw.tar.gz"
|
||||
"16.03" = "https://nixos-cloud-images.storage.googleapis.com/nixos-image-16.03.847.8688c17-x86_64-linux.raw.tar.gz"
|
||||
"17.03" = "https://nixos-cloud-images.storage.googleapis.com/nixos-image-17.03.1082.4aab5c5798-x86_64-linux.raw.tar.gz"
|
||||
"18.03" = "https://nixos-cloud-images.storage.googleapis.com/nixos-image-18.03.132536.fdb5ba4cdf9-x86_64-linux.raw.tar.gz"
|
||||
"18.09" = "https://nixos-cloud-images.storage.googleapis.com/nixos-image-18.09.1228.a4c4cbb613c-x86_64-linux.raw.tar.gz"
|
||||
"20.03" = "https://nixos-images.storage.googleapis.com/google-cloud-nixos-20.03.1639.73e73c7d6b5.raw.tar.gz"
|
||||
"latest" = "https://nixos-images.storage.googleapis.com/google-cloud-nixos-20.03.1639.73e73c7d6b5.raw.tar.gz"
|
||||
}
|
||||
|
||||
description = "A map of release series to actual releases"
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
terraform {
|
||||
required_version = ">= 0.12"
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
# google_cloud_image_nixos
|
||||
|
||||
This terraform module builds and publishes custom NixOS Google Cloud images.
|
||||
|
||||
## Runtime dependencies
|
||||
|
||||
Because this module uses the "external" provider it needs the following
|
||||
executables to be in the path to work properly:
|
||||
|
||||
* bash
|
||||
* nix
|
||||
* `readlink -f` (busybox or coreutils)
|
||||
|
||||
## Known limitations
|
||||
|
||||
NixOS images are built at Terraform plan time. This can make the plan quite
|
||||
slow.
|
||||
|
||||
Building the image doesn't yield any output, unless the build is interrupted or
|
||||
failed.
|
||||
|
||||
When a new image is published, the old-one gets removed. This potentially
|
||||
introduces a race-condition where other targets are trying to create new
|
||||
instances with the old image. To reduce the race window, `create_before_destroy` is being used. See
|
||||
https://github.com/hashicorp/terraform/issues/15485 for related discussions.
|
||||
|
||||
Only x86_64-linux is currently supported.
|
||||
|
||||
<!-- terraform-docs-start -->
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| external | n/a |
|
||||
| google | n/a |
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|:-----:|
|
||||
| NIX\_PATH | Allow to pass custom NIX\_PATH. Ignored if `-` or empty. | `string` | `"-"` | no |
|
||||
| bucket\_name | Bucket where to store the image | `any` | n/a | yes |
|
||||
| gcp\_project\_id | The ID of the project in which the resource belongs. If it is not provided, the provider project is used. | `string` | `""` | no |
|
||||
| licenses | A list of license URIs to apply to this image. Changing this forces a new resource to be created. | `list(string)` | <pre>[<br> "https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx"<br>]</pre> | no |
|
||||
| nixos\_config | Path to a nixos configuration.nix file | `any` | n/a | yes |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| NIX\_PATH | n/a |
|
||||
| self\_link | n/a |
|
||||
|
||||
<!-- terraform-docs-end -->
|
|
@ -1,94 +0,0 @@
|
|||
variable "bucket_name" {
|
||||
description = "Bucket where to store the image"
|
||||
}
|
||||
|
||||
variable "nixos_config" {
|
||||
description = "Path to a nixos configuration.nix file"
|
||||
}
|
||||
|
||||
variable "NIX_PATH" {
|
||||
type = string
|
||||
description = "Allow to pass custom NIX_PATH. Ignored if `-` or empty."
|
||||
default = "-"
|
||||
}
|
||||
|
||||
variable "gcp_project_id" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "The ID of the project in which the resource belongs. If it is not provided, the provider project is used."
|
||||
}
|
||||
|
||||
variable "licenses" {
|
||||
type = list(string)
|
||||
|
||||
default = [
|
||||
"https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx",
|
||||
]
|
||||
|
||||
description = "A list of license URIs to apply to this image. Changing this forces a new resource to be created."
|
||||
}
|
||||
|
||||
# ----------------------------------------------------
|
||||
|
||||
data "external" "nix_build" {
|
||||
program = ["${path.module}/nixos-build.sh", var.NIX_PATH, var.nixos_config]
|
||||
}
|
||||
|
||||
locals {
|
||||
out_path = data.external.nix_build.result.out_path
|
||||
image_path = data.external.nix_build.result.image_path
|
||||
|
||||
# 3x2d4rdm9kjzk9d9sz87rmhzvcphs23v
|
||||
out_hash = element(split("-", basename(local.out_path)), 0)
|
||||
|
||||
# Example: 3x2d4rdm9kjzk9d9sz87rmhzvcphs23v-19-03pre-git-x86-64-linux
|
||||
#
|
||||
# Remove a few things so that it matches the required regexp for image names
|
||||
# (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)
|
||||
image_name = "x${substr(local.out_hash, 0, 12)}-${replace(
|
||||
replace(
|
||||
basename(local.image_path),
|
||||
"/\\.raw\\.tar\\.gz|nixos-image-/",
|
||||
"",
|
||||
),
|
||||
"/[._]+/",
|
||||
"-",
|
||||
)}"
|
||||
|
||||
# 3x2d4rdm9kjzk9d9sz87rmhzvcphs23v-nixos-image-19.03pre-git-x86_64-linux.raw.tar.gz
|
||||
image_filename = "${local.out_hash}-${basename(local.image_path)}"
|
||||
}
|
||||
|
||||
resource "google_storage_bucket_object" "nixos" {
|
||||
name = "images/${local.image_filename}"
|
||||
source = local.image_path
|
||||
bucket = var.bucket_name
|
||||
content_type = "application/tar+gzip"
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_image" "nixos" {
|
||||
name = local.image_name
|
||||
family = "nixos"
|
||||
project = var.gcp_project_id
|
||||
licenses = var.licenses
|
||||
|
||||
raw_disk {
|
||||
source = "https://${var.bucket_name}.storage.googleapis.com/${google_storage_bucket_object.nixos.name}"
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
output "self_link" {
|
||||
value = google_compute_image.nixos.self_link
|
||||
}
|
||||
|
||||
output "NIX_PATH" {
|
||||
value = var.NIX_PATH
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# Special version of nix-build that integrates with the Terraform external
|
||||
# provider
|
||||
set -euo pipefail
|
||||
|
||||
nix_path="${1}"
|
||||
nixos_config=$(readlink -f "${2:-./configuration.nix}")
|
||||
|
||||
shift
|
||||
shift
|
||||
|
||||
if [[ -n "$nix_path" && "$nix_path" != "-" ]]; then
|
||||
export NIX_PATH=$nix_path
|
||||
fi
|
||||
|
||||
args=(
|
||||
--arg configuration "$nixos_config"
|
||||
--argstr system x86_64-linux
|
||||
--no-out-link
|
||||
-A config.system.build.googleComputeImage
|
||||
)
|
||||
|
||||
out_path=$(nix-build '<nixpkgs/nixos>' "${args[@]}" "$@")
|
||||
|
||||
image_path=
|
||||
for path in "$out_path"/*.tar.gz; do
|
||||
image_path=$path
|
||||
done
|
||||
|
||||
cat <<JSON
|
||||
{
|
||||
"out_path": "$out_path",
|
||||
"image_path": "$image_path"
|
||||
}
|
||||
JSON
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
terraform {
|
||||
required_version = ">= 0.12"
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
{ lib, buildGoPackage, fetchFromGitHub }:
|
||||
buildGoPackage rec {
|
||||
name = "${pname}-${version}";
|
||||
pname = "terraform-docs";
|
||||
version = "0.8.2";
|
||||
|
||||
goPackagePath = "github.com/segmentio/${pname}";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "segmentio";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
sha256 = "0g85j43l6v2cwmymc1knbziyay8rarr9ynlsa7imjvwn4ib1926s";
|
||||
};
|
||||
|
||||
preBuild = ''
|
||||
buildFlagsArray+=("-ldflags" "-X main.version=${version}")
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "A utility to generate documentation from Terraform modules in various output formats.";
|
||||
homepage = "https://${goPackagePath}/";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ zimbatm ];
|
||||
};
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Run this script in the top of a terraform folder to amend
|
||||
# the README.md with terraform input/output tables.
|
||||
#
|
||||
# Usage: ./terraform-docs-update [target_dir]
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
BANNER_START="<!-- terraform-docs-start -->"
|
||||
BANNER_END="<!-- terraform-docs-end -->"
|
||||
doc=README.md
|
||||
|
||||
|
||||
cd "${1:-$PWD}"
|
||||
|
||||
if grep "$BANNER_START" "$doc" >/dev/null ; then
|
||||
if [[ -f "$doc.bak" ]]; then
|
||||
echo "$doc.bak file detected, aborting" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mv "$doc" "$doc.bak"
|
||||
{
|
||||
sed "/$BANNER_START/q" "$doc.bak"
|
||||
terraform-docs md .
|
||||
sed -n -e "/$BANNER_END/,\$p" "$doc.bak"
|
||||
} > "$doc"
|
||||
|
||||
rm "$doc.bak"
|
||||
else
|
||||
{
|
||||
echo "$BANNER_START"
|
||||
terraform-docs md .
|
||||
echo "$BANNER_END"
|
||||
} >> "$doc"
|
||||
fi
|
|
@ -1,21 +0,0 @@
|
|||
with import <nixpkgs> {};
|
||||
let
|
||||
tf = terraform.withPlugins(p: with p; [
|
||||
external
|
||||
google
|
||||
p.null
|
||||
random
|
||||
]);
|
||||
# https://github.com/NixOS/nixpkgs/pull/51579
|
||||
terraform-docs = callPackage ./nix/terraform-docs {};
|
||||
in
|
||||
mkShell {
|
||||
buildInputs = [
|
||||
tf
|
||||
terraform-docs
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
NIX_PATH=nixpkgs=channel:nixos-18.09
|
||||
'';
|
||||
}
|
|
@ -1,201 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -1,113 +0,0 @@
|
|||
# terraform-nixos
|
||||
|
||||
[](https://builtwithnix.org)
|
||||
|
||||
This repository contains a set of Terraform Modules designed to deploy NixOS
|
||||
machines. These modules are designed to work together and support different
|
||||
deployment scenarios.
|
||||
|
||||
## What is Terraform?
|
||||
|
||||
[Terraform][terraform] is a tool that allows to declare infrastructures as
|
||||
code.
|
||||
|
||||
## What is Nix, nixpkgs and NixOS?
|
||||
|
||||
[Nix][nix] is a build system and package manager that allows to manage whole
|
||||
system configurations as code. nixpkgs is a set of 20k+ packages built with
|
||||
Nix. NixOS is a Linux distribution built on top of nixpkgs.
|
||||
|
||||
## What is a Terraform Module?
|
||||
|
||||
A Terraform Module refers to a self-contained package of Terraform
|
||||
configurations that are managed as a group. This repo contains a collection of
|
||||
Terraform Modules which can be composed together to create useful
|
||||
infrastructure patterns.
|
||||
|
||||
## Terraform + Nix vs NixOps
|
||||
|
||||
NixOps is a great tool for personal deployments. It handles a lot of things
|
||||
like cloud resource creation, machine NixOS bootstrapping and deployment.
|
||||
|
||||
The difficulty is when the cloud resources are not supported by NixOps. It
|
||||
takes a lot of work to map all the cloud APIs. Compared to NixOps, Terraform
|
||||
has become an industry standard and has thousands of people contributing new
|
||||
cloud API mapping all the time.
|
||||
|
||||
Another issue is when sharing the configuration as code with multiple
|
||||
developers. Both NixOps and Terraform maintain a state file of "known applied"
|
||||
configuration. Unlike NixOps, Terraform provides facilities to sync and lock
|
||||
the state file so it's available by other users.
|
||||
|
||||
The approach here is to use Terraform to create all the cloud resources. By
|
||||
using the `google_image_nixos_custom` module it's possible to pre-build images in
|
||||
auto-scaling scenarios. Or use a push model similar to NixOps with the generic
|
||||
`deploy_nixos` module.
|
||||
|
||||
So overall Terraform + Nix is more flexible and scales better. But it's also
|
||||
more cumbersome to use as it requires to learn two languages instead of one
|
||||
and the integration between both is also a bit clunky.
|
||||
|
||||
## Terraform Modules
|
||||
|
||||
The list of modules provided by this project:
|
||||
|
||||
* [deploy_nixos](deploy_nixos#readme) - deploy NixOS onto running NixOS
|
||||
machines
|
||||
* [google_image_nixos](google_image_nixos#readme) - setup an official GCE
|
||||
image into a Google Cloud Project.
|
||||
* [google_image_nixos_custom](google_image_nixos_custom#readme) - build and
|
||||
deploy a custom GCE image into a Google Cloud Project
|
||||
|
||||
## Using these modules from your terraform configuration
|
||||
|
||||
Terraform supports importing [modules](https://www.terraform.io/docs/configuration/modules.html) directly [from a GitHub repository](https://www.terraform.io/docs/modules/sources.html#github).
|
||||
|
||||
For example, to use the [`deploy_nixos`](deploy_nixos#readme) module:
|
||||
|
||||
```
|
||||
module "deploy_nixos" {
|
||||
source = "github.com/tweag/terraform-nixos//deploy_nixos?ref=ced68729b6a0382dda02401c8f663c9b29c29368"
|
||||
|
||||
… module-specific fields …
|
||||
}
|
||||
```
|
||||
|
||||
Beware the double `//`, which separates the github repository url from the
|
||||
subdirectory that contains the module. `?ref=` specifies a specific git ref
|
||||
of the repository, in this case the commit `ced687…`.
|
||||
|
||||
## Examples
|
||||
|
||||
To better understand how these modules can be used together, look into the
|
||||
[./examples](examples) folder.
|
||||
|
||||
## Related projects
|
||||
|
||||
* [terraform-provider-nix](https://github.com/andrewchambers/terraform-provider-nix)
|
||||
|
||||
## Future
|
||||
|
||||
* Support other cloud providers.
|
||||
* Support nixos-infect bootstrapping method.
|
||||
|
||||
Contributions are welcome!
|
||||
|
||||
## Thanks
|
||||
|
||||
Thanks to [Digital Asset][digital-asset] for generously sponsoring this work!
|
||||
|
||||
Thanks to [Tweag][tweag] for enabling this work and the continuous support!
|
||||
|
||||
## License
|
||||
|
||||
This code is released under the Apache 2.0 License. Please see
|
||||
[LICENSE](LICENSE) for more details.
|
||||
|
||||
Copyright © 2018 Tweag I/O.
|
||||
|
||||
|
||||
[digital-asset]: https://www.digitalasset.com/
|
||||
[nix]: https://nixos.org/nix/
|
||||
[terraform]: https://www.terraform.io
|
||||
[tweag]: https://www.tweag.io/
|
|
@ -1,46 +0,0 @@
|
|||
# AWS Collection of NixOS AMIs
|
||||
|
||||
This terraform module provides links to official NixOS AMIs on AWS. The AMIs are
|
||||
released by the NixOS project.
|
||||
|
||||
Since image names are unique, only one instance per version of the module is
|
||||
supported.
|
||||
|
||||
## Example
|
||||
|
||||
provider "aws" {
|
||||
region = "eu-west-1"
|
||||
}
|
||||
|
||||
module "nixos_image_1903" {
|
||||
source = "path/to/aws_image_nixos"
|
||||
release = "19.03"
|
||||
}
|
||||
|
||||
resource "aws_instance" "example" {
|
||||
ami = module.nixos_image_1903.ami
|
||||
instance_type = "t2.micro"
|
||||
|
||||
...
|
||||
}
|
||||
|
||||
## New NixOS releases
|
||||
|
||||
Run the `./update-url-map` script to fetch new image releases.
|
||||
|
||||
<!-- terraform-docs-start -->
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|:----:|:-----:|:-----:|
|
||||
| region | The region to use. If not provided, current provider's region will be used. | string | `` | no |
|
||||
| release | The NixOS version to use. For example, 18.09 | string | `latest` | no |
|
||||
| type | The type of the AMI to use -- hvm-ebs, pv-ebs, or pv-s3. | string | `hvm-ebs` | no |
|
||||
| url\_map | A map of release series to actual releases | map | `<map>` | no |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| ami | NixOS AMI on AWS |
|
||||
<!-- terraform-docs-end -->
|
|
@ -1,34 +0,0 @@
|
|||
variable "release" {
|
||||
type = string
|
||||
default = "latest"
|
||||
description = "The NixOS version to use. For example, 18.09"
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "The region to use. If not provided, current provider's region will be used."
|
||||
}
|
||||
|
||||
variable "type" {
|
||||
type = string
|
||||
default = "hvm-ebs"
|
||||
description = "The type of the AMI to use -- hvm-ebs, pv-ebs, or pv-s3."
|
||||
}
|
||||
|
||||
# ---
|
||||
|
||||
data "aws_region" "current" {}
|
||||
|
||||
locals {
|
||||
key = "${var.release}.${coalesce(var.region, data.aws_region.current.name)}.${var.type}"
|
||||
ami = var.url_map[local.key]
|
||||
}
|
||||
|
||||
# ---
|
||||
|
||||
output "ami" {
|
||||
description = "NixOS AMI on AWS"
|
||||
value = local.ami
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -p python3 -i python
|
||||
# vim: ft=python
|
||||
#
|
||||
# Run this script to update the list of EC2 images
|
||||
#
|
||||
import json
|
||||
import io
|
||||
from subprocess import check_output
|
||||
from textwrap import dedent
|
||||
from os import putenv
|
||||
|
||||
putenv('NIX_PATH', 'nixpkgs=channel:nixpkgs-unstable')
|
||||
|
||||
def render_tf():
|
||||
nix_eval = check_output(['nix-instantiate', '--json', '--strict', '--eval', './url_map.nix'])
|
||||
url_map = json.loads(nix_eval)
|
||||
|
||||
out = io.StringIO()
|
||||
out.write(dedent("""\
|
||||
# DON'T EDIT, run '%s' instead
|
||||
variable "url_map" {
|
||||
type = map(string)
|
||||
|
||||
default = {
|
||||
""" % __file__))
|
||||
|
||||
for version, regions in url_map.items():
|
||||
for region, kinds in regions.items():
|
||||
for kind, ami in kinds.items():
|
||||
out.write(' "%s.%s.%s" = "%s"\n' % (version, region, kind, ami))
|
||||
|
||||
out.write(dedent("""\
|
||||
}
|
||||
|
||||
description = "A map of release series to actual releases"
|
||||
}
|
||||
"""))
|
||||
|
||||
return out.getvalue()
|
||||
|
||||
url_map_tf = render_tf()
|
||||
|
||||
with open("url_map.tf", "w") as f:
|
||||
f.write(url_map_tf)
|
||||
|
||||
print(url_map_tf)
|
||||
|
||||
# Local Variables:
|
||||
# mode: Python
|
||||
# End:
|
|
@ -1,2 +0,0 @@
|
|||
# Indirect link to where the image map is stored
|
||||
import <nixpkgs/nixos/modules/virtualisation/ec2-amis.nix>
|
|
@ -1,353 +0,0 @@
|
|||
# DON'T EDIT, run './update-url-map' instead
|
||||
variable "url_map" {
|
||||
type = map(string)
|
||||
|
||||
default = {
|
||||
"14.04.ap-northeast-1.hvm-ebs" = "ami-71c6f470"
|
||||
"14.04.ap-northeast-1.pv-ebs" = "ami-4dcbf84c"
|
||||
"14.04.ap-northeast-1.pv-s3" = "ami-8fc4f68e"
|
||||
"14.04.ap-southeast-1.hvm-ebs" = "ami-da280888"
|
||||
"14.04.ap-southeast-1.pv-ebs" = "ami-7a9dbc28"
|
||||
"14.04.ap-southeast-1.pv-s3" = "ami-c4290996"
|
||||
"14.04.ap-southeast-2.hvm-ebs" = "ami-ab523e91"
|
||||
"14.04.ap-southeast-2.pv-ebs" = "ami-6769055d"
|
||||
"14.04.ap-southeast-2.pv-s3" = "ami-15533f2f"
|
||||
"14.04.eu-central-1.hvm-ebs" = "ami-ba0234a7"
|
||||
"14.04.eu-west-1.hvm-ebs" = "ami-96cb63e1"
|
||||
"14.04.eu-west-1.pv-ebs" = "ami-b48c25c3"
|
||||
"14.04.eu-west-1.pv-s3" = "ami-06cd6571"
|
||||
"14.04.sa-east-1.hvm-ebs" = "ami-01b90e1c"
|
||||
"14.04.sa-east-1.pv-ebs" = "ami-69e35474"
|
||||
"14.04.sa-east-1.pv-s3" = "ami-61b90e7c"
|
||||
"14.04.us-east-1.hvm-ebs" = "ami-58ba3a30"
|
||||
"14.04.us-east-1.pv-ebs" = "ami-9e0583f6"
|
||||
"14.04.us-east-1.pv-s3" = "ami-9cbe3ef4"
|
||||
"14.04.us-west-1.hvm-ebs" = "ami-0bc3d74e"
|
||||
"14.04.us-west-1.pv-ebs" = "ami-8b1703ce"
|
||||
"14.04.us-west-1.pv-s3" = "ami-27ccd862"
|
||||
"14.04.us-west-2.hvm-ebs" = "ami-3bf1bf0b"
|
||||
"14.04.us-west-2.pv-ebs" = "ami-259bd515"
|
||||
"14.04.us-west-2.pv-s3" = "ami-07094037"
|
||||
"14.12.ap-northeast-1.hvm-ebs" = "ami-24435f25"
|
||||
"14.12.ap-northeast-1.pv-ebs" = "ami-b0425eb1"
|
||||
"14.12.ap-northeast-1.pv-s3" = "ami-fed3c6ff"
|
||||
"14.12.ap-southeast-1.hvm-ebs" = "ami-6c765d3e"
|
||||
"14.12.ap-southeast-1.pv-ebs" = "ami-6a765d38"
|
||||
"14.12.ap-southeast-1.pv-s3" = "ami-d1bf9183"
|
||||
"14.12.ap-southeast-2.hvm-ebs" = "ami-af86f395"
|
||||
"14.12.ap-southeast-2.pv-ebs" = "ami-b386f389"
|
||||
"14.12.ap-southeast-2.pv-s3" = "ami-69c5ae53"
|
||||
"14.12.eu-central-1.hvm-ebs" = "ami-4a497a57"
|
||||
"14.12.eu-central-1.pv-ebs" = "ami-4c497a51"
|
||||
"14.12.eu-central-1.pv-s3" = "ami-60f2c27d"
|
||||
"14.12.eu-west-1.hvm-ebs" = "ami-d126a5a6"
|
||||
"14.12.eu-west-1.pv-ebs" = "ami-0126a576"
|
||||
"14.12.eu-west-1.pv-s3" = "ami-deda5fa9"
|
||||
"14.12.sa-east-1.hvm-ebs" = "ami-2d239e30"
|
||||
"14.12.sa-east-1.pv-ebs" = "ami-35239e28"
|
||||
"14.12.sa-east-1.pv-s3" = "ami-81e3519c"
|
||||
"14.12.us-east-1.hvm-ebs" = "ami-0c463a64"
|
||||
"14.12.us-east-1.pv-ebs" = "ami-ac473bc4"
|
||||
"14.12.us-east-1.pv-s3" = "ami-00e18a68"
|
||||
"14.12.us-west-1.hvm-ebs" = "ami-ca534a8f"
|
||||
"14.12.us-west-1.pv-ebs" = "ami-3e534a7b"
|
||||
"14.12.us-west-1.pv-s3" = "ami-2905196c"
|
||||
"14.12.us-west-2.hvm-ebs" = "ami-fb9dc3cb"
|
||||
"14.12.us-west-2.pv-ebs" = "ami-899dc3b9"
|
||||
"14.12.us-west-2.pv-s3" = "ami-cb7f2dfb"
|
||||
"15.09.ap-northeast-1.hvm-ebs" = "ami-58cac236"
|
||||
"15.09.ap-northeast-1.hvm-s3" = "ami-39c8c057"
|
||||
"15.09.ap-northeast-1.pv-ebs" = "ami-5ac9c134"
|
||||
"15.09.ap-northeast-1.pv-s3" = "ami-03cec66d"
|
||||
"15.09.ap-southeast-1.hvm-ebs" = "ami-2fc2094c"
|
||||
"15.09.ap-southeast-1.hvm-s3" = "ami-9ec308fd"
|
||||
"15.09.ap-southeast-1.pv-ebs" = "ami-95c00bf6"
|
||||
"15.09.ap-southeast-1.pv-s3" = "ami-bfc00bdc"
|
||||
"15.09.ap-southeast-2.hvm-ebs" = "ami-996c4cfa"
|
||||
"15.09.ap-southeast-2.hvm-s3" = "ami-3f6e4e5c"
|
||||
"15.09.ap-southeast-2.pv-ebs" = "ami-066d4d65"
|
||||
"15.09.ap-southeast-2.pv-s3" = "ami-cc6e4eaf"
|
||||
"15.09.eu-central-1.hvm-ebs" = "ami-3f8c6b50"
|
||||
"15.09.eu-central-1.hvm-s3" = "ami-5b836434"
|
||||
"15.09.eu-central-1.pv-ebs" = "ami-118c6b7e"
|
||||
"15.09.eu-central-1.pv-s3" = "ami-2c977043"
|
||||
"15.09.eu-west-1.hvm-ebs" = "ami-9cf04aef"
|
||||
"15.09.eu-west-1.hvm-s3" = "ami-2bea5058"
|
||||
"15.09.eu-west-1.pv-ebs" = "ami-c9e852ba"
|
||||
"15.09.eu-west-1.pv-s3" = "ami-c6f64cb5"
|
||||
"15.09.sa-east-1.hvm-ebs" = "ami-6e52df02"
|
||||
"15.09.sa-east-1.hvm-s3" = "ami-1852df74"
|
||||
"15.09.sa-east-1.pv-ebs" = "ami-4368e52f"
|
||||
"15.09.sa-east-1.pv-s3" = "ami-f15ad79d"
|
||||
"15.09.us-east-1.hvm-ebs" = "ami-84a6a0ee"
|
||||
"15.09.us-east-1.hvm-s3" = "ami-06a7a16c"
|
||||
"15.09.us-east-1.pv-ebs" = "ami-a4a1a7ce"
|
||||
"15.09.us-east-1.pv-s3" = "ami-5ba8ae31"
|
||||
"15.09.us-west-1.hvm-ebs" = "ami-22c8bb42"
|
||||
"15.09.us-west-1.hvm-s3" = "ami-a2ccbfc2"
|
||||
"15.09.us-west-1.pv-ebs" = "ami-10cebd70"
|
||||
"15.09.us-west-1.pv-s3" = "ami-fa30429a"
|
||||
"15.09.us-west-2.hvm-ebs" = "ami-ce57b9ae"
|
||||
"15.09.us-west-2.hvm-s3" = "ami-2956b849"
|
||||
"15.09.us-west-2.pv-ebs" = "ami-005fb160"
|
||||
"15.09.us-west-2.pv-s3" = "ami-cd55bbad"
|
||||
"16.03.ap-northeast-1.hvm-ebs" = "ami-40619d21"
|
||||
"16.03.ap-northeast-1.hvm-s3" = "ami-ce629eaf"
|
||||
"16.03.ap-northeast-1.pv-ebs" = "ami-ef639f8e"
|
||||
"16.03.ap-northeast-1.pv-s3" = "ami-a1609cc0"
|
||||
"16.03.ap-northeast-2.hvm-ebs" = "ami-deca00b0"
|
||||
"16.03.ap-northeast-2.hvm-s3" = "ami-a3b77dcd"
|
||||
"16.03.ap-northeast-2.pv-ebs" = "ami-7bcb0115"
|
||||
"16.03.ap-northeast-2.pv-s3" = "ami-a2b77dcc"
|
||||
"16.03.ap-south-1.hvm-ebs" = "ami-0dff9562"
|
||||
"16.03.ap-south-1.hvm-s3" = "ami-13f69c7c"
|
||||
"16.03.ap-south-1.pv-ebs" = "ami-0ef39961"
|
||||
"16.03.ap-south-1.pv-s3" = "ami-e0c8a28f"
|
||||
"16.03.ap-southeast-1.hvm-ebs" = "ami-5e964a3d"
|
||||
"16.03.ap-southeast-1.hvm-s3" = "ami-4d964a2e"
|
||||
"16.03.ap-southeast-1.pv-ebs" = "ami-ec9b478f"
|
||||
"16.03.ap-southeast-1.pv-s3" = "ami-999b47fa"
|
||||
"16.03.ap-southeast-2.hvm-ebs" = "ami-9f7359fc"
|
||||
"16.03.ap-southeast-2.hvm-s3" = "ami-987359fb"
|
||||
"16.03.ap-southeast-2.pv-ebs" = "ami-a2705ac1"
|
||||
"16.03.ap-southeast-2.pv-s3" = "ami-a3705ac0"
|
||||
"16.03.eu-central-1.hvm-ebs" = "ami-17a45178"
|
||||
"16.03.eu-central-1.hvm-s3" = "ami-f9a55096"
|
||||
"16.03.eu-central-1.pv-ebs" = "ami-c8a550a7"
|
||||
"16.03.eu-central-1.pv-s3" = "ami-6ea45101"
|
||||
"16.03.eu-west-1.hvm-ebs" = "ami-b5b3d5c6"
|
||||
"16.03.eu-west-1.hvm-s3" = "ami-c986e0ba"
|
||||
"16.03.eu-west-1.pv-ebs" = "ami-b083e5c3"
|
||||
"16.03.eu-west-1.pv-s3" = "ami-3c83e54f"
|
||||
"16.03.sa-east-1.hvm-ebs" = "ami-f6eb7f9a"
|
||||
"16.03.sa-east-1.hvm-s3" = "ami-93e773ff"
|
||||
"16.03.sa-east-1.pv-ebs" = "ami-cbb82ca7"
|
||||
"16.03.sa-east-1.pv-s3" = "ami-abb82cc7"
|
||||
"16.03.us-east-1.hvm-ebs" = "ami-c123a3d6"
|
||||
"16.03.us-east-1.hvm-s3" = "ami-bc25a5ab"
|
||||
"16.03.us-east-1.pv-ebs" = "ami-bd25a5aa"
|
||||
"16.03.us-east-1.pv-s3" = "ami-a325a5b4"
|
||||
"16.03.us-west-1.hvm-ebs" = "ami-748bcd14"
|
||||
"16.03.us-west-1.hvm-s3" = "ami-a68dcbc6"
|
||||
"16.03.us-west-1.pv-ebs" = "ami-048acc64"
|
||||
"16.03.us-west-1.pv-s3" = "ami-208dcb40"
|
||||
"16.03.us-west-2.hvm-ebs" = "ami-8263a0e2"
|
||||
"16.03.us-west-2.hvm-s3" = "ami-925c9ff2"
|
||||
"16.03.us-west-2.pv-ebs" = "ami-5e61a23e"
|
||||
"16.03.us-west-2.pv-s3" = "ami-734c8f13"
|
||||
"16.09.ap-northeast-1.hvm-ebs" = "ami-68453b0f"
|
||||
"16.09.ap-northeast-1.hvm-s3" = "ami-f9bec09e"
|
||||
"16.09.ap-northeast-1.pv-ebs" = "ami-254a3442"
|
||||
"16.09.ap-northeast-1.pv-s3" = "ami-ef473988"
|
||||
"16.09.ap-northeast-2.hvm-ebs" = "ami-18ae7f76"
|
||||
"16.09.ap-northeast-2.hvm-s3" = "ami-9eac7df0"
|
||||
"16.09.ap-northeast-2.pv-ebs" = "ami-57aa7b39"
|
||||
"16.09.ap-northeast-2.pv-s3" = "ami-5cae7f32"
|
||||
"16.09.ap-south-1.hvm-ebs" = "ami-b3f98fdc"
|
||||
"16.09.ap-south-1.hvm-s3" = "ami-98e690f7"
|
||||
"16.09.ap-south-1.pv-ebs" = "ami-aef98fc1"
|
||||
"16.09.ap-south-1.pv-s3" = "ami-caf88ea5"
|
||||
"16.09.ap-southeast-1.hvm-ebs" = "ami-80fb51e3"
|
||||
"16.09.ap-southeast-1.hvm-s3" = "ami-2df3594e"
|
||||
"16.09.ap-southeast-1.pv-ebs" = "ami-37f05a54"
|
||||
"16.09.ap-southeast-1.pv-s3" = "ami-27f35944"
|
||||
"16.09.ap-southeast-2.hvm-ebs" = "ami-57ece834"
|
||||
"16.09.ap-southeast-2.hvm-s3" = "ami-87f4f0e4"
|
||||
"16.09.ap-southeast-2.pv-ebs" = "ami-d8ede9bb"
|
||||
"16.09.ap-southeast-2.pv-s3" = "ami-a6ebefc5"
|
||||
"16.09.ca-central-1.hvm-ebs" = "ami-9f863bfb"
|
||||
"16.09.ca-central-1.hvm-s3" = "ami-ea85388e"
|
||||
"16.09.ca-central-1.pv-ebs" = "ami-ce8a37aa"
|
||||
"16.09.ca-central-1.pv-s3" = "ami-448a3720"
|
||||
"16.09.eu-central-1.hvm-ebs" = "ami-1b884774"
|
||||
"16.09.eu-central-1.hvm-s3" = "ami-b08c43df"
|
||||
"16.09.eu-central-1.pv-ebs" = "ami-888946e7"
|
||||
"16.09.eu-central-1.pv-s3" = "ami-06874869"
|
||||
"16.09.eu-west-1.hvm-ebs" = "ami-1ed3e76d"
|
||||
"16.09.eu-west-1.hvm-s3" = "ami-73d1e500"
|
||||
"16.09.eu-west-1.pv-ebs" = "ami-44c0f437"
|
||||
"16.09.eu-west-1.pv-s3" = "ami-f3d8ec80"
|
||||
"16.09.eu-west-2.hvm-ebs" = "ami-2c9c9648"
|
||||
"16.09.eu-west-2.hvm-s3" = "ami-6b9e940f"
|
||||
"16.09.eu-west-2.pv-ebs" = "ami-f1999395"
|
||||
"16.09.eu-west-2.pv-s3" = "ami-bb9f95df"
|
||||
"16.09.sa-east-1.hvm-ebs" = "ami-a11882cd"
|
||||
"16.09.sa-east-1.hvm-s3" = "ami-7726bc1b"
|
||||
"16.09.sa-east-1.pv-ebs" = "ami-9725bffb"
|
||||
"16.09.sa-east-1.pv-s3" = "ami-b027bddc"
|
||||
"16.09.us-east-1.hvm-ebs" = "ami-854ca593"
|
||||
"16.09.us-east-1.hvm-s3" = "ami-2241a834"
|
||||
"16.09.us-east-1.pv-ebs" = "ami-a441a8b2"
|
||||
"16.09.us-east-1.pv-s3" = "ami-e841a8fe"
|
||||
"16.09.us-east-2.hvm-ebs" = "ami-3f41645a"
|
||||
"16.09.us-east-2.hvm-s3" = "ami-804065e5"
|
||||
"16.09.us-east-2.pv-ebs" = "ami-f1466394"
|
||||
"16.09.us-east-2.pv-s3" = "ami-05426760"
|
||||
"16.09.us-west-1.hvm-ebs" = "ami-c2efbca2"
|
||||
"16.09.us-west-1.hvm-s3" = "ami-d71042b7"
|
||||
"16.09.us-west-1.pv-ebs" = "ami-04e8bb64"
|
||||
"16.09.us-west-1.pv-s3" = "ami-31e9ba51"
|
||||
"16.09.us-west-2.hvm-ebs" = "ami-6449f504"
|
||||
"16.09.us-west-2.hvm-s3" = "ami-344af654"
|
||||
"16.09.us-west-2.pv-ebs" = "ami-6d4af60d"
|
||||
"16.09.us-west-2.pv-s3" = "ami-de48f4be"
|
||||
"17.03.ap-northeast-1.hvm-ebs" = "ami-dbd0f7bc"
|
||||
"17.03.ap-northeast-1.hvm-s3" = "ami-7cdff81b"
|
||||
"17.03.ap-northeast-2.hvm-ebs" = "ami-c59a48ab"
|
||||
"17.03.ap-northeast-2.hvm-s3" = "ami-0b944665"
|
||||
"17.03.ap-south-1.hvm-ebs" = "ami-4f413220"
|
||||
"17.03.ap-south-1.hvm-s3" = "ami-864033e9"
|
||||
"17.03.ap-southeast-1.hvm-ebs" = "ami-e08c3383"
|
||||
"17.03.ap-southeast-1.hvm-s3" = "ami-c28f30a1"
|
||||
"17.03.ap-southeast-2.hvm-ebs" = "ami-fca9a69f"
|
||||
"17.03.ap-southeast-2.hvm-s3" = "ami-3daaa55e"
|
||||
"17.03.ca-central-1.hvm-ebs" = "ami-9b00bdff"
|
||||
"17.03.ca-central-1.hvm-s3" = "ami-e800bd8c"
|
||||
"17.03.eu-central-1.hvm-ebs" = "ami-5450803b"
|
||||
"17.03.eu-central-1.hvm-s3" = "ami-6e2efe01"
|
||||
"17.03.eu-west-1.hvm-ebs" = "ami-10754c76"
|
||||
"17.03.eu-west-1.hvm-s3" = "ami-11734a77"
|
||||
"17.03.eu-west-2.hvm-ebs" = "ami-ff1d099b"
|
||||
"17.03.eu-west-2.hvm-s3" = "ami-fe1d099a"
|
||||
"17.03.sa-east-1.hvm-ebs" = "ami-d95d3eb5"
|
||||
"17.03.sa-east-1.hvm-s3" = "ami-fca2c190"
|
||||
"17.03.us-east-1.hvm-ebs" = "ami-0940c61f"
|
||||
"17.03.us-east-1.hvm-s3" = "ami-674fc971"
|
||||
"17.03.us-east-2.hvm-ebs" = "ami-afc2e6ca"
|
||||
"17.03.us-east-2.hvm-s3" = "ami-a1cde9c4"
|
||||
"17.03.us-west-1.hvm-ebs" = "ami-587b2138"
|
||||
"17.03.us-west-1.hvm-s3" = "ami-70411b10"
|
||||
"17.03.us-west-2.hvm-ebs" = "ami-a93daac9"
|
||||
"17.03.us-west-2.hvm-s3" = "ami-5139ae31"
|
||||
"17.09.ap-northeast-1.hvm-ebs" = "ami-89b921ef"
|
||||
"17.09.ap-northeast-2.hvm-ebs" = "ami-179b3b79"
|
||||
"17.09.ap-south-1.hvm-ebs" = "ami-4e376021"
|
||||
"17.09.ap-southeast-1.hvm-ebs" = "ami-84bccff8"
|
||||
"17.09.ap-southeast-2.hvm-ebs" = "ami-0dc5386f"
|
||||
"17.09.ca-central-1.hvm-ebs" = "ami-ca8207ae"
|
||||
"17.09.eu-central-1.hvm-ebs" = "ami-266cfe49"
|
||||
"17.09.eu-west-1.hvm-ebs" = "ami-a30192da"
|
||||
"17.09.eu-west-2.hvm-ebs" = "ami-295a414d"
|
||||
"17.09.eu-west-3.hvm-ebs" = "ami-8c0eb9f1"
|
||||
"17.09.sa-east-1.hvm-ebs" = "ami-4762202b"
|
||||
"17.09.us-east-1.hvm-ebs" = "ami-40bee63a"
|
||||
"17.09.us-east-2.hvm-ebs" = "ami-9d84aff8"
|
||||
"17.09.us-west-1.hvm-ebs" = "ami-d14142b1"
|
||||
"17.09.us-west-2.hvm-ebs" = "ami-3eb40346"
|
||||
"18.03.ap-northeast-1.hvm-ebs" = "ami-456511a8"
|
||||
"18.03.ap-northeast-2.hvm-ebs" = "ami-3366d15d"
|
||||
"18.03.ap-south-1.hvm-ebs" = "ami-6a390b05"
|
||||
"18.03.ap-southeast-1.hvm-ebs" = "ami-aa0b4d40"
|
||||
"18.03.ap-southeast-2.hvm-ebs" = "ami-d0f254b2"
|
||||
"18.03.ca-central-1.hvm-ebs" = "ami-aca72ac8"
|
||||
"18.03.eu-central-1.hvm-ebs" = "ami-09faf9e2"
|
||||
"18.03.eu-west-1.hvm-ebs" = "ami-065c46ec"
|
||||
"18.03.eu-west-2.hvm-ebs" = "ami-64f31903"
|
||||
"18.03.eu-west-3.hvm-ebs" = "ami-5a8d3d27"
|
||||
"18.03.sa-east-1.hvm-ebs" = "ami-163e1f7a"
|
||||
"18.03.us-east-1.hvm-ebs" = "ami-8b3538f4"
|
||||
"18.03.us-east-2.hvm-ebs" = "ami-150b3170"
|
||||
"18.03.us-west-1.hvm-ebs" = "ami-ce06ebad"
|
||||
"18.03.us-west-2.hvm-ebs" = "ami-586c3520"
|
||||
"18.09.ap-northeast-1.hvm-ebs" = "ami-0cdba8e998f076547"
|
||||
"18.09.ap-northeast-2.hvm-ebs" = "ami-0400a698e6a9f4a15"
|
||||
"18.09.ap-south-1.hvm-ebs" = "ami-0880a678d3f555313"
|
||||
"18.09.ap-southeast-1.hvm-ebs" = "ami-0892c7e24ebf2194f"
|
||||
"18.09.ap-southeast-2.hvm-ebs" = "ami-010730f36424b0a2c"
|
||||
"18.09.ca-central-1.hvm-ebs" = "ami-04f66113f76198f6c"
|
||||
"18.09.eu-central-1.hvm-ebs" = "ami-07c9b884e679df4f8"
|
||||
"18.09.eu-west-1.hvm-ebs" = "ami-0f412186fb8a0ec97"
|
||||
"18.09.eu-west-2.hvm-ebs" = "ami-0dada3805ce43c55e"
|
||||
"18.09.eu-west-3.hvm-ebs" = "ami-074df85565f2e02e2"
|
||||
"18.09.sa-east-1.hvm-ebs" = "ami-0e4a8a47fd6db6112"
|
||||
"18.09.us-east-1.hvm-ebs" = "ami-009c9c3f1af480ff3"
|
||||
"18.09.us-east-2.hvm-ebs" = "ami-08199961085ea8bc6"
|
||||
"18.09.us-west-1.hvm-ebs" = "ami-07aa7f56d612ddd38"
|
||||
"18.09.us-west-2.hvm-ebs" = "ami-01c84b7c368ac24d1"
|
||||
"19.03.ap-northeast-1.hvm-ebs" = "ami-00db62688900456a4"
|
||||
"19.03.ap-northeast-2.hvm-ebs" = "ami-0485cdd1a5fdd2117"
|
||||
"19.03.ap-south-1.hvm-ebs" = "ami-0303deb1b5890f878"
|
||||
"19.03.ap-southeast-1.hvm-ebs" = "ami-0cff66114c652c262"
|
||||
"19.03.ap-southeast-2.hvm-ebs" = "ami-054c73a7f8d773ea9"
|
||||
"19.03.ca-central-1.hvm-ebs" = "ami-03f9fd0ef2e035ede"
|
||||
"19.03.eu-central-1.hvm-ebs" = "ami-0022b8ea9efde5de4"
|
||||
"19.03.eu-west-1.hvm-ebs" = "ami-0fe40176548ff0940"
|
||||
"19.03.eu-west-2.hvm-ebs" = "ami-03a40fd3a02fe95ba"
|
||||
"19.03.eu-west-3.hvm-ebs" = "ami-0436f9da0f20a638e"
|
||||
"19.03.sa-east-1.hvm-ebs" = "ami-0c6a43c6e0ad1f4e2"
|
||||
"19.03.us-east-1.hvm-ebs" = "ami-0efc58fb70ae9a217"
|
||||
"19.03.us-east-2.hvm-ebs" = "ami-0abf711b1b34da1af"
|
||||
"19.03.us-west-1.hvm-ebs" = "ami-07d126e8838c40ec5"
|
||||
"19.03.us-west-2.hvm-ebs" = "ami-03f8a737546e47fb0"
|
||||
"19.09.ap-east-1.hvm-ebs" = "ami-055b2348db2827ff1"
|
||||
"19.09.ap-northeast-1.hvm-ebs" = "ami-02a62555ca182fb5b"
|
||||
"19.09.ap-northeast-2.hvm-ebs" = "ami-0219dde0e6b7b7b93"
|
||||
"19.09.ap-south-1.hvm-ebs" = "ami-066f7f2a895c821a1"
|
||||
"19.09.ap-southeast-1.hvm-ebs" = "ami-0f71ae5d4b0b78d95"
|
||||
"19.09.ap-southeast-2.hvm-ebs" = "ami-057bbf2b4bd62d210"
|
||||
"19.09.ca-central-1.hvm-ebs" = "ami-07df50fc76702a36d"
|
||||
"19.09.eu-central-1.hvm-ebs" = "ami-015f8efc2be419b79"
|
||||
"19.09.eu-north-1.hvm-ebs" = "ami-07fc0a32d885e01ed"
|
||||
"19.09.eu-west-1.hvm-ebs" = "ami-071082f0fa035374f"
|
||||
"19.09.eu-west-2.hvm-ebs" = "ami-0d9dc33c54d1dc4c3"
|
||||
"19.09.eu-west-3.hvm-ebs" = "ami-09566799591d1bfed"
|
||||
"19.09.sa-east-1.hvm-ebs" = "ami-018aab68377227e06"
|
||||
"19.09.us-east-1.hvm-ebs" = "ami-03330d8b51287412f"
|
||||
"19.09.us-east-2.hvm-ebs" = "ami-0518b4c84972e967f"
|
||||
"19.09.us-west-1.hvm-ebs" = "ami-06ad07e61a353b4a6"
|
||||
"19.09.us-west-2.hvm-ebs" = "ami-0e31e30925cf3ce4e"
|
||||
"20.03.ap-east-1.hvm-ebs" = "ami-0d18fdd309cdefa86"
|
||||
"20.03.ap-northeast-1.hvm-ebs" = "ami-093d9cc49c191eb6c"
|
||||
"20.03.ap-northeast-2.hvm-ebs" = "ami-0087df91a7b6ebd45"
|
||||
"20.03.ap-south-1.hvm-ebs" = "ami-0a1a6b569af04af9d"
|
||||
"20.03.ap-southeast-1.hvm-ebs" = "ami-0dbf353e168d155f7"
|
||||
"20.03.ap-southeast-2.hvm-ebs" = "ami-04c0f3a75f63daddd"
|
||||
"20.03.ca-central-1.hvm-ebs" = "ami-02365684a173255c7"
|
||||
"20.03.eu-central-1.hvm-ebs" = "ami-0a1a94722dcbff94c"
|
||||
"20.03.eu-north-1.hvm-ebs" = "ami-02699abfacbb6464b"
|
||||
"20.03.eu-west-1.hvm-ebs" = "ami-02c34db5766cc7013"
|
||||
"20.03.eu-west-2.hvm-ebs" = "ami-0e32bd8c7853883f1"
|
||||
"20.03.eu-west-3.hvm-ebs" = "ami-061edb1356c1d69fd"
|
||||
"20.03.sa-east-1.hvm-ebs" = "ami-09859378158ae971d"
|
||||
"20.03.us-east-1.hvm-ebs" = "ami-0c5e7760748b74e85"
|
||||
"20.03.us-east-2.hvm-ebs" = "ami-030296bb256764655"
|
||||
"20.03.us-west-1.hvm-ebs" = "ami-050be818e0266b741"
|
||||
"20.03.us-west-2.hvm-ebs" = "ami-06562f78dca68eda2"
|
||||
"20.09.ap-east-1.hvm-ebs" = "ami-071f49713f86ea965"
|
||||
"20.09.ap-northeast-1.hvm-ebs" = "ami-0beb18d632cf64e5a"
|
||||
"20.09.ap-northeast-2.hvm-ebs" = "ami-0dd0316af578862db"
|
||||
"20.09.ap-south-1.hvm-ebs" = "ami-008d15ced81c88aed"
|
||||
"20.09.ap-southeast-1.hvm-ebs" = "ami-0db0304e23c535b2a"
|
||||
"20.09.ap-southeast-2.hvm-ebs" = "ami-045983c4db7e36447"
|
||||
"20.09.ca-central-1.hvm-ebs" = "ami-06d5ee429f153f856"
|
||||
"20.09.eu-central-1.hvm-ebs" = "ami-01d4a0c2248cbfe38"
|
||||
"20.09.eu-north-1.hvm-ebs" = "ami-0003f54dd99d68e0f"
|
||||
"20.09.eu-west-1.hvm-ebs" = "ami-01a79d5ce435f4db3"
|
||||
"20.09.eu-west-2.hvm-ebs" = "ami-0cbe14f32904e6331"
|
||||
"20.09.eu-west-3.hvm-ebs" = "ami-07f493412d6213de6"
|
||||
"20.09.sa-east-1.hvm-ebs" = "ami-05ded1ae35209b5a8"
|
||||
"20.09.us-east-1.hvm-ebs" = "ami-068a62d478710462d"
|
||||
"20.09.us-east-2.hvm-ebs" = "ami-01ac677ff61399caa"
|
||||
"20.09.us-west-1.hvm-ebs" = "ami-04befdb203b4b17f6"
|
||||
"20.09.us-west-2.hvm-ebs" = "ami-0fb7bd4a43261c6b2"
|
||||
"latest.ap-east-1.hvm-ebs" = "ami-071f49713f86ea965"
|
||||
"latest.ap-northeast-1.hvm-ebs" = "ami-0beb18d632cf64e5a"
|
||||
"latest.ap-northeast-2.hvm-ebs" = "ami-0dd0316af578862db"
|
||||
"latest.ap-south-1.hvm-ebs" = "ami-008d15ced81c88aed"
|
||||
"latest.ap-southeast-1.hvm-ebs" = "ami-0db0304e23c535b2a"
|
||||
"latest.ap-southeast-2.hvm-ebs" = "ami-045983c4db7e36447"
|
||||
"latest.ca-central-1.hvm-ebs" = "ami-06d5ee429f153f856"
|
||||
"latest.eu-central-1.hvm-ebs" = "ami-01d4a0c2248cbfe38"
|
||||
"latest.eu-north-1.hvm-ebs" = "ami-0003f54dd99d68e0f"
|
||||
"latest.eu-west-1.hvm-ebs" = "ami-01a79d5ce435f4db3"
|
||||
"latest.eu-west-2.hvm-ebs" = "ami-0cbe14f32904e6331"
|
||||
"latest.eu-west-3.hvm-ebs" = "ami-07f493412d6213de6"
|
||||
"latest.sa-east-1.hvm-ebs" = "ami-05ded1ae35209b5a8"
|
||||
"latest.us-east-1.hvm-ebs" = "ami-068a62d478710462d"
|
||||
"latest.us-east-2.hvm-ebs" = "ami-01ac677ff61399caa"
|
||||
"latest.us-west-1.hvm-ebs" = "ami-04befdb203b4b17f6"
|
||||
"latest.us-west-2.hvm-ebs" = "ami-0fb7bd4a43261c6b2"
|
||||
}
|
||||
|
||||
description = "A map of release series to actual releases"
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
terraform {
|
||||
required_version = ">= 0.12"
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
# deploy_nixos
|
||||
|
||||
A Terraform module that knows how to deploy NixOS onto a target host.
|
||||
|
||||
This allow to describe an infrastructure as code with Terraform and delegate
|
||||
the machine configuration with NixOS. All directed by Terraform.
|
||||
|
||||
The advantage of this method is that if any of the Nix code changes, the
|
||||
difference will be detected on the next "terraform plan".
|
||||
|
||||
## Usage
|
||||
|
||||
Either pass a "config" which is a dynamic nixos configuration and a
|
||||
"config_pwd", or a "nixos_config", a path to a nixos configuration.nix file.
|
||||
If you have defined your NixOs configuration in a Flake, use "nixos_config"
|
||||
to specify the name of the attribue and set "flake" to true.
|
||||
|
||||
### Secret handling
|
||||
|
||||
Keys can be passed to the "keys" attribute. Each key will be installed under
|
||||
`/var/keys/${key}` with the content as the value.
|
||||
|
||||
For services to access one of the keys, add the service user to the "keys"
|
||||
group.
|
||||
|
||||
The target machine needs `jq` installed prior to the deployment (as part of
|
||||
the base image). If `jq` is not found it will try to use a version from
|
||||
`<nixpkgs>`.
|
||||
|
||||
### Disabling sandboxing
|
||||
|
||||
Unfortunately some time it's required to disable the nix sandboxing. To do so,
|
||||
add `["--option", "sandbox", "false"]` to the "extra_build_args" parameter.
|
||||
|
||||
If that doesn't work, make sure that your user is part of the nix
|
||||
"trusted-users" list.
|
||||
|
||||
### Non-root `target_user`
|
||||
|
||||
It is possible to connect to the target host using a user that is not `root`
|
||||
under certain conditions:
|
||||
|
||||
* sudo needs to be installed on the machine
|
||||
* the user needs password-less sudo access on the machine
|
||||
|
||||
This would typically be provisioned in the base image.
|
||||
|
||||
### Binary cache configuration
|
||||
|
||||
One thing that might be surprising is that the binary caches (aka
|
||||
substituters) are taken from the machine configuration. This implies that the
|
||||
user Nix configuration will be ignored in that regard.
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `bash` 4.0+
|
||||
* `nix`
|
||||
* `openssh`
|
||||
* `readlink` with `-f` (coreutils or busybox)
|
||||
|
||||
## Known limitations
|
||||
|
||||
The deployment machine requires Nix with access to a remote builder with the
|
||||
same system as the target machine.
|
||||
|
||||
Because Nix code is being evaluated at "terraform plan" time, deploying a lot
|
||||
of machine in the same target will require a lot of RAM.
|
||||
|
||||
All the secrets share the same "keys" group.
|
||||
|
||||
When deploying as non-root, it assumes that passwordless `sudo` is available.
|
||||
|
||||
The target host must already have NixOS installed.
|
||||
|
||||
### config including computed values
|
||||
|
||||
The module doesn't work when `<computed>` values from other resources are
|
||||
interpolated with the "config" attribute. Because it happens at evaluation
|
||||
time, terraform will render an empty drvPath.
|
||||
|
||||
see also:
|
||||
* https://github.com/hashicorp/terraform/issues/16380
|
||||
* https://github.com/hashicorp/terraform/issues/16762
|
||||
* https://github.com/hashicorp/terraform/issues/17034
|
||||
|
||||
<!-- terraform-docs-start -->
|
||||
## Requirements
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| terraform | >= 0.12 |
|
||||
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| external | n/a |
|
||||
| null | n/a |
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|:--------:|
|
||||
| NIX\_PATH | Allow to pass custom NIX\_PATH | `string` | `""` | no |
|
||||
| build\_on\_target | Avoid building on the deployer. Must be true or false. Has no effect when deploying from an incompatible system. Unlike remote builders, this does not require the deploying user to be trusted by its host. | `string` | `false` | no |
|
||||
| config | NixOS configuration to be evaluated. This argument is required unless 'nixos\_config' is given | `string` | `""` | no |
|
||||
| config\_pwd | Directory to evaluate the configuration in. This argument is required if 'config' is given | `string` | `""` | no |
|
||||
| extra\_build\_args | List of arguments to pass to the nix builder | `list(string)` | `[]` | no |
|
||||
| extra\_eval\_args | List of arguments to pass to the nix evaluation | `list(string)` | `[]` | no |
|
||||
| hermetic | Treat the provided nixos configuration as a hermetic expression and do not evaluate using the ambient system nixpkgs. Useful if you customize eval-modules or use a pinned nixpkgs. | `bool` | false | no |
|
||||
| flake | Treat the provided nixos_config as the name of the NixOS configuration to use in the flake located in the current directory. Useful if you customize eval-modules or use a pinned nixpkgs. | `bool` | false | no |
|
||||
| keys | A map of filename to content to upload as secrets in /var/keys | `map(string)` | `{}` | no |
|
||||
| nixos\_config | Path to a NixOS configuration | `string` | `""` | no |
|
||||
| ssh\_agent | Whether to use an SSH agent. True if not ssh\_private\_key is passed | `bool` | `null` | no |
|
||||
| ssh\_private\_key | Content of private key used to connect to the target\_host | `string` | `""` | no |
|
||||
| ssh\_private\_key\_file | Path to private key used to connect to the target\_host | `string` | `""` | no |
|
||||
| target\_host | DNS host to deploy to | `string` | n/a | yes |
|
||||
| target\_port | SSH port used to connect to the target\_host | `number` | `22` | no |
|
||||
| target\_system | Nix system string | `string` | `"x86_64-linux"` | no |
|
||||
| target\_user | SSH user used to connect to the target\_host | `string` | `"root"` | no |
|
||||
| triggers | Triggers for deploy | `map(string)` | `{}` | no |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| id | random ID that changes on every nixos deployment |
|
||||
|
||||
<!-- terraform-docs-end -->
|
|
@ -1,221 +0,0 @@
|
|||
variable "target_host" {
|
||||
type = string
|
||||
description = "DNS host to deploy to"
|
||||
}
|
||||
|
||||
variable "target_user" {
|
||||
type = string
|
||||
description = "SSH user used to connect to the target_host"
|
||||
default = "root"
|
||||
}
|
||||
|
||||
variable "target_port" {
|
||||
type = number
|
||||
description = "SSH port used to connect to the target_host"
|
||||
default = 22
|
||||
}
|
||||
|
||||
variable "ssh_private_key" {
|
||||
type = string
|
||||
description = "Content of private key used to connect to the target_host"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "ssh_private_key_file" {
|
||||
type = string
|
||||
description = "Path to private key used to connect to the target_host"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "ssh_agent" {
|
||||
type = bool
|
||||
description = "Whether to use an SSH agent. True if not ssh_private_key is passed"
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "NIX_PATH" {
|
||||
type = string
|
||||
description = "Allow to pass custom NIX_PATH"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "nixos_config" {
|
||||
type = string
|
||||
description = "Path to a NixOS configuration"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "config" {
|
||||
type = string
|
||||
description = "NixOS configuration to be evaluated. This argument is required unless 'nixos_config' is given"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "config_pwd" {
|
||||
type = string
|
||||
description = "Directory to evaluate the configuration in. This argument is required if 'config' is given"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "extra_eval_args" {
|
||||
type = list(string)
|
||||
description = "List of arguments to pass to the nix evaluation"
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "extra_build_args" {
|
||||
type = list(string)
|
||||
description = "List of arguments to pass to the nix builder"
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "build_on_target" {
|
||||
type = string
|
||||
description = "Avoid building on the deployer. Must be true or false. Has no effect when deploying from an incompatible system. Unlike remote builders, this does not require the deploying user to be trusted by its host."
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "triggers" {
|
||||
type = map(string)
|
||||
description = "Triggers for deploy"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "keys" {
|
||||
type = map(string)
|
||||
description = "A map of filename to content to upload as secrets in /var/keys"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "target_system" {
|
||||
type = string
|
||||
description = "Nix system string"
|
||||
default = "x86_64-linux"
|
||||
}
|
||||
|
||||
variable "hermetic" {
|
||||
type = bool
|
||||
description = "Treat the provided nixos configuration as a hermetic expression and do not evaluate using the ambient system nixpkgs. Useful if you customize eval-modules or use a pinned nixpkgs."
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "flake" {
|
||||
type = bool
|
||||
description = "Treat the provided nixos_config as the NixOS configuration to use in the flake located in the current directory"
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "delete_older_than" {
|
||||
type = string
|
||||
description = "Can be a list of generation numbers, the special value old to delete all non-current generations, a value such as 30d to delete all generations older than the specified number of days (except for the generation that was active at that point in time), or a value such as +5 to keep the last 5 generations ignoring any newer than current, e.g., if 30 is the current generation +5 will delete generation 25 and all older generations."
|
||||
default = "+1"
|
||||
}
|
||||
|
||||
variable "deploy_environment" {
|
||||
type = map(string)
|
||||
description = "Extra environment variables to be set during deployment."
|
||||
default = {}
|
||||
}
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
locals {
|
||||
triggers = {
|
||||
deploy_nixos_drv = data.external.nixos-instantiate.result["drv_path"]
|
||||
deploy_nixos_keys = sha256(jsonencode(var.keys))
|
||||
}
|
||||
|
||||
extra_build_args = concat([
|
||||
"--option", "substituters", data.external.nixos-instantiate.result["substituters"],
|
||||
"--option", "trusted-public-keys", data.external.nixos-instantiate.result["trusted-public-keys"],
|
||||
],
|
||||
var.extra_build_args,
|
||||
)
|
||||
ssh_private_key_file = var.ssh_private_key_file == "" ? "-" : var.ssh_private_key_file
|
||||
ssh_private_key = local.ssh_private_key_file == "-" ? var.ssh_private_key : file(local.ssh_private_key_file)
|
||||
ssh_agent = var.ssh_agent == null ? (local.ssh_private_key != "") : var.ssh_agent
|
||||
build_on_target = data.external.nixos-instantiate.result["currentSystem"] != var.target_system ? true : tobool(var.build_on_target)
|
||||
}
|
||||
|
||||
# used to detect changes in the configuration
|
||||
data "external" "nixos-instantiate" {
|
||||
program = concat([
|
||||
"${path.module}/nixos-instantiate.sh",
|
||||
var.NIX_PATH == "" ? "-" : var.NIX_PATH,
|
||||
var.config != "" ? var.config : var.nixos_config,
|
||||
var.config_pwd == "" ? "." : var.config_pwd,
|
||||
var.flake,
|
||||
# end of positional arguments
|
||||
# start of pass-through arguments
|
||||
"--argstr", "system", var.target_system,
|
||||
"--arg", "hermetic", var.hermetic
|
||||
],
|
||||
var.extra_eval_args,
|
||||
)
|
||||
}
|
||||
|
||||
resource "null_resource" "deploy_nixos" {
|
||||
triggers = merge(var.triggers, local.triggers)
|
||||
|
||||
connection {
|
||||
type = "ssh"
|
||||
host = var.target_host
|
||||
port = var.target_port
|
||||
user = var.target_user
|
||||
agent = local.ssh_agent
|
||||
timeout = "100s"
|
||||
private_key = local.ssh_private_key == "-" ? "" : local.ssh_private_key
|
||||
}
|
||||
|
||||
# copy the secret keys to the host
|
||||
provisioner "file" {
|
||||
content = jsonencode(var.keys)
|
||||
destination = "packed-keys.json"
|
||||
}
|
||||
|
||||
# FIXME: move this to nixos-deploy.sh
|
||||
provisioner "file" {
|
||||
source = "${path.module}/unpack-keys.sh"
|
||||
destination = "unpack-keys.sh"
|
||||
}
|
||||
|
||||
# FIXME: move this to nixos-deploy.sh
|
||||
provisioner "file" {
|
||||
source = "${path.module}/maybe-sudo.sh"
|
||||
destination = "maybe-sudo.sh"
|
||||
}
|
||||
|
||||
provisioner "remote-exec" {
|
||||
inline = [
|
||||
"chmod +x unpack-keys.sh maybe-sudo.sh",
|
||||
"./maybe-sudo.sh ./unpack-keys.sh ./packed-keys.json",
|
||||
]
|
||||
}
|
||||
|
||||
# do the actual deployment
|
||||
provisioner "local-exec" {
|
||||
environment = var.deploy_environment
|
||||
interpreter = concat([
|
||||
"${path.module}/nixos-deploy.sh",
|
||||
data.external.nixos-instantiate.result["drv_path"],
|
||||
data.external.nixos-instantiate.result["out_path"],
|
||||
"${var.target_user}@${var.target_host}",
|
||||
var.target_port,
|
||||
local.build_on_target,
|
||||
local.ssh_private_key == "" ? "-" : local.ssh_private_key,
|
||||
"switch",
|
||||
var.delete_older_than,
|
||||
],
|
||||
local.extra_build_args
|
||||
)
|
||||
command = "ignoreme"
|
||||
}
|
||||
}
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
output "id" {
|
||||
description = "random ID that changes on every nixos deployment"
|
||||
value = null_resource.deploy_nixos.id
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Run sudo if required
|
||||
#
|
||||
# Usage: ./maybe-sudo.sh <command> [...args]
|
||||
set -euo pipefail
|
||||
if [[ "$UID" = 0 ]]; then
|
||||
exec -- "$@"
|
||||
else
|
||||
exec sudo -- "$@"
|
||||
fi
|
|
@ -1,133 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# nixos-deploy deploys a nixos-instantiate-generated drvPath to a target host
|
||||
#
|
||||
# Usage: nixos-deploy.sh <drvPath> <host> <switch-action> [<build-opts>] ignoreme
|
||||
set -euo pipefail
|
||||
|
||||
### Defaults ###
|
||||
|
||||
buildArgs=(
|
||||
--option extra-binary-caches https://cache.nixos.org/
|
||||
)
|
||||
profile=/nix/var/nix/profiles/system
|
||||
# will be set later
|
||||
sshOpts=(
|
||||
-o "ControlMaster=auto"
|
||||
-o "ControlPersist=60"
|
||||
# Avoid issues with IP re-use. This disable TOFU security.
|
||||
-o "StrictHostKeyChecking=no"
|
||||
-o "UserKnownHostsFile=/dev/null"
|
||||
-o "GlobalKnownHostsFile=/dev/null"
|
||||
# interactive authentication is not possible
|
||||
-o "BatchMode=yes"
|
||||
# verbose output for easier debugging
|
||||
-v
|
||||
)
|
||||
|
||||
### Argument parsing ###
|
||||
|
||||
drvPath="$1"
|
||||
outPath="$2"
|
||||
targetHost="$3"
|
||||
targetPort="$4"
|
||||
buildOnTarget="$5"
|
||||
sshPrivateKey="$6"
|
||||
action="$7"
|
||||
deleteOlderThan="$8"
|
||||
shift 8
|
||||
|
||||
# remove the last argument
|
||||
set -- "${@:1:$(($# - 1))}"
|
||||
buildArgs+=("$@")
|
||||
|
||||
sshOpts+=( -p "${targetPort}" )
|
||||
|
||||
workDir=$(mktemp -d)
|
||||
trap 'rm -rf "$workDir"' EXIT
|
||||
|
||||
if [[ -n "${sshPrivateKey}" && "${sshPrivateKey}" != "-" ]]; then
|
||||
sshPrivateKeyFile="$workDir/ssh_key"
|
||||
echo "$sshPrivateKey" > "$sshPrivateKeyFile"
|
||||
chmod 0700 "$sshPrivateKeyFile"
|
||||
sshOpts+=( -o "IdentityFile=${sshPrivateKeyFile}" )
|
||||
fi
|
||||
|
||||
### Functions ###
|
||||
|
||||
log() {
|
||||
echo "--- $*" >&2
|
||||
}
|
||||
|
||||
copyToTarget() {
|
||||
NIX_SSHOPTS="${sshOpts[*]}" nix-copy-closure --to "$targetHost" "$@"
|
||||
}
|
||||
|
||||
# assumes that passwordless sudo is enabled on the server
|
||||
targetHostCmd() {
|
||||
# ${*@Q} escapes the arguments losslessly into space-separted quoted strings.
|
||||
# `ssh` did not properly maintain the array nature of the command line,
|
||||
# erroneously splitting arguments with internal spaces, even when using `--`.
|
||||
# Tested with OpenSSH_7.9p1.
|
||||
#
|
||||
# shellcheck disable=SC2029
|
||||
ssh "${sshOpts[@]}" "$targetHost" "./maybe-sudo.sh ${*@Q}"
|
||||
}
|
||||
|
||||
# Setup a temporary ControlPath for this session. This speeds-up the
|
||||
# operations by not re-creating SSH sessions between each command. At the end
|
||||
# of the run, the session is forcefully terminated.
|
||||
setupControlPath() {
|
||||
sshOpts+=(
|
||||
-o "ControlPath=$workDir/ssh_control"
|
||||
)
|
||||
cleanupControlPath() {
|
||||
local ret=$?
|
||||
# Avoid failing during the shutdown
|
||||
set +e
|
||||
# Close ssh multiplex-master process gracefully
|
||||
log "closing persistent ssh-connection"
|
||||
ssh "${sshOpts[@]}" -O stop "$targetHost"
|
||||
rm -rf "$workDir"
|
||||
exit "$ret"
|
||||
}
|
||||
trap cleanupControlPath EXIT
|
||||
}
|
||||
|
||||
### Main ###
|
||||
|
||||
setupControlPath
|
||||
|
||||
if [[ "${buildOnTarget:-false}" == true ]]; then
|
||||
|
||||
# Upload derivation
|
||||
log "uploading derivations"
|
||||
copyToTarget "$drvPath" --gzip --use-substitutes
|
||||
|
||||
# Build remotely
|
||||
log "building on target"
|
||||
set -x
|
||||
targetHostCmd "nix-store" "--realize" "$drvPath" "${buildArgs[@]}"
|
||||
|
||||
else
|
||||
|
||||
# Build derivation
|
||||
log "building on deployer"
|
||||
outPath=$(nix-store --realize "$drvPath" "${buildArgs[@]}")
|
||||
|
||||
# Upload build results
|
||||
log "uploading build results"
|
||||
copyToTarget "$outPath" --gzip --use-substitutes
|
||||
|
||||
fi
|
||||
|
||||
# Activate
|
||||
log "activating configuration"
|
||||
targetHostCmd nix-env --profile "$profile" --set "$outPath"
|
||||
targetHostCmd "$outPath/bin/switch-to-configuration" "$action"
|
||||
|
||||
# Cleanup previous generations
|
||||
log "collecting old nix derivations"
|
||||
# Deliberately not quoting $deleteOlderThan so the user can configure something like "1 2 3"
|
||||
# to keep generations with those numbers
|
||||
targetHostCmd "nix-env" "--profile" "$profile" "--delete-generations" $deleteOlderThan
|
||||
targetHostCmd "nix-store" "--gc"
|
|
@ -1,94 +0,0 @@
|
|||
#! /usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Args
|
||||
nix_path=$1
|
||||
config=$2
|
||||
config_pwd=$3
|
||||
flake=$4
|
||||
shift 4
|
||||
|
||||
|
||||
command=(nix-instantiate --show-trace --expr '
|
||||
{ system, configuration, hermetic ? false, flake ? false, ... }:
|
||||
let
|
||||
importFromFlake = { nixosConfig }:
|
||||
let
|
||||
flake = (import (
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
|
||||
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; }
|
||||
) {
|
||||
src = ./.;
|
||||
}).defaultNix;
|
||||
in
|
||||
builtins.getAttr nixosConfig flake.nixosConfigurations;
|
||||
os =
|
||||
if flake
|
||||
then importFromFlake { nixosConfig = configuration; }
|
||||
else if hermetic
|
||||
then
|
||||
(
|
||||
if builtins.isString configuration
|
||||
# case: nixos_config i.e. file path
|
||||
then import configuration
|
||||
# case: config i.e. the module expression itself
|
||||
else configuration
|
||||
)
|
||||
else
|
||||
import <nixpkgs/nixos> { inherit system configuration; };
|
||||
in {
|
||||
inherit (builtins) currentSystem;
|
||||
|
||||
substituters =
|
||||
builtins.concatStringsSep " " os.config.nix.binaryCaches;
|
||||
|
||||
trusted-public-keys =
|
||||
builtins.concatStringsSep " " os.config.nix.binaryCachePublicKeys;
|
||||
|
||||
drv_path = os.config.system.build.toplevel.drvPath;
|
||||
out_path = os.config.system.build.toplevel;
|
||||
}')
|
||||
|
||||
if readlink --version | grep -q GNU; then
|
||||
readlink="readlink -f"
|
||||
else
|
||||
if command -v greadlink &> /dev/null; then
|
||||
readlink="greadlink -f"
|
||||
else
|
||||
echo "Warning: symlinks not supported because readlink is non GNU" >&2
|
||||
readlink="realpath"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -f "$config" ]]; then
|
||||
config=$($readlink "$config")
|
||||
command+=(--argstr configuration "$config")
|
||||
else
|
||||
if $flake; then
|
||||
command+=(--argstr configuration "$config" --arg flake true)
|
||||
else
|
||||
command+=(--arg configuration "$config")
|
||||
fi
|
||||
fi
|
||||
|
||||
# add all extra CLI args as extra build arguments
|
||||
command+=("$@")
|
||||
|
||||
# Setting the NIX_PATH
|
||||
if [[ -n "$nix_path" && "$nix_path" != "-" ]]; then
|
||||
export NIX_PATH=$nix_path
|
||||
fi
|
||||
|
||||
# Changing directory
|
||||
cd "$($readlink "$config_pwd")"
|
||||
|
||||
# Instantiate
|
||||
echo "running (instantiating): ${NIX_PATH:+NIX_PATH=$NIX_PATH} ${command[*]@Q}" -A out_path >&2
|
||||
"${command[@]}" -A out_path >/dev/null
|
||||
|
||||
# Evaluate some more details,
|
||||
# relying on preceding "Instantiate" command to perform the instantiation,
|
||||
# because `--eval` is required but doesn't instantiate for some reason.
|
||||
echo "running (evaluating): ${NIX_PATH:+NIX_PATH=$NIX_PATH} ${command[*]@Q}" --eval --strict --json >&2
|
||||
"${command[@]}" --eval --strict --json
|
|
@ -1,46 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Unpacks the packed-keys.json into individual keys
|
||||
set -euo pipefail
|
||||
shopt -s nullglob
|
||||
|
||||
keys_file=${1:-packed-keys.json}
|
||||
keys_dir=/var/keys
|
||||
|
||||
if [[ ! -f "$keys_file" ]]; then
|
||||
echo "error: $keys_file not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Fallback if jq is not installed
|
||||
if ! type -p jq &>/dev/null; then
|
||||
jqOut=$(nix-build '<nixpkgs>' -A jq)
|
||||
jq() {
|
||||
"$jqOut/bin/jq" "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
# cleanup
|
||||
mkdir -m 0750 -p "$keys_dir"
|
||||
chown -v root:keys "$keys_dir"
|
||||
chmod -v 0750 "$keys_dir"
|
||||
for key in "$keys_dir"/* ; do
|
||||
rm -v "$key"
|
||||
done
|
||||
|
||||
if [[ $(< "$keys_file") = "{}" ]]; then
|
||||
echo "no keys to unpack"
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "unpacking $keys_file"
|
||||
|
||||
# extract the keys from .packed.json
|
||||
for keyname in $(jq -S -r 'keys[]' "$keys_file"); do
|
||||
echo "unpacking: $keyname"
|
||||
jq -r ".\"$keyname\"" < "$keys_file" > "$keys_dir/$keyname"
|
||||
chmod 0640 "$keys_dir/$keyname"
|
||||
chown root:keys "$keys_dir/$keyname"
|
||||
done
|
||||
|
||||
echo "unpacking done"
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
terraform {
|
||||
required_version = ">= 0.12"
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
# Here we have an example of how a machine can be provisioned with some config
|
||||
# after boot. This is useful in case one doesn't want to unecessarily destroy
|
||||
# and create VMs in a pet scenario.
|
||||
|
||||
data "google_compute_network" "default" {
|
||||
name = "default"
|
||||
}
|
||||
|
||||
resource "google_compute_firewall" "deploy-nixos" {
|
||||
name = "deploy-nixos"
|
||||
network = data.google_compute_network.default.name
|
||||
|
||||
allow {
|
||||
protocol = "icmp"
|
||||
}
|
||||
|
||||
// Allow SSH access
|
||||
allow {
|
||||
protocol = "tcp"
|
||||
ports = ["22"]
|
||||
}
|
||||
|
||||
// To vm tagged with: nixos
|
||||
target_tags = ["nixos"]
|
||||
direction = "INGRESS"
|
||||
|
||||
// From anywhere.
|
||||
source_ranges = ["0.0.0.0/0"]
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "deploy-nixos" {
|
||||
name = "deploy-nixos-example"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
|
||||
// Bind the firewall rules
|
||||
tags = ["nixos"]
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
// Start with an image the deployer can SSH into
|
||||
image = module.nixos_image_custom.self_link
|
||||
size = "20"
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
|
||||
// Give it a public IP
|
||||
access_config {}
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
// No need to re-deploy the machine if the image changed
|
||||
// NixOS is already immutable
|
||||
ignore_changes = [boot_disk]
|
||||
}
|
||||
}
|
||||
|
||||
module "deploy_nixos" {
|
||||
source = "../../deploy_nixos"
|
||||
|
||||
// Deploy the given NixOS configuration. In this case it's the same as the
|
||||
// original image. So if the configuration is changed later it will be
|
||||
// deployed here.
|
||||
nixos_config = "${path.module}/image_nixos_custom.nix"
|
||||
|
||||
target_user = "root"
|
||||
target_host = google_compute_instance.deploy-nixos.network_interface[0].access_config[0].nat_ip
|
||||
|
||||
triggers = {
|
||||
// Also re-deploy whenever the VM is re-created
|
||||
instance_id = google_compute_instance.deploy-nixos.id
|
||||
}
|
||||
|
||||
// Pass some secrets. See the terraform-provider-secret to handle secrets
|
||||
// in Terraform
|
||||
keys = {
|
||||
foo = "bar"
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
# Here is a simple example that instantiates the google image and spins up an
|
||||
# instance
|
||||
|
||||
module "nixos_image_1809" {
|
||||
source = "../../google_image_nixos"
|
||||
nixos_version = "18.09"
|
||||
}
|
||||
|
||||
// This instance is not very useful since it doesn't contain any
|
||||
// configuration. This could be fixed by passing a user metadata script.
|
||||
resource "google_compute_instance" "image-nixos" {
|
||||
name = "image-nixos"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image = module.nixos_image_1809.self_link
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
{ modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
# Make sure to have this in all your configurations
|
||||
"${toString modulesPath}/virtualisation/google-compute-image.nix"
|
||||
];
|
||||
|
||||
# Bake the deploy's SSH key into the image. This is not
|
||||
# kosher Nix.
|
||||
users.users.root.openssh.authorizedKeys.keyFiles = [
|
||||
(/. + builtins.getEnv("HOME") + "/.ssh/id_rsa.pub")
|
||||
];
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
# create a random ID for the bucket
|
||||
resource "random_id" "bucket" {
|
||||
byte_length = 8
|
||||
}
|
||||
|
||||
# create a bucket to upload the image into
|
||||
resource "google_storage_bucket" "nixos-images" {
|
||||
name = "nixos-images-${random_id.bucket.hex}"
|
||||
location = "EU"
|
||||
}
|
||||
|
||||
# create a custom nixos base image the deployer can SSH into
|
||||
#
|
||||
# this could also include much more configuration and be used to feed the
|
||||
# auto-scaler with system images
|
||||
module "nixos_image_custom" {
|
||||
source = "../../google_image_nixos_custom"
|
||||
bucket_name = google_storage_bucket.nixos-images.name
|
||||
|
||||
nixos_config = "${path.module}/image_nixos_custom.nix"
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
provider "google" {
|
||||
project = "tweag-digital-assets"
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
# A simple, hermetic NixOS configuration for an AWS EC2 instance that
|
||||
# uses a nixpkgs pinned to a specific Git revision with an integrity
|
||||
# hash to ensure that we construct a NixOS system as purely as
|
||||
# possible.
|
||||
#
|
||||
# i.e. we explicitly specify which nixpkgs to use instead of relying
|
||||
# on the nixpkgs supplied on the NIX_PATH.
|
||||
#
|
||||
# The primary benefit of this is that it removes deployment surprises
|
||||
# when other developers supply a different nix-channel in the NIX_PATH
|
||||
# of their environment (even if you only add the 20.09 channel,
|
||||
# nix-channel --update can mutate that channel to a 20.09 with
|
||||
# backported changes).
|
||||
#
|
||||
# The secondary benefit is that you guard the `nixpkgs` you use, with
|
||||
# an integrity hash.
|
||||
let
|
||||
nixpkgs =
|
||||
let
|
||||
rev = "cd63096d6d887d689543a0b97743d28995bc9bc3";
|
||||
sha256 = "1wg61h4gndm3vcprdcg7rc4s1v3jkm5xd7lw8r2f67w502y94gcy";
|
||||
in
|
||||
builtins.fetchTarball {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
|
||||
inherit sha256;
|
||||
};
|
||||
|
||||
system = "x86_64-linux";
|
||||
|
||||
configuration = { config, pkgs, ... }: {
|
||||
imports = [
|
||||
"${nixpkgs}/nixos/modules/virtualisation/amazon-image.nix"
|
||||
];
|
||||
|
||||
ec2.hvm = true;
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 22 80 ];
|
||||
|
||||
environment.systemPackages = [
|
||||
pkgs.cloud-utils
|
||||
];
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts = {
|
||||
"_" = {
|
||||
root = pkgs.writeTextDir "html/index.html" ''
|
||||
<html>
|
||||
<body>
|
||||
<h1>This is a hermetic NixOS configuration!</h1>
|
||||
</body>
|
||||
</html>
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
import "${nixpkgs}/nixos" { inherit system configuration; }
|
|
@ -1,27 +0,0 @@
|
|||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
profile = "yourprofile"
|
||||
}
|
||||
|
||||
resource "aws_instance" "hermetic-nixos-system" {
|
||||
count = 1
|
||||
ami = "ami-068a62d478710462d" # NixOS 20.09 AMI
|
||||
|
||||
instance_type = "t2.micro"
|
||||
|
||||
key_name = "yourkeyname"
|
||||
|
||||
tags = {
|
||||
Name = "hermetic-nixos-system-example"
|
||||
Description = "An example of a hermetic NixOS system deployed by Terraform"
|
||||
}
|
||||
}
|
||||
|
||||
module "deploy_nixos" {
|
||||
source = "github.com/awakesecurity/terraform-nixos//deploy_nixos?ref=c4b1ee6d24b54e92fa3439a12bce349a6805bcdd"
|
||||
nixos_config = "${path.module}/configuration.nix"
|
||||
hermetic = true
|
||||
target_user = "root"
|
||||
target_host = aws_instance.hermetic-nixos-system[0].public_ip
|
||||
ssh_private_key_file = pathexpand("~/.ssh/yourkeyname.pem")
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
terraform fmt
|
||||
|
||||
fmt_docs() {
|
||||
./scripts/terraform-docs-updater "$1"
|
||||
}
|
||||
|
||||
fmt_docs deploy_nixos
|
||||
fmt_docs google_image_nixos
|
||||
fmt_docs google_image_nixos_custom
|
||||
|
||||
echo "."
|
|
@ -1,76 +0,0 @@
|
|||
# `google_image_nixos`
|
||||
|
||||
This terraform module creates a new image in the Google Cloud project using a
|
||||
public tarballs of a NixOS release. Those tarballs are released by the NixOS
|
||||
project.
|
||||
|
||||
Since image names are unique, only one instance per version of the module is
|
||||
supported per Google Cloud project.
|
||||
|
||||
## Example
|
||||
|
||||
```hcl
|
||||
module "nixos_image_1809" {
|
||||
source = "github.com/tweag/terraform-nixos/google_image_nixos"
|
||||
nixos_version = "18.09"
|
||||
}
|
||||
|
||||
resource "google_compute_instance" "example" {
|
||||
name = "example"
|
||||
machine_type = "n1-standard-1"
|
||||
zone = "us-central1-a"
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image = module.nixos_image_1809.self_link
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
network = "default"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Default configuration.nix
|
||||
|
||||
A new configuration.nix can be passed trough the userdata. Here is the default
|
||||
configuration to expand upon:
|
||||
|
||||
```nix
|
||||
{ modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
"${toString modulesPath}/virtualisation/google-compute-image.nix"
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
## New NixOS releases
|
||||
|
||||
Run the `./update-url-map` script to fetch new image releases. Please submit a
|
||||
PR as well!
|
||||
|
||||
<!-- terraform-docs-start -->
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| google | n/a |
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|:-----:|
|
||||
| gcp\_project\_id | The ID of the project in which the resource belongs. If it is not provided, the provider project is used. | `string` | `""` | no |
|
||||
| licenses | A list of license URIs to apply to this image. Changing this forces a new resource to be created. | `list(string)` | <pre>[<br> "https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx"<br>]</pre> | no |
|
||||
| nixos\_version | The NixOS version to use. Eg: 18.09 | `string` | `"latest"` | no |
|
||||
| url\_map | A map of release series to actual releases | `map(string)` | <pre>{<br> "14.12": "https://nixos-cloud-images.storage.googleapis.com/nixos-14.12.471.1f09b77-x86_64-linux.raw.tar.gz",<br> "15.09": "https://nixos-cloud-images.storage.googleapis.com/nixos-15.09.425.7870f20-x86_64-linux.raw.tar.gz",<br> "16.03": "https://nixos-cloud-images.storage.googleapis.com/nixos-image-16.03.847.8688c17-x86_64-linux.raw.tar.gz",<br> "17.03": "https://nixos-cloud-images.storage.googleapis.com/nixos-image-17.03.1082.4aab5c5798-x86_64-linux.raw.tar.gz",<br> "18.03": "https://nixos-cloud-images.storage.googleapis.com/nixos-image-18.03.132536.fdb5ba4cdf9-x86_64-linux.raw.tar.gz",<br> "18.09": "https://nixos-cloud-images.storage.googleapis.com/nixos-image-18.09.1228.a4c4cbb613c-x86_64-linux.raw.tar.gz",<br> "20.03": "https://nixos-images.storage.googleapis.com/google-cloud-nixos-20.03.1639.73e73c7d6b5.raw.tar.gz",<br> "latest": "https://nixos-images.storage.googleapis.com/google-cloud-nixos-20.03.1639.73e73c7d6b5.raw.tar.gz"<br>}</pre> | no |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| self\_link | Link to the NixOS Compute Image |
|
||||
|
||||
<!-- terraform-docs-end -->
|
|
@ -1,64 +0,0 @@
|
|||
variable "nixos_version" {
|
||||
type = string
|
||||
default = "latest"
|
||||
description = "The NixOS version to use. Eg: 18.09"
|
||||
}
|
||||
|
||||
variable "gcp_project_id" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "The ID of the project in which the resource belongs. If it is not provided, the provider project is used."
|
||||
}
|
||||
|
||||
variable "labels" {
|
||||
type = map(string)
|
||||
default = {}
|
||||
description = "A map of labels applied to this image."
|
||||
}
|
||||
|
||||
variable "licenses" {
|
||||
type = list(string)
|
||||
|
||||
default = [
|
||||
"https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx",
|
||||
]
|
||||
|
||||
description = "A list of license URIs to apply to this image. Changing this forces a new resource to be created."
|
||||
}
|
||||
|
||||
# ---
|
||||
|
||||
locals {
|
||||
image_url = var.url_map[var.nixos_version]
|
||||
|
||||
# Example: nixos-image-18-09-1228-a4c4cbb613c-x86-64-linux
|
||||
#
|
||||
# Remove a few things so that it matches the required regexp for image names
|
||||
# (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)
|
||||
image_name = replace(
|
||||
replace(basename(local.image_url), ".raw.tar.gz", ""),
|
||||
"/[._]+/",
|
||||
"-",
|
||||
)
|
||||
}
|
||||
|
||||
resource "google_compute_image" "nixos" {
|
||||
name = local.image_name
|
||||
description = "NixOS ${var.nixos_version}"
|
||||
family = "nixos"
|
||||
project = var.gcp_project_id
|
||||
labels = var.labels
|
||||
licenses = var.licenses
|
||||
|
||||
raw_disk {
|
||||
source = local.image_url
|
||||
}
|
||||
}
|
||||
|
||||
# ---
|
||||
|
||||
output "self_link" {
|
||||
description = "Link to the NixOS Compute Image"
|
||||
value = google_compute_image.nixos.self_link
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -p ruby -i ruby
|
||||
# vim: ft=ruby
|
||||
#
|
||||
# Run this script to update the list of GCE images
|
||||
#
|
||||
require "json"
|
||||
require "uri"
|
||||
|
||||
ENV['NIX_PATH'] = "nixpkgs=channel:nixpkgs-unstable"
|
||||
|
||||
def render_tf
|
||||
url_map=JSON.load(`nix-instantiate --json --strict --eval ./url_map.nix`)
|
||||
|
||||
out = <<~HEADER
|
||||
# DON'T EDIT, run $0 instead
|
||||
variable "url_map" {
|
||||
type = map(string)
|
||||
|
||||
default = {
|
||||
HEADER
|
||||
|
||||
url_map.each_pair do |version, gs_url|
|
||||
u = URI.parse(gs_url)
|
||||
# convert the gs:// URL to HTTPS URL for Terraform to consume
|
||||
#
|
||||
# Eg: "gs://nixos-cloud-images/nixos-image-18.09-x86_64-linux.raw.tar.gz"
|
||||
https_url = "https://#{u.host}.storage.googleapis.com#{u.path}"
|
||||
|
||||
out += " %- 8s = %s\n" % [ version.inspect, https_url.inspect]
|
||||
end
|
||||
|
||||
out += <<~FOOTER
|
||||
}
|
||||
|
||||
description = "A map of release series to actual releases"
|
||||
}
|
||||
FOOTER
|
||||
end
|
||||
|
||||
url_map_tf = render_tf
|
||||
|
||||
open("url_map.tf", "w") do |f|
|
||||
f.write(url_map_tf)
|
||||
end
|
||||
|
||||
puts url_map_tf
|
|
@ -1,2 +0,0 @@
|
|||
# Indirect link to where the image map is stored
|
||||
import <nixpkgs/nixos/modules/virtualisation/gce-images.nix>
|
|
@ -1,17 +0,0 @@
|
|||
# DON'T EDIT, run $0 instead
|
||||
variable "url_map" {
|
||||
type = map(string)
|
||||
|
||||
default = {
|
||||
"14.12" = "https://nixos-cloud-images.storage.googleapis.com/nixos-14.12.471.1f09b77-x86_64-linux.raw.tar.gz"
|
||||
"15.09" = "https://nixos-cloud-images.storage.googleapis.com/nixos-15.09.425.7870f20-x86_64-linux.raw.tar.gz"
|
||||
"16.03" = "https://nixos-cloud-images.storage.googleapis.com/nixos-image-16.03.847.8688c17-x86_64-linux.raw.tar.gz"
|
||||
"17.03" = "https://nixos-cloud-images.storage.googleapis.com/nixos-image-17.03.1082.4aab5c5798-x86_64-linux.raw.tar.gz"
|
||||
"18.03" = "https://nixos-cloud-images.storage.googleapis.com/nixos-image-18.03.132536.fdb5ba4cdf9-x86_64-linux.raw.tar.gz"
|
||||
"18.09" = "https://nixos-cloud-images.storage.googleapis.com/nixos-image-18.09.1228.a4c4cbb613c-x86_64-linux.raw.tar.gz"
|
||||
"20.03" = "https://nixos-images.storage.googleapis.com/google-cloud-nixos-20.03.1639.73e73c7d6b5.raw.tar.gz"
|
||||
"latest" = "https://nixos-images.storage.googleapis.com/google-cloud-nixos-20.03.1639.73e73c7d6b5.raw.tar.gz"
|
||||
}
|
||||
|
||||
description = "A map of release series to actual releases"
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
terraform {
|
||||
required_version = ">= 0.12"
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
# google_cloud_image_nixos
|
||||
|
||||
This terraform module builds and publishes custom NixOS Google Cloud images.
|
||||
|
||||
## Runtime dependencies
|
||||
|
||||
Because this module uses the "external" provider it needs the following
|
||||
executables to be in the path to work properly:
|
||||
|
||||
* bash
|
||||
* nix
|
||||
* `readlink -f` (busybox or coreutils)
|
||||
|
||||
## Known limitations
|
||||
|
||||
NixOS images are built at Terraform plan time. This can make the plan quite
|
||||
slow.
|
||||
|
||||
Building the image doesn't yield any output, unless the build is interrupted or
|
||||
failed.
|
||||
|
||||
When a new image is published, the old-one gets removed. This potentially
|
||||
introduces a race-condition where other targets are trying to create new
|
||||
instances with the old image. To reduce the race window, `create_before_destroy` is being used. See
|
||||
https://github.com/hashicorp/terraform/issues/15485 for related discussions.
|
||||
|
||||
Only x86_64-linux is currently supported.
|
||||
|
||||
<!-- terraform-docs-start -->
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| external | n/a |
|
||||
| google | n/a |
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|------|---------|:-----:|
|
||||
| NIX\_PATH | Allow to pass custom NIX\_PATH. Ignored if `-` or empty. | `string` | `"-"` | no |
|
||||
| bucket\_name | Bucket where to store the image | `any` | n/a | yes |
|
||||
| gcp\_project\_id | The ID of the project in which the resource belongs. If it is not provided, the provider project is used. | `string` | `""` | no |
|
||||
| licenses | A list of license URIs to apply to this image. Changing this forces a new resource to be created. | `list(string)` | <pre>[<br> "https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx"<br>]</pre> | no |
|
||||
| nixos\_config | Path to a nixos configuration.nix file | `any` | n/a | yes |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| NIX\_PATH | n/a |
|
||||
| self\_link | n/a |
|
||||
|
||||
<!-- terraform-docs-end -->
|
|
@ -1,94 +0,0 @@
|
|||
variable "bucket_name" {
|
||||
description = "Bucket where to store the image"
|
||||
}
|
||||
|
||||
variable "nixos_config" {
|
||||
description = "Path to a nixos configuration.nix file"
|
||||
}
|
||||
|
||||
variable "NIX_PATH" {
|
||||
type = string
|
||||
description = "Allow to pass custom NIX_PATH. Ignored if `-` or empty."
|
||||
default = "-"
|
||||
}
|
||||
|
||||
variable "gcp_project_id" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "The ID of the project in which the resource belongs. If it is not provided, the provider project is used."
|
||||
}
|
||||
|
||||
variable "licenses" {
|
||||
type = list(string)
|
||||
|
||||
default = [
|
||||
"https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx",
|
||||
]
|
||||
|
||||
description = "A list of license URIs to apply to this image. Changing this forces a new resource to be created."
|
||||
}
|
||||
|
||||
# ----------------------------------------------------
|
||||
|
||||
data "external" "nix_build" {
|
||||
program = ["${path.module}/nixos-build.sh", var.NIX_PATH, var.nixos_config]
|
||||
}
|
||||
|
||||
locals {
|
||||
out_path = data.external.nix_build.result.out_path
|
||||
image_path = data.external.nix_build.result.image_path
|
||||
|
||||
# 3x2d4rdm9kjzk9d9sz87rmhzvcphs23v
|
||||
out_hash = element(split("-", basename(local.out_path)), 0)
|
||||
|
||||
# Example: 3x2d4rdm9kjzk9d9sz87rmhzvcphs23v-19-03pre-git-x86-64-linux
|
||||
#
|
||||
# Remove a few things so that it matches the required regexp for image names
|
||||
# (?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)
|
||||
image_name = "x${substr(local.out_hash, 0, 12)}-${replace(
|
||||
replace(
|
||||
basename(local.image_path),
|
||||
"/\\.raw\\.tar\\.gz|nixos-image-/",
|
||||
"",
|
||||
),
|
||||
"/[._]+/",
|
||||
"-",
|
||||
)}"
|
||||
|
||||
# 3x2d4rdm9kjzk9d9sz87rmhzvcphs23v-nixos-image-19.03pre-git-x86_64-linux.raw.tar.gz
|
||||
image_filename = "${local.out_hash}-${basename(local.image_path)}"
|
||||
}
|
||||
|
||||
resource "google_storage_bucket_object" "nixos" {
|
||||
name = "images/${local.image_filename}"
|
||||
source = local.image_path
|
||||
bucket = var.bucket_name
|
||||
content_type = "application/tar+gzip"
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "google_compute_image" "nixos" {
|
||||
name = local.image_name
|
||||
family = "nixos"
|
||||
project = var.gcp_project_id
|
||||
licenses = var.licenses
|
||||
|
||||
raw_disk {
|
||||
source = "https://${var.bucket_name}.storage.googleapis.com/${google_storage_bucket_object.nixos.name}"
|
||||
}
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
}
|
||||
|
||||
output "self_link" {
|
||||
value = google_compute_image.nixos.self_link
|
||||
}
|
||||
|
||||
output "NIX_PATH" {
|
||||
value = var.NIX_PATH
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# Special version of nix-build that integrates with the Terraform external
|
||||
# provider
|
||||
set -euo pipefail
|
||||
|
||||
nix_path="${1}"
|
||||
nixos_config=$(readlink -f "${2:-./configuration.nix}")
|
||||
|
||||
shift
|
||||
shift
|
||||
|
||||
if [[ -n "$nix_path" && "$nix_path" != "-" ]]; then
|
||||
export NIX_PATH=$nix_path
|
||||
fi
|
||||
|
||||
args=(
|
||||
--arg configuration "$nixos_config"
|
||||
--argstr system x86_64-linux
|
||||
--no-out-link
|
||||
-A config.system.build.googleComputeImage
|
||||
)
|
||||
|
||||
out_path=$(nix-build '<nixpkgs/nixos>' "${args[@]}" "$@")
|
||||
|
||||
image_path=
|
||||
for path in "$out_path"/*.tar.gz; do
|
||||
image_path=$path
|
||||
done
|
||||
|
||||
cat <<JSON
|
||||
{
|
||||
"out_path": "$out_path",
|
||||
"image_path": "$image_path"
|
||||
}
|
||||
JSON
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
terraform {
|
||||
required_version = ">= 0.12"
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
{ lib, buildGoPackage, fetchFromGitHub }:
|
||||
buildGoPackage rec {
|
||||
name = "${pname}-${version}";
|
||||
pname = "terraform-docs";
|
||||
version = "0.8.2";
|
||||
|
||||
goPackagePath = "github.com/segmentio/${pname}";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "segmentio";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
sha256 = "0g85j43l6v2cwmymc1knbziyay8rarr9ynlsa7imjvwn4ib1926s";
|
||||
};
|
||||
|
||||
preBuild = ''
|
||||
buildFlagsArray+=("-ldflags" "-X main.version=${version}")
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "A utility to generate documentation from Terraform modules in various output formats.";
|
||||
homepage = "https://${goPackagePath}/";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ zimbatm ];
|
||||
};
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Run this script in the top of a terraform folder to amend
|
||||
# the README.md with terraform input/output tables.
|
||||
#
|
||||
# Usage: ./terraform-docs-update [target_dir]
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
BANNER_START="<!-- terraform-docs-start -->"
|
||||
BANNER_END="<!-- terraform-docs-end -->"
|
||||
doc=README.md
|
||||
|
||||
|
||||
cd "${1:-$PWD}"
|
||||
|
||||
if grep "$BANNER_START" "$doc" >/dev/null ; then
|
||||
if [[ -f "$doc.bak" ]]; then
|
||||
echo "$doc.bak file detected, aborting" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mv "$doc" "$doc.bak"
|
||||
{
|
||||
sed "/$BANNER_START/q" "$doc.bak"
|
||||
terraform-docs md .
|
||||
sed -n -e "/$BANNER_END/,\$p" "$doc.bak"
|
||||
} > "$doc"
|
||||
|
||||
rm "$doc.bak"
|
||||
else
|
||||
{
|
||||
echo "$BANNER_START"
|
||||
terraform-docs md .
|
||||
echo "$BANNER_END"
|
||||
} >> "$doc"
|
||||
fi
|
|
@ -1,21 +0,0 @@
|
|||
with import <nixpkgs> {};
|
||||
let
|
||||
tf = terraform.withPlugins(p: with p; [
|
||||
external
|
||||
google
|
||||
p.null
|
||||
random
|
||||
]);
|
||||
# https://github.com/NixOS/nixpkgs/pull/51579
|
||||
terraform-docs = callPackage ./nix/terraform-docs {};
|
||||
in
|
||||
mkShell {
|
||||
buildInputs = [
|
||||
tf
|
||||
terraform-docs
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
NIX_PATH=nixpkgs=channel:nixos-18.09
|
||||
'';
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
[
|
||||
"/nix/store/mnqkwjg5v6sx86an34b4cn075h0lapz3-opentofu-1.8.7/libexec/terraform-providers"
|
||||
]
|
Loading…
Add table
Reference in a new issue