Files
devops-directive-terraform-…/07-managing-multiple-environments/workspaces/main.tf
sidpalas 9949d314f3 Updates from bitrot livestream (#16)
- Remove minor version pin for postgres versions (i.e. 12.5 -> 12)
- Update s3 config to use separate versioning and encryption terraform resources
- Use bucket_prefix instead of bucket for bucket naming to avoid name conflicts

Stream: https://youtu.be/KWwKPYuOGBw
2023-01-13 12:43:41 -05:00

47 lines
1.1 KiB
HCL

terraform {
# Assumes s3 bucket and dynamo DB table already set up
# See /code/03-basics/aws-backend
backend "s3" {
bucket = "devops-directive-tf-state"
key = "07-managing-multiple-environments/workspaces/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-state-locking"
encrypt = true
}
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
provider "aws" {
region = "us-east-1"
}
variable "db_pass" {
description = "password for database"
type = string
sensitive = true
}
locals {
environment_name = terraform.workspace
}
module "web_app" {
source = "../../06-organization-and-modules/web-app-module"
# Input Variables
bucket_prefix = "web-app-data-${local.environment_name}"
domain = "devopsdeployed.com"
environment_name = local.environment_name
instance_type = "t2.micro"
create_dns_zone = terraform.workspace == "production" ? true : false
db_name = "${local.environment_name}mydb"
db_user = "foo"
db_pass = var.db_pass
}