2022-08-18 08:27:31 +08:00
|
|
|
# variables.tf
|
2022-08-17 16:55:28 +08:00
|
|
|
variable "aws-region" {}
|
|
|
|
variable "customer-name" {}
|
|
|
|
variable "project" {}
|
|
|
|
variable "application" {}
|
|
|
|
variable "environment" {}
|
|
|
|
|
2022-08-18 08:27:31 +08:00
|
|
|
# provider.tf
|
2022-08-17 16:55:28 +08:00
|
|
|
provider "aws" {
|
|
|
|
region = var.aws-region
|
|
|
|
default_tags {
|
|
|
|
tags = {
|
2022-08-18 08:27:31 +08:00
|
|
|
Environment = var.environment
|
|
|
|
Project = var.project
|
|
|
|
Application = var.application
|
2022-08-17 16:55:28 +08:00
|
|
|
TerraformMode = "managed"
|
2022-08-18 08:27:31 +08:00
|
|
|
TerraformDir = path.cwd
|
|
|
|
BuildDate = formatdate("YYYYMMDD", timestamp())
|
2022-08-17 16:55:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
terraform {
|
|
|
|
required_version = ">= 0.14"
|
|
|
|
required_providers {
|
|
|
|
aws = {
|
|
|
|
source = "hashicorp/aws"
|
|
|
|
version = ">= 3.25"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-18 08:27:31 +08:00
|
|
|
# main.tf
|
2022-08-17 16:55:28 +08:00
|
|
|
locals {
|
2022-09-05 11:44:39 +08:00
|
|
|
aws-region-short = substr(var.aws-region, 0, 2)
|
2022-08-18 08:27:31 +08:00
|
|
|
resource-prefix = "${var.environment}-${local.aws-region-short}-${var.customer-name}-${var.project}"
|
2022-08-18 08:23:50 +08:00
|
|
|
}
|
|
|
|
|
2022-08-17 16:55:28 +08:00
|
|
|
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"
|
|
|
|
}
|