Skip to content

Instantly share code, notes, and snippets.

View rosswickman's full-sized avatar
Using Copilot

Ross Wickman rosswickman

Using Copilot
View GitHub Profile
@lukeplausin
lukeplausin / auto_configure_aws_cli_sso_roles.sh
Last active April 9, 2024 11:50
Automatically configure AWS SSO configuration file for all available accounts and roles
#!/bin/bash -e
# How to use this script:
# 1. Follow these instructions to configure a single AWS account to do initial login with SSO
# https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html
# 2. Export AWS_PROFILE=... and then run "aws sso login" to get an SSO token
# 3. Once signed in with AWS SSO, run this script to automatically list out all the other accounts and roles and add them to your config file
# If you want to filter roles / accounts in the process, or validate config before committing it, you can customise the script to do this.
# sh -c "$(curl -fsSL https://gist.githubusercontent.com/gjgd/5a08da85a98bf147294f331461e44d1f/raw/a63bf0f4169a8ab651adfa0a56e676e6bc465876/setup-github-action-runner.sh)"
# Update instance
sudo apt update -y
sudo apt upgrade -y
# Install latest version of git
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install git -y
@benkehoe
benkehoe / aws-profile-for-bashrc.sh
Last active April 2, 2024 10:41
AWS_PROFILE env var management
# MIT No Attribution
#
# Copyright 2022 Ben Kehoe
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
# software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify,
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so.
#
@nl5887
nl5887 / spotty.sh
Last active September 10, 2020 15:39
#!/usr/bin/env bash
AWS_CLI="aws --region $AWS_REGION"
PRICE=0.2
USER_NAME=#USERNAME#
KEY_NAME=#KEY NAME#
SECURITY_GROUP_ID=#SECURITY GROUP#
SUBNET_ID=#SUBNET#
VOLUME_SIZE=40
INSTANCE_TYPE=t2.2xlarge
@mikepfeiffer
mikepfeiffer / apache.sh
Created January 26, 2019 19:43
EC2 Bootstrap Script for Apache
#!/bin/bash
yum update -y
yum install -y httpd
echo '<h1>Hello World</h1>' > /var/www/html/index.html
systemctl start httpd
systemctl enable httpd
@boyanangelov
boyanangelov / tim_show_scraper.py
Last active December 27, 2018 12:48
Scraping the Tim Ferris Show
from urllib.request import urlopen
from bs4 import BeautifulSoup
from collections import Counter
import pickle
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from __future__ import division
from nltk import FreqDist
from tqdm import tqdm
@mmasztalerczuk
mmasztalerczuk / .gitlab-ci.yml
Last active January 20, 2022 20:02
Example gitlab-ci yaml
image: node:8.12.0-alpine
cache:
paths:
- node_modules/
variables:
AWS_DEFAULT_REGION: us-east-2
BUCKET_NAME: test55555
@HSPDev
HSPDev / AllowSSHFromIP.php
Created July 2, 2018 22:56
Complementary code and IAM policy for "You don't need that Bastion host"
<?php
// For laravel 5 based systems
// /path/to/project/app/Console/Commands/AllowSSHFromIP.php
namespace App\Console\Commands;
use Aws\Ec2\Ec2Client;
use Carbon\Carbon;
use Illuminate\Console\Command;
@magnetikonline
magnetikonline / README.md
Last active September 25, 2023 13:57
AWS CloudFormation YAML template - appending to list parameter types.

AWS CloudFormation YAML template - appending to list parameter types

Documenting this here, as I often forget (what I have found) is the best way to do this at the moment.

For example, you have a list of two existing security groups given to a stack and wish to create (and use) a third - attaching all to an ALB:

AWSTemplateFormatVersion: '2010-09-09'
Description: Example template
@stu-smith
stu-smith / lambda-at-edge.yaml
Last active August 5, 2021 17:09
Shows how to use CloudFormation to attach a Lambda@Edge function to a CloudFront distribution to add HSTS and CSP custom headers. NOTE: The stack must be updated twice: once with the condition set to false, and once with it set to true.
AWSTemplateFormatVersion: 2010-09-09
Parameters:
RootDomainName:
Type: String
IncludeLambdaEdge:
Type: String
AllowedValues: ['true', 'false']
Conditions:
IncludeLambdaEdge:
!Equals ['true', !Ref IncludeLambdaEdge]