Skip to content

Instantly share code, notes, and snippets.

View mnanchev's full-sized avatar

Martin Nanchev mnanchev

View GitHub Profile
// We create the dataset which reads the parquet files in the 2021 bucket prefix
const cfnDataset = new CfnDataset(this, 'Dataset', {
name: 'cost-and-usage-report-dataset',
input: {
s3InputDefinition: {
bucket: `cost-and-usage-report-dataset-2021-12-12`,
key: `2021/<[^/]+>.parquet`,
},
},
format: 'PARQUET',
// First we create forecast dataset with datafrequency of 1
// We use a timeseries AutoML, the target column is costs
const forecastDataset = new AwsCustomResource(this, `forecastDataset`, {
onUpdate: {
service: 'ForecastService',
action: 'createDataset',
parameters: {
Domain: 'CUSTOM',
DatasetName: 'amazonForecastDataset',
DataFrequency: 'D',
@mnanchev
mnanchev / scp.json
Last active November 16, 2021 07:59
SCP
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "RegionRestriction",
"Effect": "Deny",
"NotAction": [
"apigateway:*",
"amplify:*",
"amplifybackend:*",
exports.handler = async (event, context, callback) => {
const request = event.Records[0].cf.request;
const headers = request.headers;
const user = 'YOUR_USERNAME_HERE';
const pass = 'YOUR_PASSWORD_HERE';
const basicAuthentication = 'Basic ' + new Buffer(user + ':' + pass).toString('base64');
import os
import json
import boto3
class QueueMessageSender:
def __init__(self) -> None:
self.s3_client = boto3.client("s3")
self.sqs_client = boto3.client("sqs")
@mnanchev
mnanchev / prettify.py
Created February 10, 2022 19:20 — forked from danlindow/prettify.py
lambda function to make a pretty SNS notification instead of JSON
#!/usr/bin/env python
from __future__ import print_function
import boto3
print('Loading function')
#set region
REGION = 'us-west-2'
#set the SNS topic ARN you want to alert on
SNS_TOPIC_ARN = 'arn:aws:sns:REGION:ACCOUNT_ID:TOPIC_NAME'
{
"Comment": "A description of my state machine",
"StartAt": "RaiseJiraTicket",
"States": {
"RaiseJiraTicket": {
"Type": "Task",
"Parameters": {
"DocumentName": "AWS-CreateJiraIssue",
"Parameters": {
"IssueSummary": [
{
"widgets": [
{
"height": 15,
"width": 24,
"y": 21,
"x": 0,
"type": "explorer",
"properties": {
"metrics": [
{
"widgets": [
{
"height": 15,
"width": 24,
"y": 22,
"x": 0,
"type": "explorer",
"properties": {
"metrics": [
{
"start": "-PT3H",
"widgets": [
{
"height": 15,
"width": 24,
"y": 22,
"x": 0,
"type": "explorer",
"properties": {