Category: Snippets

  • Mac software essentials

    Well, after the Firefox Essentials, here’s my list of Mac essentials:

  • My essential Firefox addons

    … can be seen on the Firefox Addons page as collection 🙂 .

    The addon ecosystem of Firefox is what keeps me with it. And the way it’s done. One example: Mouse Gestures are available on Chrome, which seems to be a lot faster and smoother today :'( … but in FF, when I go to the settings page, I can still use mouse gestures, cause it’s just another page.

    In Chrome I can’t. I like the Firefox behavior – it’s consistent, which is highly a highly underrated property these days.

  • jq stuff

    Waah. In case I *ever* need this again.

    aws ec2 describe-security-groups | \
        jq '.SecurityGroups | \
            map(select(has("Tags"))) | \
            map(select(.Tags[].Key|contains("Name"))) | \
            .[] | \
            [ .Tags , .GroupId ] | \
            [ (.[0]|map(select(.Key=="Name")))[0].Value, .[1] ] | \
            join("=") '
    

    What does it do? It makes a list

    $NAME_TAG=$GROUP_ID
    

    … for each security group which has a name tag. Yeah, right.

  • Shortcut with “ö” (o-umlaut)

    I want my clipboard history on CTRL-Ö. Don’t ask why.

    Here’s what you can enter in GNOME to get this:

    <Ctrl>odiaeresis
    
  • Rancher IAM role

    Rancher can create instances on EC2. If you want to define a dedicated IAM user for this, refer to the Amazon docs for the a profile template.

    Unfortunately the first thing you get when using those permissions in rancher is “You are not authorized”. Great. I’ll update this when I know the correct permissions.

    (Source: Rancher docs)

  • VPC with NAT to internet on AWS

    … and other TLAs.

    Anyways, as far as I remember OpenStack does not need this, so I thought I document it here. I at least was surprised.

    Situation: You want a private network sement in the cloud (in my case an Amazon VPC), and you don’t want all hosts to be accessible from the internet. So you don’t assign public IPs, and you need a router/gateway.

    Amazon creates a network internet gateway, but this thing does not do one thing: NATting. If your host does not have a private IP, it can’t connect to “the internet”.

    Solution: You actually need to instantiate an EC2 instance, which you have to configure to do NAT (which is forwarding and masquerading) with a public IP address. And you have to set routing tables which point to that instance for all networks which should be inaccessible from the internet.

    Thankfully there’s an article providing an example CloudFormation template.

    Really, thanks.

    Configuring the NAT instance is super-easy then. Amazon mentions in its docs that there are special Amazon Linux instances (“These AMIs include the string amzn-ami-vpc-nat in their names […]”) which come with NATting preconfigured. Just instantiate an instance using the appropriate AMI image, and you’re done. No further configuration needed.

  • CI / CD solutions

    Everyone wants free candy. Or a CI/CD solution, that …

    • auto-deploys container-based servcies
    • auto-updates (roll-forward, roll-back) those services on keypress and “triggers”
    • has one-click-deployment of services.

    My definition of “service” here is “A set of containers working together in a certain way, automatically load balanced where needed”. Example: A n worker nodes, loadbalanced from a web endpoint, and a database container. All deployed at the same time. Including one-click-deployment of environments (“Oh, I’d like to test this revision again, let’s deploy it quickly”…). Note that this is mostly CD (continuous deployment), cause CI is being done for a while now with – mostly – Jenins and other tools.

    What I have found so far that seems to satisfy those requirements:

    And the service-only solutions without a tools tack which you can deploy locally:

    This is kinda it. I would love to evaluate  all those tools, but most of are not really AWS-deploy-friendly, and in the Shippable and Tectonic case they are paid full stack services without local (cloud-owned) deployment anyway. And most are in beta. But the scenery is becoming interesting …

    I will try to post my findings here, as well as the final choice I made for my current client, along with the reasons.

    And for now: Mesosphere and Rancher looks really cool. And I mean “looks” – the UI is just pleasing (which is the most important selection criteria, I know 😉

    Update 2015-12-10: Added Vamp, Kubernetes

  • iTerm & keyboard

    … cause I remember having searched for this before, with a lot less useful results.

  • Docker registry, S3 and permissions

    There are a couple of bazillion blog posts saying “yah just did my docker registry on S3”.

    It’s not so easy, though. Cause what if you want to limit access to a certain IAM user? Yup, you need to go deep (well, a bit) into the policy thing of Amazon. Which sounds simple, but isn’t.

    I got “HTTP 500” errors from the docker registry when I first deployed. My configuration, which was wrong, looked like this:

    "RegistryIAMUser" : {
      "Type" : "AWS::IAM::User"
    },
    "RegistryIAMUserAccessKey" : {
      "Type" : "AWS::IAM::AccessKey",
      "Properties" : { "UserName" : { "Ref" : "RegistryIAMUser" } }
    },
    "Bucket" : {
      "Type" : "AWS::S3::Bucket",
      "Properties" : { "BucketName" : "flypenguin.docker-registry" }
    },
    
    "RegistryPrivateAccess" : {
      "Type" : "AWS::S3::BucketPolicy",
      "Properties" : {
        "Bucket" : {"Ref":"Bucket"},
        "PolicyDocument": {
          "Statement":[{
            "Action":[ "s3:*" ],
            "Effect":"Allow",
            "Resource":  { "Fn::Join" : ["", ["arn:aws:s3:::", { "Ref" : "Bucket" } , "/*" ]]},
            "Principal": {"AWS" : {"Fn::GetAtt":["RegistryIAMUser","Arn"]}}
          }]
        }
      }
    }
    

    Since this didn’t work really well, I googled my a** off and found a little post, which used a UserPolicy (instead of a bucket policy, which is basically the other way around), but did one thing different. My **working** configuration is now … (let’s see if you can see the difference):

    [... same as above ...]
    
    "UserPolicyRegistryPrivateAccess" : {
      "Type" : "AWS::IAM::Policy",
      "Properties" : {
        "PolicyName" : "AccessToDockerBucket",
        "Users" : [ {"Ref":"RegistryIAMUser"}],
        "PolicyDocument" : {
          "Version" : "2012-10-17",
          "Statement" : [{
            "Effect":"Allow",
            "Action":[ "s3:*" ],
            "Resource": [
              { "Fn::Join" : ["", ["arn:aws:s3:::", {"Ref":"Bucket"} , "/*" ]]},
              { "Fn::Join" : ["", ["arn:aws:s3:::", {"Ref":"Bucket"} ]]}
            ]
          }]
        }
      }
    }
    

    See it?

    It’s the two resources now. You need not only “resource/*” as a target, you also need “resource” itself as a target. Which makes sense if you know it and think about it. If you don’t … it’s a bit annoying. And time-consuming.

  • InsufficientCapabilities on AWS

    New project. I can play around as much as I want, as long as on day X I am done.

    Really frightening, and really cool.

    Anyway, first operation: Create a bunch of S3 buckets and IAM roles to interface with them. Which is kinda not-so-easy.

    Beacause when you create IAM capabilities with cloudformation, you get this error:

    {
        "CapabilitiesReason": "The following resource(s) require capabilities: [AWS::IAM::AccessKey, AWS::IAM::User]",
        "Capabilities": [
            "CAPABILITY_IAM"
        ],
        "Parameters": []
    }
    

    … which is a fancy way of saying “do this”:

    # aws cloudformation create-stack \
        --template-url file://env.json
        --capabilities CAPABILITY_IAM
    

    … which you don’t really find easily with google. Or everybody knows, but me. Gnaah.