Skip to content

Instantly share code, notes, and snippets.

View jeffbrl's full-sized avatar

Jeff Loughridge jeffbrl

View GitHub Profile
@jeffbrl
jeffbrl / server.py
Created April 12, 2024 20:15
Simple python webserver with HTTP header printing
import sys
from http.server import SimpleHTTPRequestHandler, HTTPServer
DEFAULT_PORT=8080
class RequestHandler(SimpleHTTPRequestHandler):
def do_GET(self):
print(self.headers)
SimpleHTTPRequestHandler.do_GET(self)
@jeffbrl
jeffbrl / user-data.yaml
Created October 21, 2018 00:04
AWS CloudFormation UserData Example
# This example is from https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html.
UserData:
Fn::Base64:
!Sub |
#!/bin/bash -xe
yum update -y aws-cfn-bootstrap
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource LaunchConfig --configsets wordpress_install --region ${AWS::Region}
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource WebServerGroup --region ${AWS::Region}
@jeffbrl
jeffbrl / docker_cloud_init.sh
Last active March 10, 2024 16:28
Cloud-init for Debian Docker Host
#cloud-config
# Adapted from Mathew Dugan's article at https://matduggan.com/idiot-proof-infrastructure/
package_update: true
package_upgrade: true
package_reboot_if_required: true
groups:
- docker
@jeffbrl
jeffbrl / macro-test.slax
Created August 31, 2015 17:06
Example of using apply-macro as generic key/value store - SLAX
version 1.0;
ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";
import "../import/junos.xsl";
match / {
@jeffbrl
jeffbrl / describe_instances.py
Created February 27, 2018 17:28
How to make datetime.datetime json serializable - boto3 ec2 describe_instances
# Adapted from https://stackoverflow.com/questions/35869985/datetime-datetime-is-not-json-serializable
import datetime
import json
import boto3
def datetime_handler(x):
if isinstance(x, datetime.datetime):
return x.isoformat()
@jeffbrl
jeffbrl / userdata.sh
Last active August 8, 2023 21:14
AWS EC2 User Data for installing apache on Amazon Linux 2
#!/bin/bash -xe
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
usermod -a -G apache ec2-user
chown -R ec2-user:apache /var/www
chmod 2775 /var/www
find /var/www -type d -exec chmod 2775 {} \;
find /var/www -type f -exec chmod 0664 {} \;
@jeffbrl
jeffbrl / user-data.sh
Last active May 31, 2023 18:18
EC2 User data for Ubuntu 18.04 to create self-signed cert and configure apache2
#!/bin/bash
domain=example.com
commonname=example.com
country=US
state=Virginia
locality=Leesburg
organization=ExampleCo
organizationalunit=IT
@jeffbrl
jeffbrl / user-data.sh
Created March 22, 2023 13:13
User-data for Amazon Linux 2 Apache with Self-Signed Cert
#!/bin/bash -xe
# Use with Amazon Linux 2
# Amazon Linux 2023 doesn't seem to have make-dummy-cert script
yum update -y
yum install -y httpd mod_ssl
systemctl start httpd
systemctl enable httpd
usermod -a -G apache ec2-user
chown -R ec2-user:apache /var/www
@jeffbrl
jeffbrl / interregion.md
Last active March 4, 2023 16:04
Technical Article Generated by ChatGPT

AWS Inter-Region Architectures

Cloud architects looking to leverage the cloud for their inter-region architectures can benefit from utilizing the services provided by Amazon Web Services (AWS). This blog will cover the basics of networking, VPC, Cloud WAN, Transit Gateway, and VPC peering and explain how they can be used to successfully set up an inter-region architecture.

Introduction to AWS Inter-Region Architectures

Using AWS for inter-region architectures can provide many benefits such as lower costs, improved scalability, and increased availability and reliability. To understand how to make use of these benefits, it is important to have a basic understanding of networking components and concepts. The main component of a network is the Virtual Private Cloud (VPC) which provides a secure and isolated environment within the cloud where resources can be hosted. A VPC consists of subnets, route tables, network gateways, security groups, and other elements that are used to set up and manage a network.

@jeffbrl
jeffbrl / linux-gui.yml
Last active September 18, 2022 19:14
Linux Bastion with GUI - CloudFormation template
AWSTemplateFormatVersion: 2010-09-09
Description: >-
AWS CloudFormation template to create a linux bastion host with a GUI that can
be accessed via x2go.
Parameters:
KeyName:
Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
Type: String
VPC: