Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Silveira RichardSilveira

View GitHub Profile
@RichardSilveira
RichardSilveira / WarnUpFunctionCloudFormationResource.yml
Created Nov 14, 2020
Event Rule to warn up a lambda function
View WarnUpFunctionCloudFormationResource.yml
WarnUpFunctionXXX:
Type: "AWS::Events::Rule"
Properties:
ScheduleExpression: cron(0/10 10-01 * * ? *)
Name: WarnUpFunctionXXX
State: ENABLED
RoleArn: arn:aws:iam::644846694994:role/my-role
Targets:
- Arn: !GetAtt XXXLambdaFunction.Arn
Id: "TargetWarnFunctionXXX"
View TimestreamTruckIoTSample.sql
SELECT
truck_id,
fleet,
fuel_capacity,
model,
load_capacity,
make,
measure_name
FROM "sampleDB".IoT
GROUP BY truck_id, fleet, fuel_capacity, model, load_capacity, make, measure_name
View LambdaFunctionListeningS3UploadFile_ReadStream.js
exports.mys3UpdaloadEventhandler = async (event, context) => {
console.log('event', event);
console.log('context', context);
const bucket = event.Records[0].s3.bucket.name;
console.log('bucket', bucket);
const key = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, ' '));
try {
@RichardSilveira
RichardSilveira / hyperlinkresponse.sample.json
Created Sep 23, 2020
Sample response from a random RESTful API with hyperlink
View hyperlinkresponse.sample.json
{
"departmentId": 10,
"departmentName": "Administration",
"locationId": 1700,
"managerId": 200,
"links": [
{
"href": "10/employees",
"rel": "employees",
"type" : "GET"
@RichardSilveira
RichardSilveira / mariabdbserver-dev.cfn.yaml
Created Aug 21, 2020
Easy way to deploy a MariaDB Server based on AWS Marketplace AMI "MariaDB Server 10.3 on AmazonLinux" for DEVELOPMENT ONLY
View mariabdbserver-dev.cfn.yaml
AWSTemplateFormatVersion: 2010-09-09
Description: |
Deploy a MariaDB Server based on AWS Marketplace AMI "MariaDB Server 10.3 on AmazonLinux" for DEVELOPMENT ONLY
Parameters:
ServerKeyPair:
Type: AWS::EC2::KeyPair::KeyName
Description: Your Amazon EC2 Key Pair.
VPCId:
Type: AWS::EC2::VPC::Id
View AthenaVPCFlowLogQuery.sql
SELECT day_of_week(from_iso8601_timestamp(dt)) AS
day,
dt,
interfaceid,
sourceaddress,
destinationport,
action,
protocol
FROM vpc_flow_logs
WHERE action = 'REJECT' AND protocol = 6
View AthenaVPCFlowLogTablePartition.sql
ALTER TABLE default.vpc_flow_logs
ADD PARTITION (dt='{Year}-{Month}-{Day}')
location 's3://<vpc-flow-logs-bucket>/AWSLogs/<account_id>/vpcflowlogs/<region>/<Year>/<Month>/<Day>';
View AthenaVPCFlowLogTable.sql
CREATE EXTERNAL TABLE IF NOT EXISTS default.vpc_flow_logs (
version int,
account string,
interfaceid string,
sourceaddress string,
destinationaddress string,
sourceport int,
destinationport int,
protocol int,
numpackets int,
@RichardSilveira
RichardSilveira / DeliverVPCFlowLogsPolicy.json
Last active Jul 2, 2020
Policy to be attached to a DeliverVPCFlowLogsRole with a Trusted relationship with "vpc-flow-logs.amazonaws.com"
View DeliverVPCFlowLogsPolicy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ec2:DeleteFlowLogs",
"ec2:CreateFlowLogs",
"ec2:DescribeFlowLogs",
"logs:CreateLogGroup",
"logs:CreateLogStream",
View CodeDeployAdditionalPermissionsForEC2ASG
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Resource": "*",
"Action": [
"ec2:RunInstances",
"ec2:CreateTags"
]
You can’t perform that action at this time.