diff --git a/examples/complete/init-tf-backend.tf b/examples/complete/init-tf-backend.tf index 7c4cb4c..325d22d 100644 --- a/examples/complete/init-tf-backend.tf +++ b/examples/complete/init-tf-backend.tf @@ -4,9 +4,9 @@ module "tfbackend" { source = "tf-mod/tfbackend/aws" version = "1.0.0" - aws_account_id = "${var.aws_account_id}" - bucket_name = "${var.bucket_name}" - dynamodb_table = "${var.dynamodb_table}" + aws_account_id = var.aws_account_id + bucket_name = var.bucket_name + dynamodb_table = var.dynamodb_table dynamodb_read_capacity = "10" dynamodb_write_capacity = "10" } diff --git a/examples/complete/provider.tf b/examples/complete/provider.tf index 02c65e2..786d302 100644 --- a/examples/complete/provider.tf +++ b/examples/complete/provider.tf @@ -3,8 +3,8 @@ terraform { } provider "aws" { - region = "${var.aws_region}" - profile = "${var.aws_profile}" - allowed_account_ids = ["${var.aws_account_id}"] + region = var.aws_region + profile = var.aws_profile + allowed_account_ids = [var.aws_account_id] version = ">= 1.15.0" } diff --git a/examples/simple/init-tf-backend.tf b/examples/simple/init-tf-backend.tf index 9d5f597..26ef5a7 100644 --- a/examples/simple/init-tf-backend.tf +++ b/examples/simple/init-tf-backend.tf @@ -4,7 +4,7 @@ module "tfbackend" { source = "tf-mod/tfbackend/aws" version = "1.0.0" - aws_account_id = "${var.aws_account_id}" - bucket_name = "${var.bucket_name}" - dynamodb_table = "${var.dynamodb_table}" + aws_account_id = var.aws_account_id + bucket_name = var.bucket_name + dynamodb_table = var.dynamodb_table } diff --git a/examples/simple/provider.tf b/examples/simple/provider.tf index 02c65e2..786d302 100644 --- a/examples/simple/provider.tf +++ b/examples/simple/provider.tf @@ -3,8 +3,8 @@ terraform { } provider "aws" { - region = "${var.aws_region}" - profile = "${var.aws_profile}" - allowed_account_ids = ["${var.aws_account_id}"] + region = var.aws_region + profile = var.aws_profile + allowed_account_ids = [var.aws_account_id] version = ">= 1.15.0" } diff --git a/main.tf b/main.tf index 17b41ac..147e7e4 100644 --- a/main.tf +++ b/main.tf @@ -1,8 +1,10 @@ +data "aws_partition" "current" {} + # DynamoDB table for lock info storage resource "aws_dynamodb_table" "terraform_lock" { - name = "${var.dynamodb_table}" - read_capacity = "${var.dynamodb_read_capacity}" - write_capacity = "${var.dynamodb_write_capacity}" + name = var.dynamodb_table + read_capacity = var.dynamodb_read_capacity + write_capacity = var.dynamodb_write_capacity hash_key = "LockID" attribute { @@ -20,7 +22,7 @@ resource "aws_dynamodb_table" "terraform_lock" { # S3 bucket for storing terraform state resource "aws_s3_bucket" "terraform_state" { - bucket = "${var.bucket_name}" + bucket = var.bucket_name versioning { enabled = true @@ -28,8 +30,8 @@ resource "aws_s3_bucket" "terraform_state" { } resource "aws_s3_bucket_policy" "bucket_policy" { - bucket = "${aws_s3_bucket.terraform_state.id}" - policy = "${data.aws_iam_policy_document.bucket_policy.json}" + bucket = aws_s3_bucket.terraform_state.id + policy = data.aws_iam_policy_document.bucket_policy.json } data "aws_iam_policy_document" "bucket_policy" { @@ -40,15 +42,15 @@ data "aws_iam_policy_document" "bucket_policy" { ] resources = [ - "arn:aws:s3:::${var.bucket_name}/*", - "arn:aws:s3:::${var.bucket_name}", + format("arn:%s:s3:::%s/*", data.aws_partition.current.partition, var.bucket_name), + format("arn:%s:s3:::%s", data.aws_partition.current.partition, var.bucket_name), ] principals { type = "AWS" identifiers = [ - "arn:aws:iam::${var.aws_account_id}:root", + format("arn:%s:iam::%s:root", data.aws_partition.current.partition, var.aws_account_id) ] } } diff --git a/outputs.tf b/outputs.tf index 1e6ce3d..e4f6a10 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,15 +1,15 @@ output "bucket_name" { - value = "${aws_s3_bucket.terraform_state.id}" + value = aws_s3_bucket.terraform_state.id } output "bucket_arn" { - value = "${aws_s3_bucket.terraform_state.arn}" + value = aws_s3_bucket.terraform_state.arn } output "dynamodb_table" { - value = "${aws_dynamodb_table.terraform_lock.id}" + value = aws_dynamodb_table.terraform_lock.id } output "dynamodb_table_arn" { - value = "${aws_dynamodb_table.terraform_lock.arn}" + value = aws_dynamodb_table.terraform_lock.arn }