[英]How to get resource identifier from ARN string using AWS SDK?
I have two AWS arns:我有两个 AWS arns:
arn:aws:elasticloadbalancing:us-east-1:1234567890:app/cmy-app/b473fda15a743462
arn:aws:elasticloadbalancing:us-east-1:1234567890:targetgroup/my-app/1234567890
that I need to return only the targetgroup/my-app/effe001bcbfe98af
and app/cmy-app/b473fda15a743462
portion.我只需要返回targetgroup/my-app/effe001bcbfe98af
和app/cmy-app/b473fda15a743462
部分。 I've been trying to find a way to retrieve that through the AWS SDK but I've not been able to find the option.我一直在尝试找到一种通过 AWS SDK 检索它的方法,但我找不到该选项。
I'm wondering if there is a way to do that with ruby?我想知道是否有办法用 ruby 做到这一点?
You can use the Aws::ARNParser
:您可以使用Aws::ARNParser
:
str = 'arn:aws:elasticloadbalancing:us-east-1:1234567890:targetgroup/my-app/1234567890'
arn = Aws::ARNParser.parse(str)
#=> #<Aws::ARN:0x00007f9b65d4b748 ...>
arn.resource
#=> "targetgroup/my-app/1234567890"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.