Skip to content

Instantly share code, notes, and snippets.

View cromyhector's full-sized avatar

Rome Hector cromyhector

View GitHub Profile
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "2.15.0"
}
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
variable "region" {
description = "The region where environment is going to be deployed"
type = string
default = "us-east-1"
}
variable "aws_access_key" {
type = string
sensitive = true
}
resource "aws_vpc" "ecs_vpc" {
cidr_block = var.vpc_cidr
tags = {
Name = "vpc_ecs_week20project"
}
}
resource "aws_vpc" "ecs_vpc" {
cidr_block = var.vpc_cidr
tags = {
Name = "vpc_ecs_week20project"
}
}
resource "aws_subnet" "private_subnet_1" {
vpc_id = aws_vpc.ecs_vpc.id
cidr_block = "10.0.2.0/24"
availability_zone = "us-east-1a"
tags = {
Name = "private_subnet_1"
}
}
resource "aws_ecs_cluster" "cluster" {
name = "week20_ecs_cluster"
capacity_providers = ["FARGATE_SPOT", "FARGATE"]
default_capacity_provider_strategy {
capacity_provider = "FARGATE_SPOT"
}
setting {
# Local .terraform directories
**/.terraform/*
**/.terraform.*
# .tfstate files
*.tfstate
*.tfstate.*
# Crash log files
crash.log
### --- ec2/providers.tf ---
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.27"
}
}
### --- ec2/providers.tf ---
resource "aws_instance" "app_server" {
ami = var.ami
instance_type = var.instance_type
tags = {
Name = var.tag_name
}
}
### --- ec2/variables.tf ---
variable "region" {
description = "The region where the instance will be deployed to"
type = string
default = "us-east-1"
}
variable "ami" {
description = "AMI ID"