Skip to content

Commit

Permalink
fix: event bridege scheduler で state machine を利用するように修正
Browse files Browse the repository at this point in the history
  • Loading branch information
morikiyo committed Jun 28, 2024
1 parent 9da9cf4 commit 074b987
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
1 change: 1 addition & 0 deletions lib/sg_fargate_rails/event_bridge_schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def initialize(name:, cron:, command:, container_type: 'small', storage_size_gb:
@use_bundler = use_bundler
end

# TODO: 利用しなくなる (state machine に移行する) ので、このメソッドは削除する
def create_run_task(group_name:, cluster_arn:, task_definition_arn:, network_configuration:)
params = {
name: @name,
Expand Down
17 changes: 1 addition & 16 deletions lib/tasks/sg_fargate_rails.rake
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,7 @@ namespace :sg_fargate_rails do
Rails.logger.info "[EventBridgeSchedule] Register schedule #{schedule.name} in #{group_name}"

# TODO: この辺で AWS の API Limit などのエラーが発生するとスケジュールが消えたままとなるので、エラーの内容に応じてリトライなどのエラー処理が必要
if true # FIXME: ここで Step Functions を使うかどうかを判定する
schedule.create_start_execution_state_machine(group_name: group_name, cluster_arn: ecs_task.cluster_arn)
else
schedule.create_run_task(
group_name: group_name,
cluster_arn: ecs_task.cluster_arn,
task_definition_arn: ecs_task.task_definition_arn,
network_configuration: {
awsvpc_configuration: {
assign_public_ip: 'ENABLED',
security_groups: ecs_task.security_group_ids,
subnets: ecs_task.public_subnet_ids,
},
}
)
end
schedule.create_start_execution_state_machine(group_name: group_name, cluster_arn: ecs_task.cluster_arn)
end
end

Expand Down

0 comments on commit 074b987

Please sign in to comment.