{"action":"created","issue":{"url":"https://api.github.com/repos/serverless/serverless/issues/2385","repository_url":"https://api.github.com/repos/serverless/serverless","labels_url":"https://api.github.com/repos/serverless/serverless/issues/2385/labels{/name}","comments_url":"https://api.github.com/repos/serverless/serverless/issues/2385/comments","events_url":"https://api.github.com/repos/serverless/serverless/issues/2385/events","html_url":"https://github.com/serverless/serverless/pull/2385","id":183101790,"number":2385,"title":"fixed overwrite resources bug","user":{"login":"eahefnawy","id":2312463,"avatar_url":"https://avatars.githubusercontent.com/u/2312463?v=3","gravatar_id":"","url":"https://api.github.com/users/eahefnawy","html_url":"https://github.com/eahefnawy","followers_url":"https://api.github.com/users/eahefnawy/followers","following_url":"https://api.github.com/users/eahefnawy/following{/other_user}","gists_url":"https://api.github.com/users/eahefnawy/gists{/gist_id}","starred_url":"https://api.github.com/users/eahefnawy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eahefnawy/subscriptions","organizations_url":"https://api.github.com/users/eahefnawy/orgs","repos_url":"https://api.github.com/users/eahefnawy/repos","events_url":"https://api.github.com/users/eahefnawy/events{/privacy}","received_events_url":"https://api.github.com/users/eahefnawy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/serverless/serverless/labels/bug","name":"bug","color":"ff0000"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2016-10-14T17:05:07Z","updated_at":"2016-10-18T16:10:44Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/serverless/serverless/pulls/2385","html_url":"https://github.com/serverless/serverless/pull/2385","diff_url":"https://github.com/serverless/serverless/pull/2385.diff","patch_url":"https://github.com/serverless/serverless/pull/2385.patch"},"body":"<!--\r\n1. Please check out and follow our Contributing Guidelines: https://github.com/serverless/serverless/blob/master/CONTRIBUTING.md\r\n2. Do not remove any section of the template. If something is not applicable leave it empty but leave it in the PR\r\n3. Please follow the template, otherwise we'll have to ask you to update it and it will take longer until your PR is merged\r\n-->\r\n\r\n## What did you implement:\r\n\r\n***Implementing Issue:*** #2359 & #2404\r\n\r\n* Fixes overwriting default resources using custom resources\r\n* Fixes creating IAM templates in the update step rather than the create step\r\n* Fixes bucket region validation for us-east-1\r\n\r\n## How did you implement it:\r\n\r\n<!--\r\nIf this is a nontrivial change please briefly describe your implementation so its easy for us to understand and review your code.\r\n-->\r\nI've moved the process of merging custom resources **after** compiling functions/events, hence enabling overwriting.\r\n\r\nI've moved IAM templates to the update step, which works fine if no custom bucket was provided. If custom bucket is provided, it gets a little complicated because the create step does not have any resources to create (no bucket to create).\r\n\r\nSo in that case I switch to a 1 step deployment process by creating **all** resources at the same time by falling back to a create method when trying to update everything. On second deployment, update works the same way.\r\n\r\n## How can we verify it:\r\n\r\n<!--\r\nAdd any applicable config, commands, screenshots or other resources\r\nto make it easy for us to verify this works. The easier you make it for us\r\nto review a PR, the faster we can review and merge it.\r\n\r\nExamples:\r\n* serverless.yml - Fully functioning to easily deploy changes\r\n* Screenshots - Showing the difference between your output and the master\r\n* AWS CLI commands - To list AWS resources and show that the correct config is in place\r\n* Other - Anything else that comes to mind to help us evaluate\r\n-->\r\nUsing this config:\r\n\r\n```yml\r\nservice: serverless-deployment-bucket-bug-4\r\n\r\nprovider:\r\n  name: aws\r\n  runtime: nodejs4.3\r\n  stage: prod\r\n  region: us-west-2\r\n\r\nfunctions:\r\n  hello:\r\n    handler: handler.hello\r\n    events:\r\n      - http:\r\n          path: hello/test\r\n          method: get\r\n          cors: true\r\n          authorizer: auth\r\n  auth:\r\n    handler: handler.auth\r\n\r\nresources:\r\n  Resources:\r\n    HelloLambdaFunction:\r\n      Type: \"AWS::Lambda::Function\"\r\n      Properties:\r\n        Timeout: 10\r\n```\r\n### Verify Resource Overwriting\r\nrun `serverless deploy` and check the AWS console for the hello function. Make sure it's Timeout is set to 10 instead of the default 6\r\n\r\n### Verifying IAM is created in the update step\r\nrun `serverless deploy --noDeploy` and make sure the IAM templates are in the update file not the create file\r\n\r\n### Verifying deploying uses 1 step in case of custom bucket\r\nrename the service to signal `create`, then add a `deploymentBucket` in the provider object, then run `serverless deploy`, you should notice that everything is packaged and uploaded to the custom bucket, then stack creation process is started without any update process. You can run deploy again and it'll update normally.\r\n\r\n### Verifying custom bucket in us-east-1 works\r\nadd the following to `serverless.yml`\r\n\r\n```yml\r\nprovider:\r\n  region: us-east-1\r\n  deploymentBucket: any-existing-us-east-1-bucket\r\n```\r\nYou should see that it deploys correctly without giving the `bucket is not in the same region as lambda` error as reported in issue #2404 \r\n\r\n## Todos:\r\n\r\n- [x] Write tests\r\n- [x] Write documentation\r\n- [x] Fix linting errors\r\n- [x] Make sure code coverage hasn't dropped\r\n- [x] Provide verification config/commands/resources\r\n- [x] Change ready for review message below\r\n\r\n\r\n***Is this ready for review?:*** YES"},"comment":{"url":"https://api.github.com/repos/serverless/serverless/issues/comments/254558198","html_url":"https://github.com/serverless/serverless/pull/2385#issuecomment-254558198","issue_url":"https://api.github.com/repos/serverless/serverless/issues/2385","id":254558198,"user":{"login":"flomotlik","id":132653,"avatar_url":"https://avatars.githubusercontent.com/u/132653?v=3","gravatar_id":"","url":"https://api.github.com/users/flomotlik","html_url":"https://github.com/flomotlik","followers_url":"https://api.github.com/users/flomotlik/followers","following_url":"https://api.github.com/users/flomotlik/following{/other_user}","gists_url":"https://api.github.com/users/flomotlik/gists{/gist_id}","starred_url":"https://api.github.com/users/flomotlik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flomotlik/subscriptions","organizations_url":"https://api.github.com/users/flomotlik/orgs","repos_url":"https://api.github.com/users/flomotlik/repos","events_url":"https://api.github.com/users/flomotlik/events{/privacy}","received_events_url":"https://api.github.com/users/flomotlik/received_events","type":"User","site_admin":false},"created_at":"2016-10-18T16:10:44Z","updated_at":"2016-10-18T16:10:44Z","body":"GTM"}}
{"actor":{"display_login":"flomotlik"}}