This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
url = 'https://api.twitter.com/1.1/account_activity/all/env-beta/subscriptions.json' | |
r = twitter.post(url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from requests_oauthlib import OAuth1Session | |
import urllib | |
CONSUMER_KEY = 'adsklfjlaksdjfasldfk' | |
CONSUMER_SECRET = 'aksdjfkjljasdfljLIJSDLKFjlskdjflaskjdfa' | |
ACCESS_TOKEN = '0923840928349082390283-kljadsflkJKLDfjdslkjklajkljdsfls' | |
ACCESS_SECRET = '098asdfkljLSkdjfsda09uaskdjflLKJESF' | |
twitter = OAuth1Session(CONSUMER_KEY, | |
client_secret=CONSUMER_SECRET, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def crc(event, context): | |
""" Returns a CRC (Challenge Response Check) to keep this webhook | |
secure. https://goo.gl/kFdJgV for more details. """ | |
# Short circuit ping from CloudWatch Events | |
if event.get('source', None) == 'aws.events': | |
print('ping') | |
return | |
import base64 | |
import hmac |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
import json | |
import boto3 | |
from botocore.vendored import requests | |
""" | |
CloudFormation Template has the following components: | |
# A defintion of your lambda function (what's included below) that | |
# creates your custom resource |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import boto3 | |
import os | |
from botocore.exceptions import ClientError | |
# CONFIGURATION | |
BUCKET_NAME = 'mybucketname' | |
DRY_RUN = True | |
S3 = boto3.client('s3') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
swagger: "2.0" | |
info: | |
version: "1.0" | |
title: "s3-sns-lambda" | |
basePath: "/dev" | |
schemes: | |
- "https" | |
paths: | |
/: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ApiGatewayApi: | |
Type: AWS::Serverless::Api | |
Properties: | |
DefinitionUri: ./swagger.yaml | |
StageName: !Ref ApiGatewayStage | |
Variables: | |
LambdaFunctionName: !Ref LambdaSNS | |
LambdaSNS: | |
Type: AWS::Serverless::Function | |
Properties: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sendResponse(event, reason, status): | |
response = { | |
'Status': status, | |
'Reason': reason, | |
'PhysicalResourceId': 'physical-resource-id', | |
'StackId': event['StackId'], | |
'RequestId': event['RequestId'], | |
'LogicalResourceId': event['LogicalResourceId'] | |
} | |
print(response) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aws_xray_sdk.core import xray_recorder | |
def get_random_ints(count): | |
"""Returns a list of random integers of size count. | |
""" | |
print 'Generating random ints' | |
subsegment = xray_recorder.begin_subsegment('generating_random_ints') | |
my_nums = [] | |
for i in range(count): | |
my_nums.append(randrange(10000)) | |
xray_recorder.end_subsegment() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CodePipelineServiceRole: | |
Type: AWS::IAM::Role | |
Properties: | |
Path: / | |
AssumeRolePolicyDocument: | | |
{ | |
"Statement": [{ | |
"Effect": "Allow", | |
"Principal": { "Service": [ "codepipeline.amazonaws.com" ]}, | |
"Action": [ "sts:AssumeRole" ] |
NewerOlder