View cloudwatch_client_mock.go
package aws | |
import ( | |
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs" | |
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/cloudwatchlogsiface" | |
) | |
// CloudWatchLogsClientMock is a mock for cloudwatch logs client | |
type CloudWatchLogsClientMock struct { | |
cloudwatchlogsiface.CloudWatchLogsAPI | |
Psfr func(input *cloudwatchlogs.PutSubscriptionFilterInput) cloudwatchlogs.PutSubscriptionFilterRequest |
View aws_error.go
package aws | |
// Error implements AWS Error interface | |
type Error struct { | |
error | |
ErrorCode string | |
ErrorMessage string | |
OriginalError error | |
} |
View aws_error.go
package aws | |
// Error implements AWS Error interface | |
type Error struct { | |
error | |
ErrorCode string | |
ErrorMessage string | |
OriginalError error | |
} |
View split_string_in_pieces_with_reduce.js
const split = (str, nmb) => { | |
return str.split('') | |
.reduce((arr, rec) => { | |
console.log(`Arr: ${arr} Rec : ${rec}`) | |
if (arr[arr.length - 1].length < nmb) { | |
arr[arr.length - 1] = [...arr[arr.length - 1], rec] | |
return arr | |
} | |
return [...arr, [rec]] | |
}, [[]]) |
View generate_rsa_ssh_keys.go
// This shows an example of how to generate a SSH RSA Private/Public key pair and save it locally | |
package main | |
import ( | |
"crypto/rand" | |
"crypto/rsa" | |
"crypto/x509" | |
"encoding/pem" | |
"golang.org/x/crypto/ssh" |
View get_all_images_in_all_gitlab_projects.py
# private token or personal token authentication | |
import gitlab | |
gl = gitlab.Gitlab('https://gitlab.com', private_token='{your_token}') | |
# make an API request to create the gl.user object. This is mandatory if you | |
# use the username/password authentication. | |
result = [] | |
gl.auth() |
View enable_x_ray_tracing_on_all_api_gateways.py
# if you gonna have more then 500 api gateways, then you gonna need to wrap this into the loop and after first 500 you gonna need to pass position parameter to get_rest_apis method | |
import boto3 | |
client = boto3.client('apigateway') | |
response = client.get_rest_apis( | |
limit=500 | |
) | |
print(f"We have {len(response['items'])} api gateways to process") | |
for apigateway in response['items']: | |
print(f"Enabling {apigateway['name']} api gateway tracing") |
View Get all logs groups subsciption details.py
import boto3 | |
import json | |
# Create CloudWatchLogs client | |
cloudwatch_logs = boto3.client('logs') | |
paginator = cloudwatch_logs.get_paginator('describe_log_groups') | |
subscription_details = {} | |
for response in paginator.paginate(): | |
for logGroup in response['logGroups']: | |
log_group_name = logGroup['logGroupName'] | |
subscription_filters = cloudwatch_logs.describe_subscription_filters(logGroupName = log_group_name) |
View subsctring_in_pipe.sh
echo "1234567890" | cut -b 1-6 |
View subsctring_in_pipe.sh
echo "1234567890" | cut -b 1-6 |
NewerOlder