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

docs(samples): update AWS sample due to API changes #576

Merged
merged 1 commit into from Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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