This error occurs when you are trying to create a CloudWatch Logs subscription filter for an Amazon Elasticsearch Service (Amazon ES) domain, but the credentials you are using are not correctly scoped to the 'es' service.

To resolve this issue, make sure you have the correct credentials that are scoped to the Amazon ES service. You can do this by following these steps:

  1. Open the Amazon Elasticsearch Service console.
  2. Select your domain.
  3. Click on the "Actions" button.
  4. Choose "Modify access policy".
  5. Ensure that the IAM role or user you are using has the necessary permissions to access the Amazon ES domain. If not, modify the access policy accordingly.
  6. Save the access policy changes.

Once you have the correct credentials, try running the aws logs put-subscription-filter command again with the updated credentials. This should resolve the 403 error

aws logs put-subscription-filter An error occurred 403 when calling the PutSubscriptionFilter operation Credential should be scoped to correct service es