👨‍👧‍👦

SAMで親子構成のStepFunctionsをデプロイしようとしたら怒られた

2023/04/14に公開

エラー内容

cloudformationから以下の怒られ

Resource handler returned message: "'arn:aws:iam::****' is not authorized to create managed-rule. (Service: AWSStepFunctions; Status Code: 400; Error Code: AccessDeniedException; Request ID: ****; Proxy: null)" (RequestToken: ****, HandlerErrorCode: AccessDenied)

解決方法

親StateMachineのポリシーに以下を追加する

  Parent:
    Type: AWS::Serverless::StateMachine
      ...
      Policies: 
        ...
        - Version: "2012-10-17"
          Statement: 
            - Effect: Allow
              Action:
                - events:PutTargets
                - events:PutRule
                - events:DescribeRule
              Resource: 
                - !Sub arn:${AWS::Partition}:events:${AWS::Region}:${AWS::AccountId}:rule/StepFunctionsGetEventsForStepFunctionsExecutionRule

解説

AWS管理のEventBridgeルールStepFunctionsGetEventsForStepFunctionsExecutionRuleで子StateMachineを管理しているらしい。。。

助けてくれたサイト

https://tech.quickguard.jp/posts/job-manager-using-step-functions/

Discussion