I do have an SNS Topic in my AWS account, which I created through Java SDK, hence the policies attached are default policies.
Is there any way to update the policy through java SDK itself?
I do have an SNS Topic in my AWS account, which I created through Java SDK, hence the policies attached are default policies.
Is there any way to update the policy through java SDK itself?
Yes, you can use the addPermission and removePermission methods with the PermissionRequest.Builder to define the actions/principals
An example code snippet:
AddPermissionRequest addPermissionRequest = new AddPermissionRequest();
addPermissionRequest.setTopicArn("arn:aws:sns:....");
addPermissionRequest.setAWSAccountIds("arn:aws:iam::account:role/role-name-with-path");
addPermissionRequest.setActionNames("sns:Publish", "sns:GetTopicAttributes");
AddPermissionResult addPermissionResult = snsClient.addPermission(addPermissionRequest);