Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[review] config.scheduled_state_machine_enabled を追加 #59

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/sg_fargate_rails/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module SgFargateRails
class Config
attr_reader :proxy_ip_addresses
attr_accessor :middleware_enabled
attr_accessor :scheduled_state_machine_enabled

# NOTE: good_jobダッシュボードへのアクセスをproxy経由のアクセスに制限するかどうか
attr_accessor :restrict_access_to_good_job_dashboard
Expand All @@ -10,6 +11,9 @@ def initialize
self.proxy_ip_addresses = ENV['SG_PROXY_IP_ADDRESSES']
self.restrict_access_to_good_job_dashboard = Rails.env.production?
self.middleware_enabled = !Rails.env.development? && !Rails.env.test?

# NOTE: このオプションは近い将来にデフォルト true へ変更、最終的に削除される予定
self.scheduled_state_machine_enabled = false
end

def proxy_ip_addresses=(ip_addresses)
Expand Down
17 changes: 16 additions & 1 deletion lib/tasks/sg_fargate_rails.rake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,22 @@ namespace :sg_fargate_rails do
Rails.logger.info "[EventBridgeSchedule] Register schedule #{schedule.name} in #{group_name}"

# TODO: この辺で AWS の API Limit などのエラーが発生するとスケジュールが消えたままとなるので、エラーの内容に応じてリトライなどのエラー処理が必要
schedule.create_start_execution_state_machine(group_name: group_name, cluster_arn: ecs_task.cluster_arn)
if SgFargateRails.config.scheduled_state_machine_enabled
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
end
end

Expand Down
Loading