Serverless User: arn:aws:iam::etc is not authorized to perform: dynamodb:PutItem on resource

When following the serverless tutorial here I got an error message which was really hard to debug. Running the following:

AWS_PROFILE=rukaya serverless invoke local --function create --path mocks/create-event.json --aws-profile rukaya

gave an error message like this: “User: [some ARN] is not authorized to perform: dynamodb:PutItem on resource”.

I set up a role for my user, I gave the role almost every permission under the sun, I gave the user account itself the permissions directly, but no joy.

I have two aws accounts set up on this machine – one for my personal stuff and one for work. The personal one is called ‘rukaya’, the work one has my company’s name in it. It took me quite a while to explicitly check the arn number realise that AWS was using my work account even though I was setting AWS_PROFILE and using –aws-profile in the serverless command.

The reason serverless was ignoring my commands is not because it hates me (my theory for the past half hour), but because I had forgotten I was setting AWS_SECRET_ACCESS_KEY=worksecret and AWS_ACCESS_KEY_ID=workkeyid in my environment variables for a script. Unsetting that sorted the problem. It’s pretty silly that your environment variables override your explicit commands, but *shrug*.

Anyway, nobody else on the internet seems to have had this issue so perhaps I’m the first, but I’m posting this on the off chance someone else encounters this.

Automate screenshot scraping with watir and ruby

require 'watir'

def resize_browser(browser)
 height = browser.execute_script("return Math.max(document.body.scrollHeight, document.body.offsetHeight, document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);")
 browser.window.resize_to(1200, height)
end

# Load from external csv
app_ids = [41109, 41110, 41112]
browser = Watir::Browser.new :chrome, headless: true
app_dir = 'apps' 
FileUtils.rm_rf(app_dir) if Dir.exist?(app_dir) 
Dir.mkdir(app_dir)

app_ids.each do |app_id|
 dir = "#{app_dir}/#{app_id}"
 Dir.mkdir(dir)
 
 tabs = ['one', 'two', 'three'] 
 tabs.each do |tab|
 browser.element(:css, "div[data-tab='#{tab}']").click
 resize_browser(browser)
 browser.screenshot.save("#{dir}/#{tab}.png")
 end
end

browser.close


Cancelling Telkom

Oh frabjous day! I’ve managed to find an internet provider which isn’t ADSL, which means I can finally ditch Telkom. Oh Telkom, it’s crazy but ringing you up every two or three days to complain about slow/dropping internet just isn’t my idea of fun.

Trying to cancel your account with them is just as much of a headache as being with them though! If you ring them up to cancel they tell you that you have to do it online, and when you log into the new self service panel that they have there isn’t an option to cancel it. If you hunt around for ages you can find something to move your line, but that’s not much help now is it!

Then I googled how to do it and found this:
https://secure.telkom.co.za/today/media/downloads/Retention_Cancellation__Three_easy_ways_to_cancel_online_V1.pdf

“Three easy steps” – my left foot! Once you’ve spent the prerequisite 3 or 4 minutes hunting around their badly designed site for the right menu options you’ll get to the service page. There they’ve not named the services things like “landline” and “adsl”, but random things that you have to just do your best guess at. Secondly their website doesn’t actually work properly, half of the select dropdowns are obscured because their CSS is shit. And thirdly… check this out:
Screen Shot 2018-06-01 at 18.28.46

 

If you’re the business owner you have to upload your ID, and if you’re dead you have to upload a certificate to prove it. However, I am neither a business owner nor dead (I checked my pulse and everything). What to do? If you click continue the validation kicks in and you get told you must upload something. And so I uploaded a png with my ID on one half, and a picture of my cat with the caption “ALERT! CAT STEALING OWNER’S IDENTITY!” on the other. That should give them a bit of excitement. Half an hour after I set out to cancel my account I felt relief, happiness and satisfaction finally when I clicked submit, marred by the barely civil message on the next screen informing me that  my service is not cancelled and they have to ring me to confirm cancellation. Bet they don’t, the bastards.

Stop a minute though. Did any of that make sense?

But I mean, do you really need your ID to cancel services if you’re logged in using Telkom credentials on their own secure platform? Especially when apparently it isn’t cancelled and they have to ring you to confirm before they cancel? Ooh don’t get me started on how annoying that is – why can’t you just cancel it over the phone in the first place then?

But to go back to the point at hand: do people go around hacking people’s Telkom credentials and then, like, cancelling their service?? That doesn’t sound quite right. If I was bad and had illegal access to someone’s Telkom account I’d use it to make MORE accounts for myself, not cancel current ones. Surely???

It’s almost like Telkom just wants to make it difficult enough for people to cancel so that they don’t bother and give in and just carry on paying for the shitty service that they don’t use. But I’m sure those little angels of amazing customer service wouldn’t be doing that now, would they?

Of course, I could always just not pay my bill 🙂

Django on IIS ValueError at [url]: underlying buffer has been detached

I got a similar error message to this stackoverflow post while running Django on IIS (also forced to do it because of organisational constraints):

ValueError at [url]
underlying buffer has been detached

This error was getting triggered because I had committed a pdb.set_trace() without noticing. It’s a weird one to track down because the page will seem to load normally at first, and then navigating to a subpage will cause the error. Anyway I hope this post helps someone, because googling comes up with f-all helpful.

The Dispossessed by Ursula Le Guin

I thought this book was absolutely brilliant. There were several themes I found really interesting, but for me the book was primarily about freedom (and how suffering/pain is a part of freedom) vs locked rooms and building walls. Trump’s literal wall makes a great metaphor if you need to explain to somebody why this book is still relevant over 40 years after its debut.
Continue reading

Drupal update to 8.04 with composer IIS windows – Fatal error: Declaration of Drupal\Component\DependencyInjection\Container…

Fatal error: Declaration of Drupal\Component\DependencyInjection\Container::set($id, $service) must be compatible with Symfony\Component\DependencyInjection\ContainerInterface::set($id, $service, $scope = self::SCOPE_CONTAINER) in C:\inetpub\wwwroot\nssl\web\core\lib\Drupal\Component\DependencyInjection\Container.php on line 47

I have, for my sins, been forced to use IIS at work. Let’s not talk about how hard it is to find error logs.

Continue reading

Trump’s withdrawal from the Paris Climate pact

Trump retweets support for his insanity

Fascinated to learn today that US leaders think American companies and American workers don’t live on the same planet as the rest of us – they can’t do if they are “hurt” by the prevention of its destruction, can they? My brother’s favourite alien conspiracy theories are sounding more plausible by the second!

Of course if you subscribe to the Global Warming is a Chinese Conspiracy conspiracy it all makes sense.

The concept of global warming was created by and for the Chinese in order to make US manufacturing non-competitive - Donald Trump, November 2012

Chosen selects in the django admin

A frustrating hour wasted and I don’t have enough rep to contribute to this stackoverflow answer, so I’m posting here. To add the jquery chosen widget to the django admin panel (django 1.10, chosen 1.6.2), so that multi select widgets show up properly, you need to do the following:

models.py – Get your manytomany set up

class Threat(models.Model):
    name = models.CharField(max_length=300, unique=True)

    def __str__(self):
        return self.name

    class Meta:
        ordering = ['name']


class Species(models.Model): 
    threats = models.ManyToManyField(Threat, blank=True)

admin.py – Register it in the admin site and add custom js and css

class SpeciesAdmin(admin.ModelAdmin):
    class Media:
        # Put your jquery in - automatically included by django but it appears below the chosen.jquery.min.js, adding it again just seems to shift it above
        js = ('//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js', 
              'chosen/chosen.jquery.min.js',
              'chosen_admin.js')
        css = {'all': ('chosen/chosen.min.css','chosen_admin.css')}

admin.site.register(models.Species, SpeciesAdmin)

chosen_admin.js – Easy, just instantiate chosen as you want

$(document).ready(function() {
    options = {
      search_contains: true, // plus whatever else you want 
    }
    $('#id_threats').chosen(options);
});

chosen_admin.css – This was the annoying bit to pinpoint and fix

.field-threats, .field-threats .related-widget-wrapper {
	overflow: visible !important;	
}
.chosen-container-multi .chosen-results {
	width: 100%;
}

Thanks to radtek and bradmontgomery.

Reader, I didn’t marry him.

I had a very weird moment recently which completely threw me for a loop. My extremely left-wing liberal family asked me why I didn’t want to get married, and just weren’t able to understand or accept that for me marriage seems pointless and ridiculous and that I feel like the term ‘wife’ has negative connotations. I did make it clear that I wasn’t imposing my views on them and I understood that for most people ‘husband’ and ‘wife’ were perfectly neutral terms. Continue reading

TDWG 2016

I had the privilege of being sent to the Biodiversity Information Standards (TDWG) group annual conference a few weeks ago, in December 2016, held in Costa Rica. The event was hosted by what must be the most friendly and kind group of people in the country (either that or all Costa Ricans are incredibly kind), at the Tecnologico de Costa Rica.

logoFinalReducido

Costa Rica was as amazing as when I last visited, although La Fortuna (nearby which the conference was held) was extremely rainy. I’m talking pretty much constant rain; the whole week we were there I think I saw the sun perhaps twice? The conference included a really cool field trip into the rainforest, where my colleague and I got absolutely soaked (no surprise there!) but we did see an awesome tarantula in its hole and a beautiful waterfall.

The conference itself was one of the best experiences I’ve had of conservation biology since I completed my CB course at the Fitzpatrick Institute. Everyone I met was intelligent, knowledgeable, turned on, engaged and curious about the field.  It felt like a very meaningful conference: biodiversity data might not be the sexiest subject ever (and “Biodiversity Information Standards” sounds downright boring), but it’s absolutely crucial for solving our modern environmental problems and that’s something which was at the forefront of everyone’s minds.  Continue reading