Skip to content

Instantly share code, notes, and snippets.

Parameters:
SSHLocation:
Description: "Allow SSH to instance from this IP"
Type: "String"
VpcId:
Description: VpcId for the SG
Type: AWS::EC2::VPC::Id
Resources:
InstanceSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
---
Description: "A text description for the template usage"
Parameters:
Resources:
Outputs:
AWSTemplateFormatVersion: "2010-09-09"
Resources:
InstanceSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
VpcId:
GroupDescription:
SecurityGroupIngress:
Ec2Instance:
Type: "AWS::EC2::Instance"
Properties:
KeyName:
ImageId:
Tags:
UserData:
NetworkInterfaces:
Parameters:
KeyPair:
Description: "The EC2 Key Pair to allow SSH access to the instance"
Type: "String"
ImageId:
Description: "The ImageId for EC2 Instances"
Type: "String"
PublicSubnet:
Description: "Public Subnet to Launch Instance"
Type: "AWS::EC2::Subnet::Id"
Outputs:
InstanceId:
Description: "The InstanceId of the newly created EC2 instance"
Value:
Ref: "Ec2Instance"
---
Description: "Create an EC2 instance"
Parameters:
KeyPair:
Description: "The EC2 Key Pair to allow SSH access to the instance"
Type: "String"
ImageId:
Description: "The ImageId for EC2 Instances"
Type: "String"
SSHLocation:
#!/bin/bash
yum update -y
yum install httpd
cat <<EOF > /var/www/html/index.html
<!DOCTYPE html>
<html>
<head>
<title>Garrett's Webpage</title>
#!/bin/bash
# Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install pip
sudo easy_install pip
# Install git
brew install git
import psycopg2
def execute_postgres(p_db_name, p_user, p_pass, p_query):
conn = None
try:
# connect to the PostgreSQL server
print('Attempting to connect...')
conn = psycopg2.connect("dbname=" + p_db_name + " user=" + p_user + " password=" + p_pass)