Skip to content

Commit

Permalink
Added appsync api with userpool and web client
Browse files Browse the repository at this point in the history
  • Loading branch information
willa75 committed May 18, 2022
1 parent 6447d6c commit 449148e
Show file tree
Hide file tree
Showing 4 changed files with 2,485 additions and 105 deletions.
50 changes: 42 additions & 8 deletions lib/cdk-typescript-stack.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,50 @@
import { Stack, StackProps } from 'aws-cdk-lib';
//import * as appsync from '@aws-cdk/aws-appsync';
import * as appsync from '@aws-cdk/aws-appsync-alpha';

import { Stack, StackProps, CfnOutput } from 'aws-cdk-lib';
import { Construct } from 'constructs';
// import * as sqs from 'aws-cdk-lib/aws-sqs';
import { aws_cognito as cognito } from 'aws-cdk-lib';


export class CdkTypescriptStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);

// The code that defines your stack goes here
const userPool = new cognito.UserPool(this, 'CdkAuth', {
userPoolName: 'CdkAuth',
selfSignUpEnabled: true,
signInAliases: {
email: true
}
});

const webClient = userPool.addClient('web', {
userPoolClientName: 'web',
authFlows: {
userPassword: true,
userSrp: true
}
});

const api = new appsync.GraphqlApi(this, 'ContractsApi', {
name: 'contracts-api',
schema: appsync.Schema.fromAsset('schema.api.graphql'),
authorizationConfig: {
defaultAuthorization: {
authorizationType: appsync.AuthorizationType.USER_POOL,
userPoolConfig: {
userPool
}
},
},

logConfig: {
fieldLogLevel: appsync.FieldLogLevel.ALL
},
xrayEnabled: true,
});

// example resource
// const queue = new sqs.Queue(this, 'CdkTypescriptQueue', {
// visibilityTimeout: cdk.Duration.seconds(300)
// });
new CfnOutput(this, 'GraphQL_URL', { value: api.graphqlUrl });

}
}
};
Loading

0 comments on commit 449148e

Please sign in to comment.