Skip to content

Commit

Permalink
Testing CDK refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Laren-AWS committed Apr 26, 2024
1 parent 654d2e9 commit 41d57cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { PoolsAndTriggersStack } from '../../../../../workflows/user_pools_and_lambda_triggers/cdk/lib/pools-and-triggers-stack';
import { PoolsAndTriggersBase } from '../../../../../workflows/user_pools_and_lambda_triggers/cdk/lib/pools-and-triggers-base';
import * as cdk from 'aws-cdk-lib';
import {CfnOutput} from 'aws-cdk-lib';
import {Construct} from 'constructs';
Expand All @@ -13,24 +13,24 @@ export class PoolsAndTriggersStackForGo extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);

const baseStack = new PoolsAndTriggersStack(this, "PoolsAndTriggersStack");
const baseConstruct = new PoolsAndTriggersBase(this, "PoolsAndTriggersBase");

const cognitoPrincipal = new iam.ServicePrincipal("cognito-idp.amazonaws.com");

const autoConfirmFunction = this.createFunction('autoConfirmHandler', '../handlers/auto_confirm',
baseStack.tableName, baseStack.lambdaRole, cognitoPrincipal);
baseConstruct.tableName, baseConstruct.lambdaRole, cognitoPrincipal);
const migrateUserFunction = this.createFunction('migrateUserHandler', '../handlers/migrate_user',
baseStack.tableName, baseStack.lambdaRole, cognitoPrincipal);
baseConstruct.tableName, baseConstruct.lambdaRole, cognitoPrincipal);
const activityLogFunction = this.createFunction('activityLogHandler', '../handlers/activity_log',
baseStack.tableName, baseStack.lambdaRole, cognitoPrincipal);
baseConstruct.tableName, baseConstruct.lambdaRole, cognitoPrincipal);

new CfnOutput(this, "AutoConfirmFunction", {value: autoConfirmFunction.functionName})
new CfnOutput(this, "AutoConfirmFunctionArn", {value: autoConfirmFunction.functionArn})
new CfnOutput(this, "MigrateUserFunction", {value: migrateUserFunction.functionName})
new CfnOutput(this, "MigrateUserFunctionArn", {value: migrateUserFunction.functionArn})
new CfnOutput(this, "ActivityLogFunction", {value: activityLogFunction.functionName})
new CfnOutput(this, "ActivityLogFunctionArn", {value: activityLogFunction.functionArn})
baseStack.outputs(this)
baseConstruct.outputs(this)
}

createFunction(name: string, path: string, tableName: string, lambdaRole: iam.IRole, principal: iam.IGrantable) {
Expand All @@ -40,6 +40,7 @@ export class PoolsAndTriggersStackForGo extends cdk.Stack {
"TABLE_NAME": tableName
},
role: lambdaRole,
moduleDir: '..',
});
fn.grantInvoke(principal)
return fn
Expand Down
8 changes: 0 additions & 8 deletions workflows/user_pools_and_lambda_triggers/cdk/bin/cdk.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import * as dynamo from 'aws-cdk-lib/aws-dynamodb';
import * as cognito from 'aws-cdk-lib/aws-cognito';
import * as iam from 'aws-cdk-lib/aws-iam';

export class PoolsAndTriggersStack extends cdk.Stack {
export class PoolsAndTriggersBase extends Construct {
readonly tableName: string;
readonly userPoolId: string;
readonly userPoolArn: string;
readonly userPoolClientId: string;
readonly lambdaRole: iam.Role;

constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
constructor(scope: Construct, id: string) {
super(scope, id);
this.tableName = "doc-example-custom-users"

const table = new dynamo.Table(this, "doc-example-custom-users", {
Expand Down

0 comments on commit 41d57cd

Please sign in to comment.