Skip to content

Instantly share code, notes, and snippets.

@mgjam
Last active October 27, 2019 16:29
Show Gist options
  • Save mgjam/a55631a9c01020636401c61097361ba5 to your computer and use it in GitHub Desktop.
Save mgjam/a55631a9c01020636401c61097361ba5 to your computer and use it in GitHub Desktop.
private createOutputLambdaInvokeRole(
outputLambda: lambda.Function
): iam.Role {
const name = 'OutputLambdaAppSyncInvokeRole';
const invokeRole = new iam.Role(this, name, {
roleName: name,
assumedBy: new iam.ServicePrincipal('appsync.amazonaws.com')
});
invokeRole.attachInlinePolicy(this.createOutputLambdaInvokePolicy(outputLambda));
return invokeRole;
}
private createOutputLambdaInvokePolicy(
outputLambda: lambda.Function
): iam.Policy {
const name = 'OutputLambdaAppSyncInvokePolicy';
return new iam.Policy(this, name, {
policyName: name,
statements: [new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: [ 'lambda:InvokeFunction' ],
resources: [ outputLambda.functionArn ]
})]
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment