Skip to content

Instantly share code, notes, and snippets.

View detect_language_from_twitter.py
#!/usr/bin/env python
import twitter
import boto3
import os
keyword = 'dev.classmethod.jp'
region = 'us-east-1'
size = 10 * 100
View detect_sentiment_from_twitter.py
#!/usr/bin/env python
import twitter
import boto3
import os
keyword = '#reinvent'
lang = 'en'
region = 'us-east-1'
size = 100 * 100
@s-fujimoto
s-fujimoto / s3-to-es-lambda-with-ingest.py
Last active May 9, 2019
Transfer s3 to Elasticsearch log from by Lambda
View s3-to-es-lambda-with-ingest.py
import boto3
import os
import gzip
from datetime import datetime
from botocore.awsrequest import AWSRequest
from botocore.auth import SigV4Auth
from botocore.endpoint import BotocoreHTTPSession
from botocore.credentials import Credentials
def lambda_handler(event, context):
@s-fujimoto
s-fujimoto / approve_release.py
Created Mar 27, 2017
Approve CodePipeline approval action with Lambda function
View approve_release.py
import boto3
def lambda_handler(event, context):
pipeline_name=event['PIPELINE_NAME']
stage_name=event['STAGE_NAME']
action_name=event['ACTION_NAME']
cp = boto3.client('codepipeline')
state = cp.get_pipeline_state(name=pipeline_name)
@s-fujimoto
s-fujimoto / cfnyaml.py
Created May 28, 2016
CloudFormation parameters use by YAML format
View cfnyaml.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import json
try:
import boto3
import yaml
except ImportError:
print '*******************************'
@s-fujimoto
s-fujimoto / swap.py
Last active May 22, 2016
Managed OS Swap space for Ansible Module
View swap.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
DOCUMENTATION = '''
---
module: swap
author: Shinji Fujimoto
short_description: Managed OS Swap space
requirements: None
description:
@s-fujimoto
s-fujimoto / cloudfront.template.json
Created Apr 27, 2016
Elasticsearch Index Template file for CloudFront log
View cloudfront.template.json
{
"template": "cloudfront-logs-*",
"mappings": {
"logs": {
"_source": {
"enabled": false
},
"_all": {
"enabled": false
},
@s-fujimoto
s-fujimoto / cloudfront-logstash.conf
Created Apr 27, 2016
Logstash configuration file for throwing CloudFront logs to Amazon ES
View cloudfront-logstash.conf
input {
s3 {
bucket => "<CLOUDFRONT_LOG_BUCKET>"
prefix => "<CLOUDFRONT_LOG_KEY_PREFIX>"
region => "<BUCKET_REGION_NAME>"
}
}
filter {
@s-fujimoto
s-fujimoto / aws_http_requests.py
Last active Mar 6, 2021
request to amazon elasticsearch service on aws signature version 4
View aws_http_requests.py
from elasticsearch.connection.http_requests import RequestsHttpConnection
from botocore.awsrequest import AWSRequest
from botocore.auth import SigV4Auth
from botocore.credentials import Credentials
from botocore.utils import InstanceMetadataFetcher
from elasticsearch.compat import urlencode
import os
try:
import requests
REQUESTS_AVAILABLE = True
View s3-to-es-lambda.py
##################################################
### Elasticsearch host name
ES_HOST = "search-******************.ap-northeast-1.es.amazonaws.com"
### Elasticsearch prefix for index name
INDEX_PREFIX = "elb_log"
### ELB name for type name
ELB_NAME = "*****"