android-无法访问DynamoDB表

android-无法访问DynamoDB表,第1张

概述我正在遵循此tutorial,并按所述设置了DynamoDB表和权限,但是该应用程序崩溃了:CognitoIdentityCredentialsisnotauthorizedtoperform:dynamodb:UpdateItemonresource:arn:aws:dynamodb:us-east-1:some_number:table/Books”(ThetablewhichIamtryingtoaccessis

我正在遵循此tutorial,并按所述设置了DynamoDB表和权限,但是该应用程序崩溃了:

CognitoIDentityCredentials is not authorized to perform: dynamodb:UpdateItem on resource: arn:aws:dynamodb:us-east-1:some_number:table/Books” (The table which I am trying to access is on us-west-2).

请在下面找到代码和错误:

码:

setContentVIEw(R.layout.activity_main);Runnable runnable = new Runnable() {    public voID run() {        //DynamoDB calls go here        CognitoCachingCredentialsProvIDer credentialsProvIDer=new CognitoCachingCredentialsProvIDer(getApplicationContext(),"us-west-2:some_num", Regions.US_WEST_2);        AmazonDynamoDBClIEnt ddbClIEnt = new AmazonDynamoDBClIEnt(credentialsProvIDer);        DynamoDBMapper mapper = new DynamoDBMapper(ddbClIEnt);        Book book = new Book();        book.setTitle("Great Expectations");        book.setAuthor("Charles Dickens");        book.setPrice(1299);        book.setIsbn("12345678901");        book.setHardCover(false);        mapper.save(book);        Toast.makeText(MainActivity.this,String.valueOf(mapper), Toast.LENGTH_LONG).show();    }};Thread mythread = new Thread(runnable);mythread.start();

错误:

E/AndroIDRuntime: FATAL EXCEPTION: Thread-9530Process: com.example.imb_bng_04.dynamodb, PID: 30264com.amazonaws.AmazonServiceException: User: arn:aws:sts::some_number:assumed-role/Cognito_sampleapp2Unauth_Role/CognitoIDentityCredentials is not authorized to perform: dynamodb:UpdateItem on resource: arn:aws:dynamodb:us-east-1:some-number:table/Books (Service: AmazonDynamoDB;Status Code: 400; Error Code: AccessDenIEdException; Request ID: NMSNFJB24D6G3MO8RL6H624FA)at com.amazonaws.http.AmazonhttpClIEnt.handleErrorResponse(AmazonhttpClIEnt.java:712)at com.amazonaws.http.AmazonhttpClIEnt.executeHelper(AmazonhttpClIEnt.java:388)at com.amazonaws.http.AmazonhttpClIEnt.execute(AmazonhttpClIEnt.java:199)at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClIEnt.invoke(AmazonDynamoDBClIEnt.java:4181)at com.amazonaws.services.dynamodbv2.AmazonDynamoDBClIEnt.updateItem(AmazonDynamoDBClIEnt.java:1582)at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper$SaveObjectHandler.doUpdateItem(DynamoDBMapper.java:1173)at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.executeLowLevelRequest(DynamoDBMapper.java:873)at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper$SaveObjectHandler.execute(DynamoDBMapper.java:1056)at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.save(DynamoDBMapper.java:904)at com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBMapper.save(DynamoDBMapper.java:688)at com.example.imb_bng_04.dynamodb.MainActivity$overrIDe.run(MainActivity.java:32)at com.example.imb_bng_04.dynamodb.MainActivity$overrIDe.access$dispatch(MainActivity.java)at com.example.imb_bng_04.dynamodb.MainActivity.run(MainActivity.java:0)at java.lang.Thread.run(Thread.java:818)01-27 18:10:16.004 1430-4135/? E/ActivityManager: InvalID thumbnail dimensions: 0x0

任何帮助,将不胜感激.

解决方法:

您可能没有在AWS上创建策略,除非有人另外定义,否则所有 *** 作都被禁止.

转到“ IAM”(将URL更改为您的区域-https://console.aws.amazon.com/iam/home?region=us-east-1)

在左侧菜单上,单击“策略”,然后单击“创建策略”,然后选择“创建自己的策略”

在“策略名称”和“描述”中输入所需内容,并在“策略”文档中插入:

{    "Version": "2012-10-17",    "Statement": [        {            "Effect": "Allow",            "Action": [                "dynamodb:*"            ],            "Resource": [                "arn:aws:dynamodb:*:table/YOUR_table_name"            ]        }    ]}

现在转到用户:
https://console.aws.amazon.com/iam/home?region=us-east-1#/users/

选择您为其创建凭据的用户,单击“权限”选项卡,然后单击“添加权限”,然后单击“直接附加现有策略”

选择您创建的策略,然后重试

总结

以上是内存溢出为你收集整理的android-无法访问DynamoDB表全部内容,希望文章能够帮你解决android-无法访问DynamoDB表所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1091331.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存