Skip to content

Instantly share code, notes, and snippets.

View theCaptN21's full-sized avatar
😎

Katoria H. theCaptN21

😎
View GitHub Profile
name: Docker Nginx ECS Build, Test, & Log Creation
on:
push:
branches:
- main
jobs:
create-ecs-repo:
runs-on: ubuntu-latest
@theCaptN21
theCaptN21 / Variables.tf
Created February 25, 2023 15:42
ECS variables
# --- variables.tf ---
variable "private_cidrs" {
type = string
default = "10.0.1.0/24"
}
variable "public_cidrs" {
type = string
default = "10.0.101.0/24"
@theCaptN21
theCaptN21 / .gitlab-ci.yml
Last active February 25, 2023 15:55
GitLab Template
# This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Terraform.gitlab-ci.yml
image:
name: hashicorp/terraform:light
entrypoint: [""]
@theCaptN21
theCaptN21 / main.tf
Created February 25, 2023 15:38
ECS mani.tf
# --- ecs.tf ---
resource "aws_ecs_cluster" "new_ecs_cluster" {
name = "katorias-cluster"
}
resource "aws_ecs_task_definition" "new-task" {
family = "service"
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
@theCaptN21
theCaptN21 / LoadBalancer
Last active February 20, 2023 20:13
LoadBalancer main.tf
resource "aws_lb" "tfcloud_lb" {
name = "tfcloud-alb"
internal = false
load_balancer_type = "application"
security_groups = [var.web_sg]
subnets = tolist(var.public_subnet)
depends_on = [
var.database_asg
]
@theCaptN21
theCaptN21 / Compute
Created February 18, 2023 15:44
Compute main.tf
data "aws_rds_engine_version" "test" {
engine = "mysql"
preferred_versions = ["8.0.27"]
}
data "aws_ami" "linux" {
most_recent = true
filter {
name = "name"
@theCaptN21
theCaptN21 / main.tf
Last active February 20, 2023 20:30
Root main.tf file
# ---root/main.tf ---
#Instance Module
module "Compute" {
source = "./Modules/Compute"
elb = module.LoadBalancer.elb
alb_tg = module.LoadBalancer.alb_tg
private_subnet = module.Networking.private_subnet
public_subnet = module.Networking.public_subnet
public_sg = module.Networking.public_sg
# --- root/main.tf ---
#Sample Instance Module
module "ec2_instance" {
source = "./Modules/Compute"
}
#Sample Security Group Module
module "vpc_sg" {
source = "./Modules/Security"
@theCaptN21
theCaptN21 / Security.tf
Created February 13, 2023 13:46
Security Group
resource "aws_security_group" "allow_http" {
name = "allow_http"
description = "Allow http inbound traffic"
vpc_id = "vpc-046434f94c971bec4"
ingress {
from_port = "443"
to_port = "443"
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
@theCaptN21
theCaptN21 / Networking.tf
Created February 13, 2023 13:42
VPC terraform file
provider "aws" {
region = var.region
}
resource "aws_vpc" "modulevpc" {
cidr_block = "10.0.0.0/16"
}
resource "aws_internet_gateway" "IGW" {
vpc_id = aws_vpc.modulevpc.id