{"action":"created","comment":{"url":"https://api.github.com/repos/hashicorp/terraform/pulls/comments/29105753","id":29105753,"diff_hunk":"@@ -0,0 +1,245 @@\n+package aws\n+\n+import (\n+\t\"fmt\"\n+\t\"log\"\n+\t\"time\"\n+\n+\t\"github.com/awslabs/aws-sdk-go/aws\"\n+\t\"github.com/awslabs/aws-sdk-go/service/elasticache\"\n+\t\"github.com/hashicorp/terraform/helper/hashcode\"\n+\t\"github.com/hashicorp/terraform/helper/resource\"\n+\t\"github.com/hashicorp/terraform/helper/schema\"\n+)\n+\n+func resourceAwsElasticache() *schema.Resource {\n+\treturn &schema.Resource{\n+\t\tCreate: resourceAwsElasticacheCreate,\n+\t\tRead:   resourceAwsElasticacheRead,\n+\t\tDelete: resourceAwsElasticacheDelete,\n+\n+\t\tSchema: map[string]*schema.Schema{\n+\t\t\t\"cluster_id\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tRequired: true,\n+\t\t\t\tForceNew: true,\n+\t\t\t},\n+\t\t\t\"engine\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tRequired: true,\n+\t\t\t\tForceNew: true,\n+\t\t\t},\n+\t\t\t\"node_type\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tRequired: true,\n+\t\t\t\tForceNew: true,\n+\t\t\t},\n+\t\t\t\"num_cache_nodes\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeInt,\n+\t\t\t\tRequired: true,\n+\t\t\t\tForceNew: true,\n+\t\t\t},\n+\t\t\t\"parameter_group_name\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tOptional: true,\n+\t\t\t\tForceNew: true,\n+\t\t\t},\n+\t\t\t\"port\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeInt,\n+\t\t\t\tDefault:  11211,\n+\t\t\t\tOptional: true,\n+\t\t\t\tForceNew: true,\n+\t\t\t},\n+\t\t\t\"engine_version\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tOptional: true,\n+\t\t\t\tForceNew: true,\n+\t\t\t},\n+\t\t\t\"subnet_group_name\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tOptional: true,\n+\t\t\t\tForceNew: true,\n+\t\t\t},\n+\t\t\t\"security_group_names\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeSet,\n+\t\t\t\tOptional: true,\n+\t\t\t\tComputed: true,\n+\t\t\t\tForceNew: true,\n+\t\t\t\tElem:     &schema.Schema{Type: schema.TypeString},\n+\t\t\t\tSet: func(v interface{}) int {\n+\t\t\t\t\treturn hashcode.String(v.(string))\n+\t\t\t\t},\n+\t\t\t},\n+\t\t\t\"security_group_ids\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeSet,\n+\t\t\t\tOptional: true,\n+\t\t\t\tComputed: true,\n+\t\t\t\tForceNew: true,\n+\t\t\t\tElem:     &schema.Schema{Type: schema.TypeString},\n+\t\t\t\tSet: func(v interface{}) int {\n+\t\t\t\t\treturn hashcode.String(v.(string))\n+\t\t\t\t},\n+\t\t\t},\n+\t\t},\n+\t}\n+}\n+\n+func resourceAwsElasticacheCreate(d *schema.ResourceData, meta interface{}) error {\n+\telasticacheconn := meta.(*AWSClient).elasticacheconn\n+\n+\tclusterId := d.Get(\"cluster_id\").(string)\n+\tnodeType := d.Get(\"node_type\").(string)           // e.g) cache.m1.small\n+\tnumNodes := int64(d.Get(\"num_cache_nodes\").(int)) // 2\n+\tengine := d.Get(\"engine\").(string)                // memcached\n+\tengineVersion := d.Get(\"engine_version\").(string) // 1.4.14\n+\tport := int64(d.Get(\"port\").(int))                // 11211\n+\tsubnetGroupName := d.Get(\"subnet_group_name\").(string)\n+\tsecurityNameSet := d.Get(\"security_group_names\").(*schema.Set)\n+\tsecurityIdSet := d.Get(\"security_group_ids\").(*schema.Set)\n+\tparamGroupName := d.Get(\"parameter_group_name\").(string) // default.memcached1.4\n+\n+\tsecurityNames := expandStringList(securityNameSet.List())\n+\tsecurityIds := expandStringList(securityIdSet.List())\n+\n+\treq := &elasticache.CreateCacheClusterInput{\n+\t\tCacheClusterID:          aws.String(clusterId),\n+\t\tCacheNodeType:           aws.String(nodeType),\n+\t\tNumCacheNodes:           aws.Long(numNodes),\n+\t\tEngine:                  aws.String(engine),\n+\t\tEngineVersion:           aws.String(engineVersion),\n+\t\tPort:                    aws.Long(port),\n+\t\tCacheSubnetGroupName:    aws.String(subnetGroupName),\n+\t\tCacheSecurityGroupNames: securityNames,\n+\t\tSecurityGroupIDs:        securityIds,\n+\t\tCacheParameterGroupName: aws.String(paramGroupName),\n+\t}\n+\n+\t_, err := elasticacheconn.CreateCacheCluster(req)\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"Error creating Elasticache: %s\", err)\n+\t}\n+\n+\t// AWS CLI complains like below if we try to delete while creating.\n+\t//     Can only delete cache clusters with state in:\n+\t//     available, failed, incompatible-parameters, incompatible-network, restore-failed\n+\t// So we cannot delete clusters in `creating` state.\n+\t// We need to wait for states which we can delete.\n+\tpending := []string{\"creating\"}\n+\tstateConf := &resource.StateChangeConf{\n+\t\tPending:    pending,\n+\t\tTarget:     \"available\",\n+\t\tRefresh:    CacheClusterStateRefreshFunc(elasticacheconn, d.Id(), \"available\", pending),\n+\t\tTimeout:    10 * time.Minute,\n+\t\tDelay:      10 * time.Second,\n+\t\tMinTimeout: 3 * time.Second,\n+\t}\n+\n+\tlog.Printf(\"[DEBUG] Waiting for state to become available: %v\", d.Id())\n+\t_, sterr := stateConf.WaitForState()\n+\tif sterr != nil {\n+\t\treturn fmt.Errorf(\"Error waiting for elasticache (%s) to be deletable: %s\", d.Id(), sterr)","path":"builtin/providers/aws/resource_aws_elasticache.go","position":140,"original_position":140,"commit_id":"763a9ae30dee7a71fe9d2408e6495fd319f358ea","original_commit_id":"763a9ae30dee7a71fe9d2408e6495fd319f358ea","user":{"login":"phinze","id":37534,"avatar_url":"https://avatars.githubusercontent.com/u/37534?v=3","gravatar_id":"","url":"https://api.github.com/users/phinze","html_url":"https://github.com/phinze","followers_url":"https://api.github.com/users/phinze/followers","following_url":"https://api.github.com/users/phinze/following{/other_user}","gists_url":"https://api.github.com/users/phinze/gists{/gist_id}","starred_url":"https://api.github.com/users/phinze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phinze/subscriptions","organizations_url":"https://api.github.com/users/phinze/orgs","repos_url":"https://api.github.com/users/phinze/repos","events_url":"https://api.github.com/users/phinze/events{/privacy}","received_events_url":"https://api.github.com/users/phinze/received_events","type":"User","site_admin":false},"body":"This message needs an update now that this lives in `Create` \"to be deletable\" -> \"to be created\"","created_at":"2015-04-26T00:54:34Z","updated_at":"2015-04-26T00:54:34Z","html_url":"https://github.com/hashicorp/terraform/pull/1331#discussion_r29105753","pull_request_url":"https://api.github.com/repos/hashicorp/terraform/pulls/1331","_links":{"self":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/comments/29105753"},"html":{"href":"https://github.com/hashicorp/terraform/pull/1331#discussion_r29105753"},"pull_request":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/1331"}}},"pull_request":{"url":"https://api.github.com/repos/hashicorp/terraform/pulls/1331","id":32161496,"html_url":"https://github.com/hashicorp/terraform/pull/1331","diff_url":"https://github.com/hashicorp/terraform/pull/1331.diff","patch_url":"https://github.com/hashicorp/terraform/pull/1331.patch","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/1331","number":1331,"state":"open","locked":false,"title":"provider/aws: resource ElastiCache","user":{"login":"tmtk75","id":425100,"avatar_url":"https://avatars.githubusercontent.com/u/425100?v=3","gravatar_id":"","url":"https://api.github.com/users/tmtk75","html_url":"https://github.com/tmtk75","followers_url":"https://api.github.com/users/tmtk75/followers","following_url":"https://api.github.com/users/tmtk75/following{/other_user}","gists_url":"https://api.github.com/users/tmtk75/gists{/gist_id}","starred_url":"https://api.github.com/users/tmtk75/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmtk75/subscriptions","organizations_url":"https://api.github.com/users/tmtk75/orgs","repos_url":"https://api.github.com/users/tmtk75/repos","events_url":"https://api.github.com/users/tmtk75/events{/privacy}","received_events_url":"https://api.github.com/users/tmtk75/received_events","type":"User","site_admin":false},"body":"Hello everyone,\r\n\r\nI implemented three AWS resources for ElastiCache.\r\n* New resources for ElastiCache\r\n  * `aws_ecache`\r\n  * `aws_ecache_subnet_group`\r\n  * `aws_ecache_security_group`\r\n* Acceptance test summary\r\n  * Launch clusters in both VPC & none-VPC\r\n  * Ensure `memcached` and `redis` engine work\r\n  * The acceptance test of aws_ecache takes about 12 minutes.\r\n```\r\n--- PASS: TestAccAWSElasticache (720.46s)\r\nPASS\r\nok      github.com/hashicorp/terraform/builtin/providers/aws    720.470s\r\n```\r\n\r\nIt would be great for me if you reviewed, gave me feedbacks and then merged.","created_at":"2015-03-28T08:45:08Z","updated_at":"2015-04-26T00:54:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ca8f6cfded95dc58bfacab560d51568c0d15612a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/hashicorp/terraform/pulls/1331/commits","review_comments_url":"https://api.github.com/repos/hashicorp/terraform/pulls/1331/comments","review_comment_url":"https://api.github.com/repos/hashicorp/terraform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/1331/comments","statuses_url":"https://api.github.com/repos/hashicorp/terraform/statuses/763a9ae30dee7a71fe9d2408e6495fd319f358ea","head":{"label":"tmtk75:dev/aws_ecache","ref":"dev/aws_ecache","sha":"763a9ae30dee7a71fe9d2408e6495fd319f358ea","user":{"login":"tmtk75","id":425100,"avatar_url":"https://avatars.githubusercontent.com/u/425100?v=3","gravatar_id":"","url":"https://api.github.com/users/tmtk75","html_url":"https://github.com/tmtk75","followers_url":"https://api.github.com/users/tmtk75/followers","following_url":"https://api.github.com/users/tmtk75/following{/other_user}","gists_url":"https://api.github.com/users/tmtk75/gists{/gist_id}","starred_url":"https://api.github.com/users/tmtk75/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmtk75/subscriptions","organizations_url":"https://api.github.com/users/tmtk75/orgs","repos_url":"https://api.github.com/users/tmtk75/repos","events_url":"https://api.github.com/users/tmtk75/events{/privacy}","received_events_url":"https://api.github.com/users/tmtk75/received_events","type":"User","site_admin":false},"repo":{"id":22866938,"name":"terraform","full_name":"tmtk75/terraform","owner":{"login":"tmtk75","id":425100,"avatar_url":"https://avatars.githubusercontent.com/u/425100?v=3","gravatar_id":"","url":"https://api.github.com/users/tmtk75","html_url":"https://github.com/tmtk75","followers_url":"https://api.github.com/users/tmtk75/followers","following_url":"https://api.github.com/users/tmtk75/following{/other_user}","gists_url":"https://api.github.com/users/tmtk75/gists{/gist_id}","starred_url":"https://api.github.com/users/tmtk75/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmtk75/subscriptions","organizations_url":"https://api.github.com/users/tmtk75/orgs","repos_url":"https://api.github.com/users/tmtk75/repos","events_url":"https://api.github.com/users/tmtk75/events{/privacy}","received_events_url":"https://api.github.com/users/tmtk75/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tmtk75/terraform","description":"Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.","fork":true,"url":"https://api.github.com/repos/tmtk75/terraform","forks_url":"https://api.github.com/repos/tmtk75/terraform/forks","keys_url":"https://api.github.com/repos/tmtk75/terraform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tmtk75/terraform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tmtk75/terraform/teams","hooks_url":"https://api.github.com/repos/tmtk75/terraform/hooks","issue_events_url":"https://api.github.com/repos/tmtk75/terraform/issues/events{/number}","events_url":"https://api.github.com/repos/tmtk75/terraform/events","assignees_url":"https://api.github.com/repos/tmtk75/terraform/assignees{/user}","branches_url":"https://api.github.com/repos/tmtk75/terraform/branches{/branch}","tags_url":"https://api.github.com/repos/tmtk75/terraform/tags","blobs_url":"https://api.github.com/repos/tmtk75/terraform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tmtk75/terraform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tmtk75/terraform/git/refs{/sha}","trees_url":"https://api.github.com/repos/tmtk75/terraform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tmtk75/terraform/statuses/{sha}","languages_url":"https://api.github.com/repos/tmtk75/terraform/languages","stargazers_url":"https://api.github.com/repos/tmtk75/terraform/stargazers","contributors_url":"https://api.github.com/repos/tmtk75/terraform/contributors","subscribers_url":"https://api.github.com/repos/tmtk75/terraform/subscribers","subscription_url":"https://api.github.com/repos/tmtk75/terraform/subscription","commits_url":"https://api.github.com/repos/tmtk75/terraform/commits{/sha}","git_commits_url":"https://api.github.com/repos/tmtk75/terraform/git/commits{/sha}","comments_url":"https://api.github.com/repos/tmtk75/terraform/comments{/number}","issue_comment_url":"https://api.github.com/repos/tmtk75/terraform/issues/comments{/number}","contents_url":"https://api.github.com/repos/tmtk75/terraform/contents/{+path}","compare_url":"https://api.github.com/repos/tmtk75/terraform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tmtk75/terraform/merges","archive_url":"https://api.github.com/repos/tmtk75/terraform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tmtk75/terraform/downloads","issues_url":"https://api.github.com/repos/tmtk75/terraform/issues{/number}","pulls_url":"https://api.github.com/repos/tmtk75/terraform/pulls{/number}","milestones_url":"https://api.github.com/repos/tmtk75/terraform/milestones{/number}","notifications_url":"https://api.github.com/repos/tmtk75/terraform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tmtk75/terraform/labels{/name}","releases_url":"https://api.github.com/repos/tmtk75/terraform/releases{/id}","created_at":"2014-08-12T06:18:14Z","updated_at":"2015-04-25T15:00:53Z","pushed_at":"2015-04-26T00:31:04Z","git_url":"git://github.com/tmtk75/terraform.git","ssh_url":"git@github.com:tmtk75/terraform.git","clone_url":"https://github.com/tmtk75/terraform.git","svn_url":"https://github.com/tmtk75/terraform","homepage":"http://www.terraform.io","size":20861,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hashicorp:master","ref":"master","sha":"3d367794e93ce56fb7f6f29f2e5035ea62c6e0d3","user":{"login":"hashicorp","id":761456,"avatar_url":"https://avatars.githubusercontent.com/u/761456?v=3","gravatar_id":"","url":"https://api.github.com/users/hashicorp","html_url":"https://github.com/hashicorp","followers_url":"https://api.github.com/users/hashicorp/followers","following_url":"https://api.github.com/users/hashicorp/following{/other_user}","gists_url":"https://api.github.com/users/hashicorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hashicorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hashicorp/subscriptions","organizations_url":"https://api.github.com/users/hashicorp/orgs","repos_url":"https://api.github.com/users/hashicorp/repos","events_url":"https://api.github.com/users/hashicorp/events{/privacy}","received_events_url":"https://api.github.com/users/hashicorp/received_events","type":"Organization","site_admin":false},"repo":{"id":17728164,"name":"terraform","full_name":"hashicorp/terraform","owner":{"login":"hashicorp","id":761456,"avatar_url":"https://avatars.githubusercontent.com/u/761456?v=3","gravatar_id":"","url":"https://api.github.com/users/hashicorp","html_url":"https://github.com/hashicorp","followers_url":"https://api.github.com/users/hashicorp/followers","following_url":"https://api.github.com/users/hashicorp/following{/other_user}","gists_url":"https://api.github.com/users/hashicorp/gists{/gist_id}","starred_url":"https://api.github.com/users/hashicorp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hashicorp/subscriptions","organizations_url":"https://api.github.com/users/hashicorp/orgs","repos_url":"https://api.github.com/users/hashicorp/repos","events_url":"https://api.github.com/users/hashicorp/events{/privacy}","received_events_url":"https://api.github.com/users/hashicorp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hashicorp/terraform","description":"Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.","fork":false,"url":"https://api.github.com/repos/hashicorp/terraform","forks_url":"https://api.github.com/repos/hashicorp/terraform/forks","keys_url":"https://api.github.com/repos/hashicorp/terraform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hashicorp/terraform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hashicorp/terraform/teams","hooks_url":"https://api.github.com/repos/hashicorp/terraform/hooks","issue_events_url":"https://api.github.com/repos/hashicorp/terraform/issues/events{/number}","events_url":"https://api.github.com/repos/hashicorp/terraform/events","assignees_url":"https://api.github.com/repos/hashicorp/terraform/assignees{/user}","branches_url":"https://api.github.com/repos/hashicorp/terraform/branches{/branch}","tags_url":"https://api.github.com/repos/hashicorp/terraform/tags","blobs_url":"https://api.github.com/repos/hashicorp/terraform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hashicorp/terraform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hashicorp/terraform/git/refs{/sha}","trees_url":"https://api.github.com/repos/hashicorp/terraform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hashicorp/terraform/statuses/{sha}","languages_url":"https://api.github.com/repos/hashicorp/terraform/languages","stargazers_url":"https://api.github.com/repos/hashicorp/terraform/stargazers","contributors_url":"https://api.github.com/repos/hashicorp/terraform/contributors","subscribers_url":"https://api.github.com/repos/hashicorp/terraform/subscribers","subscription_url":"https://api.github.com/repos/hashicorp/terraform/subscription","commits_url":"https://api.github.com/repos/hashicorp/terraform/commits{/sha}","git_commits_url":"https://api.github.com/repos/hashicorp/terraform/git/commits{/sha}","comments_url":"https://api.github.com/repos/hashicorp/terraform/comments{/number}","issue_comment_url":"https://api.github.com/repos/hashicorp/terraform/issues/comments{/number}","contents_url":"https://api.github.com/repos/hashicorp/terraform/contents/{+path}","compare_url":"https://api.github.com/repos/hashicorp/terraform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hashicorp/terraform/merges","archive_url":"https://api.github.com/repos/hashicorp/terraform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hashicorp/terraform/downloads","issues_url":"https://api.github.com/repos/hashicorp/terraform/issues{/number}","pulls_url":"https://api.github.com/repos/hashicorp/terraform/pulls{/number}","milestones_url":"https://api.github.com/repos/hashicorp/terraform/milestones{/number}","notifications_url":"https://api.github.com/repos/hashicorp/terraform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hashicorp/terraform/labels{/name}","releases_url":"https://api.github.com/repos/hashicorp/terraform/releases{/id}","created_at":"2014-03-13T22:25:48Z","updated_at":"2015-04-26T00:07:10Z","pushed_at":"2015-04-26T00:31:05Z","git_url":"git://github.com/hashicorp/terraform.git","ssh_url":"git@github.com:hashicorp/terraform.git","clone_url":"https://github.com/hashicorp/terraform.git","svn_url":"https://github.com/hashicorp/terraform","homepage":"http://www.terraform.io","size":42436,"stargazers_count":2285,"watchers_count":2285,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":390,"mirror_url":null,"open_issues_count":255,"forks":390,"open_issues":255,"watchers":2285,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/1331"},"html":{"href":"https://github.com/hashicorp/terraform/pull/1331"},"issue":{"href":"https://api.github.com/repos/hashicorp/terraform/issues/1331"},"comments":{"href":"https://api.github.com/repos/hashicorp/terraform/issues/1331/comments"},"review_comments":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/1331/comments"},"review_comment":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/1331/commits"},"statuses":{"href":"https://api.github.com/repos/hashicorp/terraform/statuses/763a9ae30dee7a71fe9d2408e6495fd319f358ea"}}}}