terraform.aws-baseline-infra/modules/terraform-setup/examples/main.tf

46 lines
1.2 KiB
HCL

# variables.tf
variable "aws-region" {}
variable "customer-name" {}
variable "project" {}
variable "application" {}
variable "environment" {}
# provider.tf
provider "aws" {
region = var.aws-region
default_tags {
tags = {
Environment = var.environment
Project = var.project
Application = var.application
TerraformMode = "managed"
TerraformDir = path.cwd
BuildDate = formatdate("YYYYMMDD", timestamp())
}
}
}
terraform {
required_version = ">= 0.14"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.25"
}
}
}
# main.tf
locals {
aws-region-short = substr(var.aws-region, 0, 2)
resource-prefix = "${var.environment}-${local.aws-region-short}-${var.customer-name}-${var.project}"
}
module "terraform-state-store" {
source = "git::https://xpk.headdesk.me/git/xpk/terraform.aws-baseline-infra//modules/terraform-setup"
enable-bucket-versioning = true
transition-ia-days = 30
bucket-acl = "private"
ddb-table-name = "${local.resource-prefix}-tflock"
bucket-name = "${local.resource-prefix}-tfstate"
}