LoginSignup
4
0

dynein使用時にcredentialsの設定をsource_profileまたはrole_arnにしているとエラーが出る

Posted at

こんにちは。

dynein使用時にcredentialsエラーが出たので、自分用メモがわりに記載します。

結論

タイトルの通り、dynein使用時にcredentialsの設定をsource_profileまたはrole_arnにしているとcredentialsエラーになるので、そちらを避けたcredentialsの設定にしなければならなかったというお話です。

dyneinを試したみたが、credentialsエラーが出た

dynamoDBに対してcsvで簡単にimportしたかったので、dyneinを試したみた。

こちらのREADMEを参考にインストールし、dy --helpコマンドも正常に動作することを確認。

$ dy --help
dynein 0.2.1
dynein is a command line tool to interact with DynamoDB tables/data using concise interface.
dynein looks for config files under $HOME/.dynein/ directory.

USAGE:
    dy [FLAGS] [OPTIONS] [SUBCOMMAND]

~~~

次はdy lsコマンドを実行し、AWSアカウントにアクセスできるか確認した所、下記Credentialsエラーが発生。

[2023-12-20T08:24:24Z ERROR dy::control] Couldn't find AWS credentials in environment, credentials file, or IAM role.

元々AWS CLIのCredentials設定はしていたので、aws dynamodb list-tablesが通るか確認。

$ aws dynamodb list-tables
{
    "TableNames": [
        "XXXXX",
        "YYYYY",
        "ZZZZZ"
    ]
}

aws cliは問題なく動く。

rusoto依存で、source_profileまたはrole_arnに対応してない

もう一度ドキュメントを確認。

Prerequisites - AWS Credentials
First of all, please make sure you've already configured AWS Credentials in your environment. dynein depends on rusoto and rusoto can utilize standard AWS credential toolchains - for example ~/.aws/credentials file, IAM EC2 Instance Profile, or environment variables such as AWS_DEFAULT_REGION / AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_PROFILE.

dyneinはrusotoに依存しているが、AWS標準認証情報ツールチェーンを使えば動くとある。

このrusoto辺りが怪しそうなので、issueを検索したら下記の様な内容が見つかった。

https://github.com/rusoto/rusoto/issues/1559
https://github.com/rusoto/rusoto/issues/1758

rusotoはcliでのsource_profileまたはrole_arnに対応してなさそう。(2023年12月現在)

と言うことで設定されていた、自身のcredentialsはsource_profileを使用した設定だった為、こちらをAWS_ACCESS_KEY_ID、AWS_SECRET_ACCESS_KEYをcredentialsに直指定して再度試してみる。

# before

[sample-test-a]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = samplexxxxxxxxxxxxxxxxxxxxxx
region = ap-northeast-1

[default]
region = ap-northeast-1
role_arn=arn:aws:iam::xxxxxxxxxxxx:role/AdministratorRole
source_profile=sample-test-a
# after

[sample-test-a]
aws_access_key_id = AKIAIOSFODNN7EXAMPLEA
aws_secret_access_key = samplexxxxxxxxxxxxxxxxxxxxxA
region = ap-northeast-1

[default]
region = ap-northeast-1
aws_access_key_id = AKIAIOSFODNN7EXAMPLEB
aws_secret_access_key = samplexxxxxxxxxxxxxxxxxxxxxB
region = ap-northeast-1

dy ls
DynamoDB tables in region: ap-northeast-1
    XXXXX,
    YYYYY,
    ZZZZZ
~~~

結果'dy ls'コマンドが成功した。

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