Failed to set number of replicas due no permissions

Hi,

I have the problem with running index managment policy for new indices. I get following error on “set number_of_replicas” step:

{
    "cause": "no permissions for [indices:admin/settings/update] and associated roles [index_management_full_access, own_index, security_rest_api_access]",
    "message": "Failed to set number_of_replicas to 2 [index=sample.name-2022.10.22]"
}

The indices are created by logstash with “sample.name-YYYY.MM.DD” name template, so in the index policy I have “sample.name-*” index pattern.

Retry of the policy doesn’t work.
The policy works only if I manually reassign it to index by Dashboards or API.

My policy:

{
    "policy_id": "sample.name-*",
    "description": "sample.name-* policy ",
    "schema_version": 16,
    "error_notification": null,
    "default_state": "set replicas",
    "states": [
        {
            "name": "set replicas",
            "actions": [
                {
                    "retry": {
                        "count": 3,
                        "backoff": "exponential",
                        "delay": "1m"
                    },
                    "replica_count": {
                        "number_of_replicas": 2
                    }
                }
            ],
            "transitions": [
                {
                    "state_name": "delete",
                    "conditions": {
                        "min_index_age": "30d"
                    }
                }
            ]
        },
        {
            "name": "delete",
            "actions": [
                {
                    "retry": {
                        "count": 3,
                        "backoff": "exponential",
                        "delay": "1m"
                    },
                    "delete": {}
                }
            ],
            "transitions": []
        }
    ],
    "ism_template": [
        {
            "index_patterns": [
                "sample.name-*"
            ],
            "priority": 1
        }
    ]
}

I don’t understand the reason of this error.
Am I doing something wrong?

Thanks.

Update.

First time I created the policy using API under custom internal user with mapped “security_rest_api_access” security role only.

So I added all_access rights to my internal user and re-created policy and it works!

Seems that the policy runs under my internal user, which created it.

Is that a bug ?