我在AWS上进行了以下设置:
帐户A 在us-west-2中拥有一个SNS主题。任何人都允许订阅权限。我无权访问此帐户中的IAM角色。
帐户B 在eu-west-1中拥有一个SQS队列。我可以完全访问此帐户。
我想将帐户B上的SQS队列订阅到帐户A上的主题。我已经使用AWS Java SDK 1.11版尝试了以下内容:
AmazonSNSClient snsClient = new AmazonSNSClient(<credentials from B>);
snsClient.setEndpoint(<sns endpoint with region>);
snsClient.setRegion(Region.getRegion(Regions.fromName(region)));
SubscribeRequest subscribeRequest = new SubscribeRequest()
.withEndpoint(sqsQueueArn)
.withProtocol("sqs")
.withTopicArn(snsTopicArn);
snsClient.subscribe(subscribeRequest);
但我一直在InvalidParameterException
:
com.amazonaws.services.sns.model.InvalidParameterException: Invalid parameter: TopicArn (Service: AmazonSNS; Status Code: 400; Error Code: InvalidParameter; Request ID: 00e878c5-8766-5fe1-8670-281bd3ca8d87)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1586)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1254)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1035)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:747)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:721)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:704)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:672)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:654)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:518)
at com.amazonaws.services.sns.AmazonSNSClient.doInvoke(AmazonSNSClient.java:2003)
at com.amazonaws.services.sns.AmazonSNSClient.invoke(AmazonSNSClient.java:1979)
at com.amazonaws.services.sns.AmazonSNSClient.subscribe(AmazonSNSClient.java:1881)
我为什么会这样做的理论是,由于snsClient
属于帐户B,因此无法在帐户中找到SNS主题,因此失败。
问题是,我可以使用最新的Java SDK for AWS将B上的SQS队列订阅到A上的主题吗?
更多想法: