Skip to content

Instantly share code, notes, and snippets.

View 1oglop1's full-sized avatar

Jan Gazda 1oglop1

  • Amsterdam
View GitHub Profile
@1oglop1
1oglop1 / example.ts
Last active April 4, 2024 23:03
pulumi build lambda function with esbuild and set zip hash to be deterministic
export const exampleLambda = new ESBuildNodeFunction('example', {
entry: path.resolve(__dirname, 'handler.ts'),
role: role.arn,
timeout: 8,
memorySize: 128,
environment: {
variables: {
DB_HOST: db.address,
DB_USER: db.username,
DB_PASS: dbPassword,
@1oglop1
1oglop1 / original.py
Last active September 20, 2021 05:29
What pattern should I use?
import enum
from dataclasses import dataclass
# ========= Helper code to set the scene =========
# fake data loaded from csv
DATA = [
{"object_id": "1", "state": "0"},
{"object_id": "2", "state": "1"},
{"object_id": "3", "state": "2"},
{"object_id": "4", "state": "0"},
@1oglop1
1oglop1 / original_component.py
Created August 4, 2021 12:10
pulumi aliases
class EBEnvironmentEc2(pulumi.ComponentResource):
def __init__(self, env_config: EBEnvironmentEc2Config, opts: pulumi.ResourceOptions = None):
super().__init__(
"stekz:infrastructure:aws:elastic-beanstalk:EBEnvironmentEc2",
f"{env_config.environment_name}-eb-component",
None,
opts,
)
self._config = env_config
@1oglop1
1oglop1 / __main__.py
Last active July 28, 2021 13:20
pulumi problem
"""A Python Pulumi program."""
import enum
import pulumi
import pulumi_aws.ec2 as ec2
from pulumi import ResourceOptions
class Situation(str, enum.Enum):
current = "a"
"""A Python Pulumi program."""
import pulumi
import pulumi_aws.sns as sns
import pulumi
from pydantic import BaseModel
from pulumi import ComponentResource, ResourceOptions, Alias
@1oglop1
1oglop1 / __main__.py
Last active July 12, 2021 23:37
Pulumi component resources
import pulumi
from pulumi_aws import s3
from pulumi import Output, Input, ResourceOptions, ComponentResource, set, get
import time
import json
from pydantic import BaseModel
async def w2():
"""Awaitable simulating output"""
@1oglop1
1oglop1 / now.json
Created November 14, 2019 21:19
Now config
{
"version": 2,
"name": "blog",
"builds": [
{
"src": "api/**/*.py",
"use": "@now/python"
},
{
"src": "www/**/*",
@1oglop1
1oglop1 / log.txt
Created November 14, 2019 21:17
Zeit.co Now dbg
[debug] [2019-11-14T20:59:48.611Z] Found config in file ~/blog/pelican/blog/now.json
> [debug] [2019-11-14T20:59:48.617Z] Using Now CLI 16.5.2
> [debug] [2019-11-14T20:59:48.619Z] user supplied a possible target for deployment
> [debug] [2019-11-14T20:59:48.643Z] GET https://api.zeit.co/www/user
> [debug] [2019-11-14T21:00:24.470Z] GET https://api.zeit.co/www/user : 35825.794ms
> Deploying ~/blog/pelican/blog/public under 1oglop1
> Using project blog
[now-client-debug] 2019-11-14T21:00:24.491Z Creating deployment...
[now-client-debug] 2019-11-14T21:00:24.491Z Provided 'path' is a directory. Reading subpaths...
[now-client-debug] 2019-11-14T21:00:24.493Z Read 4 subpaths
@1oglop1
1oglop1 / now.json
Created October 24, 2019 12:59
how about Now.sh?
{
"version": 2,
"name": "my-python-project",
"builds": [
{ "src": "www/**/*", "use": "@now/static" },
{ "src": "api/**/*.py", "use": "@now/python" }
],
"routes": [
{
"src": "/",
@1oglop1
1oglop1 / get_cert_chain.py
Created October 5, 2019 08:02
Get fingerprints of certificates in certificate chain (python)
"""
https://stackoverflow.com/questions/19145097/
"""
import socket
from OpenSSL import SSL
import certifi
hostname='www.google.com'
port=443