use of com.google.cloud.bigquery.connection.v1.AwsAccessRole in project java-bigqueryconnection by googleapis.
the class CreateAwsConnectionIT method testCreateAwsConnection.
@Test
public void testCreateAwsConnection() throws IOException {
String iamRoleId = String.format("arn:aws:iam::%s:role/%s", AWS_ACCOUNT_ID, AWS_ROLE_ID);
AwsAccessRole awsRole = AwsAccessRole.newBuilder().setIamRoleId(iamRoleId).build();
AwsProperties awsProperties = AwsProperties.newBuilder().setAccessRole(awsRole).build();
Connection connection = Connection.newBuilder().setAws(awsProperties).build();
CreateAwsConnection.createAwsConnection(PROJECT_ID, LOCATION, connectionId, connection);
assertThat(bout.toString()).contains("Aws connection created successfully :");
}
use of com.google.cloud.bigquery.connection.v1.AwsAccessRole in project java-bigqueryconnection by googleapis.
the class CreateAwsConnection method createAwsConnection.
public static void createAwsConnection(String projectId, String location, String connectionId, Connection connection) throws IOException {
try (ConnectionServiceClient client = ConnectionServiceClient.create()) {
LocationName parent = LocationName.of(projectId, location);
CreateConnectionRequest request = CreateConnectionRequest.newBuilder().setParent(parent.toString()).setConnection(connection).setConnectionId(connectionId).build();
Connection response = client.createConnection(request);
AwsAccessRole role = response.getAws().getAccessRole();
System.out.println("Aws connection created successfully : Aws userId :" + role.getIamRoleId() + " Aws externalId :" + role.getIdentity());
}
}
Aggregations