Skip to content

Instantly share code, notes, and snippets.

View luisc009's full-sized avatar
🔄
Do DevOps!

luisc009 luisc009

🔄
Do DevOps!
  • Guadalajara, Jalisco.
  • 12:49 (UTC -06:00)
  • X @mister009
View GitHub Profile
@luisc009
luisc009 / systemd-cloudwatch-logs-tutorial.md
Created March 3, 2025 18:42 — forked from adam-hanna/systemd-cloudwatch-logs-tutorial.md
Forward systemd service logs to AWS Cloudwatch

Introduction

I often find myself ssh'ing into my servers and checking my systemd service logs with $ journalctl -f -u {name}.service. One day I got tired of this and wanted all of my important logs in once place (Amazon AWS Cloudwatch). To my dismay, there weren't any real good tutorials on how to do so. So, voilà.

Steps

Overall, it's a fairly simple process consisting of the following few steps.

1. Modify the service file

Open the service file with $ sudo vi /lib/systemd/system/{name}.service

Modify the [Service] section:

#!/usr/bin/env bash
ln -sf /usr/share/zoneinfo/America/Mexico_City /etc/localtime
hwclock --systohc
sed -i '177s/.//' /etc/locale.gen
locale-gen
echo "LANG=en_US.UTF-8" >> /etc/locale.conf
echo "KEYMAP=de_CH-latin1" >> /etc/vconsole.conf
echo "hostname" >> /etc/hostname
echo "127.0.0.1 localhost" >> /etc/hosts
@luisc009
luisc009 / switch_terraform.sh
Created May 27, 2019 22:04
Downloads Terraform 12 and 11.14 and creates a function to switch between them.
OS=$(uname | awk '{ print tolower($0)}')
#Download Terraform 12
curl -s -o terraform12.zip https://releases.hashicorp.com/terraform/0.12.0/terraform_0.12.0_${OS}_amd64.zip
#Download Terraform 11.14
curl -s -o terraform11.14.zip https://releases.hashicorp.com/terraform/0.11.14/terraform_0.11.14_${OS}_amd64.zip
mkdir -p $HOME/.bin/terraform/11.14/ $HOME/.bin/terraform/12/
unzip terraform12.zip -d $HOME/.bin/terraform/12
@luisc009
luisc009 / bash
Last active January 9, 2019 22:21
LC - Snippets
# Remove unused dependencies from a Node project.
npm-check --no-emoji | grep uninstall | gsed 's/To remove this package://' | bash

Keybase proof

I hereby claim:

  • I am luisc09 on github.
  • I am luiscarbajal (https://keybase.io/luiscarbajal) on keybase.
  • I have a public key ASCN40DSGwYz4vFQfFljqZH0cOM9jVnqlq0IHfvmFobSXAo

To claim this, I am signing this object: