terraform: describe nixpkgs-tarballs cloudfront
zimbatm committed
Jul 10, 2018 at 15:59 UTC
ebd0631582f91413f2140b748a4b2a9e37274b96
4 files changed
+66
terraform/README.md
new
+14
@@ -0,0 +1,14 @@
1
+# For the bits that are not nixops-able
2
+
3
+For now this manages only resources in the main AWS account.
4
+
5
+## Usage
6
+
7
+Make sure to have the AWS key-pair in the environment, in
8
+`~/.aws/credentials` or as the EC2 metadata service.
9
+
10
+Then run:
11
+
12
+```
13
+nix-shell --run "terraform apply"
14
+```
terraform/nixpkgs-tarballs.tf
new
+45
@@ -0,0 +1,45 @@
1
+resource "aws_s3_bucket" "nixpkgs-tarballs" {
2
+ bucket = "nixpkgs-tarballs"
3
+ region = "eu-west-1"
4
+ acl = "public-read"
5
+
6
+ website {
7
+ index_document = "index.html"
8
+ }
9
+}
10
+
11
+resource "aws_cloudfront_distribution" "nixpkgs-tarballs" {
12
+ enabled = true
13
+ is_ipv6_enabled = true
14
+ default_root_object = "index.html"
15
+ price_class = "PriceClass_All"
16
+ aliases = ["tarballs.nixos.org"]
17
+
18
+ origin {
19
+ domain_name = "${aws_s3_bucket.nixpkgs-tarballs.website_domain}"
20
+ origin_id = "${aws_s3_bucket.nixpkgs-tarballs.name}"
21
+ }
22
+
23
+ default_cache_behavior {
24
+ allowed_methods = ["HEAD", "GET"]
25
+ cached_methods = ["HEAD", "GET"]
26
+ target_origin_id = "${aws_s3_bucket.nixpkgs-tarballs.name}"
27
+ viewer_protocol_policy = "allow-all"
28
+ min_ttl = 0
29
+ default_ttl = 86400
30
+ max_ttl = 31536000
31
+
32
+ forwarded_values {
33
+ query_string = false
34
+
35
+ cookies {
36
+ forward = "none"
37
+ }
38
+ }
39
+
40
+ }
41
+
42
+ viewer_certificate {
43
+ cloudfront_default_certificate = true
44
+ }
45
+}
terraform/providers.tf
new
+3
@@ -0,0 +1,3 @@
1
+provider "aws" {
2
+ region = "us-east-1"
3
+}
terraform/shell.nix
new
+4
@@ -0,0 +1,4 @@
1
+with import <nixpkgs> {};
2
+mkShell {
3
+ buildInputs = [ terraform-full ];
4
+}