Skip to content

Instantly share code, notes, and snippets.

View shimo164's full-sized avatar

shimo164

  • Osaka, Japan
View GitHub Profile
@shimo164
shimo164 / change_lambda_env_variables.sh
Last active May 16, 2023 21:29
Update or remove environment variables of a Lambda function using AWS CLI commands in a shell script
#!/bin/bash
# This script updates AWS Lambda environment variables using the AWS CLI.
# It can add or update environment variables, and remove specified variables.
#
# Parameters:
# function_name: The name of the Lambda function you want to update
# region: The AWS region where your Lambda function is located
# env_vars_key_value_upsert: An array containing key-value pairs of environment variables to add or update
# env_vars_key_remove: An array containing keys of environment variables to remove
@shimo164
shimo164 / compare_regions_available_aws_services.py
Last active May 14, 2023 08:23
Compare the availability of AWS services across two specified regions
"""
This script compares the availability of AWS services across two specified
regions (region1 and region2) and outputs the results. Prints the results,
showing the count and names of the services in each category (common,
region-specific, and not available).
Parameters:
- region1 (str): The first AWS region
- region2 (str): The second AWS region
@shimo164
shimo164 / find_longest_line_in_files.py
Created May 4, 2023 06:02
This script searches for Python files in a given directory and its subdirectories, then finds and prints the longest line of each file if the line length is greater than a specified threshold.
"""
This script searches for Python files in a given directory and its
subdirectories, then finds and prints the longest line of each file if the
line length is greater than a specified threshold.
Output:
- The file path.
- The line number of the longest line.
- The first 100 characters of the longest line.
- The length of the longest line.
@shimo164
shimo164 / find_lambda_executed_in_specific_time_range.py
Last active May 14, 2023 08:24
This script finds and prints AWS Lambda functions executed in a specific time range using boto3 and CloudWatch Logs.
"""
This script finds and prints AWS Lambda functions executed in a specific time range using boto3 and CloudWatch Logs.
Parameters:
prefix (str): Log group name prefix to filter the desired log groups.
Example: '/aws/lambda' to fetch log groups for Lambda functions.
filter_pattern (str): The filter pattern to apply on the logs.
Example: 'START RequestId' to find logs that contain the string 'START RequestId'.
@shimo164
shimo164 / myLambdaCustomWidget.py
Created October 23, 2021 01:31
Lambda function for custom widget on CloudWatch Dashboard
import boto3
def lambda_handler(event, context):
client = boto3.client("elasticbeanstalk")
response = client.describe_environment_health(
EnvironmentName="Myebapp-env", AttributeNames=["HealthStatus"]
)
@shimo164
shimo164 / generate_password.py
Last active August 11, 2021 00:02
Python script for generating password on your local machine.
"""Password generater
Generate random passwords on your local computer.
Usage: $ python filename.py [num]
Option: num: Password characters number. Default 16. num > 3 (with special chars, > 4)
- Type of characters: Number, uppercase, lowercase. At least once.
- Option: Set special_characters variable when using symbols or specific characters
Output: Genarated password is copied to clipboard (not shown in console)
@shimo164
shimo164 / mv_lambda.sh
Last active August 3, 2022 05:40
Move AWS Lambda function with another name, region.
#!/bin/bash
# Rename Lambda by moviong function to another name.
# Moving to another region is also possible.
# Param: role_lambda_execute
# See. https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-awscli.html
# accountID
# function_name_orig
# region_orig
# function_name_orig
@shimo164
shimo164 / cron_git_arbitray_file.sh
Last active February 20, 2022 10:22
Auto back up of any files to Github
#!/bin/bash
# Back up specific files on any directories.
# Using cron job, check update for each file.
# Up-to-date files are copied to local repository
# and pushed to github.
#
# Usage:
# $ bash ./cron_git_arbitray_file.sh
# cron example. execute at every 4am:
@shimo164
shimo164 / DigiMouseWiggler.iso
Created September 2, 2020 21:00
DigiSpark ATTINY85 Micro USB to prevent PC going sleep
// DigiMouse Mouse Wiggler
// Originally wrote by Jeff White (jwhite@white.nu)
// MIT License
// to write
// 1. Start without inserting Digispark.
// 2. When you see "Please plug in the device ... " message, insert Degispark.
// setting: set "mode" 0 or 1
// see http://digistump.com/wiki/digispark/tutorials/modelbi2c
@shimo164
shimo164 / aws-qwiklabs-list.csv
Last active September 2, 2023 06:37
DEPRECATED: aws qwiklabs are no longer available.
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 4.
Name,Type,Level,Duration,Cost,Lang,Description
Security on AWS,Quest,,27 minutes,Free,,"This quest is designed to teach you how to apply AWS Identity and Access Management, in concert with several other AWS Services, to address real-world application and service security management scenarios."
Serverless Web Apps using Amazon DynamoDB,Quest,,5 hours,3 Credits,,"Serverless architectures allow you to build and run applications and services without needing to provision, manage, and scale infrastructure. This quest will show how to design, build, and deploy interactive serverless web applications, using a simple HTML/JavaScript web interface which uses Amazon API Gateway calls to send requests to AWS Lambda backends that query Amazon DynamoDB data."
Alexa Skills Development,Quest,,4 hours,30 Credits,,"In this Quest, you will learn how to create Alexa skills that respond to voice commands and which can be used on the Amazon Echo, Dot, and Tap devices. You will create back-end functions in AWS Lambda, and then conn