Skip to content

Instantly share code, notes, and snippets.

View filipeandre's full-sized avatar

Filipe Ferreira filipeandre

View GitHub Profile
---
Resources:
QueueForPipe:
Type: AWS::SQS::Queue
LambdaServiceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
@stekern
stekern / cfn-ddb-sfn.yml
Created November 12, 2023 16:12
CloudFormation template that demonstrates how to start a Step Functions State Machine using DynamoDB Streams and EventBridge Pipes
AWSTemplateFormatVersion: "2010-09-09"
Description: Creates a Step Functions State Machine that is executed when new items are added to a DynamoDB Table.
Resources:
Table:
Type: "AWS::DynamoDB::Table"
Properties:
AttributeDefinitions:
- AttributeName: "PK"
AttributeType: "S"
KeySchema:
@phillip-le
phillip-le / assert-to-have-received-put-command-command.ts
Last active May 10, 2024 16:52
Unit Testing AWS SDK in TypeScript
it('should persist user to dynamodb', async () => {
await createUser(userInput);
expect(mockDynamoDbDocumentClient).toHaveReceivedCommandWith(PutCommand, {
TableName: 'TestUserTable',
Item: userToCreate,
});
});
@ChrisSwanson
ChrisSwanson / docker-compose.yml
Created April 4, 2023 01:24
changedetection.io playwright chrome docker compose
version: "3.8"
services:
changedetection:
container_name: changedetection
hostname: changedetection
image: ghcr.io/dgtlmoon/changedetection.io:latest
environment:
- TZ=America/Los_Angeles
- PLAYWRIGHT_DRIVER_URL=ws://playwright-chrome:3000/?stealth=1&--disable-web-security=true&token=<redacted>
@ronaldbradford
ronaldbradford / lambda.auto-shutdown.py
Created January 26, 2023 15:06
Autoshutdown AWS RDS Instances and Clusters
# this Code will help to schedule stop the RDS databasrs using Lambda
# Yesh
# Version -- 2.0
# Adapted from https://aws.amazon.com/blogs/database/schedule-amazon-rds-stop-and-start-using-aws-lambda/
import boto3
import os
import sys
import time
from datetime import datetime, timezone
@hackmajoris
hackmajoris / start-stop-rds-lambda.ts
Last active February 6, 2024 10:31
Start and Stop RDS Scheduler with Lambda and CDK TypeScript Stack
import { Handler } from 'aws-lambda';
import * as AWS from 'aws-sdk';
const rds = new AWS.RDS();
enum InstanceStatus {
STOPPED = 'stopped',
AVAILABLE = 'available',
}
AWSTemplateFormatVersion: '2010-09-09'
Description: Template to connect DynamoDB Stream to EventBridge
Resources:
OrdersTable:
Type: AWS::DynamoDB::Table
Properties:
TableName:
Fn::Sub: ${AWS::StackName}-orders
AttributeDefinitions:
- AttributeName: id
@filipeandre
filipeandre / get-ec2.yaml
Created October 11, 2022 18:08 — forked from JAMSUPREME/get-ec2.yaml
SSM Automation
description: |-
### EC2 stopper by tag
Stop EC2 instances by tag
schemaVersion: '0.3'
mainSteps:
- name: getInstancesByTag
action: 'aws:executeAwsApi'
outputs:
- Name: InstanceIds
@filipeandre
filipeandre / check_tag_exists.py
Created August 5, 2022 12:47 — forked from nathanieltalbot/check_tag_exists.py
A simple Python function to check if an image tag exists in an ECR repo using boto3
# Checks if an image tag exists in the repo
def check_tag_exists(tag, repo):
ecr_client = boto3.client('ecr', region_name='us-east-1')
response = ecr_client.describe_images(repositoryName=repo, filter={'tagStatus': 'TAGGED'})
for i in response['imageDetails']:
if tag in i['imageTags']:
return True
return False
@SerhatTeker
SerhatTeker / ve
Created May 10, 2022 16:02
Automate Python Virtual Environment with a Script - https://tech.serhatteker.com/post/2022-04/automate-python-virtualenv
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
# vim: set ft=sh et ts=4 sw=4 sts=4:
# =================================================================================================
#
# Copyright 2022 Serhat Teker <me@serhatteker.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at