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
myAppSettings: | |
Type: AWS::Pinpoint::ApplicationSettings | |
Properties: | |
ApplicationId: !Ref myPinpointApp | |
CampaignHook: | |
LambdaFunctionName: !Ref myHookFunction | |
Mode: FILTER |
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
AWSTemplateFormatVersion : '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Resources: | |
myHookFunction: | |
Type: AWS::Serverless::Function | |
Properties: | |
Handler: index.handler | |
# ... | |
# all the other properties here |
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 random | |
def handler(event, context): | |
# fetch events from input event | |
endpoints = event['Endpoints'] | |
# iterate over endpoints one by one | |
for id, endpoint in endpoints.items(): | |
print("Processing endpoint with id: %s" % id) | |
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
{ | |
"MessageConfiguration": {...}, | |
"ApplicationId": "ABC", | |
"CampaignId": "XYZ", | |
"TreatmentId": "XYZ2", | |
"ActivityId": "123", | |
"ScheduledTime": "2019-10-08T15:00:00.000Z", | |
"Endpoints": {...} | |
} |
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
AWSTemplateFormatVersion : '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Resources: | |
myPipelineFunction: | |
Type: AWS::Serverless::Function | |
Properties: | |
Handler: index.handler | |
Policies: | |
- AWSLambdaExecute # Managed Policy |
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
const http = require('http'); | |
const AWS = require('aws-sdk'); | |
const codepipeline = new AWS.CodePipeline(); | |
exports.handler = async (event, context) => { | |
// Retrieve event data | |
const jobData = event["CodePipeline.job"]; | |
const jobId = jobData.id; | |
const url = jobData.data.actionConfiguration.configuration.UserParameters; | |
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
AWSTemplateFormatVersion : '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Resources: | |
myFunctionToBeDeployed: | |
Type: AWS::Serverless::Function | |
Properties: | |
Handler: index.handler | |
AutoPublishAlias: live | |
DeploymentPreference: | |
Type: Linear10PercentEvery1Minute |
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
const AWS = require('aws-sdk'); | |
const codedeploy = new AWS.CodeDeploy(); | |
exports.handler = async (event, context) => { | |
const {DeploymentId, LifecycleEventHookExecutionId} = event; | |
const functionToTest = process.env.NewVersion; // to be defined in CFN | |
/* Enter validation tests here */ | |
const status = 'Succeeded'; // 'Succeeded' or 'Failed' |
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 json | |
import numpy as np | |
def compute_primes_up_to(n): | |
# https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188 | |
""" Input n>=6, Returns a array of primes, 2 <= p < n """ | |
sieve = np.ones(int(n/3) + (n%6==2), dtype=np.bool) | |
sieve[0] = False | |
for i in range(int(int(n**0.5)/3+1)): | |
if sieve[i]: |
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
# pip install boto3 | |
import boto3 | |
lambda_client = boto3.client('lambda', region_name='us-west-2') | |
response = lambda_client.list_functions() | |
iam_client = boto3.client('iam', region_name='us-west-2') |