About Gert-Jan van de Streek

Owner and Engineer at Avisi, Arnhem, The Netherlands

AWS cloudformation, meta data and local file templates

I have been trying to use mustache templates to create files on EC2 instances via cloudformation. Huh? I lost you already. Ok you might have to do some reading here, here and specifically for this post here and here.

If you are still here, it’s most probably, because you ran into an error message like this one:

Failed to retrieve file: No connection adapters were found for 'file:///tmp/ddb-transactor.mustache'

All the examples use an http:// url to fetch a mustache template from a public s3 bucket. I was looking to use a local file. But apparently file:// url’s are not supported.

I ended up using an s3 bucket anyways, but not a public one. Here is the snippet from my UserData:

"aws s3 cp s3://third-party-releases/ddb-transactor.mustache .", "\n", 
"python -m SimpleHTTPServer 8000 &", "\n", 
"/opt/aws/bin/cfn-init -v ", 
 " --stack ", { "Ref" : "AWS::StackName" }, 
 " --resource TransactorLaunchConfig ", 
 " --region ", { "Ref" : "AWS::Region" }, "\n", 
"killall python", "\n",

What this does is copy a file over from s3, store it locally, then serve it via http with a litte python magic. Now you are ready to run cfn-init, which creates the files on your instance that you specified in MetaData:

"files" : { 
 "/tmp/ddb-transactor.properties" : { 
 "source" : "http://localhost:8000/ddb-transactor.mustache", 
 "context" : { 
   "aws-dynamodb-table" : "RelationsForJira", 
   "aws-dynamodb-region" : { "Ref" : "AWS::Region" }, 
   "aws-transactor-role" : { "Ref" : "TransactorRole" }, 
   "aws-peer-role" : { "Ref" : "ApplicationRole" } 
 }
}

You can see that you can use http:// urls now, referring to the locally running http server. After cfn-init is done, the python script is killed with killall.

Hope this helps and if you find a better way, let me know.

How to inspect a legacy Java application with the Clojure REPL

When you get used to the REPL in Clojure it’s hard to go back to the compile / redeploy round trip in Java. In very complex projects/products it’s nice to have a REPL around where you can quickly try stuff. But wait, Clojure runs on the VM and the Java interop is great. Why not add the Clojure REPL to your Java project and take this as a start for adding Clojure modules! Continue reading

SSE without Jersey

Sometimes you are not working on the edge of technology. For example when you have to add something to a project that has not been touched for over 4 years. Or when you are integrating with a product that uses not so up-to-date library dependencies. This is where this blog post starts: in JIRA, with an ancient version of Jersey. And I want to implement Server Side Events (SSE). Ready? Continue reading

How a Drip Feed helps Increase Your Add-on Sales

blogrb

Most of our Atlassian add-ons started out of frustration. They solve problems that we have internally, or they fill blanks in the Atlassian products. Preparing these add-ons for others to use came as an afterthought. Finding a way to sell them came… after that. Little did we know about marketing and such, but we took it as a challenge and we are learning about what works and what does not. Here’s the story about our drip feed. Continue reading

TostiTalk (TM)

We talk to a lot of upcoming talent from the local university. Sometimes we’re impressed, but a lot of times we realize that there is still a lot of ground to cover for these youngsters. We also know they need to eat at some point during the day. So, we can’t help but jump in and spend our lunchtime talking about stuff we’re excited about and stuff that we know can help them make a big leap.

Continue reading