Skip to content

Instantly share code, notes, and snippets.

@htnosm
htnosm / rewrite-host-header-index.js
Created Sep 24, 2021
Lambda@Edge origin-request trigger to change HTTP Host Header.
View rewrite-host-header-index.js
'use strict';
exports.handler = (event, context, callback) => {
console.log('event:' + JSON.stringify(event));
// Get contents of request
const request = event.Records[0].cf.request;
// Rewrite
request.headers.host[0].value = '${rewrite_value}';
console.log('request headers:' + JSON.stringify(request.headers));
@htnosm
htnosm / README.md
Last active May 1, 2021
Generate bookmarks HTML based on ~/.aws/config
View README.md
@htnosm
htnosm / zabbix_export.py
Created Nov 8, 2020
Zabbix Export Sample. (Zabbix Ver 4.x)
View zabbix_export.py
from pyzabbix import ZabbixAPI
import os
import json
zapi = ZabbixAPI("Your Zabbix URL")
zapi.session.verify = False
zapi.login("Your Zabbix User", "Your Zabbix Password")
print("Connected to Zabbix API Version %s" % zapi.api_version())
output_dir = './var'
@htnosm
htnosm / get-latest-pd-incident.sh
Created Apr 10, 2020
PagerDuty の直近インシデントを取得するサンプルスクリプト
View get-latest-pd-incident.sh
#!/bin/bash
# [REST API v2 Overview](https://v2.developer.pagerduty.com/docs/rest-api)
# [API Reference](https://developer.pagerduty.com/api-reference)
_TOKEN="" # REST API Key
_API_VERSION=2
_SERVICE_ID="" # service ID
_TIME_ZONE="Asia/Tokyo"
_LIMIT=100 # Def:25/Max:100
@htnosm
htnosm / sns2slack.py
Last active Aug 7, 2019
[Lambda] e.g. Amazon SNS -> Lambda -> Slack
View sns2slack.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import boto3
import json
import logging
import os
from base64 import b64decode
from urllib.request import Request, urlopen
@htnosm
htnosm / README.md
Last active Jun 25, 2019
URL Check of GET
View README.md

Usage

Usage: ./check-url.sh "target csv"

Setting

cat <<_EOF > target.csv
@htnosm
htnosm / tf-dd-prov-imp2tf.py
Last active Nov 3, 2019
Convert tfstate to tf for datadog_monitor on Terraform Datadog Provider
View tf-dd-prov-imp2tf.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import sys
import codecs
#reload(sys) # for OSX
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
#sys.setdefaultencoding('utf-8') # for OSX
@htnosm
htnosm / postSlack.py
Created Feb 18, 2017
[Lambda] e.g. API Gateway->Lambda->Slack
View postSlack.py
from __future__ import print_function
import boto3
import json
import logging
import os
from base64 import b64decode
from urllib2 import Request, urlopen, URLError, HTTPError
@htnosm
htnosm / convertDistributionId.py
Created Feb 18, 2017
[Lambda] e.g. DatadogMonitor->SNS->Lambda->Slack
View convertDistributionId.py
from __future__ import print_function
import boto3
import json
import logging
import os
import re
from base64 import b64decode
from urllib2 import Request, urlopen, URLError, HTTPError