{"action":"created","issue":{"url":"https://api.github.com/repos/capitalone/cloud-custodian/issues/114","repository_url":"https://api.github.com/repos/capitalone/cloud-custodian","labels_url":"https://api.github.com/repos/capitalone/cloud-custodian/issues/114/labels{/name}","comments_url":"https://api.github.com/repos/capitalone/cloud-custodian/issues/114/comments","events_url":"https://api.github.com/repos/capitalone/cloud-custodian/issues/114/events","html_url":"https://github.com/capitalone/cloud-custodian/issues/114","id":155200203,"number":114,"title":"Lambda Function not detecting EC2 Instances","user":{"login":"ASmink","id":4868248,"avatar_url":"https://avatars.githubusercontent.com/u/4868248?v=3","gravatar_id":"","url":"https://api.github.com/users/ASmink","html_url":"https://github.com/ASmink","followers_url":"https://api.github.com/users/ASmink/followers","following_url":"https://api.github.com/users/ASmink/following{/other_user}","gists_url":"https://api.github.com/users/ASmink/gists{/gist_id}","starred_url":"https://api.github.com/users/ASmink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ASmink/subscriptions","organizations_url":"https://api.github.com/users/ASmink/orgs","repos_url":"https://api.github.com/users/ASmink/repos","events_url":"https://api.github.com/users/ASmink/events{/privacy}","received_events_url":"https://api.github.com/users/ASmink/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/capitalone/cloud-custodian/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"kapilt","id":21650,"avatar_url":"https://avatars.githubusercontent.com/u/21650?v=3","gravatar_id":"","url":"https://api.github.com/users/kapilt","html_url":"https://github.com/kapilt","followers_url":"https://api.github.com/users/kapilt/followers","following_url":"https://api.github.com/users/kapilt/following{/other_user}","gists_url":"https://api.github.com/users/kapilt/gists{/gist_id}","starred_url":"https://api.github.com/users/kapilt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kapilt/subscriptions","organizations_url":"https://api.github.com/users/kapilt/orgs","repos_url":"https://api.github.com/users/kapilt/repos","events_url":"https://api.github.com/users/kapilt/events{/privacy}","received_events_url":"https://api.github.com/users/kapilt/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/capitalone/cloud-custodian/milestones/2","html_url":"https://github.com/capitalone/cloud-custodian/milestones/2016-05-28","labels_url":"https://api.github.com/repos/capitalone/cloud-custodian/milestones/2/labels","id":1747239,"number":2,"title":"2016-05-28","description":"","creator":{"login":"kapilt","id":21650,"avatar_url":"https://avatars.githubusercontent.com/u/21650?v=3","gravatar_id":"","url":"https://api.github.com/users/kapilt","html_url":"https://github.com/kapilt","followers_url":"https://api.github.com/users/kapilt/followers","following_url":"https://api.github.com/users/kapilt/following{/other_user}","gists_url":"https://api.github.com/users/kapilt/gists{/gist_id}","starred_url":"https://api.github.com/users/kapilt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kapilt/subscriptions","organizations_url":"https://api.github.com/users/kapilt/orgs","repos_url":"https://api.github.com/users/kapilt/repos","events_url":"https://api.github.com/users/kapilt/events{/privacy}","received_events_url":"https://api.github.com/users/kapilt/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":0,"state":"open","created_at":"2016-05-04T10:19:56Z","updated_at":"2016-05-17T09:23:17Z","due_on":"2016-05-28T04:00:00Z","closed_at":null},"comments":2,"created_at":"2016-05-17T08:11:22Z","updated_at":"2016-05-17T11:01:37Z","closed_at":null,"body":"Hi\r\n\r\nI have created a simple policy that creates a lambda function that runs every 5 minutes to shut down any EC2 Instances with no Owner tag.\r\n\r\nThe Policy passes validation and when I do a dryrun it logs that I have 11 Instances of which 3 of them does not have an Owner tag but when I do the official run it creates the lambda function and the function runs every 5 minutes as it should but it is logging that there are 0 EC2 Instances.\r\n\r\nPolicy:\r\n\r\n```\r\npolicies:\r\n  - name: ec2-tag-compliance-test\r\n    resource: ec2\r\n    mode:\r\n      type: periodic\r\n      events:\r\n      - running\r\n      schedule: \"rate(5 minutes)\"\r\n    comment: |\r\n       Stop instances that do not follow tagging policy\r\n    filters:\r\n      - tag:Owner: absent\r\n    actions:\r\n      - stop\r\n```\r\n\r\nDry Run and Log:\r\n`custodian run --dryrun -c policies/policy_stop_ec2_with_no_owner.yml --region eu-west-1 -s out`\r\n```\r\n2016-05-17 07:46:52,591: custodian.output:INFO Storing output with <DirectoryOutput to dir:out/ec2-tag-compliance-test>\r\n2016-05-17 07:46:52,591: custodian.policy:INFO Running policy ec2-tag-compliance-test\r\n2016-05-17 07:46:52,592: c7n.cache:INFO Using cache file /home/ec2-user/.cache/cloud-custodian.cache\r\n2016-05-17 07:46:52,592: custodian.resources.ec2:INFO Querying ec2 instances with []\r\n2016-05-17 07:46:52,943: custodian.resources.ec2:INFO Filtered from 11 to 3 ec2\r\n2016-05-17 07:46:52,944: custodian.policy:INFO policy: ec2-tag-compliance-test resource:ec2 has count:3 time:0.35\r\n```\r\n\r\nRun and Log:\r\n`custodian run -c policies/policy_stop_ec2_with_no_owner.yml --region eu-west-1 --assume \"<ROLE>\" -s out`\r\n```\r\n2016-05-17 07:47:07,098: custodian.output:INFO Storing output with <DirectoryOutput to dir:out/ec2-tag-compliance-test>\r\n2016-05-17 07:47:07,098: custodian.policy:INFO Provisioning policy lambda ec2-tag-compliance-test\r\n2016-05-17 07:47:07,601: custodian.lambda:INFO Publishing custodian policy lambda function custodian-ec2-tag-compliance-test\r\n```\r\n\r\nLambda Log:\r\n```\r\n[INFO]\t2016-05-17T07:52:39.765Z\tRunning policy ec2-tag-compliance-test \r\n[INFO]\t2016-05-17T07:52:39.765Z\tQuerying ec2 instances with [] \r\n[DEBUG]\t2016-05-17T07:52:40.800Z\tFound 0 instances on 0 reservations \r\n[INFO]\t2016-05-17T07:52:40.801Z\tFiltered from 0 to 0 ec2 \r\n[INFO]\t2016-05-17T07:52:40.802Z\tpolicy: ec2-tag-compliance-test resource:ec2 has count:0 time:1.04 \r\n[DEBUG]\t2016-05-17T07:52:40.802Z\tmetric:ResourceCount Count:0 policy:ec2-tag-compliance-test restype:ec2 scope:policy\r\n```\r\n\r\nThe role I give to the lambda function has full access to lambda and ec2."},"comment":{"url":"https://api.github.com/repos/capitalone/cloud-custodian/issues/comments/219685878","html_url":"https://github.com/capitalone/cloud-custodian/issues/114#issuecomment-219685878","issue_url":"https://api.github.com/repos/capitalone/cloud-custodian/issues/114","id":219685878,"user":{"login":"kapilt","id":21650,"avatar_url":"https://avatars.githubusercontent.com/u/21650?v=3","gravatar_id":"","url":"https://api.github.com/users/kapilt","html_url":"https://github.com/kapilt","followers_url":"https://api.github.com/users/kapilt/followers","following_url":"https://api.github.com/users/kapilt/following{/other_user}","gists_url":"https://api.github.com/users/kapilt/gists{/gist_id}","starred_url":"https://api.github.com/users/kapilt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kapilt/subscriptions","organizations_url":"https://api.github.com/users/kapilt/orgs","repos_url":"https://api.github.com/users/kapilt/repos","events_url":"https://api.github.com/users/kapilt/events{/privacy}","received_events_url":"https://api.github.com/users/kapilt/received_events","type":"User","site_admin":false},"created_at":"2016-05-17T11:01:37Z","updated_at":"2016-05-17T11:01:37Z","body":"fix for this will be in my next pull request"}}