Amazon Web Services: Using AWS? You Should Enable IAM

Most of our clients are using Amazon Web Services for most, if not all, of their infastructure needs. They’re doing things like using EC2 for servers, S3 for storage and backups, Route53 for DNS, and SES for sending transactional email. For the most part, everything works pretty well and the overall experience is pretty solid. One issue that does come up is that with this strong reliance on Amazon, a lot of people within an organization end up needing to login to the AWS Console. Doing things like pulling data off S3, managing EC2 instances, and creating email addresses all ultimately require logging in to Amazon. Unfortunately, as an organization grows they’ll usually end up passing around a single “master password” for their single Amazon account. Passing around a password like this poses a huge operational risk but AWS actually has built in functionality to mitigate this called Amazon IAM which helps you administer rights access on your account.

What is it?

Amazon IAM is AWS’s identty and access management solution. What it does is allows you to add additional authorized users to your Amazon account, organize them in groups, and then grant the individual groups various permissions on your account. IAM would allow you to do something like setup a group called “access backup only”, add 3 users to it, and then only allow them to download files from S3. From an operational perspective, IAM will allow every user that needs access to have their own account with its own set of permissions which can be revoked at any time.

Why you should use it

The biggest direct benefit to using IAM is that you’ll be able to give every authorized user a separate account which they can access AWS with. This means if you have to terminate an employee or stop working with an agency you won’t have to do a “fire drill” and change your AWS password or worry about which access keys they have. On top of this, since each group has limited permissions you can be confident that inexperienced users won’t accidentally do something inappropriate.

The other big benefit to implementing IAM is that you’ll be able to take advantage of multi-factor authentication. Multi-factor authentication basically means that instead of *just* needing a password to login, you’ll also need a one-time use secure token. MFA tokens can be generated in several ways, from an RSA token to a smartphone app. If you’re already using Google’s Authenticator app for your Google Account (and you should) you can just link it in with your IAM account.

Anyway, enable Amazon IAM and you’ll sleep better at night.

AppNexus: Using the AppNexus platform for retargeting

One of the most interesting companies in the ad:tech space right now is AppNexus. What AppNexus provides is basically the infrastructure necessary to build and run an internet display advertising business. In addition, they also provide a REST API to access the majority of the platform’s capabilities. This post will walk through how to use the AppNexus platform to setup audience retargeting.

What is retargeting?

With the rise of “real time bidding” in the display advertising space, it’s now possible for advertising choices to be made in real time at the individual user level. Basically, what that translates to is that as a web user every time you see a display ad an algorithm is transparently deciding how much to pay to serve you that ad. Using this technology then, its possible to “retarget” visitors that had been on your site as they see ads across the Internet. So with AppNexus, you’d basically be using their platform to “tag” your users and then leverage their RTB connections to show those users ads as they browse the internet.

The setup

Using the AppNexus platform to set up retargeting is relatively easy. First, you’ll need to leverage the “Get UID” call to retrieve the AppNexus id for your user. The URL is structured like:

http://ib.adnxs.com/getuid?http://www.yourdomain.com/getId?id=%24UID

The /getuid service will generate a 301 redirect to the URL you specify and replace the $UID placeholder with the user’s Appnexus id. If you’re planning to process users with a batch process, you’d want to store the id that gets returned from AppNexus so that you can target those users.

The next step is adding users to AppNexus segments which will allow you to target them across RTB exchanges. There are two ways to achieve this, you can either add users to segments in real time using an AJAX call or you can add them in bulk by uploading a file to AppNexus. Adding users in real time is straightforward, the AJAX endpoint is:

http://ib.adnxs.com/seg?member=USER_ID&add=SEGMENT_ID

Using the batch process is a bit more involved, you’ll have to generate a file with AppNexus ids and segment ids and then use the batch service to process the file.

Great, but what can I do with it?

Plugging into the AppNexus infrastructure like this opens up a lot potential applications and use cases. Some potential use cases are:

  • Users that are viewing handbags on your site could get added to an AppNexus in real time to re-target them with handbag advertising.
  • Using the batch service, you could dynamically add users to opt-in for promotions to a specific segment.
  • In real time, you could monitor user behavior and add users that complete specific actions to a segment so they receive targeted advertising.

Anyway, if you’re interested in building solutions on the AppNexus API we’d love to work with you so drop us a line.

Visualizing the Startup Institute Spring ’13 Class

Last week, we got our hands on the class list for the Spring ’13 Startup Institute class. I had some time to burn so I decided to throw together a visualization using the names and email addresses of the members of the class. You can check it out at http://symf.setfive.com/d3_startup_school/

How it works

Basically, the visualization represents every student with a 3×3 color grid by using various attributes of their names and email addresses. The various squares are calculated with the following formulas:

  • Top left: Calculated by taking the first letter of the first name (say C) and then converting it to a % for how far down the alphabet the letter is. So C would come out to 3 / 25 = 12% Then, this percentage value is applied to the “lightness” component of a HSL color tuple for “hsl(40,100%,92%)”
  • Top middle: Calculated by taking the length of the first name and then calculating a % for how long it is compared to the other names in the list. So basically, it finds the length of the longest name and then divides the current student’s name by that value for a %. The % is then used in the lightness component of “hsl(340,100%,73%)”
  • Top right: A color generated using the metaphone of the first name. The metaphone is generated, then split up into 3 pieces, and then the ASCII values of those 3 components are summed. Then, the 3 parts are mapped to HSL values depending on the % maximum they are for the entire sample size.
  • The second row is identical to the first except using the last name.
  • Bottom left: Calculated depending on the “track” that the user is in.
  • Bottom middle and right: These use the same metaphone algorithm except using the email address and email domain name respectively.

Technically, the squares are drawn using the d3 library and the page layout is done with Bootstrap.

Anyway, as always comments and feedback are welcome.

Symfony2 and Ordering of Relations and Collection Form Fields

Recently I was working on a project where I kept finding myself ordering a relation over and over by other than something than ID order (ie id= 1,2,3,4,5). For example, I always wanted my relation to be ordered by the ‘name’ field, rather than the ID or order it was inserted into the DB. Let’s take this schema as an example:

The issue is each time I attempted:

I wanted the output to be in alphabetical order for example. To make this the default for that relation you can add the following annotation to your ‘Post’ entity:

Now if you do “$post->getPostAttachments()” they’ll be automatically in order. The ‘@ORM\OrderBy’ column takes care of the ordering automatically. You can specify as many columns on the relation as you’d like there. In addition, this will make it so that all form collections on post with post_attachments are also ordered by name, rather than ID. This affects the relation call every time. If you are only looking into having it some of the time, look into using the repository to do the ordering for those calls.

Symfony2: A Few Slideshares Worth Checking Out

Earlier this week, a buddy of mine reached out looking for interesting Symfony2 resources that went beyond the “basic” tutorial type content. He was looking to really get into the “nitty gritty” of the framework, how larger projects are using it, and hopefully understand some of the philosophy behind service oriented architectures, dependency injection, and behavior driven development.

Not wanting to leave him hanging, Daum and I took to Slideshare to compile a list of presentations that we thought demonstrated some of these concepts well. Anyway, here is the list we came up with.

How Kris Writes Symfony Apps
You’ve seen Kris’ open source libraries, but how does he tackle coding out an application? Walk through green fields with a Symfony expert as he takes his latest “next big thing” idea from the first line of code to a functional prototype. Learn design patterns and principles to guide your way in organizing your own code and take home some practical examples to kickstart your next project.

Practical BDD with Behat and Mink
An introduction into behavior-driven development with Behat and Mink. A Symfony2 application is used for examples.
This was presented in the Top Shelf PHP tutorial at OSCON 2011: http://www.oscon.com/oscon2011/public/schedule/detail/18980
There were some issues converting from ODP, so a PDF version is here: http://jmikola.net/slides/20110725_bdd.pdf

BDD in Symfony2
Quality assurance is one of the most difficult things to implement around software development. Most of time it is left for the final phase of development and very often overlooked entirely. As many experienced web development teams already know, QA needs to be part of the development process from the get-go. Behavior development/testing is just one aspect of quality assurance. And we’ll talk about that.

Being Dangerous with Twig
Twig – the PHP templating engine – is easy to use, friendly and extensible. This presentation will introduce you to Twig and show you how to extend it to your bidding.

OpenSky Infrastructure

Dependency Injection in PHP 5.3/5.4

If you have other presentations you think we should check out, leave them in the comments or shoot us a tweet @setfive.