In the previous posts I looked at using Amazonica to get details on AWS and then how to put those details into a graph. Why would you want to do this? There is a lot you can learn by having your architecture or even just part of it in a graph, you can ask questions that in many cases would be difficult, impossible or expensive to answer.
In this post we’ll extend the ideas of the previous two by pulling in more details from AWS and use our graph to build a slightly more complete model of our architecture.
When we refer to architecture we often mean one particular aspect of the whole. It depends on the context at hand as to what we mean by the systems architectyre, it may be network, logical, physical, data flow and so on. One of the good things about using a graph is that these different aspects can all live together in the same graph enabling you to move between the different aspects easily and uncover more insight by doing so.
First lets start with a question I might want to ask.
- given a particular FDQN (fully qualified domain name) what are the components underlying it, and how are they reached?
This is a typical use case when investigating a problem. What do we need to be able to answer this question?
- some representation of dns entries
- some representation of IP addresses
- some representation of Amazon Load Balancers (ELBs)
- some relationship between dns entries and IP addresses (e.g. A-Records)
- some relationship between dns entries and other dns entries (e.g. CNAME)
- some representation of relationships between ELBs and Instances
- some representation of Instances and components
This translates to a graph model like:

In this context :ALIAS_FOR
is an AWS feature from Route53 which enables A-Record aliases to AWS systems and services.
Clone the graphing your architecture repo from github
Ensure that you have neo4j running as per the last post, and that your environment has suitable AWS access and then:
bash$ lein repl
graph-your-arch.core=> (go)
You will then see some information displayed and then it will attempt to open your browser to the neo4j web console so you can explore the graph interactively.
Lets find the instances in a path from a given FQDN using the browser:
MATCH p=(dns:DNS)-[*0..3]-()-[:BALANCES|:POINTS_TO]->(i:Instance)
WHERE dns.dns = '{your fqdn}' RETURN p;

This should give you the sub-graph showing the path from the FDQN node through to list of instances that are reachable. This query is saying from a starting node which is the node labeled as dns where the dns is {your fqdn} follow up to three relations deep in order to find nodes that balances or point to one or more instances.
There are a lot of questions you can ask of even this simple graph, but I’d encourage you to try it out, click around on the results and actually see what your architecture looks like.
Now this is only the beginning, there is a lot more you can add to this graph using the AWS apis. You can make use of AWS’s ability to add tags to entities to augment AWS information with your own specific domain, and its of course also possible to use other apis to yet further expand the graph to provide much deeper insights.
I’ve used this approach to help understand and describe architectures, as well as to help identify waste in usage of AWS resources, for example how many ELB’s are you running with no balanced instances? With a graph that is a simple query.
My thanks to Mark Needham and Rik Van Bruggen for reviewing an early draft of this post