{"action":"created","issue":{"url":"https://api.github.com/repos/babbel/dynameister/issues/8","repository_url":"https://api.github.com/repos/babbel/dynameister","labels_url":"https://api.github.com/repos/babbel/dynameister/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/babbel/dynameister/issues/8/comments","events_url":"https://api.github.com/repos/babbel/dynameister/issues/8/events","html_url":"https://github.com/babbel/dynameister/pull/8","id":133990841,"number":8,"title":"Refactor `table_exists?`","user":{"login":"pixelpogo","id":284758,"avatar_url":"https://avatars.githubusercontent.com/u/284758?v=3","gravatar_id":"","url":"https://api.github.com/users/pixelpogo","html_url":"https://github.com/pixelpogo","followers_url":"https://api.github.com/users/pixelpogo/followers","following_url":"https://api.github.com/users/pixelpogo/following{/other_user}","gists_url":"https://api.github.com/users/pixelpogo/gists{/gist_id}","starred_url":"https://api.github.com/users/pixelpogo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixelpogo/subscriptions","organizations_url":"https://api.github.com/users/pixelpogo/orgs","repos_url":"https://api.github.com/users/pixelpogo/repos","events_url":"https://api.github.com/users/pixelpogo/events{/privacy}","received_events_url":"https://api.github.com/users/pixelpogo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-16T14:10:05Z","updated_at":"2016-02-16T15:20:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/babbel/dynameister/pulls/8","html_url":"https://github.com/babbel/dynameister/pull/8","diff_url":"https://github.com/babbel/dynameister/pull/8.diff","patch_url":"https://github.com/babbel/dynameister/pull/8.patch"},"body":"Refactor `table_exists?` to use `describe_table` instead of `list_tables`. This enables the use of a more fine grained access control with IAM role based permissions.\r\n\r\nFor instance: Imagine you have a service that should have full permissions on all of it's DynamoDB tables. Let's call the service *petstore*. It is a Rails app and has a *Dog* and a *Cat* model. Additionally we apply the following naming convention for the DynamoDB tables:\r\n\r\n```ruby\r\n\ttable name: \"petstore-#{Rails.env}.dogs\"\r\n\t{…}\r\n\ttable name: \"petstore-#{Rails.env}.cats\"\r\n```\r\n\r\nThen you could have an IAM policy like this:\r\n\r\n```json\r\n{\r\n    \"Version\": \"2012-10-17\",\r\n    \"Statement\": [\r\n        {\r\n            \"Effect\": \"Allow\",\r\n            \"Action\": [\r\n                \"dynamodb:*\"\r\n            ],\r\n            \"Resource\": [\r\n                \"arn:aws:dynamodb:eu-west-1:23423644:table/petstore-staging.*\"\r\n            ]\r\n        }\r\n    ]\r\n}\r\n```\r\n\r\nIf you apply this policy to your application server instance(s), then you can perform any DynamoDB action on any table that is prefixed with `petstore-staging.`, e.g. you can create the `dogs` and `cats` tables with Dynameister. But you wouldn’t be allowed to perform any DynamoDB action on any other table - not even a `list_tables`.\r\n\r\nIn other words, given the above IAM role, the invocation of `table_exists?` would raise a `Aws::DynamoDB::Errors::AccessDeniedException` exception.\r\n\r\nThis is what this PR will change."},"comment":{"url":"https://api.github.com/repos/babbel/dynameister/issues/comments/184726078","html_url":"https://github.com/babbel/dynameister/pull/8#issuecomment-184726078","issue_url":"https://api.github.com/repos/babbel/dynameister/issues/8","id":184726078,"user":{"login":"nicsnet","id":1889716,"avatar_url":"https://avatars.githubusercontent.com/u/1889716?v=3","gravatar_id":"","url":"https://api.github.com/users/nicsnet","html_url":"https://github.com/nicsnet","followers_url":"https://api.github.com/users/nicsnet/followers","following_url":"https://api.github.com/users/nicsnet/following{/other_user}","gists_url":"https://api.github.com/users/nicsnet/gists{/gist_id}","starred_url":"https://api.github.com/users/nicsnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicsnet/subscriptions","organizations_url":"https://api.github.com/users/nicsnet/orgs","repos_url":"https://api.github.com/users/nicsnet/repos","events_url":"https://api.github.com/users/nicsnet/events{/privacy}","received_events_url":"https://api.github.com/users/nicsnet/received_events","type":"User","site_admin":false},"created_at":"2016-02-16T15:20:07Z","updated_at":"2016-02-16T15:20:07Z","body":":+1: "}}