This file contains 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 | |
Description: Cognito Resources for your Service. | |
Resources: | |
LambdaForCloudFormation: | |
Type: 'AWS::IAM::Role' | |
Properties: | |
RoleName: LambdaForCloudFormation | |
AssumeRolePolicyDocument: |
This file contains 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 { Callback, Context } from 'aws-lambda'; | |
import AWS from 'aws-sdk'; | |
import sendResponse from './CloudFormationSendResponse'; | |
export default async ( | |
event: any, | |
context: Context, | |
callback: Callback<any>) => { | |
try { | |
const cognitoIdentityServiceProvider = new AWS.CognitoIdentityServiceProvider(); |
This file contains 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 { Callback, Context } from 'aws-lambda'; | |
import AWS from 'aws-sdk'; | |
import sendResponse from './CloudFormationSendResponse'; | |
export default async ( | |
event: any, | |
context: Context, | |
callback: Callback<any>) => { | |
try { | |
switch (event.RequestType) { |
This file contains 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 axios from 'axios'; | |
interface SendRequest { | |
ResponseStatus: string; | |
StackId: string; | |
RequestId: string; | |
LogicalResourceId: string; | |
ResponseData: any; | |
ResponseURL: string; | |
} |
This file contains 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
private final AmazonDynamoDB mClient = AmazonDynamoDBClientBuilder | |
.standard() | |
.build(); | |
private final DynamoDB dynamoDB = new DynamoDB(mClient); | |
private Context mContext; | |
public Response handleRequest(final Request request, final Context context) { | |
mContext = context; | |
... |
This file contains 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
private void logSomething() { | |
mContext.getLogger().log("something"); | |
} |
This file contains 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
private ExampleComponent mComponent; | |
public SimpleLoggingHandler() { | |
mComponent = DaggerExampleComponent.builder().build(); | |
} |
This file contains 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
public class Injector { | |
public static ExampleComponent getInjector(final Context context) { | |
return DaggerExampleComponent | |
.builder() | |
.dynamoDBModule(new DynamoDBModule()) | |
.lambdaModule(new LambdaModule(context)) | |
.build(); | |
} | |
} |
This file contains 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
public class SimpleLoggingHandler implements RequestHandler<String, Boolean> { | |
@Inject LambdaLogger mLogger; | |
public Boolean handleRequest(final String request, final Context context) { | |
Injector.getInjector(context).inject(this); | |
mLogger.log(String.format("Received Request: %s", request)); | |
return true; | |
} |
This file contains 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
@Singleton | |
@Component(modules = { | |
LambdaModule.class | |
}) | |
public interface ExampleComponent { | |
void inject(SimpleLoggingHandler simpleLoggingHandler); | |
} |
NewerOlder