{"action":"created","issue":{"url":"https://api.github.com/repos/fog/fog-aws/issues/407","repository_url":"https://api.github.com/repos/fog/fog-aws","labels_url":"https://api.github.com/repos/fog/fog-aws/issues/407/labels{/name}","comments_url":"https://api.github.com/repos/fog/fog-aws/issues/407/comments","events_url":"https://api.github.com/repos/fog/fog-aws/issues/407/events","html_url":"https://github.com/fog/fog-aws/pull/407","id":267654283,"number":407,"title":"Add emulation of default VPC to mocked mode.","user":{"login":"rzaharenkov","id":27693283,"avatar_url":"https://avatars3.githubusercontent.com/u/27693283?v=4","gravatar_id":"","url":"https://api.github.com/users/rzaharenkov","html_url":"https://github.com/rzaharenkov","followers_url":"https://api.github.com/users/rzaharenkov/followers","following_url":"https://api.github.com/users/rzaharenkov/following{/other_user}","gists_url":"https://api.github.com/users/rzaharenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/rzaharenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rzaharenkov/subscriptions","organizations_url":"https://api.github.com/users/rzaharenkov/orgs","repos_url":"https://api.github.com/users/rzaharenkov/repos","events_url":"https://api.github.com/users/rzaharenkov/events{/privacy}","received_events_url":"https://api.github.com/users/rzaharenkov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-10-23T12:47:00Z","updated_at":"2017-10-24T17:10:43Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/fog/fog-aws/pulls/407","html_url":"https://github.com/fog/fog-aws/pull/407","diff_url":"https://github.com/fog/fog-aws/pull/407.diff","patch_url":"https://github.com/fog/fog-aws/pull/407.patch"},"body":"When you create some resources in VPC-enabled environment (security groups, servers, load balaners etc.) AWS automatically attaches it to the default VPC. I am trying to emulate the same behavior in mocked mode. \r\n\r\nIn order to to it I am going to create following resources:\r\n- default vpc;\r\n- internet gateway;\r\n- routes table;\r\n- subnets for each availability zone.\r\n\r\nIt's not possible to create such resources using requests cause:\r\n\r\n1. It doesn't accept some attributes (e.g. `is_default` or `default_for_az`).\r\n2. It creates resources in :pending state.\r\n\r\nSo I am going to push raw data to `data` collection.\r\n\r\nAlso I don't think it should be created by default because it may break some existing specs. So I propose to add a new method `Fog::Compute::AWS::Mock#setup_default_vpc!`. All data is stored in the class attribute so in order to use it you can create an instance of compute service and call this method, e.g.:\r\n\r\n```ruby\r\ncompute = Fog::Compute.new(provider: 'aws', region: 'us-east-1')\r\ncompute.setup_default_vpc!\r\nsecurity_group = compute.create_security_group('test_group', 'New test group')\r\nexpect(security_group.vpc_id).to be_present\r\n```\r\n\r\nI am looking forward for your comments/suggestions."},"comment":{"url":"https://api.github.com/repos/fog/fog-aws/issues/comments/339063437","html_url":"https://github.com/fog/fog-aws/pull/407#issuecomment-339063437","issue_url":"https://api.github.com/repos/fog/fog-aws/issues/407","id":339063437,"user":{"login":"rzaharenkov","id":27693283,"avatar_url":"https://avatars3.githubusercontent.com/u/27693283?v=4","gravatar_id":"","url":"https://api.github.com/users/rzaharenkov","html_url":"https://github.com/rzaharenkov","followers_url":"https://api.github.com/users/rzaharenkov/followers","following_url":"https://api.github.com/users/rzaharenkov/following{/other_user}","gists_url":"https://api.github.com/users/rzaharenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/rzaharenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rzaharenkov/subscriptions","organizations_url":"https://api.github.com/users/rzaharenkov/orgs","repos_url":"https://api.github.com/users/rzaharenkov/repos","events_url":"https://api.github.com/users/rzaharenkov/events{/privacy}","received_events_url":"https://api.github.com/users/rzaharenkov/received_events","type":"User","site_admin":false},"created_at":"2017-10-24T17:10:43Z","updated_at":"2017-10-24T17:10:43Z","author_association":"CONTRIBUTOR","body":"The thing is AWS works in the different way depend on creation date of the account and region. It depends on supported platforms property. You can see it on ec2 dashboard or in the response on `describe_account_attributes` requests. In case when you have both VPC and EC2 flags it won't create a default VPC.\r\n\r\nHere is a screenshots of EC2 summary for the same account in different regions:\r\n\r\n![monosnap 2017-10-24 19-07-14](https://user-images.githubusercontent.com/27693283/31957357-cf4697f8-b8ee-11e7-8e8b-19cb5b4075cc.png)\r\n![monosnap 2017-10-24 19-07-50](https://user-images.githubusercontent.com/27693283/31957364-d4454c40-b8ee-11e7-9905-d35751b9db4c.png)\r\n"}}
{"actor":{"display_login":"rzaharenkov"}}