Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/complete/init-tf-backend.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
6 changes: 3 additions & 3 deletions examples/complete/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
6 changes: 3 additions & 3 deletions examples/simple/init-tf-backend.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 3 additions & 3 deletions examples/simple/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
20 changes: 11 additions & 9 deletions main.tf
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -20,16 +22,16 @@ 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
}
}

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" {
Expand All @@ -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)
]
}
}
Expand Down
8 changes: 4 additions & 4 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -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
}