Skip to content

Instantly share code, notes, and snippets.

View ohaval's full-sized avatar
💭
Code can be a piece of art

Ohav ohaval

💭
Code can be a piece of art
View GitHub Profile
@ohaval
ohaval / apigatewayv2_integration_to_event_bridge.tf
Last active December 3, 2022 14:46
An example of Terraform code shows how to integrate AWS API Gateway V2 with Event Bridge
# 3 important steps:
#
# A) Create a role for the integration (allowing PutEvents)
# B) Create the integration resource (specify that role)
# C) Create a route targeting that integration
resource "aws_apigatewayv2_integration" "api-gw-v2-integration-to-event-bridge" {
api_id = aws_apigatewayv2_api.some-api-gw-v2.id
integration_type = "AWS_PROXY"
integration_subtype = "EventBridge-PutEvents"
@ohaval
ohaval / multi_file_commit.py
Created December 12, 2022 06:30
An example shows how to push a single commit with multiple files to an existing branch using PyGithub
"""
Main Steps:
1. Create blob for each file
2. Create tree with the blobs on top of the specific branch
3. Commit the tree
4. Update the branch to point to the new commit
"""
import os
@ohaval
ohaval / dynamic-matrix-ghaction.yml
Created December 20, 2022 07:04
Example showing how to set a dynamic matrix sequence based on input
name: Dynamic Matrix
on:
push:
workflow_dispatch:
inputs:
someInput:
description: 'Some input'
required: true
type: choice
options: [ one, two, three ]
@ohaval
ohaval / aws_classic_keys.py
Created June 11, 2023 15:00
Use classic AWS keys with boto3
import boto3
session = boto3.Session(
region_name='us-east-1',
aws_access_key_id=AWS_ACCESS_KEY_ID,
aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
)
session.client('s3').list_buckets()
@ohaval
ohaval / aws_classic_keys.sh
Created June 12, 2023 13:32
Usage of classic AWS keys with the CLI
> cat ~/.aws/config
[default]
region=us-east-1
aws_access_key_id=***
aws_secret_access_key=***
> aws s3 ls
@ohaval
ohaval / aws-vault-exec.sh
Created June 12, 2023 13:34
AWS-Vault exec example
> aws-vault exec some-developer -- env | grep AWS
AWS_ACCESS_KEY_ID=***
AWS_SECRET_ACCESS_KEY=***
AWS_SESSION_TOKEN=***
@ohaval
ohaval / aws-vault-list.sh
Created June 12, 2023 13:40
AWS-Vault list example
> aws-vault list
Profile Credentials Sessions
======= =========== ========
default - -
some-developer some-developer sts.GetSessionToken:8h29m31s
dev - -
staging - -
prod - -
@ohaval
ohaval / config
Created June 12, 2023 13:42
Sample AWS config file with multiple environment
[default]
region = us-east-1
mfa_serial = arn:aws:iam::1000:mfa/some-developer
[profile some-developer]
Credential_process = aws-vault export --format=json some-developer
[profile dev]
role_arn = arn:aws:iam::2000:role/Admin
source_profile = some-developer
@ohaval
ohaval / aws-vault-exec-different-profiles.sh
Created June 12, 2023 13:49
AWS-Vault exec example with different profiles
> aws-vault exec dev -- aws lambda invoke --function-name some-function --payload '{}'
> aws-vault exec staging -- aws lambda list-functions
@ohaval
ohaval / get-session-token-usage-example.sh
Created June 12, 2023 13:51
get-sessiont-token usage example
> aws sts get-session-token
{
"Credentials": {
"AccessKeyId": "***",
"SecretAccessKey": "***",
"SessionToken": "***",
...
}
}