This file contains hidden or 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
| app/ | |
| |——src/ | |
| | |——app/ | |
| | |——app.csproj | |
| |——cdk/ | |
| |——cdk.json |
This file contains hidden or 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 static createUser(scope: cdk.Construct): iam.User { | |
| const name = 'User'; | |
| return new iam.User(scope, name, { | |
| userName: name | |
| }); | |
| } | |
| private static createAccessKey( | |
| scope: cdk.Construct, |
This file contains hidden or 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 static createS3Bucket(scope: cdk.Construct, user: iam.User): s3.Bucket { | |
| const name = 'bucket'; | |
| const bucket = new s3.Bucket(scope, name, { | |
| bucketName: name, | |
| accessControl: s3.BucketAccessControl.PUBLIC_READ, | |
| cors: [{ | |
| allowedOrigins: [ '*' ], | |
| allowedMethods: [ s3.HttpMethods.GET ], | |
| allowedHeaders: [ '*' ] |
This file contains hidden or 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 static createAccessKeyOutputs(scope: cdk.Construct, accessKey: iam.CfnAccessKey) { | |
| new cdk.CfnOutput(scope, 'UserAccessKeyId', { | |
| value: accessKey.ref | |
| }); | |
| new cdk.CfnOutput(scope, 'UserSecretAccessKey', { | |
| value: accessKey.attrSecretAccessKey | |
| }); | |
| } | |
| private static createS3BucketOutputs(scope: cdk.Construct, s3Bucket: s3.Bucket) { |
This file contains hidden or 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 createApi(): appsync.CfnGraphQLApi { | |
| const name = 'Api'; | |
| const cloudWatchLogsRoleArn = this.createApiCloudWatchRole().roleArn | |
| return new appsync.CfnGraphQLApi(this, name, { | |
| name: name, | |
| authenticationType: 'AWS_IAM', | |
| logConfig: { | |
| fieldLogLevel: 'ERROR', | |
| cloudWatchLogsRoleArn: cloudWatchLogsRoleArn |
This file contains hidden or 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 createSchema( | |
| api: appsync.CfnGraphQLApi | |
| ): appsync.CfnGraphQLSchema { | |
| const name = 'Schema'; | |
| const definition = ` | |
| type Output { | |
| Numbers: [Int!]! | |
| } | |
| type Query { |
This file contains hidden or 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 Function | |
| { | |
| public Output FunctionHandler(Input input, ILambdaContext context) | |
| { | |
| return new Output | |
| { | |
| Numbers = Enumerable.Repeat(input.Number, input.Count).ToArray() | |
| }; | |
| } | |
| } |
This file contains hidden or 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 createOutputLambda(): lambda.Function { | |
| const name = 'OutputLambda'; | |
| return new lambda.Function(this, name, { | |
| functionName: name, | |
| runtime: lambda.Runtime.DOTNET_CORE_2_1, | |
| code: lambda.Code.asset('../src/appsync/bin/Release/netcoreapp2.1/publish'), | |
| handler: 'appsync::appsync.Function::FunctionHandler', | |
| timeout: cdk.Duration.seconds(15) | |
| }); |
This file contains hidden or 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 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)); |
This file contains hidden or 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 createOutputDataSource( | |
| api: appsync.CfnGraphQLApi, | |
| outputLambda: lambda.Function, | |
| ): appsync.CfnDataSource { | |
| const name = 'OutputDataSource'; | |
| const invokeRole = this.createOutputLambdaInvokeRole(outputLambda); | |
| const outputDataSource = new appsync.CfnDataSource(this, name, { | |
| apiId: api.attrApiId, | |
| name: name, | |
| type: 'AWS_LAMBDA', |
OlderNewer