This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_subnet" "database_subnet" { | |
cidr_block = "${var.database_private_cidr}" | |
availability_zone = "${data.aws_availability_zones.available_zones.names[0]}" | |
vpc_id = "${module.aero_bastion_network.bastion_vpc_id}" | |
tags { | |
Application = "${var.cluster_name}" | |
Environment = "${terraform.workspace}" | |
Name = "${var.cluster_name}-database-subnet" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_subnet" "bastion_private_subnet" { | |
cidr_block = "${var.bastion_private_cidr}" | |
availability_zone = "${var.available_zone}" | |
vpc_id = "${aws_vpc.bastion_vpc.id}" | |
tags { | |
Application = "${var.bastion_cluster_name}" | |
Environment = "${terraform.workspace}" | |
Name = "${var.bastion_cluster_name}-private-subnet" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
export playbook=$1 | |
sudo apt-get upgrade -y | |
sudo apt-get update | |
sudo apt-get install software-properties-common -y | |
sudo apt-add-repository ppa:ansible/ansible | |
sudo apt-get update | |
sudo apt-get install ansible -y | |
cd /var/tmp | |
sudo ansible-playbook -i "localhost," -c local $playbook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /bin/bash | |
chmod +x environment.sh | |
# add aws keys | |
AWS_ACCESS_KEY= | |
AWS_SECRET_KEY= | |
function buildImage { | |
export MACHINE_TYPE=$1 | |
/usr/local/bin/packer build -force $2.json | |
} | |
buildImage mongodb aws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_vpc" "bastion_vpc" { | |
cidr_block = "${var.bastion_cidr}" | |
enable_dns_hostnames = true | |
enable_dns_support = true | |
tags { | |
Application = "${var.bastion_cluster_name}" | |
Environment = "${terraform.workspace}" | |
Name = "${var.bastion_cluster_name}-vpc" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_security_group" "bastion_sg" { | |
description = "Enable HTTP ingress" | |
vpc_id = "${aws_vpc.bastion_vpc.id}" | |
ingress { | |
from_port = 22 | |
to_port = 22 | |
protocol = "tcp" | |
cidr_blocks = ["0.0.0.0/0"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cluster = require('cluster') | |
const testW = require('./test-worker') | |
let readlogs, saveLogs | |
// local logic worker recieved | |
const test = () => { | |
readlogs.send({msg: 'hey calmenla !!!'}) | |
readlogs.on('message', ({msg, id}) => { | |
console.log('Master ' + process.pid + ' received message from worker ' + id + '.', msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ############################################## | |
// WORKERS | |
} else if (process.env.WorkerName === 'readlogs') { | |
console.log('👉🏽 Worker readlogs ' + process.pid + ' has started.') | |
process.on('message', async ({logfiles}) => { | |
try { | |
const read = await readLogFiles.parseFiles(logfiles) | |
process.send({read, logfiles}) | |
} catch (e) { | |
console.log(`something went wrong with reading logs => ${e}`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const cluster = require('cluster') | |
const watch = require('node-watch') | |
const FtpClient = require('ftp-client') | |
const fs = require('fs') | |
const config = require('./config/config') | |
const readLogFiles = require('./read-files') | |
const saveToDB = require('./db-actions') | |
const moveAndDelete = require('./move-delete-files') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fisrt we need to be in the master worker scope to be able | |
// to init all the main process | |
if (cluster.isMaster) { | |
console.log(` | |
--- 🤘🏽 Master ${process.pid} is running 🤘🏽 --- | |
`) | |
// then we start all the workers process | |
let readlogs = cluster.fork({WorkerName: 'readlogs'}) | |
let savelogs = cluster.fork({WorkerName: 'savelogs'}) |