[{"data":1,"prerenderedAt":82},["ShallowReactive",2],{"pattern-apigw-sfn-athena-typescript-cdk":3,"pattern-group-apigw-sfn-athena-typescript-cdk":6},{"id":4,"title":5,"architectureURL":6,"cleanup":7,"contributors":11,"deploy":13,"description":18,"extension":19,"framework":20,"gitHub":21,"highlight":6,"introBox":25,"language":31,"level":32,"meta":33,"patternArch":34,"patternGroup":6,"patternGroupLabel":6,"resources":69,"stem":77,"testing":78,"videoId":6,"__hash__":81},"patterns\u002Fpatterns\u002Fapigw-sfn-athena-typescript-cdk.json","Amazon API Gateway to AWS Step Functions Express to Amazon Athena",null,{"text":8},[9,10],"Delete the stack: \u003Ccode>cd apigw-sfn-athena\u002Ftypescript\u002Fcdk\u002Fcdk\u003C\u002Fcode> then \u003Ccode>npx cdk destroy\u003C\u002Fcode>.","Warning: this deletes the Amazon S3 bucket and all sample data and Amazon Athena query results.",[12],"content\u002Fcontributors\u002Fnithin-chandran-r.json",{"text":14},[15,16,17],"\u003Ccode>cd apigw-sfn-athena\u002Ftypescript\u002Fcdk\u002Fcdk\u003C\u002Fcode>","\u003Ccode>npm install\u003C\u002Fcode>","\u003Ccode>npx cdk deploy\u003C\u002Fcode>","Run an Amazon Athena query through an AWS Step Functions Express Workflow and return the rows in one synchronous Amazon API Gateway call, with no Lambda function.","json","AWS CDK",{"template":22},{"patternPath":23,"templateFile":24},"apigw-sfn-athena\u002Ftypescript\u002Fcdk","cdk\u002Flib\u002Fapigw-sfn-express-athena-stack.ts",{"headline":26,"text":27},"How it works",[28,29,30],"This pattern runs an Amazon Athena query and returns its rows in one synchronous Amazon API Gateway request. The REST API starts an AWS Step Functions Express Workflow with `StartSyncExecution`, and the workflow calls Athena through native service integrations, so there's no AWS Lambda function in the request path.","Express Workflows don't support the `.sync` integration pattern, so the workflow starts the query with `StartQueryExecution` and polls `GetQueryExecution` in a `Wait` and `Choice` loop. When the query succeeds, `GetQueryResults` reads the rows, which must fit in the 256 KiB Step Functions payload. After 10 polls the workflow calls `StopQueryExecution` and fails, so the caller gets an HTTP 500 before the 29-second integration timeout.","The method uses IAM authorization, because the caller's SQL goes straight to Athena, and the stage is throttled to 5 requests per second. Athena reads a sample CSV file through an AWS Glue table and writes results to an Amazon S3 prefix set by its workgroup.","TypeScript","300",{},{"icon1":35,"icon2":40,"icon3":44,"icon4":48,"icon5":52,"line1":56,"line2":60,"line3":63,"line4":66},{"x":36,"y":37,"service":38,"label":39},10,45,"icon-internet","Client",{"x":41,"y":37,"service":42,"label":43},31,"apigw","Amazon API\nGateway",{"x":45,"y":37,"service":46,"label":47},50,"sfn","AWS Step\nFunctions\nExpress",{"x":49,"y":37,"service":50,"label":51},70,"athena","Amazon\nAthena",{"x":53,"y":37,"service":54,"label":55},89,"s3","Amazon S3",{"from":57,"to":58,"label":59},"icon1","icon2","POST",{"from":58,"to":61,"label":62},"icon3","Sync",{"from":61,"to":64,"label":65},"icon4","Query",{"from":64,"to":67,"label":68},"icon5","Read",{"bullets":70},[71,74],{"text":72,"link":73},"Call Amazon Athena with AWS Step Functions","https:\u002F\u002Fdocs.aws.amazon.com\u002Fstep-functions\u002Flatest\u002Fdg\u002Fconnect-athena.html",{"text":75,"link":76},"Synchronous Express Workflows","https:\u002F\u002Fdocs.aws.amazon.com\u002Fstep-functions\u002Flatest\u002Fdg\u002Fexpress-synchronous.html","patterns\u002Fapigw-sfn-athena-typescript-cdk",{"text":79},[80],"Send a SigV4-signed \u003Ccode>POST\u003C\u002Fcode> with a \u003Ccode>queryString\u003C\u002Fcode> to the \u003Ccode>ApiEndpoint\u003C\u002Fcode> output, for example with \u003Ccode>curl --aws-sigv4\u003C\u002Fcode>. See the README in the GitHub repo for the commands.","lhj1079Zd10-cKA78HloS7ax5RaHQPAFAN7kgCv2BMI",1795189148278]