Bug: "aws sns get-topic-attribute" does not accept required parameter "--topic-arn"

0

When executing:

aws sns get-topic-attributes --topic-arn arn:aws:sns:us-east-1:137112412989:amazon-linux-2023-ami-updates

I get an error:

An error occurred (InvalidParameter) when calling the GetTopicAttributes operation: Invalid parameter: TopicArn

Which makes the command unusable. This is a required parameter:

> aws sns get-topic-attributes

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

aws: error: the following arguments are required: --topic-arn

I'm using the latest AWS CLI version available via Homebrew on Mac:

❯ aws --version
aws-cli/2.13.5 Python/3.11.4 Darwin/22.5.0 source/arm64 prompt/off
2 Antworten
0

Hi, it may just be a quote issue: see example of https://awscli.amazonaws.com/v2/documentation/api/latest/reference/sns/get-topic-attributes.html

aws sns get-topic-attributes \
    --topic-arn "arn:aws:sns:us-west-2:123456789012:my-topic"

Output:

{
    "Attributes": {
        "SubscriptionsConfirmed": "1",
        "DisplayName": "my-topic",
        "SubscriptionsDeleted": "0",
        "EffectiveDeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false}}",
        "Owner": "123456789012",
        "Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:DeleteTopic\",\"SNS:GetTopicAttributes\",\"SNS:Publish\",\"SNS:RemovePermission\",\"SNS:AddPermission\",\"SNS:SetTopicAttributes\"],\"Resource\":\"arn:aws:sns:us-west-2:123456789012:my-topic\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"0123456789012\"}}}]}",
        "TopicArn": "arn:aws:sns:us-west-2:123456789012:my-topic",
        "SubscriptionsPending": "0"
    }
}

Best,

Didier

profile pictureAWS
EXPERTE
beantwortet vor 9 Monaten
  • Thanks for looking into this but the example doesn't work for me. I copied and pasted the example as you suggest and still get:

    ❯ aws sns get-topic-attributes \
        --topic-arn "arn:aws:sns:us-west-2:123456789012:my-topic"
    
    An error occurred (InvalidParameter) when calling the GetTopicAttributes operation: Invalid parameter: TopicArn
    

    I'm using Bash 5 on a Mac, in case this matters:

    ❯ echo $BASH_VERSION
    5.2.15(1)-release
    

    I also tried with single quotes, still the same error.

  • It works for me:

    aws sns get-topic-attributes --topic-arn "arn:aws:sns:us-west-2:xxxxx:DD-tests"

    { "Attributes": { etc}", "SubscriptionsConfirmed": "0", "D

  • I am on zsh on macos

  • Can you run with the cli command with --debug: the additional details may help understand what is going wrong in your case.

  • A possible case is that your CLI is pointing to another default region than the us-west-2 of your ARN. Can you add --region us-west-2 to your CLI command? (In that case, I would agree that the error message could be better by detailing the fact that current CLI default region does not match ARN region...)

0

Hi Didier,

Thanks again for looking into this, and apologise for slow response - I'm on Australia time (UTC+10).

Today I tried with one of our own topics and the command works fine. The debug output from trying a topic we don't own points to an authentication issue.

Amos
beantwortet vor 9 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen