LoginSignup
4
2

More than 3 years have passed since last update.

AWS Appflow で ServiceNow からデータを連携させる

Last updated at Posted at 2020-04-26

はじめに

AWS から Appflow というデータ連携の新しいサービスがリリースされましたね!
連携できるサービスの中に ServiceNow があったので、AWS & ServiceNow の有資格者としては早速試さないわけにはいかないので、簡単に実装してみました。

1.事前準備

ServiceNow にてアカウントを作る。

何も見ずに早速 Appflow を作ろうとすると、こんな画面が出てきました。
1-01.png
まぁ、当たり前ですが、然るべき権限(role)を持ったユーザを指定してほしい、という事です。早速 ServiceNow で作りましょう。
ServiceNow のインスタンスは、Orland の Developer instance を使用しています。
1-02.png
role は以下の2つと指定されたので、まずはそれでやってみましょう。

  1. web_service_admin
  2. rest_api_explorer

1-03.png

2. Appflow を作成する

2-1. Appflow の作成

じゃあ、準備完了したので早速作りましょうかね。
2-1-1.png
2-1-2.png
2-1-3.png
テーブルの指定が出てきました。まぁ当たり前ですね。っていうか、テーブルの参照権限(role)をappflow_userに付与していないのに出てくる、という事は、このテーブルは現在は固定値なんですね。テーブルから明らかですが、現在サポートしているのは、以下の2つだという事がわかります。

  • CMDB
  • ITSM

そのまま進んでみると、権限がなくて取れないエラーが起きますね。
2-1-4.png

2-2. ServiceNow で再権限付与

Incident を対象にしてみましょう。なので、ITILをつける事にします。
2-2-1.png

でもやっぱりまだエラーです。
2-2-2.png

よくよく考えてみると、フィールドって書いてあるので、テーブルのカラム名を取得に行っているんじゃないかと想定。
ServiceNow 上では、テーブルのカラムは sys_dictionary というテーブルに保持しているため、そのアクセス権がないんじゃないかと想定されますね。早速 personalize_dictionary を付与しましょう。
2-2-3.png

出来ました!
2-2-4.png

2-3. Appflow 作成の続き

それでは続けていきましょう。
2-3-1.png

フィールドがマッピングされます。
2-3-2.png

作成完了!
2020-04-26 103018.png

3. 動作確認

早速、動かしてみましょう。右上の フローを実行 を押すと、実行され、完了すると以下の様になります。
3-1.png

S3を見てみましょう。
3-2.png
何かファイルが出来ていますね。

test-appflow/4d37c1d95cdbe26802f050b51695b4c2
{"business_stc":"28800","calendar_stc":"102197","caller_id":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/681ccaf9c0a8016400b98a06818d57c7","value":"681ccaf9c0a8016400b98a06818d57c7"},"category":"inquiry","caused_by":"","child_incidents":"0","close_code":"Solved (Permanently)","hold_reason":"","incident_state":"7","notify":"1","parent_incident":"","problem_id":"","reopened_by":"","reopened_time":"","reopen_count":"0","resolved_at":"2016-12-13 21:43:14","resolved_by":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/5137153cc611227c000bbd1bd8cd2007","value":"5137153cc611227c000bbd1bd8cd2007"},"rfc":"","severity":"3","subcategory":"email","sys_id":"1c741bd70b2322007518478d83673af3"}
{"business_stc":"1749949","calendar_stc":"7333549","caller_id":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/5137153cc611227c000bbd1bd8cd2006","value":"5137153cc611227c000bbd1bd8cd2006"},"category":"inquiry","caused_by":"","child_incidents":"","close_code":"Closed/Resolved by Caller","hold_reason":"","incident_state":"7","notify":"1","parent_incident":"","problem_id":"","reopened_by":"","reopened_time":"","reopen_count":"","resolved_at":"2019-09-05 19:56:12","resolved_by":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/6816f79cc0a8016401c5a33be04be441","value":"6816f79cc0a8016401c5a33be04be441"},"rfc":"","severity":"3","subcategory":"","sys_id":"46b66a40a9fe198101f243dfbc79033d"}
{"business_stc":"1864990","calendar_stc":"7851790","caller_id":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/5137153cc611227c000bbd1bd8cd2005","value":"5137153cc611227c000bbd1bd8cd2005"},"category":"database","caused_by":"","child_incidents":"","close_code":"Closed/Resolved by Caller","hold_reason":"","incident_state":"7","notify":"1","parent_incident":"","problem_id":"","reopened_by":"","reopened_time":"","reopen_count":"","resolved_at":"2019-09-05 19:56:12","resolved_by":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/6816f79cc0a8016401c5a33be04be441","value":"6816f79cc0a8016401c5a33be04be441"},"rfc":"","severity":"3","subcategory":"","sys_id":"46b9490da9fe1981003c938dab89bda3"}
{"business_stc":"1720500","calendar_stc":"7246500","caller_id":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/9ee1b13dc6112271007f9d0efdb69cd0","value":"9ee1b13dc6112271007f9d0efdb69cd0"},"category":"inquiry","caused_by":"","child_incidents":"","close_code":"Closed/Resolved by Caller","hold_reason":"","incident_state":"7","notify":"1","parent_incident":"","problem_id":"","reopened_by":"","reopened_time":"","reopen_count":"","resolved_at":"2019-09-05 19:56:12","resolved_by":{"link":"https://devxxxxx.service-now.com/api/now/v2/table/sys_user/6816f79cc0a8016401c5a33be04be441","value":"6816f79cc0a8016401c5a33be04be441"},"rfc":"","severity":"3","subcategory":"","sys_id":"46c03489a9fe19810148cd5b8cbf501e"}
~~~略~~~

連携されていますね!

4. Appflow のオプション機能(少し脱線)

右上の方に、式を追加値を変更というボタンがありますので、押してみました。
4-1.png

4-1. 式を追加

取得したカラム同士の数値演算や文字列連結が出来ます。
4-1-1.png
試しに一番下の連結を押したらこうなります。
4-1-2.png
これは文字列として連結する事が出来るようです。

4-2. 値を変更

こちらは値をマスクしたり、文字列そのものではなく、文字数にしたりすることが可能です。
4-2-1.png
値をマスクする
4-2-2.png
テキスト値の切り捨て
4-2-3.png

5. 考察

さて、本題に戻ります。データが連携されたのはいいんですが…
例えば、ServiceNow のインシデントとしては割と重要な以下とかがないんですよね…

  • short description
  • description
  • comments
  • work_notes

まじまじと連携できるカラムを眺めてもやっぱりありません。
2020-04-26 103021.png

データ分析目的のデータ連携だから、という話なのかもしれません。
また、Problem などは取れてはいますが、SYS_ID で取れている状態なので、分析するにしても Lookup で実レコードの値を持ってきたいですよね。
『それは Redshift でやる』というのもまぁ当然の意見としてはありますが、Flow Designer + Database viewの方が楽なのでは?という場合もあるでしょうから、やりたい事に対して、いくつか方式案を検討した方がよさそうですね。
まだ機能の出始めという事ですし、データ連携は結構煩わしい箇所なので、それをGUIベースで簡単に出来るようにしたのは良いと思います。今後に期待しています。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2