{"action":"created","issue":{"url":"https://api.github.com/repos/kubernetes/kops/issues/1055","repository_url":"https://api.github.com/repos/kubernetes/kops","labels_url":"https://api.github.com/repos/kubernetes/kops/issues/1055/labels{/name}","comments_url":"https://api.github.com/repos/kubernetes/kops/issues/1055/comments","events_url":"https://api.github.com/repos/kubernetes/kops/issues/1055/events","html_url":"https://github.com/kubernetes/kops/issues/1055","id":193357687,"number":1055,"title":"Kops Generate (Terraform Refactor)","user":{"login":"kris-nova","id":13757818,"avatar_url":"https://avatars2.githubusercontent.com/u/13757818?v=4","gravatar_id":"","url":"https://api.github.com/users/kris-nova","html_url":"https://github.com/kris-nova","followers_url":"https://api.github.com/users/kris-nova/followers","following_url":"https://api.github.com/users/kris-nova/following{/other_user}","gists_url":"https://api.github.com/users/kris-nova/gists{/gist_id}","starred_url":"https://api.github.com/users/kris-nova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kris-nova/subscriptions","organizations_url":"https://api.github.com/users/kris-nova/orgs","repos_url":"https://api.github.com/users/kris-nova/repos","events_url":"https://api.github.com/users/kris-nova/events{/privacy}","received_events_url":"https://api.github.com/users/kris-nova/received_events","type":"User","site_admin":false},"labels":[{"id":498771089,"url":"https://api.github.com/repos/kubernetes/kops/labels/area/terraform","name":"area/terraform","color":"c5def5","default":false},{"id":498770884,"url":"https://api.github.com/repos/kubernetes/kops/labels/Feature%20Request","name":"Feature Request","color":"bfd4f2","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/kubernetes/kops/milestones/6","html_url":"https://github.com/kubernetes/kops/milestone/6","labels_url":"https://api.github.com/repos/kubernetes/kops/milestones/6/labels","id":2218273,"number":6,"title":"1.5.2","description":"","creator":{"login":"justinsb","id":100893,"avatar_url":"https://avatars2.githubusercontent.com/u/100893?v=4","gravatar_id":"","url":"https://api.github.com/users/justinsb","html_url":"https://github.com/justinsb","followers_url":"https://api.github.com/users/justinsb/followers","following_url":"https://api.github.com/users/justinsb/following{/other_user}","gists_url":"https://api.github.com/users/justinsb/gists{/gist_id}","starred_url":"https://api.github.com/users/justinsb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinsb/subscriptions","organizations_url":"https://api.github.com/users/justinsb/orgs","repos_url":"https://api.github.com/users/justinsb/repos","events_url":"https://api.github.com/users/justinsb/events{/privacy}","received_events_url":"https://api.github.com/users/justinsb/received_events","type":"User","site_admin":false},"open_issues":210,"closed_issues":119,"state":"open","created_at":"2016-12-28T02:16:03Z","updated_at":"2017-07-25T01:50:03Z","due_on":"2017-02-28T08:00:00Z","closed_at":null},"comments":0,"created_at":"2016-12-04T15:46:12Z","updated_at":"2017-08-16T17:15:34Z","closed_at":null,"body":"# Terraform Configuration in Kops - The saga begins\r\n\r\nRight now kops supports generating Terraform configuration files instead of actually applying changes to your defined cloud. In other words, instead of using kops to make changes in AWS/GCE, a user could opt-out and actually generate raw Terraform configuration files. \r\n\r\nMore information on the feature [here](https://github.com/kubernetes/kops/blob/master/docs/terraform.md)\r\nMore information on us deciding to support the feature https://github.com/kubernetes/kops/issues/793\r\n\r\n# Terraform logic in AWS - Attack of the cloned Render() method\r\n\r\nRight now our `cloudup` engine uses a smart methodology for applying deltas in AWS. These are called `awstask`'s. The engine has a concept of `a` (actual), and `e` (expected) resources at time of application.\r\n\r\nWe store the AWS Terraform configuration logic in the same place. I think we could separate our concerns a little better here. While I think **yes** we need AWS specific Terraform logic, I also think it should be supported outside the concerns of the AWS API application logic.\r\n\r\nExample of AWS and Terraform logic in the same place can be found in the VPC `awstask` [here](https://github.com/kubernetes/kops/blob/master/upup/pkg/fi/cloudup/awstasks/vpc.go#L199)\r\n\r\n# Confusion around targets - Revenge of the --yes\r\n\r\nI think `--target=terraform` might be a round about way of saying \"Do not apply my changes, but rather generate Terraform configuration for me\". Which is fine, and we need the support to be open like this to further support other targets like `CloudFormation`\r\n\r\nBut as it stands, there is some confusion around the best way to handle this.\r\n\r\nExamples of confusion : \r\nhttps://github.com/kubernetes/kops/issues/352\r\nhttps://github.com/kubernetes/kops/issues/354\r\nhttps://github.com/kubernetes/kops/issues/536\r\n\r\n# kops generate - A new hope\r\n\r\nI propose we implement a **NEW** kops command that would fall under the `kops generate $target` guise.\r\n\r\nAn example of a user generating terraform config could look something like :\r\n\r\n```\r\nexport KOPS_STATE_STORE=s3://<somes3bucket>\r\nexport CLUSTER_NAME=<kubernetes.mydomain.com>\r\nkops create cluster ${CLUSTER_NAME} --zones us-east-1c\r\nkops generate terraform ${CLUSTER_NAME} --no-provider --module-only\r\n\r\ncd out/terraform\r\nterraform plan\r\nterraform apply\r\n```\r\n\r\nProposed example to generate module code only for https://github.com/kubernetes/kops/issues/1026 above with `--module-only`\r\nProposed example to neglect provider for https://github.com/kubernetes/kops/issues/386 with `--no-provider`\r\n\r\n#### What we gain\r\n* A unique workflow for generating configuration of any kind, terraform being our first option.\r\n* Flexibility in customizing use cases for configurations, as we obviously have many use cases for one-offs\r\n* We can get Terraform code out of `awstask`'s \r\n* We can work on cloud code, and generation code independently of each other.\r\n* We can eliminate confusion around `--yes` and `--target`\r\n* This makes the code easier to test, which makes it easier to maintain\r\n\r\n#### How to make this happen\r\n\r\n1. We need unit tests around our terraform logic, bottom line. If we can harden and flesh these tests out in a PR (or series of PRs) in the near future, it should help us when it comes time for a switch\r\n2. Flip the core over to the new command `kops generate`. This is it's own PR.\r\n3. Deprecate the `--target` flag, with a warning message about `kops generate`\r\n4. Profit"},"comment":{"url":"https://api.github.com/repos/kubernetes/kops/issues/comments/322839536","html_url":"https://github.com/kubernetes/kops/issues/1055#issuecomment-322839536","issue_url":"https://api.github.com/repos/kubernetes/kops/issues/1055","id":322839536,"user":{"login":"lsowen","id":1014577,"avatar_url":"https://avatars1.githubusercontent.com/u/1014577?v=4","gravatar_id":"","url":"https://api.github.com/users/lsowen","html_url":"https://github.com/lsowen","followers_url":"https://api.github.com/users/lsowen/followers","following_url":"https://api.github.com/users/lsowen/following{/other_user}","gists_url":"https://api.github.com/users/lsowen/gists{/gist_id}","starred_url":"https://api.github.com/users/lsowen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsowen/subscriptions","organizations_url":"https://api.github.com/users/lsowen/orgs","repos_url":"https://api.github.com/users/lsowen/repos","events_url":"https://api.github.com/users/lsowen/events{/privacy}","received_events_url":"https://api.github.com/users/lsowen/received_events","type":"User","site_admin":false},"created_at":"2017-08-16T17:15:34Z","updated_at":"2017-08-16T17:15:34Z","body":"@kris-nova are you still thinking this is the proper path forward?  If so, any suggestions for bite sized pieces I could work on to help start pushing towards it?"}}
{"actor":{"display_login":"lsowen"}}