Skip to content

Instantly share code, notes, and snippets.

View jeffbrl's full-sized avatar

Jeff Loughridge jeffbrl

View GitHub Profile
@jeffbrl
jeffbrl / find_cisco_amis.sh
Created October 25, 2019 18:50
Finding Cisco CSR AMIs for AWS EC2
aws ec2 describe-images --filters "Name=name,Values=cisco-CSR*" \
--query 'Images[].[ImageId,Name]' --output text --region us-west-1 | grep -m5 "ami-"
@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 / jinja2_rendering.py
Last active April 3, 2019 16:48
Jinja2 rendering examples in python
from jinja2 import Environment, FileSystemLoader, BaseLoader
import yaml
env = Environment(loader=FileSystemLoader("./"), trim_blocks=True, lstrip_blocks=True)
template = env.get_template("simple_template.j2")
# Example of rendering template using dict
vpc = dict(name='dev-west', id='vpc-3432344' )
print(template.render(vpc=vpc))
module "vpc-one" {
source = "terraform-aws-modules/vpc/aws"
version = "1.53.0"
name = "terraform-vpc-one"
cidr = "10.1.0.0/16"
azs = ["ap-northeast-1a", "ap-northeast-1c"]
@jeffbrl
jeffbrl / vpc-full-mesh-tgw.tf
Last active January 16, 2020 00:58
Terraform templates for Regional Full VPC Mesh with the AWS Transit Gateway
module "vpc-one" {
source = "terraform-aws-modules/vpc/aws"
version = "1.53.0"
name = "terraform-vpc-one"
cidr = "10.1.0.0/16"
azs = ["ap-northeast-1a", "ap-northeast-1c"]
@jeffbrl
jeffbrl / app_vpc_proxy_access.yml
Last active January 29, 2019 18:23
Outbound Internet Access by Web Proxy for AWS VPCs - CloudFormation templates
AWSTemplateFormatVersion: 2010-09-09
Description: >-
AWS CloudFormation template to create an App VPC that uses a proxy in the Outbound VPC
for HTTP/HTTPS Internet access.
Parameters:
KeyName:
Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
Type: String
OutboundVpcStack:
Description: Name of the Cloudformation stack used to create the Outbound VPC
@jeffbrl
jeffbrl / vpc_peering.tf
Created January 28, 2019 17:04
Terraform example of Simple VPC peering
module "vpc-west" {
source = "terraform-aws-modules/vpc/aws"
version = "1.53.0"
name = "terraform-vpc-west"
cidr = "10.0.0.0/16"
azs = ["us-west-1a", "us-west-1b"]
public_subnets = ["10.0.0.0/24", "10.0.1.0/24"]
@jeffbrl
jeffbrl / lxde_desktop_user_data.sh
Last active November 17, 2018 17:45
LXDE Desktop on AWS EC2 Ubuntu 18.04 - Access via X2GO
#!/bin/bash -xe
apt-get -y update
apt-get -y install xorg lxde-core lxterminal autocutsel chromium-browser
add-apt-repository -y ppa:x2go/stable
apt-get -y update
apt-get install -y x2goserver x2goserver-xsession
@jeffbrl
jeffbrl / CF_lambda_custom_resource_vpn_IPs.yml
Last active November 15, 2018 21:04
AWS Lambda Custom Resource to Obtain VPN Outside IP Addresses in CloudFormation
AWSTemplateFormatVersion: 2010-09-09
Description: >-
AWS CloudFormation template to demonstrate the use of an Lambda-backed custom resource.
In this example, I use boto3 in the Lambda function to find and return the two Outside
IP addresses for the VGW side of the VPN connection.
Parameters:
VpnConnectionId:
Description: Identifer of the VPN for which to obtain the Outside IP addresses
Type: String
Resources:
@jeffbrl
jeffbrl / AWS-cloudformation-aliases.md
Last active November 9, 2018 12:48
AWS CloudFormation aliases collection

Add the lines in the alias file to ~/.aws/cli/alias. These will take effect immediately.

cvt - validates template on local disk

dse - describe stack events; prints nice table with logical nresources with associated status

instances - list table of EC2 instances including Name tag, status, and IP addresses

active-stacks - list of stack names that are not in DELETE_COMPLETED. The name is a bit of a misnomer. Change it to something to is logical to you.