@cryptotaxi247 / infra / commits / 1a3b4670

terraform: import the nix-cache bucket definition

I used `terraform import` and then changed the terraform config until no diff would appear

Eelco Dolstra committed Dec 15, 2018 at 16:47 UTC 1a3b46707c490bdcb395e75f53399ecb76e6d1bc
1 file changed +32 -1
terraform/cache.tf
+32 -1
@@ -1,3 +1,34 @@
1 +resource "aws_s3_bucket" "cache" {
2 + provider = "aws.us"
3 + bucket = "nix-cache"
4 +
5 + lifecycle_rule {
6 + enabled = true
7 +
8 + transition {
9 + days = 365
10 + storage_class = "STANDARD_IA"
11 + }
12 + }
13 +
14 + cors_rule {
15 + allowed_headers = ["Authorization"]
16 + allowed_methods = ["GET"]
17 + allowed_origins = ["*"]
18 + max_age_seconds = 3000
19 + }
20 +}
21 +
22 +resource "aws_s3_bucket_policy" "cache" {
23 + provider = "aws.us"
24 + bucket = "${aws_s3_bucket.cache.id}"
25 +
26 + # imported from existing
27 + policy = <<EOF
28 +{"Version":"2008-10-17","Statement":[{"Sid":"AllowPublicRead","Effect":"Allow","Principal":{"AWS":"*"},"Action":"s3:GetObject","Resource":"arn:aws:s3:::nix-cache/*"},{"Sid":"AllowUploadDebuginfoWrite","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::080433136561:user/s3-upload-releases"},"Action":["s3:PutObject","s3:PutObjectAcl"],"Resource":"arn:aws:s3:::nix-cache/debuginfo/*"},{"Sid":"AllowUploadDebuginfoRead","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::080433136561:user/s3-upload-releases"},"Action":"s3:GetObject","Resource":"arn:aws:s3:::nix-cache/*"},{"Sid":"AllowUploadDebuginfoRead2","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::080433136561:user/s3-upload-releases"},"Action":["s3:ListBucket","s3:GetBucketLocation"],"Resource":"arn:aws:s3:::nix-cache"}]}
29 +EOF
30 +}
31 +
32 resource "aws_cloudfront_distribution" "cache" {
33 enabled = true
34 is_ipv6_enabled = true
@@ -6,7 +37,7 @@ resource "aws_cloudfront_distribution" "cache" {
37
38 origin {
39 origin_id = "S3-nix-cache"
9 - domain_name = "nix-cache.s3.amazonaws.com"
40 + domain_name = "${aws_s3_bucket.cache.bucket_domain_name}"
41
42 s3_origin_config {
43 origin_access_identity = "origin-access-identity/cloudfront/E11I84008FX6W9"