Skip to content

Latest commit

 

History

History
114 lines (101 loc) · 1.83 KB

README.md

File metadata and controls

114 lines (101 loc) · 1.83 KB

terraform-aws-microservices

Terraform configuration sample to create AWS 3-Tier Infrastructure for deploying Microservices using ECS & RDS/Aurora PostgreSQL

Install AWS CLI

Configure access_key & secret_key using aws profile

aws configure --profile myprofile

or use access_key & secret_key variables.

variables.tf

variable "region" {
  type = string
}

variable "app_name" {
  type = string
}

# Route 53 Hosted Zone
variable "domain_name" {
  type = string
}

# ALB https
variable "certificate_arn" {
  type = string
}

variable "env_name" {
  type = string
  validation {
    condition     = var.env_name == "dev" || var.env_name == "stage" || var.env_name == "prod"
    error_message = "The env_name value must be dev, stage or prod."
  }
}

variable "db_master_username" {
  type = string
}

#variable "access_key" {
#  type = string
#}
#
#variable "secret_key" {
#  type = string
#}

main.tf

provider "aws" {
  region     = var.region
#  access_key = var.access_key
#  secret_key = var.secret_key
  profile = ""
}

Terraform backend is disabled. view versions.tf

https://www.terraform.io/language/settings/backends/configuration

// Terraform Cloud
terraform {
  cloud {
    organization = ""

    workspaces {
      name = ""
    }
  }
  required_providers {
    aws = {
      source = "hashicorp/aws"
    }
  }
}

// AWS S3
terraform {
  backend "s3" {
    bucket  = ""
    key     = ""
    region  = ""
    profile = ""
#    access_key = ""
#    secret_key = ""
  }
  required_providers {
    aws = {
      source = "hashicorp/aws"
    }
  }
}

Initialize Terraform

cd src
terraform init

Plan & Apply

terraform plan
terraform apply

Destroy

terraform destroy