diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index fd6f8b5a..655588fa 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -10,10 +10,10 @@ [auto-ap.graphql.import-batch :as gq-import-batches] [auto-ap.graphql.intuit-bank-accounts :as gq-intuit-bank-accounts] [auto-ap.graphql.invoices :as gq-invoices] + [auto-ap.graphql.jobs :as gq-jobs] [auto-ap.graphql.ledger :as gq-ledger] [auto-ap.graphql.plaid :as gq-plaid] [auto-ap.graphql.reports :as gq-reports] - [auto-ap.graphql.requests :as gq-requests] [auto-ap.graphql.sales-orders :as gq-sales-orders] [auto-ap.graphql.transaction-rules :as gq-transaction-rules] [auto-ap.graphql.transactions :as gq-transactions] @@ -534,11 +534,7 @@ {:enum-value :equity} {:enum-value :revenue}]}} :mutations - {:request_import - {:type 'String - :args {:which {:type 'String} - :args {:type 'String}} - :resolve :mutation/request-import} + { :delete_transaction_rule {:type :id @@ -784,7 +780,6 @@ :mutation/upsert-vendor gq-vendors/upsert-vendor :mutation/upsert-account gq-accounts/upsert-account :mutation/merge-vendors gq-vendors/merge-vendors - :mutation/request-import gq-requests/request-import :get-vendor gq-vendors/get-graphql :search-vendor gq-vendors/search :search-account gq-accounts/search}) @@ -799,6 +794,7 @@ gq-invoices/attach gq-clients/attach gq-sales-orders/attach + gq-jobs/attach schema/compile)) diff --git a/src/clj/auto_ap/graphql/jobs.clj b/src/clj/auto_ap/graphql/jobs.clj new file mode 100644 index 00000000..d5d2919b --- /dev/null +++ b/src/clj/auto_ap/graphql/jobs.clj @@ -0,0 +1,153 @@ +(ns auto-ap.graphql.jobs + (:require + [amazonica.aws.ecs :as ecs] + [auto-ap.graphql.utils + :refer [assert-admin assert-failure result->page]] + [clj-time.coerce :as coerce] + [clj-time.core :as time] + [clojure.string :as str] + [config.core :refer [env]] + [clojure.tools.logging :as log] + [com.walmartlabs.lacinia.util :refer [attach-resolvers]]) + (:import + (com.amazonaws.services.ecs.model AssignPublicIp))) + +(defn get-ecs-tasks [] + (->> + (concat (:task-arns (ecs/list-tasks :max-results 50)) (:task-arns (ecs/list-tasks :desired-status "STOPPED" :max-results 50))) + (ecs/describe-tasks :include [] :tasks) + :tasks + (map #(assoc % :task-definition (:task-definition (ecs/describe-task-definition :task-definition (:task-definition-arn %))))) + (sort-by :created-at) + reverse)) + +(defn is-background-job? [task] + (->> task + :task-definition + :container-definitions + (mapcat :environment) + (filter (comp #{"INTEGREAT_JOB"} :name)) + seq)) + +(defn task-definition->job-name [task-definition] + (->> (:container-definitions task-definition) + (mapcat :environment) + (filter (comp #{"INTEGREAT_JOB"} :name)) + (map :value) + first)) + +(defn job-exited-successfully? [task] + (if (= 0 (->> task + :containers + (filter (comp #{"integreat-app" } :name)) + (first) + :exit-code)) + true + false)) + +(defn ecs-task->job [task] + + {:status (condp = (:last-status task) + "RUNNING" :running + "PENDING" :pending + "PROVISIONING" :pending + "DEPROVISIONING" :running + "STOPPED" (if (job-exited-successfully? task) + :succeeded + :failed)) + :name (task-definition->job-name (:task-definition task)) + :end-date (some-> (:stopped-at task) coerce/to-date-time (time/to-time-zone (time/time-zone-for-offset 0))) + :start-date (some-> (:created-at task) coerce/to-date-time (time/to-time-zone (time/time-zone-for-offset 0)))}) + +(defn get-jobs-page [context args _] + (assert-admin (:id context)) + (let [args (assoc (:filters args) :id (:id context)) + jobs (->> (get-ecs-tasks) + (filter is-background-job?) + (map ecs-task->job))] + (result->page + jobs + (count jobs) + :data + args))) + + +(defn currently-running-jobs [] + (->> (get-ecs-tasks) + (filter is-background-job?) + (map ecs-task->job) + (filter (comp #{:pending :running} :status)) + (map :name) + set)) + +(defn run-task [task] + (log/info "running job" task) + (ecs/run-task :capacity-provider-strategy [{:base 1 :weight 1 :capacity-provider "FARGATE_SPOT"}] + :count 1 + :cluster "default" + :enable-ecs-managed-tags true + :task-definition task + :network-configuration {:aws-vpc-configuration {:subnets ["subnet-5e675761" "subnet-8519fde2" "subnet-89bab8d4"] + :security-groups ["sg-004e5855310c453a3" "sg-02d167406b1082698"] + :assign-public-ip AssignPublicIp/ENABLED}})) + +(defn request-job [context value _] + (assert-admin (:id context)) + (if (not (get (currently-running-jobs) (:which value))) + (let [new-job (run-task (str (str/replace (:which value) #"-" "_") "_" (:dd-env env)))] + {:message (str "task " (str new-job) " started.")}) + (assert-failure "This job is already running"))) + + +(def objects + {:job {:fields {:name {:type 'String} + :start_date {:type :iso_date_time} + :end_date {:type :iso_date_time} + :status {:type :job_status}}} + + :jobs_page {:fields {:data {:type '(list :job)} + :count {:type 'Int} + :total {:type 'Int} + :start {:type 'Int} + :end {:type 'Int}}}}) + +(def input-objects + {:jobs_filters {:fields {:sort {:type '(list :sort_item)} + :start {:type 'Int} + :per_page {:type 'Int}}}}) + +(def queries + {:jobs_page {:type :jobs_page + :args {:filters {:type :jobs_filters} + :sort {:type '(list :sort_item)} + :start {:type 'Int} + :per_page {:type 'Int}} + :resolve :get-jobs-page}}) + +(def enums + {:job_status {:values [{:enum-value :pending} + {:enum-value :running} + {:enum-value :succeeded} + {:enum-value :failed}]} }) + +(def resolvers + {:get-jobs-page get-jobs-page + :mutation/request-job request-job}) + +(def mutations + {:request_job + {:type :message + :args {:which {:type 'String} + :args {:type 'String}} + :resolve :mutation/request-job}}) + +(defn attach [schema] + (-> + (merge-with merge schema + {:objects objects + :input-objects input-objects + :queries queries + :enums enums + :mutations mutations}) + (attach-resolvers resolvers))) + diff --git a/src/clj/auto_ap/graphql/requests.clj b/src/clj/auto_ap/graphql/requests.clj deleted file mode 100644 index 2c6e8bc0..00000000 --- a/src/clj/auto_ap/graphql/requests.clj +++ /dev/null @@ -1,41 +0,0 @@ -(ns auto-ap.graphql.requests - (:require - [amazonica.aws.ecs :as ecs] - [auto-ap.graphql.utils :refer [assert-admin assert-failure]] - [clojure.string :as str] - [config.core :refer [env]] - [clojure.tools.logging :as log]) - (:import - (com.amazonaws.services.ecs.model AssignPublicIp))) - -(defn currently-running-jobs [] - (->> (ecs/list-tasks :cluster "default" ) - :task-arns - (ecs/describe-tasks :include [] :tasks) - :tasks - #_(filter #(= "RUNNING" (:last-status %))) - (map (comp (comp last butlast) #(str/split % #"[/:]") :task-definition-arn) - - #_(mapcat (comp :container-overrides :overrides))) - (set)) - - ) - -(defn run-task [task] - (log/info "running job" task) - (ecs/run-task :capacity-provider-strategy [{:base 1 :weight 1 :capacity-provider "FARGATE_SPOT"}] - :count 1 - :cluster "default" - :enable-ecs-managed-tags true - :task-definition task - :network-configuration {:aws-vpc-configuration {:subnets ["subnet-5e675761" "subnet-8519fde2" "subnet-89bab8d4"] - :security-groups ["sg-004e5855310c453a3" "sg-02d167406b1082698"] - :assign-public-ip AssignPublicIp/ENABLED}})) - -(defn request-import [context value _] - (assert-admin (:id context)) - (let [job (str (str/replace (str/replace (name (:which value)) #":" "") #"-" "_") "_" (:dd-env env))] - (if (not (get (currently-running-jobs) job)) - (run-task job) - (assert-failure "This job is already running")))) - diff --git a/src/cljc/auto_ap/client_routes.cljc b/src/cljc/auto_ap/client_routes.cljc index 9f9118ee..b183767c 100644 --- a/src/cljc/auto_ap/client_routes.cljc +++ b/src/cljc/auto_ap/client_routes.cljc @@ -13,6 +13,7 @@ "rules" :admin-rules "accounts" :admin-accounts "import-batches" :admin-import-batches + "jobs" :admin-jobs "vendors" :admin-vendors "excel-import" :admin-excel-import } diff --git a/src/cljs/auto_ap/views/components/admin/side_bar.cljs b/src/cljs/auto_ap/views/components/admin/side_bar.cljs index 86fef4ed..5549c781 100644 --- a/src/cljs/auto_ap/views/components/admin/side_bar.cljs +++ b/src/cljs/auto_ap/views/components/admin/side_bar.cljs @@ -59,6 +59,10 @@ [:span {:class "icon"} [:i {:class "fa fa-download"}]] - [:span {:class "name"} "Import Batches"]]]] + [:span {:class "name"} "Import Batches"]]] + [:li.menu-item + [:a {:href (bidi/path-for routes/routes :admin-jobs) :class (str "item" (active-when ap = :admin-jobs))} + [:span {:class "icon icon-cog-play-1" :style {:font-size "25px"}}] + [:span {:class "name"} "Background Jobs"]]]] (into [:div ] (r/children (r/current-component)))])) diff --git a/src/cljs/auto_ap/views/main.cljs b/src/cljs/auto_ap/views/main.cljs index 6cdb524a..3de7a80d 100644 --- a/src/cljs/auto_ap/views/main.cljs +++ b/src/cljs/auto_ap/views/main.cljs @@ -11,6 +11,7 @@ [auto-ap.views.pages.reports :refer [reports-page]] [auto-ap.views.pages.error :refer [error-page]] [auto-ap.views.pages.ledger.balance-sheet :refer [balance-sheet-page]] + [auto-ap.views.pages.admin.jobs :refer [jobs-page]] [auto-ap.views.pages.ledger.external-import :refer [external-import-page]] [auto-ap.views.pages.ledger.external-ledger :refer [external-ledger-page]] [auto-ap.views.pages.ledger.profit-and-loss :refer [profit-and-loss-page]] @@ -109,6 +110,9 @@ (defmethod page :admin-import-batches [_] [import-batches-page]) +(defmethod page :admin-jobs [_] + [jobs-page]) + (defmethod page :yodlee2 [_] (yodlee2/admin-yodlee-provider-accounts-page)) diff --git a/src/cljs/auto_ap/views/pages/admin/import_batches.cljs b/src/cljs/auto_ap/views/pages/admin/import_batches.cljs index 0032d977..38a4b979 100644 --- a/src/cljs/auto_ap/views/pages/admin/import_batches.cljs +++ b/src/cljs/auto_ap/views/pages/admin/import_batches.cljs @@ -1,6 +1,5 @@ (ns auto-ap.views.pages.admin.import-batches (:require - [auto-ap.status :as status] [auto-ap.subs :as subs] [auto-ap.views.components.admin.side-bar :refer [admin-side-bar]] [auto-ap.views.components.layouts :refer [side-bar-layout]] @@ -33,67 +32,6 @@ (set/rename-keys (:result result) {:import-batches :data})])}})) -(re-frame/reg-sub - ::msg - (fn [db] - (::msg db))) - -(re-frame/reg-event-db - ::success-intuit - (fn [db [_ n]] - (assoc db ::msg (str "Your job " (:request-import n) " has been scheduled." )))) - - - -(re-frame/reg-event-fx ::request-intuit - [with-user ] - (fn [{:keys [user]} [_ _]] - {:graphql {:token user - :owns-state {:single ::intuit} - :query "mutation RequestIntuitImport{request_import(which: \":intuit\")}" - :on-success [::success-intuit] - }})) - -(re-frame/reg-event-db - ::success-yodlee2 - (fn [db [_ n]] - (assoc db ::msg (str "Your job " (:request-import n) " has been scheduled." )))) - -(re-frame/reg-event-fx - ::request-yodlee2 - [with-user ] - (fn [{:keys [user]} [_ _]] - {:graphql {:token user - :owns-state {:single ::yodlee2} - :query "mutation RequestIntuitImport{request_import(which: \":yodlee2\")}" - :on-success [::success-yodlee2] - }})) - - - -(re-frame/reg-event-db - ::success-plaid - (fn [db [_ n]] - (assoc db ::msg (str "Your job " (:request-import n) " has been scheduled." )))) - -(re-frame/reg-event-fx - ::request-plaid - [with-user ] - (fn [{:keys [user]} [_ _]] - {:graphql {:token user - :owns-state {:single ::plaid} - :query "mutation RequestIntuitImport{request_import(which: \":plaid\")}" - :on-success [::success-plaid]}})) - -(re-frame/reg-event-fx - ::request-yodlee2-accounts - [with-user ] - (fn [{:keys [user]} [_ _]] - {:graphql {:token user - :owns-state {:single ::yodlee2-accounts} - :query "mutation RequestIntuitImport{request_import(which: \":yodlee2-accounts\")}" - :on-success [::success-yodlee2-accounts]}})) - (re-frame/reg-event-fx ::mounted @@ -115,10 +53,6 @@ (with-meta (fn [] (let [user @(re-frame/subscribe [::subs/user]) - intuit-request-import-status @(re-frame/subscribe [::status/single ::intuit]) - yodlee2-request-import-status @(re-frame/subscribe [::status/single ::yodlee2]) - yodlee2-accounts-request-import-status @(re-frame/subscribe [::status/single ::yodlee2-accounts]) - plaid-request-import-status @(re-frame/subscribe [::status/single ::plaid]) message @(re-frame/subscribe [::msg])] [:div [:h1.title "Import Batches"] @@ -127,32 +61,7 @@ (when (= "admin" (:user/role user)) [:div [:div.is-pulled-right - [:div.buttons - - [:button.button.is-primary-two {:aria-haspopup true - :type "button" - :on-click (dispatch-event [::request-yodlee2]) - :disabled (status/disabled-for yodlee2-request-import-status) - :class (status/class-for yodlee2-request-import-status)} - "Start Yodlee2 Import"] - [:button.button.is-primary-two {:aria-haspopup true - :type "button" - :on-click (dispatch-event [::request-intuit]) - :disabled (status/disabled-for intuit-request-import-status) - :class (status/class-for intuit-request-import-status)} - "Start Intuit Import"] - [:button.button.is-primary-two {:aria-haspopup true - :type "button" - :on-click (dispatch-event [::request-plaid]) - :disabled (status/disabled-for plaid-request-import-status) - :class (status/class-for plaid-request-import-status)} - "Start Plaid Import"] - [:button.button.is-primary-two {:aria-haspopup true - :type "button" - :on-click (dispatch-event [::request-yodlee2-accounts]) - :disabled (status/disabled-for yodlee2-accounts-request-import-status) - :class (status/class-for yodlee2-accounts-request-import-status)} - "Start Yodlee Accounts"]]] + [:div.buttons]] [table/table {:id :import-batches :data-page ::page}]])])) {:component-did-mount (dispatch-event [::mounted ]) diff --git a/src/cljs/auto_ap/views/pages/admin/jobs.cljs b/src/cljs/auto_ap/views/pages/admin/jobs.cljs new file mode 100644 index 00000000..577ff900 --- /dev/null +++ b/src/cljs/auto_ap/views/pages/admin/jobs.cljs @@ -0,0 +1,135 @@ +(ns auto-ap.views.pages.admin.jobs + (:require + [auto-ap.status :as status] + [auto-ap.subs :as subs] + [auto-ap.views.components.admin.side-bar :refer [admin-side-bar]] + [auto-ap.views.components.layouts :refer [side-bar-layout]] + [auto-ap.views.pages.admin.jobs.table :as table] + [auto-ap.views.pages.data-page :as data-page] + [auto-ap.views.utils :refer [dispatch-event with-user]] + [clojure.set :as set] + [re-frame.core :as re-frame] + [vimsical.re-frame.fx.track :as track])) + + +(def default-read [:name :start-date :end-date :status]) +(def job-types [:yodlee2 :yodlee2-accounts :intuit :plaid]) + +(re-frame/reg-event-fx + ::params-change + [with-user ] + (fn [{:keys [user]} [_ params]] + {:graphql {:token user + :owns-state {:single [::data-page/page ::page]} + :query-obj {:venia/queries [{:query/data [:jobs_page + {:filters {:sort (:sort params) + :start (:start params 0) + :per-page (:per-page params)}} + [[:data default-read] + :total + :start + :end]] + :query/alias :result}]} + :on-success (fn [result] + [::data-page/received ::page + (set/rename-keys (:result result) + {:jobs :data})])}})) + +(re-frame/reg-sub + ::msg + (fn [db] + (::msg db))) + +(re-frame/reg-event-fx + ::success + (fn [{:keys [db]} [_ n]] + {:db (assoc db ::msg (:message (:request-job n))) + :dispatch [::params-change]})) + +(re-frame/reg-event-fx + ::request + [with-user ] + (fn [{:keys [user]} [_ which]] + {:graphql {:token user + :owns-state {:single which} + :query-obj + {:venia/operation {:operation/type :mutation + :operation/name "RequestJob"} + :venia/queries [{:query/data + [:request-job + {:which (name which)} + [:message]]}]} + :on-success [::success]}})) + + +(re-frame/reg-event-fx + ::mounted + (fn [_] + {::track/register {:id ::params + :subscription [::data-page/params ::page] + :event-fn (fn [params] + [::params-change params])}})) + +(re-frame/reg-event-fx + ::unmounted + (fn [{:keys [db]}] + {:dispatch-n (into [[::data-page/dispose ::page]] + (map (fn [jt] + [::status/dispose-single jt] + ) + job-types)) + ::track/dispose {:id ::params} + :db (dissoc db ::msg)})) + +(defn job-button [{:keys [which]} content] + (let [status @(re-frame/subscribe [::status/single which])] + (println status) + [:button.button.is-primary-two {:type "button" + :on-click (dispatch-event [::request which]) + :disabled (status/disabled-for status) + :class (status/class-for status)} + content])) + +(defn notification [] + [:<> + (when-let [msg @(re-frame/subscribe [::msg])] + [:div.notification.is-info.is-light msg]) + (doall (for [status job-types + :let [state @(re-frame/subscribe [::status/single status])]] + ^{:key (str status) } + [:div + (cond (:info state) + [:div.notification.is-info.is-light (:info state)] + + (seq (:error state)) + [:div.notification.is-info.is-warning.is-light (:message (first (:error state)))] + + :else + nil)]))]) + +;; VIEWS +(def jobs-content + (with-meta + (fn [] + (let [user @(re-frame/subscribe [::subs/user])] + [:div + [:h1.title "Jobs"] + [notification] + + (when (= "admin" (:user/role user)) + [:div + [:div.is-pulled-right + [:div.buttons + [job-button {:which :yodlee2} "Start Yodlee Import"] + [job-button {:which :yodlee2-accounts} "Start Yodlee Account Import"] + [job-button {:which :intuit} "Start Intuit"] + [job-button {:which :plaid} "Start Plaid"]]] + [table/table {:id :jobs + :data-page ::page}]])])) + {:component-did-mount (dispatch-event [::mounted ]) + :component-will-unmount #(re-frame/dispatch-sync [::unmounted])})) + +(defn jobs-page [] + [side-bar-layout {:side-bar [admin-side-bar {}] + :main [jobs-content]}]) + diff --git a/src/cljs/auto_ap/views/pages/admin/jobs/table.cljs b/src/cljs/auto_ap/views/pages/admin/jobs/table.cljs new file mode 100644 index 00000000..d0ae70c1 --- /dev/null +++ b/src/cljs/auto_ap/views/pages/admin/jobs/table.cljs @@ -0,0 +1,72 @@ +(ns auto-ap.views.pages.admin.jobs.table + (:require + [auto-ap.status :as status] + [auto-ap.subs :as subs] + [auto-ap.views.components.grid :as grid] + [auto-ap.views.pages.data-page :as data-page] + [auto-ap.views.utils + :refer [action-cell-width date->str dispatch-event pretty-long]] + [cljs-time.core :as time] + [re-frame.core :as re-frame] + [reagent.core :as r])) + +(re-frame/reg-sub + ::specific-table-params + (fn [db] + (::table-params db))) + + +(re-frame/reg-event-db + ::unmounted + (fn [db] + (status/reset-multi db ::run))) + +(re-frame/reg-sub + ::table-params + :<- [::specific-table-params] + :<- [::subs/query-params] + (fn [[specific-table-params query-params]] + (merge (select-keys query-params #{:start :sort}) specific-table-params ))) + +(defn table* [{:keys [data-page]}] + (let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])] + [grid/grid {:data-page data-page + :column-count 6} + [grid/controls data] + [grid/table {:fullwidth true } + [grid/header + [grid/row {} + [grid/header-cell {} + "Start Date"] + + [grid/header-cell + "End Date"] + + [grid/header-cell + "Duration"] + [grid/header-cell + "Job Name"] + + [grid/header-cell {} + "Status"] + + [grid/header-cell {:style {:width (action-cell-width 3)}}]]] + [grid/body + (for [{:keys [start-date end-date status name] :as r} (:data data)] + ^{:key (str start-date)} + [grid/row {:class (:class r) :id (str start-date)} + [grid/cell {} (some-> start-date (date->str pretty-long))] + [grid/cell {} (some-> end-date (date->str pretty-long))] + [grid/cell {} (when (and start-date end-date) + (str (time/in-minutes (time/interval start-date end-date)) " minutes"))] + [grid/cell {} name] + [grid/cell {} status] + + [grid/button-cell {} + ] + ])]]])) + +(defn table [] + (r/create-class {:component-will-unmount (dispatch-event [::unmounted]) + :reagent-render (fn [params] + [table* params])})) diff --git a/terraform/deploy.tf b/terraform/deploy.tf index ed55a9fa..1d938f0e 100644 --- a/terraform/deploy.tf +++ b/terraform/deploy.tf @@ -415,6 +415,6 @@ module "yodlee2_accounts_job" { job_name = "yodlee2-accounts" execution_role_arn = var.execution_role_arn use_schedule = false - memory = 1024 + memory = 2048 cpu = 512 } \ No newline at end of file diff --git a/terraform/terraform.tfstate.d/prod/terraform.tfstate b/terraform/terraform.tfstate.d/prod/terraform.tfstate index 1bee9e79..3ae5ec71 100644 --- a/terraform/terraform.tfstate.d/prod/terraform.tfstate +++ b/terraform/terraform.tfstate.d/prod/terraform.tfstate @@ -1,7 +1,7 @@ { "version": 4, "terraform_version": "1.2.7", - "serial": 214, + "serial": 217, "lineage": "9b630886-8cee-a57d-c7a2-4f19f13f9c51", "outputs": { "aws_access_key_id": { @@ -164,7 +164,7 @@ ], "tags": {}, "tags_all": {}, - "task_definition": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod:370", + "task_definition": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod:372", "timeouts": { "delete": null }, @@ -2413,7 +2413,7 @@ { "schema_version": 1, "attributes": { - "arn": "arn:aws:ecs:us-east-1:679918342773:task-definition/yodlee2_accounts_prod:1", + "arn": "arn:aws:ecs:us-east-1:679918342773:task-definition/yodlee2_accounts_prod:2", "container_definitions": "[{\"cpu\":0,\"dockerLabels\":{\"com.datadoghq.tags.env\":\"prod\",\"com.datadoghq.tags.service\":\"yodlee2-accounts\"},\"environment\":[{\"name\":\"DD_CONTAINER_ENV_AS_TAGS\",\"value\":\"{\\\"INTEGREAT_JOB\\\":\\\"background_job\\\"}\"},{\"name\":\"DD_ENV\",\"value\":\"prod\"},{\"name\":\"DD_SERVICE\",\"value\":\"yodlee2-accounts\"},{\"name\":\"INTEGREAT_JOB\",\"value\":\"yodlee2-accounts\"},{\"name\":\"config\",\"value\":\"/usr/local/config/prod-background-worker.edn\"}],\"essential\":true,\"image\":\"679918342773.dkr.ecr.us-east-1.amazonaws.com/integreat:prod\",\"logConfiguration\":{\"logDriver\":\"awslogs\",\"options\":{\"awslogs-group\":\"/ecs/integreat-background-worker-prod\",\"awslogs-region\":\"us-east-1\",\"awslogs-stream-prefix\":\"ecs\"}},\"mountPoints\":[],\"name\":\"integreat-app\",\"portMappings\":[{\"containerPort\":9000,\"hostPort\":9000,\"protocol\":\"tcp\"},{\"containerPort\":9090,\"hostPort\":9090,\"protocol\":\"tcp\"}],\"volumesFrom\":[]},{\"cpu\":0,\"environment\":[{\"name\":\"DD_API_KEY\",\"value\":\"ce10d932c47b358e81081ae67bd8c112\"},{\"name\":\"ECS_FARGATE\",\"value\":\"true\"}],\"essential\":true,\"image\":\"public.ecr.aws/datadog/agent:latest\",\"mountPoints\":[],\"name\":\"datadog-agent\",\"portMappings\":[],\"volumesFrom\":[]}]", "cpu": "512", "ephemeral_storage": [], @@ -2422,7 +2422,7 @@ "id": "yodlee2_accounts_prod", "inference_accelerator": [], "ipc_mode": "", - "memory": "1024", + "memory": "2048", "network_mode": "awsvpc", "pid_mode": "", "placement_constraints": [], @@ -2430,7 +2430,7 @@ "requires_compatibilities": [ "FARGATE" ], - "revision": 1, + "revision": 2, "runtime_platform": [], "tags": null, "tags_all": {}, diff --git a/terraform/terraform.tfstate.d/prod/terraform.tfstate.backup b/terraform/terraform.tfstate.d/prod/terraform.tfstate.backup index 223128cf..1bee9e79 100644 --- a/terraform/terraform.tfstate.d/prod/terraform.tfstate.backup +++ b/terraform/terraform.tfstate.d/prod/terraform.tfstate.backup @@ -1,7 +1,7 @@ { "version": 4, "terraform_version": "1.2.7", - "serial": 212, + "serial": 214, "lineage": "9b630886-8cee-a57d-c7a2-4f19f13f9c51", "outputs": { "aws_access_key_id": { @@ -118,7 +118,7 @@ ], "deployment_maximum_percent": 200, "deployment_minimum_healthy_percent": 100, - "desired_count": 4, + "desired_count": 2, "enable_ecs_managed_tags": false, "enable_execute_command": false, "force_new_deployment": null, @@ -164,7 +164,7 @@ ], "tags": {}, "tags_all": {}, - "task_definition": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod:368", + "task_definition": "arn:aws:ecs:us-east-1:679918342773:task-definition/integreat_app_prod:370", "timeouts": { "delete": null }, @@ -1071,6 +1071,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 0, "attributes": { "arn": "arn:aws:events:us-east-1:679918342773:rule/close-auto-invoices-schedule", @@ -1099,6 +1100,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 1, "attributes": { "arn": "arn:aws:ecs:us-east-1:679918342773:cluster/default", @@ -1203,6 +1205,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 0, "attributes": { "arn": "arn:aws:events:us-east-1:679918342773:rule/current-balance-cache-schedule", @@ -1231,6 +1234,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 1, "attributes": { "arn": "arn:aws:ecs:us-east-1:679918342773:cluster/default", @@ -1335,6 +1339,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 0, "attributes": { "arn": "arn:aws:events:us-east-1:679918342773:rule/import-uploaded-invoices-schedule", @@ -1363,6 +1368,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 1, "attributes": { "arn": "arn:aws:ecs:us-east-1:679918342773:cluster/default", @@ -1467,6 +1473,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 0, "attributes": { "arn": "arn:aws:events:us-east-1:679918342773:rule/intuit-schedule", @@ -1495,6 +1502,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 1, "attributes": { "arn": "arn:aws:ecs:us-east-1:679918342773:cluster/default", @@ -1599,6 +1607,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 0, "attributes": { "arn": "arn:aws:events:us-east-1:679918342773:rule/plaid-schedule", @@ -1627,6 +1636,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 1, "attributes": { "arn": "arn:aws:ecs:us-east-1:679918342773:cluster/default", @@ -1731,6 +1741,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 0, "attributes": { "arn": "arn:aws:events:us-east-1:679918342773:rule/reconcile-ledger-schedule", @@ -1759,6 +1770,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 1, "attributes": { "arn": "arn:aws:ecs:us-east-1:679918342773:cluster/default", @@ -1863,6 +1875,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 0, "attributes": { "arn": "arn:aws:events:us-east-1:679918342773:rule/square2-import-job-schedule", @@ -1891,6 +1904,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 1, "attributes": { "arn": "arn:aws:ecs:us-east-1:679918342773:cluster/default", @@ -1995,6 +2009,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 0, "attributes": { "arn": "arn:aws:events:us-east-1:679918342773:rule/square-import-job-schedule", @@ -2023,6 +2038,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 1, "attributes": { "arn": "arn:aws:ecs:us-east-1:679918342773:cluster/default", @@ -2127,6 +2143,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 0, "attributes": { "arn": "arn:aws:events:us-east-1:679918342773:rule/sysco-schedule", @@ -2155,6 +2172,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 1, "attributes": { "arn": "arn:aws:ecs:us-east-1:679918342773:cluster/default", @@ -2259,6 +2277,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 0, "attributes": { "arn": "arn:aws:events:us-east-1:679918342773:rule/vendor-usages-schedule", @@ -2287,6 +2306,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 1, "attributes": { "arn": "arn:aws:ecs:us-east-1:679918342773:cluster/default", @@ -2383,6 +2403,45 @@ } ] }, + { + "module": "module.yodlee2_accounts_job", + "mode": "managed", + "type": "aws_ecs_task_definition", + "name": "background_taskdef", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ecs:us-east-1:679918342773:task-definition/yodlee2_accounts_prod:1", + "container_definitions": "[{\"cpu\":0,\"dockerLabels\":{\"com.datadoghq.tags.env\":\"prod\",\"com.datadoghq.tags.service\":\"yodlee2-accounts\"},\"environment\":[{\"name\":\"DD_CONTAINER_ENV_AS_TAGS\",\"value\":\"{\\\"INTEGREAT_JOB\\\":\\\"background_job\\\"}\"},{\"name\":\"DD_ENV\",\"value\":\"prod\"},{\"name\":\"DD_SERVICE\",\"value\":\"yodlee2-accounts\"},{\"name\":\"INTEGREAT_JOB\",\"value\":\"yodlee2-accounts\"},{\"name\":\"config\",\"value\":\"/usr/local/config/prod-background-worker.edn\"}],\"essential\":true,\"image\":\"679918342773.dkr.ecr.us-east-1.amazonaws.com/integreat:prod\",\"logConfiguration\":{\"logDriver\":\"awslogs\",\"options\":{\"awslogs-group\":\"/ecs/integreat-background-worker-prod\",\"awslogs-region\":\"us-east-1\",\"awslogs-stream-prefix\":\"ecs\"}},\"mountPoints\":[],\"name\":\"integreat-app\",\"portMappings\":[{\"containerPort\":9000,\"hostPort\":9000,\"protocol\":\"tcp\"},{\"containerPort\":9090,\"hostPort\":9090,\"protocol\":\"tcp\"}],\"volumesFrom\":[]},{\"cpu\":0,\"environment\":[{\"name\":\"DD_API_KEY\",\"value\":\"ce10d932c47b358e81081ae67bd8c112\"},{\"name\":\"ECS_FARGATE\",\"value\":\"true\"}],\"essential\":true,\"image\":\"public.ecr.aws/datadog/agent:latest\",\"mountPoints\":[],\"name\":\"datadog-agent\",\"portMappings\":[],\"volumesFrom\":[]}]", + "cpu": "512", + "ephemeral_storage": [], + "execution_role_arn": "arn:aws:iam::679918342773:role/ecsTaskExecutionRole", + "family": "yodlee2_accounts_prod", + "id": "yodlee2_accounts_prod", + "inference_accelerator": [], + "ipc_mode": "", + "memory": "1024", + "network_mode": "awsvpc", + "pid_mode": "", + "placement_constraints": [], + "proxy_configuration": [], + "requires_compatibilities": [ + "FARGATE" + ], + "revision": 1, + "runtime_platform": [], + "tags": null, + "tags_all": {}, + "task_role_arn": "arn:aws:iam::679918342773:role/datomic-ddb", + "volume": [] + }, + "sensitive_attributes": [], + "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==" + } + ] + }, { "module": "module.yodlee2_job", "mode": "managed", @@ -2391,6 +2450,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 0, "attributes": { "arn": "arn:aws:events:us-east-1:679918342773:rule/yodlee2-schedule", @@ -2419,6 +2479,7 @@ "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", "instances": [ { + "index_key": 0, "schema_version": 1, "attributes": { "arn": "arn:aws:ecs:us-east-1:679918342773:cluster/default",