Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
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 e5907fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}
}
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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 :");
Expand Down

0 comments on commit e5907fe

Please sign in to comment.