From 820b2cff29bf3a0d97399667264591b995cc9e45 Mon Sep 17 00:00:00 2001 From: Peter Turcsanyi Date: Mon, 7 Jun 2021 10:21:14 +0200 Subject: [PATCH] NIFI-8662: Using the configured AWS region when parsing from VPCE endpoint URL fails in AbstractAWSProcessor This closes #5140. Signed-off-by: Tamas Palfy --- .../processors/aws/AbstractAWSProcessor.java | 20 ++++--- .../nifi/processors/aws/sqs/ITPutSQS.java | 53 +++++++++++++------ 2 files changed, 49 insertions(+), 24 deletions(-) diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java index 47672fc639..44da97832e 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java @@ -154,6 +154,7 @@ public abstract class AbstractAWSProcessor attrs = new HashMap<>(); attrs.put("filename", "1.txt"); runner.enqueue(Paths.get("src/test/resources/hello.txt"), attrs); - runner.setProperty(PutSQS.AWS_CREDENTIALS_PROVIDER_SERVICE, "awsCredentialsProvider"); runner.run(1); - final List flowFiles = runner.getFlowFilesForRelationship(PutSQS.REL_SUCCESS); - for (final MockFlowFile mff : flowFiles) { - System.out.println(mff.getAttributes()); - System.out.println(new String(mff.toByteArray())); - } + runner.assertAllFlowFilesTransferred(PutSQS.REL_SUCCESS, 1); + } + @Test + public void testVpceEndpoint() throws IOException { + // additional AWS environment setup for testing VPCE endpoints: + // - create an Interface Endpoint in your VPC for SQS (https://docs.aws.amazon.com/vpc/latest/privatelink/vpce-interface.html#create-interface-endpoint) + // - create a Client VPN Endpoint in your VPC (https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/cvpn-getting-started.html) + // and connect your local machine (running the test) to your VPC via VPN + // - alternatively, the test can be run on an EC2 instance located on the VPC + + final TestRunner runner = TestRunners.newTestRunner(new PutSQS()); + runner.setProperty(PutSQS.CREDENTIALS_FILE, System.getProperty("user.home") + "/aws-credentials.properties"); + runner.setProperty(PutSQS.REGION, Regions.US_WEST_2.getName()); + runner.setProperty(PutSQS.QUEUE_URL, VPCE_QUEUE_URL); + runner.setProperty(PutSQS.ENDPOINT_OVERRIDE, VPCE_ENDPOINT_OVERRIDE); + + runner.enqueue(Paths.get("src/test/resources/hello.txt")); + runner.run(1); + + runner.assertAllFlowFilesTransferred(PutSQS.REL_SUCCESS, 1); } }