Skip to content

Instantly share code, notes, and snippets.

View timoguin's full-sized avatar
🚫
No

Tim O'Guin timoguin

🚫
No
View GitHub Profile
@timoguin
timoguin / init.sls
Created January 17, 2014 20:02
Ubuntu elasticsearch state for salt
elasticsearch-installer:
file.managed:
- name: /home/vagrant/elasticsearch-0.90.10.deb
- source: http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.10.deb
- source_hash: md5=f01196f101a6c074b260d47d915a558f
- user: vagrant
- group: vagrant
- mode: 644
elasticsearch:
@timoguin
timoguin / gist:9349413
Created March 4, 2014 16:08
pydls render time state execution
#!pydsl
s = state()
# configure it
s.pkg.installed('mako')
s() # execute the two states now
@timoguin
timoguin / gist:9353429
Created March 4, 2014 19:10
foobananas
ubuntu_test:
provider: do
image: Ubuntu 12.04.3 x64
size: 512MB
location: New York 2
private_networking: True
script_args: -M git v0.17.5
@timoguin
timoguin / .kitchen.yml
Created March 6, 2014 20:27
snippet for specifying box in .kitchen.yml
platforms:
- name: ubuntu-12.04
driver_config:
box: ubuntu-12.04-cloudimg
box_url: http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box
@timoguin
timoguin / gist:9964865
Created April 3, 2014 23:23
cmd.run module vs. cmd.run state from the command line
salt@master01:~$ salt web01.flexdeaf.dev cmd.run 'ufw allow proto tcp from 192.168.1.115 to any port 9997'
web01.flexdeaf.dev:
Rules updated
salt@master01:~$ salt web01.flexdeaf.dev state.single cmd.run 'ufw allow proto tcp from 192.168.1.115 to any port 9998'
web01.flexdeaf.dev:
----------
ID: ufw allow proto tcp from 192.168.1.115 to any port 9998
Function: cmd.run
Result: True
Comment: Command "ufw allow proto tcp from 192.168.1.115 to any port 9998" run
@timoguin
timoguin / gist:51778e6ecd64ca5ab775
Created September 25, 2014 16:38
salt managed file with dynamic filename
{% set files_list = salt['file.find']('/path/', name='*pattern*') %}
{% if files_list|length > 0 %}
{% set filename = files_list[0] %}
{% endif %}
ensure managed file:
file.managed:
- name: {{ filename }}
@timoguin
timoguin / policy.json
Created December 28, 2016 16:38
IAM policy for the Packer Builder
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "NonResourceBasedReadOnlyPermissions",
"Effect": "Allow",
"Action": [
"ec2:DescribeVolumes",
"ec2:DescribeKeyPairs",
"ec2:DescribeSecurityGroups",
@timoguin
timoguin / iam.tf
Created June 16, 2017 18:41
AWS Require MFA IAM Policy attached to all users
# IAM policy for all users that requires MFA
data "aws_iam_policy_document" "require_mfa_policy" {
statement {
sid = "AllowAllUsersToListAccounts"
effect = "Allow"
actions = [
"iam:ListAccountAliases",
"iam:ListUsers",
]
@timoguin
timoguin / data_dynamodb_query.tf
Created February 27, 2020 15:47
Terraform AWS Provider: Proposed design for DynamoDB Query and GetItem Data Sources
# =========================================================================== #
#
# Proposed arguments for DynamoDB query data source, using an HCL example.
#
# Status: Initial Design
#
# --------------------------------------------------------------------------- #
#
# We would want to stick pretty closely to DynamoDB's Query API for this:
# https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html
@timoguin
timoguin / sparky_spark.py
Created January 24, 2024 23:01
Working with Iceberg tables in Athena Notebooks (pySpark)
from pyspark.sql import DataFrame
import boto3
GLUE_CLIENT = boto3.client("glue", region_name="us-east-2")
def get_table_metadata_location(glue_client, table: str) -> str:
"""