From fc47988ed2f8688029c939ffb2b79de366c2cbf2 Mon Sep 17 00:00:00 2001 From: Nick Dumas Date: Wed, 1 Feb 2023 04:59:20 +0000 Subject: [PATCH] parameterized domain for terraform code --- tform/blog/main.tf | 6 +++--- tform/blog/variables.tf | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 tform/blog/variables.tf diff --git a/tform/blog/main.tf b/tform/blog/main.tf index e3791f3..b485eba 100644 --- a/tform/blog/main.tf +++ b/tform/blog/main.tf @@ -1,5 +1,5 @@ resource "aws_s3_bucket" "blog" { - bucket = "blog.ndumas.com" + bucket = var.domain force_destroy = true } @@ -21,7 +21,7 @@ resource "aws_s3_bucket_cors_configuration" "blog_cors" { cors_rule { allowed_headers = ["*"] allowed_methods = ["GET"] - allowed_origins = ["https://blog.ndumas.com", "http://blog.ndumas.com"] + allowed_origins = ["https://{var.domain}", "http://{var.domain}"] max_age_seconds = 3000 } } @@ -54,7 +54,7 @@ resource "aws_iam_policy" "blog_bucket_policy" { ], "Resource" : [ "arn:aws:s3:::*/*", - "arn:aws:s3:::blog.ndumas.com" + "arn:aws:s3:::{var.domain}" ] } ] diff --git a/tform/blog/variables.tf b/tform/blog/variables.tf new file mode 100644 index 0000000..e1ef504 --- /dev/null +++ b/tform/blog/variables.tf @@ -0,0 +1,3 @@ +variable "domain" { + type = string +}