Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Generate ARNs in order to be able to get the right ones from cloudformation lists. #6

Open
mikedlr opened this issue Oct 2, 2019 · 4 comments

Comments

@mikedlr
Copy link

mikedlr commented Oct 2, 2019

With cloudformation I can recover a list of resources created by each stack but the data about each resource does not include the ARN.

In order to be able to match resources to cloudformation stacks I would like to be able to be able to use arnparse to generate ARNs from the constituent data recovered from a cloudformation stack. See also the output of aws cloudformation list-stack-resources

I'd propose implementing a __str__ method which returns the ARN and a __repr__ method which returns an ARN instantiation call.

In fact I'm probably going to go ahead and do this, but I'd like to put up an issue to explain it first.

@laurrentt
Copy link
Contributor

Hey @mikedlr, that sounds cool. However, for it to work it would require the code to gather your account id, current region and somehow find the service the resource belongs to. It would have to know all the corner cases regarding ARNs, like the fact that S3 buckets don't specify the region, etc. Would you input all those properties? or would you expect arnparse to make the appropriate boto3 calls to gather this information?

@mikedlr
Copy link
Author

mikedlr commented Oct 2, 2019

I think I'd normally provide the missing parameters since it's impossible to be sure what parameters were actually used during a call that created the JSON but I would provide a function like guess_aws_params which would use normal AWS credential resolution (arguments / environment / default credentials in .aws from environemnt / default in .aws) to fill in the rest on demand. Maybe a guess=true parmeter when creating the ARN object?

In my use case I would get an ARN for a cloudformation stack and then parse it and then call the cloudformation API call, so I would already know (from the original ARN) all the parameters I need. Also I will be scanning over all regions so I couldn't rely on the guess function.

@mikedlr
Copy link
Author

mikedlr commented Oct 3, 2019

@laurrentt further on the comment on the need to understand the structure of ARNs - that's precisely the reason I went looking for a library. My most important need is to be able to match against other ARNs so I'll need a consistent way of understanding and generating them correctly.

@laurrentt
Copy link
Contributor

I was skeptical at first, mainly because I didn't get that the actual gathering of information would be left outside arnparse. But I like the idea and I think it's compatible with the goal of this library.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants