Search in sources :

Example 11 with CloudFormationClient

use of com.amazonaws.athena.connector.integ.clients.CloudFormationClient in project aws-athena-query-federation by awslabs.

the class DocDbIntegTest method setUpTableData.

/**
 * Create and invoke a special Lambda function that sets up the MongoDB table used by the integration tests.
 */
@Override
protected void setUpTableData() {
    logger.info("----------------------------------------------------");
    logger.info("Setting up table for DB ({}): {}", docdbDbName, docdbTableMovies);
    logger.info("----------------------------------------------------");
    String mongoLambdaName = "integ-mongodb-" + UUID.randomUUID();
    AWSLambda lambdaClient = AWSLambdaClientBuilder.defaultClient();
    CloudFormationClient cloudFormationMongoClient = new CloudFormationClient(getMongoLambdaStack(mongoLambdaName));
    try {
        // Create the Lambda function.
        cloudFormationMongoClient.createStack();
        // Invoke the Lambda function.
        lambdaClient.invoke(new InvokeRequest().withFunctionName(mongoLambdaName).withInvocationType(InvocationType.RequestResponse));
    } finally {
        // Delete the Lambda function.
        cloudFormationMongoClient.deleteStack();
        lambdaClient.shutdown();
    }
}
Also used : AWSLambda(com.amazonaws.services.lambda.AWSLambda) InvokeRequest(com.amazonaws.services.lambda.model.InvokeRequest) CloudFormationClient(com.amazonaws.athena.connector.integ.clients.CloudFormationClient)

Aggregations

CloudFormationClient (com.amazonaws.athena.connector.integ.clients.CloudFormationClient)11 BeforeClass (org.testng.annotations.BeforeClass)8 AWSLambda (com.amazonaws.services.lambda.AWSLambda)3 InvokeRequest (com.amazonaws.services.lambda.model.InvokeRequest)3 Endpoint (com.amazonaws.services.elasticache.model.Endpoint)1 EntityNotFoundException (com.amazonaws.services.glue.model.EntityNotFoundException)1