I have two 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. 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.
I'm wondering if there is a way to do that with ruby?
CodePudding user response:
You can use the 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"