Skip to content

Instantly share code, notes, and snippets.

View diegofcornejo's full-sized avatar
🪄
randomtechguy

Diego Cornejo diegofcornejo

🪄
randomtechguy
View GitHub Profile
@diegofcornejo
diegofcornejo / index.js
Created October 15, 2022 03:11
AWS Lambda - Validate if domain point to specific IP's
const dns = require('dns');
const ips = ["XX.XX.XX.XX", "XX.XX.XX.XX"];
exports.handler = (event, context, callback) => {
// context.callbackWaitsForEmptyEventLoop = false;
let body = JSON.parse(event.body);
var done = function(code, message) {
let response = {
"statusCode": code,
"body": JSON.stringify(message)
};
@diegofcornejo
diegofcornejo / README.md
Last active March 26, 2023 17:26
Deploy Express API - Kubernetes (EKS) with HTTPS endpoint

Important: This tutorial assume you already has installed and know how to use, aws cli, kubectl and eksctl

Create and Setup Cluster and required policies

1. Create Fargate Cluster

eksctl create cluster --region us-west-1 --name express-api --version 1.25 --fargate

Note: This command create a stack in cloudformation

@diegofcornejo
diegofcornejo / get-ssm-parameters.sh
Last active April 23, 2023 05:40
Export SSM Parameters to Environment Variables and Append to .bashrc
#======================#
# Without dependencies #
#======================#
#!/bin/bash
# This script will export all SSM parameters under a given path as environment variables
# It will also append the export statements to the ~/.bashrc file so that they are available on future logins
# Set some parameters
@diegofcornejo
diegofcornejo / Dockerfile
Last active October 22, 2023 19:44
Dockerize: Build (Vite) React App inside Turborepo and serve on nginx
# Build stage
from node:18-alpine3.17 as build
WORKDIR /app
# Copy whole project
COPY ../../ .
# Install dependencies
RUN yarn install
@diegofcornejo
diegofcornejo / Dockerfile
Last active October 23, 2023 05:15
Dockerize: Build (Vite) React App inside Turborepo and serve on ASMTTPD
# Base image
FROM alpine:3.18.4 as base
RUN apk update && apk upgrade
RUN apk add --no-cache make yasm binutils git nodejs npm
RUN npm install -g yarn
# Compile asmttpd http server
from base as build-asmttpd
RUN git clone --depth 1 https://github.com/nemasu/asmttpd
@diegofcornejo
diegofcornejo / cloudclusters-backup-db.sh
Last active November 17, 2023 02:53
Cloudclusters.io: Backup postgresql db and upload to AWS S3
#! /bin/bash
CLOUDCLUSTERS_HOME="/cloudclusters"
LOG_FILE="$CLOUDCLUSTERS_HOME/logs/db-backup.log"
SCRIPT_DIR="$CLOUDCLUSTERS_HOME/scripts"
BACKUP_DIR="$CLOUDCLUSTERS_HOME/backups"
S3_BUCKET="s3://<bucket_name>"
DB_NAME="<dbname>"
DB_USER="<dbuser>"
@diegofcornejo
diegofcornejo / README.md
Last active September 30, 2024 01:15
Redis: Create docker containers dinamically with secure connection using stunnel

Redis Container with stunnel Secure Access

This script automates the setup of a Redis container with secure access via stunnel. It generates a unique ID for the Redis instance, a secure password, and finds free ports for Redis and stunnel.

Features

  • Starts a Redis container with a unique volume and password.
  • Sets up a stunnel container to provide secure access to the Redis instance.
  • Assumes the availability of a wildcard certificate, key, and CA file for your domain.
@diegofcornejo
diegofcornejo / SYSTEMD-SERVICES-EXAMPLES.md
Created February 18, 2024 16:53
SYSTEMD - Services files examples

Systemd Service Examples

Add a new service to systemd

sudo nano /etc/systemd/system/my-service.service

NOTE: And add the following content from section Service File Examples

Some useful commands

@diegofcornejo
diegofcornejo / deploy_to_s3.yml
Created February 18, 2024 17:00
Github Action - Deploy to S3 and Invalidate CloudFront Cache
name: Deploy to S3 and Invalidate CloudFront Cache
on:
push:
branches:
- main
- develop
jobs:
build-and-deploy:
@diegofcornejo
diegofcornejo / weblogic14c-on-rhel9.md
Last active March 1, 2024 17:53
Install Oracle WebLogic Server 14c (14.1.1.0) on RHEL 9.3 (AWS EC2)

Install Oracle WebLogic Server 14c (14.1.1.0) on RHEL 9.3 (AWS EC2)

Prerequisites

  1. Create Swap Space
[ec2-user@hostname ~] sudo su -
[root@hostname ~] dd if=/dev/zero of=/swapfile bs=1M count=1024
[root@hostname ~] chmod 600 /swapfile
[root@hostname ~] mkswap /swapfile