4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AppSheet のデータソースに Amazon DynamoDB を設定する最小手順

Last updated at Posted at 2023-10-02

とりあえず、この程度まで作る手順

image.png

Amazon DynamoDB

リージョンは任意です

DynamoDB テーブルを作成

ここで使うリソース名例:

  • テーブル名: db_for_appsheet1
    • パーティションキー: pkey1
    • カラム:
      • c1_str 文字列
      • c2_num 数値

image.png

モックデータの投入

image.png

モックデータを入れておくと、AppSheet のデータソース生成時に自動的にカラム属性を推測して設定してくれます。1アイテムだけ作ります。投入予定のデータを入れておくと良いでしょう。

AWS IAM

AppSheet は、IAM ロール認証に非対応です (2023年10月時点)

ここで使うリソース名例:

  • IAM ポリシー名: access_for_appsheet1
  • IAM ユーザー名: accessuser_for_appsheet1

IAM ポリシーの作成

access_for_appsheet1
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "dynamodb:ListTables",
            "Resource": "*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "dynamodb:PutItem",
                "dynamodb:DeleteItem",
                "dynamodb:Scan",
                "dynamodb:Query",
                "dynamodb:UpdateItem"
            ],
            "Resource": "arn:aws:dynamodb:*:*:table/db_for_appsheet1"
        }
    ]
}
  • Resource の table/db_for_appsheet1table/* として広い範囲の設定も可能ですが、限定化することをオススメします。

IAM ユーザー作成

  • ユーザー名: accessuser_for_appsheet1
  • 許可ポリシー: access_for_appsheet1

アクセスキーを作成

  • ユースケース > サードパーティーサービス
  • 説明タグ値: 任意ですが for_appsheet あたりにしておくと良いでしょう

作成されたアクセスキーとシークレットアクセスキーは、必ずメモしてください。

AppSheet

ここで使用するリソース名例:

  • App name: Amazon DynamoDB App1

アプリケーション作成

  • Home -> Create -> App -> Start with existing date

  • Select data source -> New source

    • Cloud Database
      • Type: DynamoDB
      • AWS region: db_for_appsheet1 が存在するリージョンを選択
      • S3 bucket: not_exists_s3_bucket
      • Access key id: 先ほど作成したアクセスキー
      • Secret key: 先ほど作成したシークレットアクセスキー
      • -> Test -> 成功すると "Authorized Access" ボタンが有効化される > Authorized Access -> Homeに戻る
  • S3 bucket はアクセスチェックは行いません。存在しないバケット名を指定してもTestは通過します (AppSheet 上で画像を扱いたい場合は存在するバケット、かつ適切なポリシーをの設定が不可欠です)

  • Home -> Create -> App -> Start with existing date

  • Select data source -> Cloud Database

    • Tables -> db_for_appsheet1

これで、Amazon DynamoDB テーブルから既存データを読み込み、カラム属性を自動的に設定した踏み台的な AppSheet アプリケーションが生成されます。

この後

  • Datasource 削除: https://www.appsheet.com/Account/Account/Sources
  • 一時的なアクセス断: a.IAM ユーザーの当該アクセスキーを無効化 b.IAM ポリシーの変更
  • DynamoDB テーブルへのカラム追加: DynamoDB テーブルへモックデータを追加後(モックデータのみとなるようにする)、AppSheet で Regenerate すると再読み込み→再構築をしてくれる

EoT

4
3
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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?