Skip to content

Instantly share code, notes, and snippets.

View stavxyz's full-sized avatar
😿

samuel stavxyz

😿
View GitHub Profile
@stavxyz
stavxyz / tf_debug.txt
Last active May 9, 2019 21:16
TF_LOG=DEBUG terraform import digitalocean_record.my_z_sub_record z.example.com,70910975
2019-05-09T16:03:32.209-0500 [DEBUG] plugin.terraform-provider-digitalocean_v1.2.0_x4:
2019-05-09T16:03:32.209-0500 [DEBUG] plugin.terraform-provider-digitalocean_v1.2.0_x4: {
2019-05-09T16:03:32.209-0500 [DEBUG] plugin.terraform-provider-digitalocean_v1.2.0_x4: "id": "not_found",
2019-05-09T16:03:32.209-0500 [DEBUG] plugin.terraform-provider-digitalocean_v1.2.0_x4: "message": "The resource you were accessing could not be found."
2019-05-09T16:03:32.209-0500 [DEBUG] plugin.terraform-provider-digitalocean_v1.2.0_x4: }
2019-05-09T16:03:32.209-0500 [DEBUG] plugin.terraform-provider-digitalocean_v1.2.0_x4: -----------------------------------------------------
2019/05/09 16:03:32 [ERROR] root: eval: *terraform.EvalImportState, err: import digitalocean_record.my_z_sub_record (id: z.example.com,70910975): nil entry in ImportState results. This is always a bug with
the resource that is being imported. Please report this as
a bug to Terraform.
2019/05/09 16:03:32 [ERROR] root: eval: *terraform.EvalSequence, err: imp
@stavxyz
stavxyz / delve demo.md
Created May 3, 2019 13:55
how to use delve

dlv debug compiles your program with optimizations disabled, starts and attaches to it.

By default, with no arguments, Delve will compile the 'main' package in the current directory, and begin to debug it. Alternatively you can specify a package name and Delve will compile that package instead, and begin a new debug session.

(similar to go run ...)

@stavxyz
stavxyz / playground.md
Last active January 24, 2019 21:59
Github Flavored Markdown Playground

What if I want my link to be fixed width?

[`something/like/a/path`](https://google.com)

result

something/like/a/path

@stavxyz
stavxyz / build.sh
Last active October 4, 2018 17:00
terraform & lambda - source code in s3. support for apigateway integration, xray and logging
#! /usr/bin/env bash
# Exit script if you try to use an uninitialized variable.
set -o nounset
# Exit script if a statement returns a non-true return value.
set -o errexit
# Use the error status of the first failure, rather than that of the last item in a pipeline.
set -o pipefail
@stavxyz
stavxyz / publicSubnets.go
Last active August 21, 2020 15:13
finding public subnets in go
package main
import (
"fmt"
"sort"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
@stavxyz
stavxyz / awslblogs.py
Last active April 10, 2018 19:04
stream logs from an ELB or an ALB (it determines this for you). pipe to `jq` to find 5xx's or whatever (requires python3)
#! /usr/bin/env python
"""
# this one has load balancer name
# and does not end in gz
bucket[/prefix]/AWSLogs/aws-account-id/elasticloadbalancing/region/yyyy/mm/dd/aws-account-id_elasticloadbalancing_region_load-balancer-name_end-time_ip-address_random-string.log
# this one has load balancer ID
# and ends in gz
@stavxyz
stavxyz / query_params.py
Last active April 3, 2017 22:57
All the code you need to mess with query params successfully. Works for pretty much any scenario, including python 2 AND 3.
#
# This is for python 2/3 compatibility.
#
try:
import urlparse
from urllib import urlencode
except:
import urllib.parse as urlparse
from urllib.parse import urlencode
@stavxyz
stavxyz / wff.py
Created March 2, 2017 19:59
Get details on SWF workflow failures
import json
import time
import boto3
# aws swf list-closed-workflow-executions
# --domain $SWF_DOMAIN
# --type-filter name=$WORKFLOW_NAME
@stavxyz
stavxyz / bootstrap_tf
Last active March 6, 2023 14:27
Bootstrap terraform remote config 🐔 🥚
tf plan -target=aws_s3_bucket.tf_remote_config_bucket -out=confbucket.plan
tf apply confbucket.plan
# Configure against your new bucket.
terraform remote config -backend="S3" \
-backend-config="bucket=project-name-terraform-state" \
-backend-config="key=env-region-terraform-state/terraform.tfstate" \
-backend-config="region=us-west-2" \
-backend-config="encrypt=1"
@stavxyz
stavxyz / sjs.md
Last active November 6, 2018 17:01
Shit Janus Says

mozair

this hopefully won't break all the things we've ever built

integration tests passed
I don't know if I should be happy or sad

On the release of AWS Edge Location in Vienna

schnitzel shops rejoice