Getting accountID from resolvers

0

How can we get the account id from vtl in appsync resolvers?

Jehan
質問済み 1ヶ月前122ビュー
1回答
0

To get the AWS account ID from a Velocity Template Language (VTL) resolver in AWS AppSync, you can use the $util.awsAccountId() utility function provided by AWS AppSync VTL. This function returns the AWS account ID associated with the current execution context.

Here's an example of how you can use it in your resolver:

#set($accountId = $util.awsAccountId())
{
  "accountId": "$accountId"
}

here, $util.awsAccountId() is called to retrieve the AWS account ID, and the value is assigned to the $accountId variable. Then, the account ID is returned as part of the response object.

You can include this VTL code in the response mapping template of your resolver to dynamically fetch the AWS account ID during each resolver execution.

profile picture
エキスパート
回答済み 1ヶ月前
profile picture
エキスパート
レビュー済み 1ヶ月前
  • This doesn't work for me. I need it for request template. Is there any other way to do this?

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ