@cryptotaxi247 / infra / commits / dfa57b00

fix: cors_rule is deprecated. Use the aws_s3_bucket_cors_configuration resource instead.

Arian van Putten committed Jun 9, 2025 at 13:30 UTC dfa57b0047d4b21f6feb6596cee3461b7d7a9297
3 files changed +26
terraform/cache-bucket/main.tf
+6
@@ -16,6 +16,11 @@ resource "aws_s3_bucket" "cache" {
16 storage_class = "STANDARD_IA"
17 }
18 }
19 +}
20 +
21 +resource "aws_s3_bucket_cors_configuration" "cache" {
22 + provider = aws
23 + bucket = aws_s3_bucket.cache.bucket
24
25 cors_rule {
26 allowed_headers = ["Authorization"]
@@ -25,6 +30,7 @@ resource "aws_s3_bucket" "cache" {
30 }
31 }
32
33 +
34 resource "aws_s3_bucket_public_access_block" "cache" {
35 bucket = aws_s3_bucket.cache.bucket
36
terraform/cache-staging.tf
+11
@@ -11,6 +11,12 @@ module "cache-staging-202010" {
11 }
12 }
13
14 +import {
15 + to = module.cache-staging-202010.aws_s3_bucket_cors_configuration.cache
16 + id = "nix-cache-staging"
17 +}
18 +
19 +
20 # This is the new bucket we want to use in future.
21 module "cache-staging-202410" {
22 source = "./cache-bucket"
@@ -21,6 +27,11 @@ module "cache-staging-202410" {
27 }
28 }
29
30 +import {
31 + to = module.cache-staging-202410.aws_s3_bucket_cors_configuration.cache
32 + id = "nix-cache-staging-202410"
33 +}
34 +
35 # The fastly configuration below will first try the new bucket and than the old bucket.
36 # As demonstation we have two files in the buckets:
37 # $ curl https://cache-staging.nixos.org/new-cache │
terraform/cache.tf
+9
@@ -16,7 +16,11 @@ resource "aws_s3_bucket" "cache" {
16 storage_class = "STANDARD_IA"
17 }
18 }
19 +}
20
21 +resource "aws_s3_bucket_cors_configuration" "cache" {
22 + provider = aws.us
23 + bucket = aws_s3_bucket.cache.id
24 cors_rule {
25 allowed_headers = ["Authorization"]
26 allowed_methods = ["GET"]
@@ -25,6 +29,11 @@ resource "aws_s3_bucket" "cache" {
29 }
30 }
31
32 +import {
33 + to = aws_s3_bucket_cors_configuration.cache
34 + id = aws_s3_bucket.cache.bucket
35 +}
36 +
37 resource "aws_s3_bucket_object" "cache-nix-cache-info" {
38 provider = aws.us
39