From 5d1c420a3e638304e8af03926dbaa3785493f72a Mon Sep 17 00:00:00 2001 From: Morikiyo INOHA Date: Fri, 19 Apr 2024 17:22:04 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20state=20machine=20=E7=94=A8=E3=81=AE=20r?= =?UTF-8?q?ole=20=E3=82=92=E6=8C=87=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/sg_fargate_rails/event_bridge_schedule.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/sg_fargate_rails/event_bridge_schedule.rb b/lib/sg_fargate_rails/event_bridge_schedule.rb index c04809d..f3c40f0 100644 --- a/lib/sg_fargate_rails/event_bridge_schedule.rb +++ b/lib/sg_fargate_rails/event_bridge_schedule.rb @@ -56,12 +56,12 @@ def create_start_execution_state_machine(group_name:, state_machine_arn:) schedule_expression_timezone: timezone, target: { arn: state_machine_arn, - input: input_overrides_json, # FIXME: このまま? + input: input_overrides_json, retry_policy: { maximum_event_age_in_seconds: 120, maximum_retry_attempts: 2, }, - role_arn: role_arn_for(group_name, cluster_arn), # FIXME: IAM Role は同じものを利用できる? + role_arn: role_arn_for_state_machine(group_name, cluster_arn), }, } client.create_schedule(params) @@ -111,6 +111,11 @@ def role_arn_for(group_name, cluster_arn) "arn:aws:iam::#{account_id}:role/#{group_name}-eventbridge-scheduler-role" end + def role_arn_for_state_machine(group_name, cluster_arn) + account_id = cluster_arn.split(':')[4] + "arn:aws:iam::#{account_id}:role/#{group_name}-step-functions-state-machine-role" + end + def client self.class.client end