use of software.amazon.awssdk.services.iam.model.CreateRoleRequest in project aws-doc-sdk-examples by awsdocs.
the class DemoUtils method createPersonalizeRole.
public static String createPersonalizeRole(IamClient iamClient, String roleName) {
String roleArn = checkRoleExists(iamClient, roleName);
String minimumPersonalizeAccessPolicyArn;
try {
if (roleArn.length() == 0) {
CreateRoleRequest createRoleRequest = CreateRoleRequest.builder().roleName(roleName).assumeRolePolicyDocument(ASSUME_ROLE_POLICY).description("PersonalizeRole").build();
CreateRoleResponse response = iamClient.createRole(createRoleRequest);
roleArn = response.role().arn();
System.out.println("The ARN of your Amazon Personalize service role is " + roleArn);
}
minimumPersonalizeAccessPolicyArn = createPersonalizeIamPolicy(iamClient, "minimumPersonalizeAccessPolicy");
attachIamPolicyToRole(iamClient, roleName, minimumPersonalizeAccessPolicyArn);
attachIamPolicyToRole(iamClient, roleName, "arn:aws:iam::aws:policy/AmazonS3FullAccess");
return roleArn;
} catch (IamException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
return roleArn;
}
use of software.amazon.awssdk.services.iam.model.CreateRoleRequest in project flink by apache.
the class AWSServicesTestUtils method createIAMRole.
public static void createIAMRole(IamAsyncClient iam, String roleName) throws ExecutionException, InterruptedException {
CreateRoleRequest request = CreateRoleRequest.builder().roleName(roleName).build();
CompletableFuture<CreateRoleResponse> responseFuture = iam.createRole(request);
responseFuture.get();
}
Aggregations