Skip to content

Instantly share code, notes, and snippets.

View Tirke's full-sized avatar

Thomas Schersach Tirke

View GitHub Profile
@Tirke
Tirke / pulumi-epsagon.ts
Created September 25, 2018 12:30
Epsagon + Pulumi
// @ts-ignore
import * as epsagon from '@epsagon/epsagon'
import * as pulumi from '@pulumi/pulumi'
import * as aws from '@pulumi/aws'
import * as serverless from '@pulumi/aws-serverless'
const config = new pulumi.Config('epsagon')
const epsToken = config.require('token')
const hello = new aws.serverless.Function('hello', {
2019/08/06 16:29:59 [INFO] Terraform version: 0.11.14
2019/08/06 16:29:59 [INFO] Go runtime version: go1.12.5
2019/08/06 16:29:59 [INFO] CLI args: []string{"/usr/local/Cellar/terraform@0.11/0.11.14/bin/terraform", "apply"}
2019/08/06 16:29:59 [DEBUG] Attempting to open CLI config file: /Users/thomas.schersach/.terraformrc
2019/08/06 16:29:59 Loading CLI configuration from /Users/thomas.schersach/.terraformrc
2019/08/06 16:29:59 [INFO] CLI command args: []string{"apply"}
2019/08/06 16:29:59 [INFO] command: empty terraform config, returning nil
2019/08/06 16:29:59 [DEBUG] command: no data state file found for backend config
2019/08/06 16:29:59 [DEBUG] New state was assigned lineage "aeefe1f5-f392-f499-52df-ffe0b22fafc2"
2019/08/06 16:29:59 [INFO] command: backend initialized: <nil>
2019/08/06 16:29:59 [INFO] Terraform version: 0.11.14
2019/08/06 16:29:59 [INFO] Go runtime version: go1.12.5
2019/08/06 16:29:59 [INFO] CLI args: []string{"/usr/local/Cellar/terraform@0.11/0.11.14/bin/terraform", "apply"}
2019/08/06 16:29:59 [DEBUG] Attempting to open CLI config file: /Users/thomas.schersach/.terraformrc
2019/08/06 16:29:59 Loading CLI configuration from /Users/thomas.schersach/.terraformrc
2019/08/06 16:29:59 [INFO] CLI command args: []string{"apply"}
2019/08/06 16:29:59 [INFO] command: empty terraform config, returning nil
2019/08/06 16:29:59 [DEBUG] command: no data state file found for backend config
2019/08/06 16:29:59 [DEBUG] New state was assigned lineage "aeefe1f5-f392-f499-52df-ffe0b22fafc2"
2019/08/06 16:29:59 [INFO] command: backend initialized: <nil>
2019/09/16 18:45:45 [INFO] Terraform version: 0.12.8
2019/09/16 18:45:45 [INFO] Go runtime version: go1.12.9
2019/09/16 18:45:45 [INFO] CLI args: []string{"/usr/local/Cellar/tfenv/1.0.1/versions/0.12.8/terraform", "plan"}
2019/09/16 18:45:45 [DEBUG] Attempting to open CLI config file: /Users/thomas.schersach/.terraformrc
2019/09/16 18:45:45 Loading CLI configuration from /Users/thomas.schersach/.terraformrc
2019/09/16 18:45:45 [INFO] CLI command args: []string{"plan"}
2019/09/16 18:45:45 [TRACE] Meta.Backend: built configuration for "s3" backend with hash value 3623474248
2019/09/16 18:45:45 [TRACE] Preserving existing state lineage "431c9ce8-1a85-bf2e-0d95-326d914b3151"
2019/09/16 18:45:45 [TRACE] Preserving existing state lineage "431c9ce8-1a85-bf2e-0d95-326d914b3151"
2019/09/16 18:45:45 [TRACE] Meta.Backend: working directory was previously initialized for "s3" backend
@Tirke
Tirke / crash.log
Last active September 17, 2019 07:28
This file has been truncated, but you can view the full file.
2019/09/16 18:45:45 [INFO] Terraform version: 0.12.8
2019/09/16 18:45:45 [INFO] Go runtime version: go1.12.9
2019/09/16 18:45:45 [INFO] CLI args: []string{"/usr/local/Cellar/tfenv/1.0.1/versions/0.12.8/terraform", "plan"}
2019/09/16 18:45:45 [DEBUG] Attempting to open CLI config file: /Users/thomas.schersach/.terraformrc
2019/09/16 18:45:45 Loading CLI configuration from /Users/thomas.schersach/.terraformrc
2019/09/16 18:45:45 [INFO] CLI command args: []string{"plan"}
2019/09/16 18:45:45 [TRACE] Meta.Backend: built configuration for "s3" backend with hash value 3623474248
2019/09/16 18:45:45 [TRACE] Preserving existing state lineage "431c9ce8-1a85-bf2e-0d95-326d914b3151"
2019/09/16 18:45:45 [TRACE] Preserving existing state lineage "431c9ce8-1a85-bf2e-0d95-326d914b3151"
2019/09/16 18:45:45 [TRACE] Meta.Backend: working directory was previously initialized for "s3" backend
@Tirke
Tirke / truc.ts
Created September 19, 2019 14:09
import * as request from 'superagent';
import {
Observable,
from,
throwError
} from 'rxjs';
import {
SuperAgentStatic
} from "superagent";
type Config<T> =
T extends { type: 'sftp' } ? { login: string, password: string } :
T extends { type: 'post' } ? { url: string, header: string } : {};
const union: { type: 'post' | 'sftp' } = { type: 'post' }
const simple: { type: 'post' } = { type: 'post' }
const splitUnion: { type: 'post' } | { type: 'sftp' } = { type: 'post' }
type Instance = Config<typeof union> // ==> Instance is {} and not {url: string, header: string}
type InstanceOk = Config<typeof simple> // ==> Instance is { url: string, header: string }
type InstanceOk2 = Config<typeof splitUnion> // ==> Instance is { url: string, header: string }
@Tirke
Tirke / get-failed-record.js
Created December 9, 2019 20:02
Kinesis + Lambda + Lambda Destinations on Failure (SQS Queue)
const Kinesis = require('aws-sdk/clients/kinesis')
const cli = new Kinesis({ region: 'eu-west-1' })
cli.getShardIterator({
StartingSequenceNumber: '49595535202406761165676766185764002510013872440053071874',
StreamName: 'test',
ShardId: 'shardId-000000000000',
ShardIteratorType: 'AT_SEQUENCE_NUMBER'
}).promise().then(async ({ ShardIterator }) => {
const rec = await cli.getRecords({ ShardIterator, Limit: 1 }).promise()
@Tirke
Tirke / alias.tf
Created January 10, 2020 08:40
alias
resource "aws_lambda_function" "lambda" {
...
publish = true // Publish a new version of the lambda when the code changes
}
resource "aws_lambda_alias" "lambda-alias" {
name = "latest"
description = "alias pointing to the latest published version of the lambda"
function_name = aws_lambda_function.lambda.function_name
resource "aws_lambda_alias" "lambda-alias" {
name = "latest"
description = "alias pointing to the latest published version of the lambda"
function_name = aws_lambda_function.lambda.function_name
function_version = aws_lambda_function.lambda.version
}
resource "aws_appautoscaling_target" "scale-warmer-target" {
max_capacity = 1
min_capacity = 0