mirror of
https://github.com/sidpalas/devops-directive-terraform-course.git
synced 2025-12-10 12:51:14 +00:00
- 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
48 lines
969 B
HCL
48 lines
969 B
HCL
terraform {
|
|
backend "s3" {
|
|
bucket = "devops-directive-tf-state"
|
|
key = "04-variables-and-outputs/examples/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"
|
|
}
|
|
|
|
locals {
|
|
extra_tag = "extra-tag"
|
|
}
|
|
|
|
resource "aws_instance" "instance" {
|
|
ami = var.ami
|
|
instance_type = var.instance_type
|
|
|
|
tags = {
|
|
Name = var.instance_name
|
|
ExtraTag = local.extra_tag
|
|
}
|
|
}
|
|
|
|
resource "aws_db_instance" "db_instance" {
|
|
allocated_storage = 20
|
|
storage_type = "gp2"
|
|
engine = "postgres"
|
|
engine_version = "12"
|
|
instance_class = "db.t2.micro"
|
|
name = "mydb"
|
|
username = var.db_user
|
|
password = var.db_pass
|
|
skip_final_snapshot = true
|
|
}
|
|
|