31

I am trying to use awscli to add tags to my api gateway stage https://docs.aws.amazon.com/cli/latest/reference/apigateway/tag-resource.html

I am required to supply the --resource-arn for the stage, however I am unable to ascertain this value.

I have tried using both awscli and the console to determine this value, but have been unable to find what the arn for the api gateway stage is. I have also tried guessing based off arn pattern/formats.

How can I determine this value, or alternatively what is the format for this arn?

user3559247
  • 1,117
  • 1
  • 11
  • 21
  • Have you checked out this page? https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-apigateway – demokritos Jan 30 '18 at 20:08

2 Answers2

40

I finally found the format for an api gateway stage at aws docs for set up tags via the API Gateway REST API.

The format for the ARN is arn:aws:apigateway:{region}::/restapis/{rest_api_id}/stages/{stage_name}

CodeMonkeyKing
  • 4,556
  • 1
  • 32
  • 34
user3559247
  • 1,117
  • 1
  • 11
  • 21
  • 2
    An edit was put to refer to https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-apigateway I had already look at this page and it lacks the detail that I needed to determine the ARN – user3559247 Feb 01 '18 at 01:05
  • Just had to figure this out, this is the only place I can find with the actual answer. I see nothing in AWS docs explaining why you need the `/restapis` and `/stages` strings in the ARN, plus you must leave out the account ID. A life saver... – dmulter Sep 04 '18 at 23:10
  • I actually found that it worked with the account id. – Adrian Baker Apr 05 '19 at 02:27
  • 2
    https://docs.aws.amazon.com/apigateway/latest/developerguide/arn-format-reference.html Only API Gate way specific ARN formats – BraveNinja Nov 24 '20 at 14:52
  • 2
    the AWS docs are frustratingly unclear at times : – Caleb Keene Jan 05 '21 at 17:31
  • New info with help on this: https://aws.amazon.com/blogs/devops/easily-protect-your-aws-cdk-defined-infrastructure-with-aws-wafv2/ – Efren May 05 '23 at 01:44
  • 1
    Every other service I use has a templated page with a header section giving many details always including the ARN with a little copy icon that you can click to copy the ARN to the clipboard. But API Gateway? No, we're special. We're different. We're *better*. – NeilG Aug 19 '23 at 03:57
1

At the very bottom there are samples for different APIGW artifacts, last one is stage.

arn:aws:apigateway:region::/restapis/api-id/stages/stage-name

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-control-access-using-iam-policies-to-create-and-manage-api.html

  • That link now redirects to the developer guide welcome page. Possibly this link may be the kind of content that was intended and is more useful now at any rate: https://docs.aws.amazon.com/apigateway/latest/developerguide/arn-format-reference.html – NeilG Aug 19 '23 at 04:07