{"action":"created","comment":{"url":"https://api.github.com/repos/hashicorp/terraform/pulls/comments/73808858","id":73808858,"diff_hunk":"@@ -0,0 +1,135 @@\n+package aws\n+\n+import (\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"io/ioutil\"\n+\t\"log\"\n+\t\"sort\"\n+\t\"strconv\"\n+\t\"strings\"\n+\n+\t\"github.com/hashicorp/go-cleanhttp\"\n+\t\"github.com/hashicorp/terraform/helper/schema\"\n+)\n+\n+type dataSourceAwsIPRangesResult struct {\n+\tCreateDate string\n+\tPrefixes   []dataSourceAwsIPRangesPrefix\n+\tSyncToken  string\n+}\n+\n+type dataSourceAwsIPRangesPrefix struct {\n+\tIpPrefix string `json:\"ip_prefix\"`\n+\tRegion   string\n+\tService  string\n+}\n+\n+func dataSourceAwsIPRanges() *schema.Resource {\n+\treturn &schema.Resource{\n+\t\tRead: dataSourceAwsIPRangesRead,\n+\n+\t\tSchema: map[string]*schema.Schema{\n+\t\t\t\"cidr_blocks\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeList,\n+\t\t\t\tComputed: true,\n+\t\t\t\tElem:     &schema.Schema{Type: schema.TypeString},\n+\t\t\t},\n+\t\t\t\"create_date\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeString,\n+\t\t\t\tComputed: true,\n+\t\t\t},\n+\t\t\t\"regions\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeSet,\n+\t\t\t\tElem:     &schema.Schema{Type: schema.TypeString},\n+\t\t\t\tOptional: true,\n+\t\t\t},\n+\t\t\t\"services\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeSet,\n+\t\t\t\tRequired: true,\n+\t\t\t\tElem:     &schema.Schema{Type: schema.TypeString},\n+\t\t\t},\n+\t\t\t\"sync_token\": &schema.Schema{\n+\t\t\t\tType:     schema.TypeInt,\n+\t\t\t\tComputed: true,\n+\t\t\t},\n+\t\t},\n+\t}\n+}\n+\n+func dataSourceAwsIPRangesRead(d *schema.ResourceData, meta interface{}) error {\n+\n+\tconn := cleanhttp.DefaultClient()\n+\n+\tlog.Printf(\"[DEBUG] Reading IP ranges\")\n+\n+\tres, err := conn.Get(\"https://ip-ranges.amazonaws.com/ip-ranges.json\")\n+\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"Error listing IP ranges: %s\", err)\n+\t}\n+\n+\tdefer res.Body.Close()\n+\n+\tdata, err := ioutil.ReadAll(res.Body)\n+\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"Error reading response body: %s\", err)\n+\t}\n+\n+\tresult := new(dataSourceAwsIPRangesResult)\n+\n+\tif err := json.Unmarshal(data, result); err != nil {\n+\t\treturn fmt.Errorf(\"Error parsing result: %s\", err)\n+\t}\n+\n+\tif err := d.Set(\"create_date\", result.CreateDate); err != nil {\n+\t\treturn fmt.Errorf(\"Error setting create date: %s\", err)\n+\t}\n+\n+\tsyncToken, err := strconv.Atoi(result.SyncToken)\n+\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"Error while converting sync token: %s\", err)\n+\t}\n+\n+\td.SetId(result.SyncToken)\n+\n+\tif err := d.Set(\"sync_token\", syncToken); err != nil {\n+\t\treturn fmt.Errorf(\"Error setting sync token: %s\", err)\n+\t}\n+\n+\tvar (\n+\t\tregions         = d.Get(\"regions\").(*schema.Set)\n+\t\tservices        = d.Get(\"services\").(*schema.Set)","path":"builtin/providers/aws/data_source_aws_ip_ranges.go","position":104,"original_position":104,"commit_id":"67bf13fccf21d7c4411b69761d58fd53c222631d","original_commit_id":"67bf13fccf21d7c4411b69761d58fd53c222631d","user":{"login":"yawn","id":18242,"avatar_url":"https://avatars.githubusercontent.com/u/18242?v=3","gravatar_id":"","url":"https://api.github.com/users/yawn","html_url":"https://github.com/yawn","followers_url":"https://api.github.com/users/yawn/followers","following_url":"https://api.github.com/users/yawn/following{/other_user}","gists_url":"https://api.github.com/users/yawn/gists{/gist_id}","starred_url":"https://api.github.com/users/yawn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yawn/subscriptions","organizations_url":"https://api.github.com/users/yawn/orgs","repos_url":"https://api.github.com/users/yawn/repos","events_url":"https://api.github.com/users/yawn/events{/privacy}","received_events_url":"https://api.github.com/users/yawn/received_events","type":"User","site_admin":false},"body":"Unsure. I believe most users will expect the regions and services to be lower case (since that's the default in TF everywhere else) and will probably not know the AWS API for IP ranges in detail.\r\n\r\nAnybody else has a stronger opinion here? Since it won't hurt I can easily add it ...","created_at":"2016-08-07T20:54:44Z","updated_at":"2016-08-07T20:54:44Z","html_url":"https://github.com/hashicorp/terraform/pull/7984#discussion_r73808858","pull_request_url":"https://api.github.com/repos/hashicorp/terraform/pulls/7984","_links":{"self":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/comments/73808858"},"html":{"href":"https://github.com/hashicorp/terraform/pull/7984#discussion_r73808858"},"pull_request":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/7984"}}},"pull_request":{"url":"https://api.github.com/repos/hashicorp/terraform/pulls/7984","id":80117302,"html_url":"https://github.com/hashicorp/terraform/pull/7984","diff_url":"https://github.com/hashicorp/terraform/pull/7984.diff","patch_url":"https://github.com/hashicorp/terraform/pull/7984.patch","issue_url":"https://api.github.com/repos/hashicorp/terraform/issues/7984","number":7984,"state":"open","locked":false,"title":"[WIP] Datasource for AWS and Fastly IP ranges","user":{"login":"yawn","id":18242,"avatar_url":"https://avatars.githubusercontent.com/u/18242?v=3","gravatar_id":"","url":"https://api.github.com/users/yawn","html_url":"https://github.com/yawn","followers_url":"https://api.github.com/users/yawn/followers","following_url":"https://api.github.com/users/yawn/following{/other_user}","gists_url":"https://api.github.com/users/yawn/gists{/gist_id}","starred_url":"https://api.github.com/users/yawn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yawn/subscriptions","organizations_url":"https://api.github.com/users/yawn/orgs","repos_url":"https://api.github.com/users/yawn/repos","events_url":"https://api.github.com/users/yawn/events{/privacy}","received_events_url":"https://api.github.com/users/yawn/received_events","type":"User","site_admin":false},"body":"This will allow the referencing of IP ranges like so:\r\n\r\n```\r\nprovider \"aws\" {\r\n  region = \"eu-west-1\"\r\n}\r\n\r\nprovider \"fastly\" {\r\n  api_key = \"test\"\r\n}\r\n\r\ndata \"fastly_ip_ranges\" \"fastly\" {\r\n}\r\n\r\ndata \"aws_ip_ranges\" \"cloudfront\" {\r\n  services = [ \"cloudfront\" ]\r\n}\r\n\r\ndata \"aws_ip_ranges\" \"healthchecks\" {\r\n  services = [ \"route53_healthchecks\" ]\r\n}\r\n\r\ndata \"aws_ip_ranges\" \"european_ec2\" {\r\n  services = [ \"ec2\" ]\r\n  regions = [ \"eu-west-1\", \"eu-central-1\" ]\r\n}\r\n\r\nresource \"aws_security_group\" \"from_cloudfront\" {\r\n\r\n  name = \"from_cf\"\r\n\r\n  ingress {\r\n    from_port = \"443\"\r\n    to_port = \"443\"\r\n    protocol = \"tcp\"\r\n    cidr_blocks = [ \"${data.aws_ip_ranges.cloudfront.cidr_blocks}\" ]\r\n  }\r\n\r\n  tags {\r\n    CreateDate = \"${data.aws_ip_ranges.cloudfront.create_date}\"\r\n    SyncToken = \"${data.aws_ip_ranges.cloudfront.sync_token}\"\r\n  }\r\n\r\n}\r\n\r\nresource \"aws_security_group\" \"from_europe\" {\r\n\r\n  name = \"from_europe\"\r\n\r\n  ingress {\r\n    from_port = \"443\"\r\n    to_port = \"443\"\r\n    protocol = \"tcp\"\r\n    cidr_blocks = [ \"${data.aws_ip_ranges.european_ec2.cidr_blocks}\" ]\r\n  }\r\n\r\n  tags {\r\n    CreateDate = \"${data.aws_ip_ranges.european_ec2.create_date}\"\r\n    SyncToken = \"${data.aws_ip_ranges.european_ec2.sync_token}\"\r\n  }\r\n\r\n}\r\n\r\nresource \"aws_security_group\" \"from_fastly\" {\r\n\r\n  name = \"from_fastly\"\r\n\r\n  ingress {\r\n    from_port = \"443\"\r\n    to_port = \"443\"\r\n    protocol = \"tcp\"\r\n    cidr_blocks = [ \"${data.fastly_ip_ranges.fastly.cidr_blocks}\" ]\r\n  }\r\n\r\n}\r\n\r\nresource \"aws_security_group\" \"from_r53\" {\r\n\r\n  name = \"from_r53\"\r\n\r\n  ingress {\r\n    from_port = \"443\"\r\n    to_port = \"443\"\r\n    protocol = \"tcp\"\r\n    cidr_blocks = [ \"${data.aws_ip_ranges.healthchecks.cidr_blocks}\" ]\r\n  }\r\n\r\n  tags {\r\n    CreateDate = \"${data.aws_ip_ranges.healthchecks.create_date}\"\r\n    SyncToken = \"${data.aws_ip_ranges.healthchecks.sync_token}\"\r\n  }\r\n\r\n}\r\n```\r\n\r\nIf you like this contribution, I'll\r\n\r\n* [X] add documentation\r\n* [ ] add tests\r\n* [X] rename `blocks` to `cidr_blocks`\r\n\r\nThe `main.tf` referenced above should already be `apply`able.","created_at":"2016-08-04T17:25:00Z","updated_at":"2016-08-07T20:54:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7791501a44a001233fca0d231709c58ba7a8ff6b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/hashicorp/terraform/pulls/7984/commits","review_comments_url":"https://api.github.com/repos/hashicorp/terraform/pulls/7984/comments","review_comment_url":"https://api.github.com/repos/hashicorp/terraform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/7984/comments","statuses_url":"https://api.github.com/repos/hashicorp/terraform/statuses/67bf13fccf21d7c4411b69761d58fd53c222631d","head":{"label":"yawn:ips","ref":"ips","sha":"67bf13fccf21d7c4411b69761d58fd53c222631d","user":{"login":"yawn","id":18242,"avatar_url":"https://avatars.githubusercontent.com/u/18242?v=3","gravatar_id":"","url":"https://api.github.com/users/yawn","html_url":"https://github.com/yawn","followers_url":"https://api.github.com/users/yawn/followers","following_url":"https://api.github.com/users/yawn/following{/other_user}","gists_url":"https://api.github.com/users/yawn/gists{/gist_id}","starred_url":"https://api.github.com/users/yawn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yawn/subscriptions","organizations_url":"https://api.github.com/users/yawn/orgs","repos_url":"https://api.github.com/users/yawn/repos","events_url":"https://api.github.com/users/yawn/events{/privacy}","received_events_url":"https://api.github.com/users/yawn/received_events","type":"User","site_admin":false},"repo":{"id":64826113,"name":"terraform","full_name":"yawn/terraform","owner":{"login":"yawn","id":18242,"avatar_url":"https://avatars.githubusercontent.com/u/18242?v=3","gravatar_id":"","url":"https://api.github.com/users/yawn","html_url":"https://github.com/yawn","followers_url":"https://api.github.com/users/yawn/followers","following_url":"https://api.github.com/users/yawn/following{/other_user}","gists_url":"https://api.github.com/users/yawn/gists{/gist_id}","starred_url":"https://api.github.com/users/yawn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yawn/subscriptions","organizations_url":"https://api.github.com/users/yawn/orgs","repos_url":"https://api.github.com/users/yawn/repos","events_url":"https://api.github.com/users/yawn/events{/privacy}","received_events_url":"https://api.github.com/users/yawn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yawn/terraform","description":"Terraform is a tool for building, changing, and combining infrastructure safely and efficiently.","fork":true,"url":"https://api.github.com/repos/yawn/terraform","forks_url":"https://api.github.com/repos/yawn/terraform/forks","keys_url":"https://api.github.com/repos/yawn/terraform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yawn/terraform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yawn/terraform/teams","hooks_url":"https://api.github.com/repos/yawn/terraform/hooks","issue_events_url":"https://api.github.com/repos/yawn/terraform/issues/events{/number}","events_url":"https://api.github.com/repos/yawn/terraform/events","assignees_url":"https://api.github.com/repos/yawn/terraform/assignees{/user}","branches_url":"https://api.github.com/repos/yawn/terraform/branches{/branch}","tags_url":"https://api.github.com/repos/yawn/terraform/tags","blobs_url":"https://api.github.com/repos/yawn/terraform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yawn/terraform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yawn/terraform/git/refs{/sha}","trees_url":"https://api.github.com/repos/yawn/terraform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yawn/terraform/statuses/{sha}","languages_url":"https://api.github.com/repos/yawn/terraform/languages","stargazers_url":"https://api.github.com/repos/yawn/terraform/stargazers","contributors_url":"https://api.github.com/repos/yawn/terraform/contributors","subscribers_url":"https://api.github.com/repos/yawn/terraform/subscribers","subscription_url":"https://api.github.com/repos/yawn/terraform/subscription","commits_url":"https://api.github.com/repos/yawn/terraform/commits{/sha}","git_commits_url":"https://api.github.com/repos/yawn/terraform/git/commits{/sha}","comments_url":"https://api.github.com/repos/yawn/terraform/comments{/number}","issue_comment_url":"https://api.github.com/repos/yawn/terraform/issues/comments{/number}","contents_url":"https://api.github.com/repos/yawn/terraform/contents/{+path}","compare_url":"https://api.github.com/repos/yawn/terraform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yawn/terraform/merges","archive_url":"https://api.github.com/repos/yawn/terraform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yawn/terraform/downloads","issues_url":"https://api.github.com/repos/yawn/terraform/issues{/number}","pulls_url":"https://api.github.com/repos/yawn/terraform/pulls{/number}","milestones_url":"https://api.github.com/repos/yawn/terraform/milestones{/number}","notifications_url":"https://api.github.com/repos/yawn/terraform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yawn/terraform/labels{/name}","releases_url":"https://api.github.com/repos/yawn/terraform/releases{/id}","deployments_url":"https://api.github.com/repos/yawn/terraform/deployments","created_at":"2016-08-03T07:43:10Z","updated_at":"2016-08-03T07:43:19Z","pushed_at":"2016-08-05T19:31:50Z","git_url":"git://github.com/yawn/terraform.git","ssh_url":"git@github.com:yawn/terraform.git","clone_url":"https://github.com/yawn/terraform.git","svn_url":"https://github.com/yawn/terraform","homepage":"https://www.terraform.io/","size":51532,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"de822d909c4013a99082918bc563262e3ef4ae89","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}","deployments_url":"https://api.github.com/repos/hashicorp/terraform/deployments","created_at":"2014-03-13T22:25:48Z","updated_at":"2016-08-07T19:46:11Z","pushed_at":"2016-08-07T18:56:30Z","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":"https://www.terraform.io/","size":101295,"stargazers_count":5405,"watchers_count":5405,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1694,"mirror_url":null,"open_issues_count":1477,"forks":1694,"open_issues":1477,"watchers":5405,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/7984"},"html":{"href":"https://github.com/hashicorp/terraform/pull/7984"},"issue":{"href":"https://api.github.com/repos/hashicorp/terraform/issues/7984"},"comments":{"href":"https://api.github.com/repos/hashicorp/terraform/issues/7984/comments"},"review_comments":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/7984/comments"},"review_comment":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hashicorp/terraform/pulls/7984/commits"},"statuses":{"href":"https://api.github.com/repos/hashicorp/terraform/statuses/67bf13fccf21d7c4411b69761d58fd53c222631d"}}}}
{"actor":{"display_login":"yawn"}}