use of software.amazon.awssdk.services.iam.model.Policy in project aws-doc-sdk-examples by awsdocs.
the class DemoUtils method getIamPolicyArn.
private static String getIamPolicyArn(IamClient iamClient, String policyName) {
try {
ListPoliciesRequest listPoliciesRequest = ListPoliciesRequest.builder().build();
ListPoliciesResponse listPoliciesResponse = iamClient.listPolicies(listPoliciesRequest);
for (Policy policy : listPoliciesResponse.policies()) {
if (policy.policyName().equals(policyName)) {
return policy.arn();
}
}
} catch (IamException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
return null;
}
Aggregations