Skip to content

Instantly share code, notes, and snippets.

Mike Roberts mikebroberts

View GitHub Profile
@mikebroberts
mikebroberts / gist:bd483a5079c90e55ed78e1ffacf7fe32
Created Apr 28, 2020
Thundra online debugging SAM template updates
View gist:bd483a5079c90e55ed78e1ffacf7fe32
diff --git a/chapter5-api/template.yaml b/chapter5-api/template.yaml
index 7c6e0a5..b47084a 100755
--- a/chapter5-api/template.yaml
+++ b/chapter5-api/template.yaml
@@ -41,6 +41,13 @@ Resources:
Properties:
CodeUri: target/lambda.zip
Handler: book.api.WeatherQueryLambda::handler
+ Timeout: 300
+ Layers:
View AWSChatbotRole.yaml
AWSChatbotRole:
Type: AWS::IAM::Role
Properties:
RoleName: AWSChatbotRole
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: 'chatbot.amazonaws.com'
@mikebroberts
mikebroberts / event.json
Created Feb 28, 2020
book-chapter-5-sample
View event.json
{
"Records": [
{
"EventSubscriptionArn": "arn:aws:sns:us-east-1::ExampleTopic",
"Sns": {
"Type": "Notification",
"MessageId": "95df01b4-ee98-5cb9-9903-4c221d41eb5e",
"TopicArn": "arn:aws:sns:us-east-1:123456789012:ExampleTopic",
"Subject": "example subject",
"Message": "example message",
View logging-lambda-1.java
package io.symphonia;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LoggingLambda {
// Configure our SLF4J Logger interface
private static final Logger LOG = LoggerFactory.getLogger(LoggingLambda.class);
public void handler(String s) {
View pom-lambda-logging.xml
<dependencies>
<dependency>
<groupId>io.symphonia</groupId>
<artifactId>lambda-logging</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
@mikebroberts
mikebroberts / pipeline.yaml
Created Jan 2, 2019
Selectively triggering a GitHub sourced CodePipeline (only for one file)
View pipeline.yaml
# CodePipeline by default runs an execution whenever any change is detected in the configured source repository
# We can use a CodePipeline Webhook resource to filter such executions.
#
# This is a snippet that would be part of a CloudFormation template containing
# a CodePipeline resource (AWS::CodePipeline::Pipeline), named CodePipeline in this case, and
# assumes the GutHub OAuth token is available in the parameter GitHubOAuthToken.
# Typically a CodePipeline Webhook only contains the $.ref filter to check for
# the desired branch.
# However we can add up to 4 more filters, each of which can query the incoming webhook payload from Github.
# Such payloads are of the form:
View MyLambda.java
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.services.dynamodbv2.document.*;
public class MyLambda {
private final DynamoDB dynamoDB;
private final String tableName;
public MyLambda() {
this.dynamoDB = new DynamoDB(AmazonDynamoDBClientBuilder.defaultClient());
this.tableName = System.getenv("LOCATIONS_TABLE");
View MyLambda.java
public class MyLambda {
private static final String containerId = java.util.UUID.randomUUID().toString();
public String handler(String input) throws Exception {
Thread.sleep(5000);
return "This is function instance " + containerId;
}
}
View pom.xml
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.11.226</version>
</dependency>
</dependencies>
View MyLambda.java
public class MyLambda {
private static final String containerId = java.util.UUID.randomUUID().toString();
public String handler(String input) {
return "This is function instance " + containerId;
}
}
You can’t perform that action at this time.