Skip to content
Permalink
Browse files
docs(samples): update AWS sample due to API changes (#576)
AwsCrossAccountRole is replaced with AwsAccessRole
Fixes #571
  • Loading branch information
stephaniewang526 committed Nov 11, 2021
1 parent 439d33c commit e5907fe5b33ebabd17e3a1c6ccbd646c8ffaa217
@@ -17,6 +17,7 @@
package com.example.bigqueryconnection;

// [START bigqueryconnection_create_aws_connection]
import com.google.cloud.bigquery.connection.v1.AwsAccessRole;
import com.google.cloud.bigquery.connection.v1.AwsCrossAccountRole;
import com.google.cloud.bigquery.connection.v1.AwsProperties;
import com.google.cloud.bigquery.connection.v1.Connection;
@@ -54,12 +55,12 @@ public static void createAwsConnection(
.setConnectionId(connectionId)
.build();
Connection response = client.createConnection(request);
AwsCrossAccountRole role = response.getAws().getCrossAccountRole();
AwsAccessRole role = response.getAws().getAccessRole();
System.out.println(
"Aws connection created successfully : Aws userId :"
+ role.getIamUserId()
+ role.getIamRoleId()
+ " Aws externalId :"
+ role.getExternalId());
+ role.getIdentity());
}
}
}
@@ -19,7 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.TestCase.assertNotNull;

import com.google.cloud.bigquery.connection.v1.AwsCrossAccountRole;
import com.google.cloud.bigquery.connection.v1.AwsAccessRole;
import com.google.cloud.bigquery.connection.v1.AwsProperties;
import com.google.cloud.bigquery.connection.v1.Connection;
import java.io.ByteArrayOutputStream;
@@ -83,8 +83,8 @@ public void tearDown() throws IOException {
@Test
public void testCreateAwsConnection() throws IOException {
String iamRoleId = String.format("arn:aws:iam::%s:role/%s", AWS_ACCOUNT_ID, AWS_ROLE_ID);
AwsCrossAccountRole role = AwsCrossAccountRole.newBuilder().setIamRoleId(iamRoleId).build();
AwsProperties awsProperties = AwsProperties.newBuilder().setCrossAccountRole(role).build();
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 :");

0 comments on commit e5907fe

Please sign in to comment.