botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the CreateStateMachine operation

非 Y 不嫁゛ 提交于 2020-04-16 02:16:00

问题


I am getting the following error when I try to create a state machine based on my state machine definition:

botocore.exceptions.ClientError: An error occurred (AccessDeniedException) when calling the CreateStateMachine operation: 'role' is not authorized to create managed-rule.

The creation code:

state_machine = sfn_client.create_state_machine(
    name = 'state-machine',
    definition = state_machine_def,
    roleArn = SFN_ROLE,
)

My IAM role that I use contains all necessary permissions as described here. What kind of managed-rule does it need to have a permission to create?


回答1:


The reason was that CloudWatchFullAccess policy attached to the SFN_ROLE has not enough permissions for Step Functions workflow to post events into CloudWatch. Once I replaced it with CloudWatchEventsFullAccess everything works ok.




回答2:


Most likely you have missed adding the right policy to the IAM role. Here is a policy from the official documentation that allows you to create, list state machines.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "states:ListStateMachines",
        "states:ListActivities",
        "states:CreateStateMachine",
        "states:CreateActivity"
      ],
      "Resource": [ 
        "arn:aws:states:*:*:*" 
      ]
    },
    {
      "Effect": "Allow",
      "Action": [ 
        "iam:PassRole"
      ],
      "Resource": [
        "arn:aws:iam:::role/my-execution-role"
      ]
    }
  ]



回答3:


It turns out that adding CloudWatchEventsFullAccess works for stepfunctions



来源:https://stackoverflow.com/questions/58002280/botocore-exceptions-clienterror-an-error-occurred-accessdeniedexception-when

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!