From 80112d08a741e0204687e6dbdfd0a6818ed555a4 Mon Sep 17 00:00:00 2001 From: BC Date: Thu, 14 Jun 2018 23:16:10 -0700 Subject: [PATCH] automated imports. --- .../1529005616-DOWN-add-yodleee-staging.sql | 2 +- .../1529005616-UP-add-yodleee-staging.sql | 8 +- src/clj/auto_ap/db/checks.clj | 5 +- src/clj/auto_ap/db/transactions.clj | 32 ++++ src/clj/auto_ap/db/yodlee_imports.clj | 14 -- src/clj/auto_ap/graphql.clj | 32 ++++ src/clj/auto_ap/graphql/invoices.clj | 2 +- src/clj/auto_ap/handler.clj | 17 +- src/clj/auto_ap/server.clj | 2 +- src/clj/auto_ap/yodlee/import.clj | 78 ++++++--- src/cljs/auto_ap/routes.cljs | 3 +- .../auto_ap/views/components/typeahead.cljs | 1 - src/cljs/auto_ap/views/main.cljs | 11 +- src/cljs/auto_ap/views/pages.cljs | 4 + src/cljs/auto_ap/views/pages/checks.cljs | 2 +- .../auto_ap/views/pages/unpaid_invoices.cljs | 1 - src/cljs/auto_ap/views/utils.cljs | 1 - .../staging/terraform.tfstate | 150 +++++++++++++++- .../staging/terraform.tfstate.backup | 164 +++++++++++++++++- 19 files changed, 458 insertions(+), 71 deletions(-) create mode 100644 src/clj/auto_ap/db/transactions.clj delete mode 100644 src/clj/auto_ap/db/yodlee_imports.clj diff --git a/migrator/migrations/1529005616-DOWN-add-yodleee-staging.sql b/migrator/migrations/1529005616-DOWN-add-yodleee-staging.sql index 8ece9cc4..a7c284c6 100644 --- a/migrator/migrations/1529005616-DOWN-add-yodleee-staging.sql +++ b/migrator/migrations/1529005616-DOWN-add-yodleee-staging.sql @@ -1,2 +1,2 @@ -- 1529005616 DOWN add-yodleee-staging -drop table yodlee_imports; +drop table transactions; diff --git a/migrator/migrations/1529005616-UP-add-yodleee-staging.sql b/migrator/migrations/1529005616-UP-add-yodleee-staging.sql index 34da9a2d..a01409e1 100644 --- a/migrator/migrations/1529005616-UP-add-yodleee-staging.sql +++ b/migrator/migrations/1529005616-UP-add-yodleee-staging.sql @@ -1,5 +1,5 @@ -- 1529005616 UP add-yodleee-staging -create table yodlee_imports ( +create table transactions ( amount decimal, description_original varchar(255), description_simple varchar (255), @@ -10,6 +10,10 @@ date timestamp, post_date timestamp, type varchar(255), account_id int, -status varchar(255)); +status varchar(255), +vendor_id int references vendors(id), +company_id int references companies(id), +check_id int references checks(id) +); diff --git a/src/clj/auto_ap/db/checks.clj b/src/clj/auto_ap/db/checks.clj index 1c07acf3..ca5d95f4 100644 --- a/src/clj/auto_ap/db/checks.clj +++ b/src/clj/auto_ap/db/checks.clj @@ -68,9 +68,10 @@ :else q))) -(defn base-graphql [{:keys [company-id]}] +(defn base-graphql [{:keys [company-id vendor-id]}] (cond-> base-query - (not (nil? company-id)) (helpers/merge-where [:= :company-id company-id]))) + (not (nil? company-id)) (helpers/merge-where [:= :company-id company-id]) + (not (nil? vendor-id)) (helpers/merge-where [:= :vendor-id vendor-id]))) (defn get-graphql [{:keys [start sort-by asc] :as args}] (query diff --git a/src/clj/auto_ap/db/transactions.clj b/src/clj/auto_ap/db/transactions.clj new file mode 100644 index 00000000..3eebb77b --- /dev/null +++ b/src/clj/auto_ap/db/transactions.clj @@ -0,0 +1,32 @@ +(ns auto-ap.db.transactions + (:require [clojure.java.jdbc :as j] + [honeysql.core :as sql] + [honeysql.helpers :as helpers] + [honeysql-postgres.format :as postgres-format] + [honeysql-postgres.helpers :as postgres-helpers] + [auto-ap.db.utils :refer [clj->db kebab->snake db->clj get-conn query] :as utils])) + +(defn upsert! [row] + (j/db-do-prepared (get-conn) + (sql/format (-> (helpers/insert-into :transactions) + (helpers/values [row]) + (postgres-helpers/upsert (-> (postgres-helpers/on-conflict :id) + (postgres-helpers/do-update-set :post_date :status))))))) + +(def base-query (sql/build :select :* + :from :transactions)) + +(defn base-graphql [{:keys [company-id]}] + (cond-> base-query + (not (nil? company-id)) (helpers/merge-where [:= :company-id company-id]))) + +(defn get-graphql [{:keys [start sort-by asc] :as args}] + (query + (cond-> (base-graphql args) + #_#_(not (nil? sort-by) ) (add-sort-by sort-by asc) + true (assoc :limit 20) + start (assoc :offset start)))) + +(defn count-graphql [args] + (:count (first (query + (assoc (base-graphql args) :select [:%count.*]))))) diff --git a/src/clj/auto_ap/db/yodlee_imports.clj b/src/clj/auto_ap/db/yodlee_imports.clj deleted file mode 100644 index db0cc780..00000000 --- a/src/clj/auto_ap/db/yodlee_imports.clj +++ /dev/null @@ -1,14 +0,0 @@ -(ns auto-ap.db.yodlee-imports - (:require [clojure.java.jdbc :as j] - [honeysql.core :as sql] - [honeysql.helpers :as helpers] - [honeysql-postgres.format :as postgres-format] - [honeysql-postgres.helpers :as postgres-helpers] - [auto-ap.db.utils :refer [clj->db kebab->snake db->clj get-conn query] :as utils])) - -(defn upsert! [row] - (j/db-do-prepared (get-conn) - (sql/format (-> (helpers/insert-into :yodlee-imports) - (helpers/values [row]) - (postgres-helpers/upsert (-> (postgres-helpers/on-conflict :id) - (postgres-helpers/do-update-set :amount :status))))))) diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index bdb7c7e9..74c77d68 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -16,6 +16,7 @@ [auto-ap.graphql.checks :as gq-checks] [auto-ap.graphql.expense-accounts :as expense-accounts] [auto-ap.graphql.invoices :as gq-invoices] + [auto-ap.graphql.transactions :as gq-transactions] [auto-ap.db.reminders :as reminders] [auto-ap.db.invoices-checks :as invoices-checks] [auto-ap.db.utils :as utils] @@ -69,6 +70,19 @@ :s3_url {:type 'String} :check_number {:type 'Int}}} + :transaction {:fields {:id {:type 'Int} + :amount {:type 'String} + :description_original {:type 'String} + :description_simple {:type 'String} + :status {:type 'String} + :vendor {:type :vendor + :resolve :get-vendor-for-transaction} + :company {:type :company + :resolve :get-company-for-transaction} + :check {:type :check + :resolve :get-check-for-transaction} + :date {:type 'String} + :post_date {:type 'String}}} :invoice_check {:fields {:id {:type 'Int} :amount {:type 'String} @@ -126,6 +140,12 @@ :start {:type 'Int} :end {:type 'Int}}} + :transaction_page {:fields {:transactions {:type '(list :transaction)} + :count {:type 'Int} + :total {:type 'Int} + :start {:type 'Int} + :end {:type 'Int}}} + :reminder_page {:fields {:reminders {:type '(list :reminder)} :count {:type 'Int} :total {:type 'Int} @@ -150,6 +170,14 @@ :resolve :get-invoice-page} + :transaction_page {:type '(list :transaction_page) + :args {:company_id {:type 'Int} + :start {:type 'Int} + :sort_by {:type 'String} + :asc {:type 'Boolean}} + + :resolve :get-transaction-page} + :check_page {:type '(list :check_page) :args {:company_id {:type 'Int} :start {:type 'Int} @@ -352,10 +380,14 @@ (-> integreat-schema (attach-resolvers {:get-invoice-page get-invoice-page :get-check-page gq-checks/get-check-page + :get-transaction-page gq-transactions/get-transaction-page :get-reminder-page get-reminder-page :get-vendor-for-invoice get-vendor-for-invoice :get-vendor-for-check gq-checks/get-vendor-for-check :get-company-for-check gq-checks/get-company-for-check + :get-company-for-transaction gq-transactions/get-company-for-transaction + :get-vendor-for-transaction gq-transactions/get-vendor-for-transaction + :get-check-for-transaction gq-transactions/get-check-for-transaction :get-company-for-invoice get-company-for-invoice :get-invoices-checks get-invoices-checks :get-check-by-id get-check-by-id diff --git a/src/clj/auto_ap/graphql/invoices.clj b/src/clj/auto_ap/graphql/invoices.clj index d14be75a..f97bf96d 100644 --- a/src/clj/auto_ap/graphql/invoices.clj +++ b/src/clj/auto_ap/graphql/invoices.clj @@ -8,7 +8,7 @@ (defn -create-vendor-if-necessary [vendor-id vendor-name] (if vendor-id vendor-id - (:id (doto (vendors/insert {:name vendor-name :default-expense-account 0}) println)))) + (:id (vendors/insert {:name vendor-name :default-expense-account 0})))) (defn add-invoice [context {{:keys [total invoice_number company_id vendor_id vendor_name date] :as in} :invoice} value] (let [vendor_id (-create-vendor-if-necessary vendor_id vendor_name)] diff --git a/src/clj/auto_ap/handler.clj b/src/clj/auto_ap/handler.clj index 0d5d4d5b..330deceb 100644 --- a/src/clj/auto_ap/handler.clj +++ b/src/clj/auto_ap/handler.clj @@ -6,6 +6,7 @@ [auto-ap.routes.reminders :as reminders] [auto-ap.routes.graphql :as graphql] [auto-ap.routes.vendors :as vendors] + [auto-ap.routes.events :as events] [auto-ap.routes.checks :as checks] [auto-ap.db.utils :as u] [buddy.auth.backends.token :refer [jws-backend]] @@ -41,11 +42,6 @@ (def auth-backend (jws-backend {:secret (:jwt-secret env) :options {:alg :hs512}})) -(def app-routes - (routes - api-routes - static-routes)) - (defn wrap-transaction [handler] (fn [request] (jdbc/with-db-transaction [t (u/get-conn)] @@ -56,9 +52,18 @@ (jdbc/db-set-rollback-only! t) (throw e))))))) +(def app-routes + (routes + (wrap-transaction api-routes) + (context "/api" [] events/routes) + + + static-routes)) + + + (def app (-> #'app-routes - (wrap-transaction) (wrap-authorization auth-backend) (wrap-authentication auth-backend) (wrap-reload) diff --git a/src/clj/auto_ap/server.clj b/src/clj/auto_ap/server.clj index 5e6f5c05..2204694a 100644 --- a/src/clj/auto_ap/server.clj +++ b/src/clj/auto_ap/server.clj @@ -7,5 +7,5 @@ (defn -main [& args] (let [port (Integer/parseInt (or (env :port) "3000"))] - (future (always-process-sqs)) + #_(future (always-process-sqs)) (run-jetty app {:port port :join? false}))) diff --git a/src/clj/auto_ap/yodlee/import.clj b/src/clj/auto_ap/yodlee/import.clj index 12fd737c..b6d3540c 100644 --- a/src/clj/auto_ap/yodlee/import.clj +++ b/src/clj/auto_ap/yodlee/import.clj @@ -1,30 +1,60 @@ (ns auto-ap.yodlee.import (:require [auto-ap.yodlee.core :as client] - [auto-ap.db.yodlee-imports :as yodlee-imports] + [auto-ap.db.transactions :as transactions] + [auto-ap.db.vendors :as vendors] + [auto-ap.db.companies :as companies] + [auto-ap.db.checks :as checks] [auto-ap.time :as time])) +(defn account->company-id [account-id] + (-> (companies/get-all) + first + :id)) + +(defn transaction->vendor-id [_] + (-> (vendors/get-all) + first + :id)) + +(defn transaction->check-id [_ company-id vendor-id] + (when (= 0 (rand-int 2)) + (-> (checks/get-graphql {:company-id company-id + :vendor-id vendor-id}) + first + :id))) + (defn do-import [] (doseq [transaction (client/get-transactions) - :let [{post-date :postDate - account-id :accountId - date :date - id :id - {amount :amount} :amount - {description-original :original - description-simple :simple} :description - {merchant-id :i - merchant-name :name} :merchant - type :type - status :status - } - transaction]] - (yodlee-imports/upsert! - {:post-date (time/parse post-date "YYYY-MM-dd") - :id id - :account-id account-id - :date (time/parse date "YYYY-MM-dd") - :amount amount - :description-original description-original - :description-simple description-simple - :type type - :status status}))) + :let [{post-date :postDate + account-id :accountId + date :date + id :id + {amount :amount} :amount + {description-original :original + description-simple :simple} :description + {merchant-id :i + merchant-name :name} :merchant + type :type + status :status} + transaction + company-id (account->company-id account-id) + vendor-id (transaction->vendor-id transaction)] + ] + + (try + (transactions/upsert! + {:post-date (time/parse post-date "YYYY-MM-dd") + :id id + :account-id account-id + :date (time/parse date "YYYY-MM-dd") + :amount amount + :description-original description-original + :description-simple description-simple + :type type + :status status + :company-id company-id + :vendor-id vendor-id + :check-id (transaction->check-id transaction company-id vendor-id) + }) + (catch Exception e + (println e))))) diff --git a/src/cljs/auto_ap/routes.cljs b/src/cljs/auto_ap/routes.cljs index d12a2c5c..ee7d1ae7 100644 --- a/src/cljs/auto_ap/routes.cljs +++ b/src/cljs/auto_ap/routes.cljs @@ -15,4 +15,5 @@ "import" :import-invoices "unpaid" :unpaid-invoices "paid" :paid-invoices - "new" :new-invoice}}]) + "new" :new-invoice} + "transactions/" {"" :transactions}}]) diff --git a/src/cljs/auto_ap/views/components/typeahead.cljs b/src/cljs/auto_ap/views/components/typeahead.cljs index 8fd373be..84829762 100644 --- a/src/cljs/auto_ap/views/components/typeahead.cljs +++ b/src/cljs/auto_ap/views/components/typeahead.cljs @@ -10,7 +10,6 @@ select (fn [[id text-description text-value]] (reset! selected id) (reset! text text-description) - (println (= :not-found id)) (when on-change (if (= :not-found id) (on-change nil text-description text-value) diff --git a/src/cljs/auto_ap/views/main.cljs b/src/cljs/auto_ap/views/main.cljs index 427db083..9c85bd88 100644 --- a/src/cljs/auto_ap/views/main.cljs +++ b/src/cljs/auto_ap/views/main.cljs @@ -15,6 +15,7 @@ :needs-activation :blank :index :left-panel :invoices :left-panel + :transactions :left-panel :import-invoices :left-panel :unpaid-invoices :left-panel :paid-invoices :left-panel @@ -191,8 +192,14 @@ [:li.menu-item [:a {:href (bidi/path-for routes/routes :checks), :class (str "item" (active-when= ap :checks))} [:span {:class "icon"} - [:i {:class "fa fa-envelope-o"}]] - [:span {:class "name"} "Payments"]]] + [:i {:class "fa fa-money"}]] + [:span {:class "name"} "Checks"]]] + + [:li.menu-item + [:a {:href (bidi/path-for routes/routes :transactions), :class (str "item" (active-when= ap :transactions))} + [:span {:class "icon"} + [:i {:class "fa fa-exchange"}]] + [:span {:class "name"} "Transactions"]]] [:ul ]]] diff --git a/src/cljs/auto_ap/views/pages.cljs b/src/cljs/auto_ap/views/pages.cljs index 36393035..8761eaee 100644 --- a/src/cljs/auto_ap/views/pages.cljs +++ b/src/cljs/auto_ap/views/pages.cljs @@ -15,6 +15,7 @@ [auto-ap.views.pages.admin.reminders :refer [admin-reminders-page]] [auto-ap.views.pages.unpaid-invoices :refer [unpaid-invoices-page]] [auto-ap.views.pages.checks :refer [checks-page]] + [auto-ap.views.pages.transactions :refer [transactions-page]] [auto-ap.views.pages.new-invoice :refer [new-invoice-page]] [auto-ap.views.pages.import-invoices :refer [import-invoices-page]] [auto-ap.views.pages.admin.excel-import :refer [admin-excel-import-page]] @@ -68,6 +69,9 @@ (defmethod active-page :checks [] [checks-page]) +(defmethod active-page :transactions [] + [transactions-page]) + (defmethod active-page :invoices [] [(with-meta (fn [] diff --git a/src/cljs/auto_ap/views/pages/checks.cljs b/src/cljs/auto_ap/views/pages/checks.cljs index 1edafd07..8f47f025 100644 --- a/src/cljs/auto_ap/views/pages/checks.cljs +++ b/src/cljs/auto_ap/views/pages/checks.cljs @@ -131,7 +131,7 @@ (fn [] (let [current-company @(re-frame/subscribe [::subs/company])] [:div - [:h1.title "Payments"] + [:h1.title "Checks"] [check-table {:id :checks :params (re-frame/subscribe [::params]) :check-page (re-frame/subscribe [::check-page]) diff --git a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs index f98fdc9d..89c80413 100644 --- a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs +++ b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs @@ -207,7 +207,6 @@ ::create-invoice (fn [{:keys [db]} _] (let [new-invoice @(re-frame/subscribe [::new-invoice])] - (println new-invoice) {:graphql {:token (-> db :user) :query-obj {:venia/operation {:operation/type :mutation diff --git a/src/cljs/auto_ap/views/utils.cljs b/src/cljs/auto_ap/views/utils.cljs index 7a7be429..42d16e0b 100644 --- a/src/cljs/auto_ap/views/utils.cljs +++ b/src/cljs/auto_ap/views/utils.cljs @@ -73,7 +73,6 @@ event (if (keyword? event) [event] event) keys (assoc keys :on-change (fn [selected text-description text-value] - (println "HERE " selected text-description text-value) (re-frame/dispatch (conj (conj event field) selected)) (when text-field (re-frame/dispatch (conj (conj event text-field) text-value)))) diff --git a/terraform/terraform.tfstate.d/staging/terraform.tfstate b/terraform/terraform.tfstate.d/staging/terraform.tfstate index 04201d2f..88f6d1fc 100644 --- a/terraform/terraform.tfstate.d/staging/terraform.tfstate +++ b/terraform/terraform.tfstate.d/staging/terraform.tfstate @@ -1,7 +1,7 @@ { "version": 3, - "terraform_version": "0.11.5", - "serial": 10, + "terraform_version": "0.11.7", + "serial": 12, "lineage": "91d10fe0-8033-8778-c202-78d5a81632e8", "modules": [ { @@ -53,6 +53,28 @@ "deposed": [], "provider": "provider.aws" }, + "aws_cloudwatch_event_rule.yodlee_rule": { + "type": "aws_cloudwatch_event_rule", + "depends_on": [ + "aws_iam_role.yodlee_role" + ], + "primary": { + "id": "schedule-yodlee-import-staging", + "attributes": { + "arn": "arn:aws:events:us-east-1:679918342773:rule/schedule-yodlee-import-staging", + "description": "", + "id": "schedule-yodlee-import-staging", + "is_enabled": "true", + "name": "schedule-yodlee-import-staging", + "role_arn": "arn:aws:iam::679918342773:role/yodlee-role-staging", + "schedule_expression": "rate(4 hours)" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "provider.aws" + }, "aws_cloudwatch_event_target.sns": { "type": "aws_cloudwatch_event_target", "depends_on": [ @@ -76,6 +98,29 @@ "deposed": [], "provider": "provider.aws" }, + "aws_cloudwatch_event_target.yodlee_sns_target": { + "type": "aws_cloudwatch_event_target", + "depends_on": [ + "aws_cloudwatch_event_rule.yodlee_rule", + "aws_sns_topic.yodlee_topic" + ], + "primary": { + "id": "schedule-yodlee-import-staging-SendToSNS", + "attributes": { + "arn": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging", + "id": "schedule-yodlee-import-staging-SendToSNS", + "input": "", + "input_path": "", + "role_arn": "", + "rule": "schedule-yodlee-import-staging", + "target_id": "SendToSNS" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "provider.aws" + }, "aws_iam_access_key.app_user": { "type": "aws_iam_access_key", "depends_on": [ @@ -107,6 +152,7 @@ "create_date": "2018-04-08T22:09:45Z", "force_detach_policies": "false", "id": "reminder-send-role-staging", + "max_session_duration": "3600", "name": "reminder-send-role-staging", "path": "/", "unique_id": "AROAJAFVZGVDEZFXYYIDA" @@ -117,6 +163,46 @@ "deposed": [], "provider": "provider.aws" }, + "aws_iam_role.yodlee_role": { + "type": "aws_iam_role", + "depends_on": [], + "primary": { + "id": "yodlee-role-staging", + "attributes": { + "arn": "arn:aws:iam::679918342773:role/yodlee-role-staging", + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"events.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}", + "create_date": "2018-06-15T05:38:04Z", + "force_detach_policies": "false", + "id": "yodlee-role-staging", + "max_session_duration": "3600", + "name": "yodlee-role-staging", + "path": "/", + "unique_id": "AROAINMCBMUJQ6W26AGTQ" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "provider.aws" + }, + "aws_iam_role_policy_attachment.allow_schedule_yodlee": { + "type": "aws_iam_role_policy_attachment", + "depends_on": [ + "aws_iam_role.yodlee_role" + ], + "primary": { + "id": "yodlee-role-staging-20180615053805090200000001", + "attributes": { + "id": "yodlee-role-staging-20180615053805090200000001", + "policy_arn": "arn:aws:iam::aws:policy/AmazonSNSFullAccess", + "role": "yodlee-role-staging" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "provider.aws" + }, "aws_iam_role_policy_attachment.allow_send": { "type": "aws_iam_role_policy_attachment", "depends_on": [ @@ -183,6 +269,7 @@ "arn": "arn:aws:s3:::data.staging.app.integreatconsult.com", "bucket": "data.staging.app.integreatconsult.com", "bucket_domain_name": "data.staging.app.integreatconsult.com.s3.amazonaws.com", + "bucket_regional_domain_name": "data.staging.app.integreatconsult.com.s3.amazonaws.com", "force_destroy": "false", "hosted_zone_id": "Z3AQBSTGFYJSTF", "id": "data.staging.app.integreatconsult.com", @@ -223,6 +310,7 @@ "arn": "arn:aws:s3:::integreat-mail-staging", "bucket": "integreat-mail-staging", "bucket_domain_name": "integreat-mail-staging.s3.amazonaws.com", + "bucket_regional_domain_name": "integreat-mail-staging.s3.amazonaws.com", "force_destroy": "false", "hosted_zone_id": "Z3AQBSTGFYJSTF", "id": "integreat-mail-staging", @@ -353,6 +441,37 @@ "deposed": [], "provider": "provider.aws" }, + "aws_sns_topic.yodlee_topic": { + "type": "aws_sns_topic", + "depends_on": [], + "primary": { + "id": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging", + "attributes": { + "application_failure_feedback_role_arn": "", + "application_success_feedback_role_arn": "", + "application_success_feedback_sample_rate": "0", + "arn": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging", + "delivery_policy": "", + "display_name": "", + "http_failure_feedback_role_arn": "", + "http_success_feedback_role_arn": "", + "http_success_feedback_sample_rate": "0", + "id": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging", + "lambda_failure_feedback_role_arn": "", + "lambda_success_feedback_role_arn": "", + "lambda_success_feedback_sample_rate": "0", + "name": "events-yodlee-staging", + "policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:Publish\",\"SNS:RemovePermission\",\"SNS:SetTopicAttributes\",\"SNS:DeleteTopic\",\"SNS:ListSubscriptionsByTopic\",\"SNS:GetTopicAttributes\",\"SNS:Receive\",\"SNS:AddPermission\",\"SNS:Subscribe\"],\"Resource\":\"arn:aws:sns:us-east-1:679918342773:yodlee\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"679918342773\"}}},{\"Sid\":\"__console_pub_0\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"SNS:Publish\",\"Resource\":\"arn:aws:sns:us-east-1:679918342773:yodlee\"}]}", + "sqs_failure_feedback_role_arn": "", + "sqs_success_feedback_role_arn": "", + "sqs_success_feedback_sample_rate": "0" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "provider.aws" + }, "aws_sns_topic_subscription.send_reminders_to_service": { "type": "aws_sns_topic_subscription", "depends_on": [ @@ -376,6 +495,29 @@ "deposed": [], "provider": "provider.aws" }, + "aws_sns_topic_subscription.trigger_yodlee_import": { + "type": "aws_sns_topic_subscription", + "depends_on": [ + "aws_sns_topic.yodlee_topic" + ], + "primary": { + "id": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging:ff22864e-4245-4f63-8ef5-10d97eae549f", + "attributes": { + "arn": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging:ff22864e-4245-4f63-8ef5-10d97eae549f", + "confirmation_timeout_in_minutes": "1", + "endpoint": "https://staging.app.integreatconsult.com:8443/api/events/yodlee-import", + "endpoint_auto_confirms": "true", + "id": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging:ff22864e-4245-4f63-8ef5-10d97eae549f", + "protocol": "https", + "raw_message_delivery": "false", + "topic_arn": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "provider.aws" + }, "aws_sqs_queue.integreat-mail": { "type": "aws_sqs_queue", "depends_on": [ @@ -407,11 +549,11 @@ "type": "aws_caller_identity", "depends_on": [], "primary": { - "id": "2018-05-12 00:18:13.939881377 +0000 UTC", + "id": "2018-06-15 05:40:53.367513 +0000 UTC", "attributes": { "account_id": "679918342773", "arn": "arn:aws:iam::679918342773:user/bryce", - "id": "2018-05-12 00:18:13.939881377 +0000 UTC", + "id": "2018-06-15 05:40:53.367513 +0000 UTC", "user_id": "AIDAJPUJFTOKO4IRADMV4" }, "meta": {}, diff --git a/terraform/terraform.tfstate.d/staging/terraform.tfstate.backup b/terraform/terraform.tfstate.d/staging/terraform.tfstate.backup index 89afa1e0..37f91a2e 100644 --- a/terraform/terraform.tfstate.d/staging/terraform.tfstate.backup +++ b/terraform/terraform.tfstate.d/staging/terraform.tfstate.backup @@ -1,7 +1,7 @@ { "version": 3, - "terraform_version": "0.11.5", - "serial": 10, + "terraform_version": "0.11.7", + "serial": 12, "lineage": "91d10fe0-8033-8778-c202-78d5a81632e8", "modules": [ { @@ -53,6 +53,28 @@ "deposed": [], "provider": "provider.aws" }, + "aws_cloudwatch_event_rule.yodlee_rule": { + "type": "aws_cloudwatch_event_rule", + "depends_on": [ + "aws_iam_role.yodlee_role" + ], + "primary": { + "id": "schedule-yodlee-import-staging", + "attributes": { + "arn": "arn:aws:events:us-east-1:679918342773:rule/schedule-yodlee-import-staging", + "description": "", + "id": "schedule-yodlee-import-staging", + "is_enabled": "true", + "name": "schedule-yodlee-import-staging", + "role_arn": "arn:aws:iam::679918342773:role/yodlee-role-staging", + "schedule_expression": "rate(4 hours)" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "provider.aws" + }, "aws_cloudwatch_event_target.sns": { "type": "aws_cloudwatch_event_target", "depends_on": [ @@ -76,6 +98,29 @@ "deposed": [], "provider": "provider.aws" }, + "aws_cloudwatch_event_target.yodlee_sns_target": { + "type": "aws_cloudwatch_event_target", + "depends_on": [ + "aws_cloudwatch_event_rule.yodlee_rule", + "aws_sns_topic.yodlee_topic" + ], + "primary": { + "id": "schedule-yodlee-import-staging-SendToSNS", + "attributes": { + "arn": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging", + "id": "schedule-yodlee-import-staging-SendToSNS", + "input": "", + "input_path": "", + "role_arn": "", + "rule": "schedule-yodlee-import-staging", + "target_id": "SendToSNS" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "provider.aws" + }, "aws_iam_access_key.app_user": { "type": "aws_iam_access_key", "depends_on": [ @@ -107,6 +152,7 @@ "create_date": "2018-04-08T22:09:45Z", "force_detach_policies": "false", "id": "reminder-send-role-staging", + "max_session_duration": "3600", "name": "reminder-send-role-staging", "path": "/", "unique_id": "AROAJAFVZGVDEZFXYYIDA" @@ -117,6 +163,46 @@ "deposed": [], "provider": "provider.aws" }, + "aws_iam_role.yodlee_role": { + "type": "aws_iam_role", + "depends_on": [], + "primary": { + "id": "yodlee-role-staging", + "attributes": { + "arn": "arn:aws:iam::679918342773:role/yodlee-role-staging", + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"events.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}", + "create_date": "2018-06-15T05:38:04Z", + "force_detach_policies": "false", + "id": "yodlee-role-staging", + "max_session_duration": "3600", + "name": "yodlee-role-staging", + "path": "/", + "unique_id": "AROAINMCBMUJQ6W26AGTQ" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "provider.aws" + }, + "aws_iam_role_policy_attachment.allow_schedule_yodlee": { + "type": "aws_iam_role_policy_attachment", + "depends_on": [ + "aws_iam_role.yodlee_role" + ], + "primary": { + "id": "yodlee-role-staging-20180615053805090200000001", + "attributes": { + "id": "yodlee-role-staging-20180615053805090200000001", + "policy_arn": "arn:aws:iam::aws:policy/AmazonSNSFullAccess", + "role": "yodlee-role-staging" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "provider.aws" + }, "aws_iam_role_policy_attachment.allow_send": { "type": "aws_iam_role_policy_attachment", "depends_on": [ @@ -174,9 +260,7 @@ }, "aws_s3_bucket.data": { "type": "aws_s3_bucket", - "depends_on": [ - "data.aws_caller_identity.current" - ], + "depends_on": [], "primary": { "id": "data.staging.app.integreatconsult.com", "attributes": { @@ -185,11 +269,12 @@ "arn": "arn:aws:s3:::data.staging.app.integreatconsult.com", "bucket": "data.staging.app.integreatconsult.com", "bucket_domain_name": "data.staging.app.integreatconsult.com.s3.amazonaws.com", + "bucket_regional_domain_name": "data.staging.app.integreatconsult.com.s3.amazonaws.com", "force_destroy": "false", "hosted_zone_id": "Z3AQBSTGFYJSTF", "id": "data.staging.app.integreatconsult.com", "logging.#": "0", - "policy": "", + "policy": "{\"Id\":\"Policy1526084187222\",\"Statement\":[{\"Action\":\"s3:GetObject\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Resource\":\"arn:aws:s3:::data.staging.app.integreatconsult.com/*\",\"Sid\":\"Stmt1526084185514\"}],\"Version\":\"2012-10-17\"}", "region": "us-east-1", "replication_configuration.#": "0", "request_payer": "BucketOwner", @@ -198,7 +283,13 @@ "versioning.#": "1", "versioning.0.enabled": "false", "versioning.0.mfa_delete": "false", - "website.#": "0" + "website.#": "1", + "website.0.error_document": "", + "website.0.index_document": "index.html", + "website.0.redirect_all_requests_to": "", + "website.0.routing_rules": "", + "website_domain": "s3-website-us-east-1.amazonaws.com", + "website_endpoint": "data.staging.app.integreatconsult.com.s3-website-us-east-1.amazonaws.com" }, "meta": {}, "tainted": false @@ -219,6 +310,7 @@ "arn": "arn:aws:s3:::integreat-mail-staging", "bucket": "integreat-mail-staging", "bucket_domain_name": "integreat-mail-staging.s3.amazonaws.com", + "bucket_regional_domain_name": "integreat-mail-staging.s3.amazonaws.com", "force_destroy": "false", "hosted_zone_id": "Z3AQBSTGFYJSTF", "id": "integreat-mail-staging", @@ -349,6 +441,37 @@ "deposed": [], "provider": "provider.aws" }, + "aws_sns_topic.yodlee_topic": { + "type": "aws_sns_topic", + "depends_on": [], + "primary": { + "id": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging", + "attributes": { + "application_failure_feedback_role_arn": "", + "application_success_feedback_role_arn": "", + "application_success_feedback_sample_rate": "0", + "arn": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging", + "delivery_policy": "", + "display_name": "", + "http_failure_feedback_role_arn": "", + "http_success_feedback_role_arn": "", + "http_success_feedback_sample_rate": "0", + "id": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging", + "lambda_failure_feedback_role_arn": "", + "lambda_success_feedback_role_arn": "", + "lambda_success_feedback_sample_rate": "0", + "name": "events-yodlee-staging", + "policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:Publish\",\"SNS:RemovePermission\",\"SNS:SetTopicAttributes\",\"SNS:DeleteTopic\",\"SNS:ListSubscriptionsByTopic\",\"SNS:GetTopicAttributes\",\"SNS:Receive\",\"SNS:AddPermission\",\"SNS:Subscribe\"],\"Resource\":\"arn:aws:sns:us-east-1:679918342773:yodlee\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"679918342773\"}}},{\"Sid\":\"__console_pub_0\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"SNS:Publish\",\"Resource\":\"arn:aws:sns:us-east-1:679918342773:yodlee\"}]}", + "sqs_failure_feedback_role_arn": "", + "sqs_success_feedback_role_arn": "", + "sqs_success_feedback_sample_rate": "0" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "provider.aws" + }, "aws_sns_topic_subscription.send_reminders_to_service": { "type": "aws_sns_topic_subscription", "depends_on": [ @@ -372,6 +495,29 @@ "deposed": [], "provider": "provider.aws" }, + "aws_sns_topic_subscription.trigger_yodlee_import": { + "type": "aws_sns_topic_subscription", + "depends_on": [ + "aws_sns_topic.yodlee_topic" + ], + "primary": { + "id": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging:ff22864e-4245-4f63-8ef5-10d97eae549f", + "attributes": { + "arn": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging:ff22864e-4245-4f63-8ef5-10d97eae549f", + "confirmation_timeout_in_minutes": "1", + "endpoint": "https://staging.app.integreatconsult.com:8443/api/events/yodlee-import", + "endpoint_auto_confirms": "true", + "id": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging:ff22864e-4245-4f63-8ef5-10d97eae549f", + "protocol": "https", + "raw_message_delivery": "false", + "topic_arn": "arn:aws:sns:us-east-1:679918342773:events-yodlee-staging" + }, + "meta": {}, + "tainted": false + }, + "deposed": [], + "provider": "provider.aws" + }, "aws_sqs_queue.integreat-mail": { "type": "aws_sqs_queue", "depends_on": [ @@ -403,11 +549,11 @@ "type": "aws_caller_identity", "depends_on": [], "primary": { - "id": "2018-05-12 00:10:04.257096257 +0000 UTC", + "id": "2018-06-15 05:37:45.588447 +0000 UTC", "attributes": { "account_id": "679918342773", "arn": "arn:aws:iam::679918342773:user/bryce", - "id": "2018-05-12 00:10:04.257096257 +0000 UTC", + "id": "2018-06-15 05:37:45.588447 +0000 UTC", "user_id": "AIDAJPUJFTOKO4IRADMV4" }, "meta": {},