From 928d5f76ab899f5f1edca2412656d564200bcc65 Mon Sep 17 00:00:00 2001 From: Nathan Sullivan Date: Thu, 2 Jul 2015 20:34:58 +1000 Subject: [PATCH 1/8] updated docs for aws_ecs_task_definition to avoid confusion --- .../aws/r/ecs_task_definition.html.markdown | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/website/source/docs/providers/aws/r/ecs_task_definition.html.markdown b/website/source/docs/providers/aws/r/ecs_task_definition.html.markdown index e89a81e1a0..1d1578bcfc 100644 --- a/website/source/docs/providers/aws/r/ecs_task_definition.html.markdown +++ b/website/source/docs/providers/aws/r/ecs_task_definition.html.markdown @@ -12,6 +12,8 @@ Provides an ECS task definition to be used in `aws_ecs_service`. ## Example Usage +### jenkins.tf + ``` resource "aws_ecs_task_definition" "jenkins" { family = "jenkins" @@ -24,12 +26,34 @@ resource "aws_ecs_task_definition" "jenkins" { } ``` +### task-definitions/jenkins.json + +This is a small subset of the available parameters, see the [AWS docs](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html) for a full list. + +``` +[ + { + "name": "jenkins", + "image": "jenkins", + "cpu": 10, + "memory": 500, + "essential": true, + "portMappings": [ + { + "containerPort": 80, + "hostPort": 80 + } + ] + } +] +``` + ## Argument Reference The following arguments are supported: * `family` - (Required) The family, unique name for your task definition. -* `container_definitions` - (Required) A list of container definitions in JSON format. See [AWS docs](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_defintions.html) for syntax. +* `container_definitions` - (Required) A list of container definitions in JSON format. See [AWS docs](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-task-definition.html) for syntax. Note, you only need the containerDefinitions array contents, not the parent hash including the family and volumes keys. * `volume` - (Optional) A volume block. Volumes documented below. Volumes support the following: From 857f1394046a8c9d1006a8b785f07855a8e3d43a Mon Sep 17 00:00:00 2001 From: Kel Cecil Date: Wed, 1 Jul 2015 20:09:04 -0400 Subject: [PATCH 2/8] Add ebs_optimized argument to launch_configuration docs --- .../docs/providers/aws/r/launch_configuration.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/source/docs/providers/aws/r/launch_configuration.html.markdown b/website/source/docs/providers/aws/r/launch_configuration.html.markdown index 49201e6f5d..ebfe7397f5 100644 --- a/website/source/docs/providers/aws/r/launch_configuration.html.markdown +++ b/website/source/docs/providers/aws/r/launch_configuration.html.markdown @@ -35,6 +35,7 @@ The following arguments are supported: * `associate_public_ip_address` - (Optional) Associate a public ip address with an instance in a VPC. * `user_data` - (Optional) The user data to provide when launching the instance. * `enable_monitoring` - (Optional) Enables/disables detailed monitoring. This is enabled by default. +* `ebs_optimized` - (Optional) If true, the launched EC2 instance will be EBS-optimized. * `block_device_mapping` - (Optional) A list of block devices to add. Their keys are documented below. From 21a336fb4af0c3717c3466dfbd4dd8f00a3966d1 Mon Sep 17 00:00:00 2001 From: Nathan Sullivan Date: Fri, 3 Jul 2015 18:30:55 +1000 Subject: [PATCH 3/8] updates as per @radeksimko's comments --- .../aws/r/ecs_task_definition.html.markdown | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/website/source/docs/providers/aws/r/ecs_task_definition.html.markdown b/website/source/docs/providers/aws/r/ecs_task_definition.html.markdown index 1d1578bcfc..ac47f847e0 100644 --- a/website/source/docs/providers/aws/r/ecs_task_definition.html.markdown +++ b/website/source/docs/providers/aws/r/ecs_task_definition.html.markdown @@ -12,23 +12,9 @@ Provides an ECS task definition to be used in `aws_ecs_service`. ## Example Usage -### jenkins.tf - -``` -resource "aws_ecs_task_definition" "jenkins" { - family = "jenkins" - container_definitions = "${file("task-definitions/jenkins.json")}" - - volume { - name = "jenkins-home" - host_path = "/ecs/jenkins-home" - } -} -``` - ### task-definitions/jenkins.json -This is a small subset of the available parameters, see the [AWS docs](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html) for a full list. +The below would be passed into the `container_definitions` attribute. This is a small subset of the available parameters, see the [AWS docs](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html) for a full list. ``` [ @@ -53,7 +39,7 @@ This is a small subset of the available parameters, see the [AWS docs](http://do The following arguments are supported: * `family` - (Required) The family, unique name for your task definition. -* `container_definitions` - (Required) A list of container definitions in JSON format. See [AWS docs](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-task-definition.html) for syntax. Note, you only need the containerDefinitions array contents, not the parent hash including the family and volumes keys. +* `container_definitions` - (Required) A list of container definitions in JSON format. See [AWS docs](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-task-definition.html) for syntax. Note, you only need the containerDefinitions array, not the parent hash including the family and volumes keys. * `volume` - (Optional) A volume block. Volumes documented below. Volumes support the following: From e376f61d1dcac015c88b8aab4709e2fa7cc12679 Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Fri, 3 Jul 2015 12:26:38 +0200 Subject: [PATCH 4/8] core: Return correct number of planned updates --- command/hook_count.go | 2 +- command/hook_count_test.go | 173 +++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+), 1 deletion(-) diff --git a/command/hook_count.go b/command/hook_count.go index 12fb229abf..5f3f514c2c 100644 --- a/command/hook_count.go +++ b/command/hook_count.go @@ -97,7 +97,7 @@ func (h *CountHook) PostDiff( h.ToAdd += 1 case terraform.DiffDestroy: h.ToRemove += 1 - default: + case terraform.DiffUpdate: h.ToChange += 1 } diff --git a/command/hook_count_test.go b/command/hook_count_test.go index 37fc72b69c..deb8226997 100644 --- a/command/hook_count_test.go +++ b/command/hook_count_test.go @@ -1,6 +1,7 @@ package command import ( + "reflect" "testing" "github.com/hashicorp/terraform/terraform" @@ -9,3 +10,175 @@ import ( func TestCountHook_impl(t *testing.T) { var _ terraform.Hook = new(CountHook) } + +func TestCountHookPostDiff_DestroyOnly(t *testing.T) { + h := new(CountHook) + + resources := map[string]*terraform.InstanceDiff{ + "foo": &terraform.InstanceDiff{Destroy: true}, + "bar": &terraform.InstanceDiff{Destroy: true}, + "lorem": &terraform.InstanceDiff{Destroy: true}, + "ipsum": &terraform.InstanceDiff{Destroy: true}, + } + + n := &terraform.InstanceInfo{} // TODO + + for _, d := range resources { + h.PostDiff(n, d) + } + + expected := new(CountHook) + expected.ToAdd = 0 + expected.ToChange = 0 + expected.ToRemoveAndAdd = 0 + expected.ToRemove = 4 + + if !reflect.DeepEqual(expected, h) { + t.Fatalf("Expected %#v, got %#v instead.", + expected, h) + } +} + +func TestCountHookPostDiff_AddOnly(t *testing.T) { + h := new(CountHook) + + resources := map[string]*terraform.InstanceDiff{ + "foo": &terraform.InstanceDiff{ + Attributes: map[string]*terraform.ResourceAttrDiff{ + "foo": &terraform.ResourceAttrDiff{RequiresNew: true}, + }, + }, + "bar": &terraform.InstanceDiff{ + Attributes: map[string]*terraform.ResourceAttrDiff{ + "foo": &terraform.ResourceAttrDiff{RequiresNew: true}, + }, + }, + "lorem": &terraform.InstanceDiff{ + Attributes: map[string]*terraform.ResourceAttrDiff{ + "foo": &terraform.ResourceAttrDiff{RequiresNew: true}, + }, + }, + } + + n := &terraform.InstanceInfo{} + + for _, d := range resources { + h.PostDiff(n, d) + } + + expected := new(CountHook) + expected.ToAdd = 3 + expected.ToChange = 0 + expected.ToRemoveAndAdd = 0 + expected.ToRemove = 0 + + if !reflect.DeepEqual(expected, h) { + t.Fatalf("Expected %#v, got %#v instead.", + expected, h) + } +} + +func TestCountHookPostDiff_ChangeOnly(t *testing.T) { + h := new(CountHook) + + resources := map[string]*terraform.InstanceDiff{ + "foo": &terraform.InstanceDiff{ + Destroy: false, + Attributes: map[string]*terraform.ResourceAttrDiff{ + "foo": &terraform.ResourceAttrDiff{}, + }, + }, + "bar": &terraform.InstanceDiff{ + Destroy: false, + Attributes: map[string]*terraform.ResourceAttrDiff{ + "foo": &terraform.ResourceAttrDiff{}, + }, + }, + "lorem": &terraform.InstanceDiff{ + Destroy: false, + Attributes: map[string]*terraform.ResourceAttrDiff{ + "foo": &terraform.ResourceAttrDiff{}, + }, + }, + } + + n := &terraform.InstanceInfo{} + + for _, d := range resources { + h.PostDiff(n, d) + } + + expected := new(CountHook) + expected.ToAdd = 0 + expected.ToChange = 3 + expected.ToRemoveAndAdd = 0 + expected.ToRemove = 0 + + if !reflect.DeepEqual(expected, h) { + t.Fatalf("Expected %#v, got %#v instead.", + expected, h) + } +} + +func TestCountHookPostDiff_Mixed(t *testing.T) { + h := new(CountHook) + + resources := map[string]*terraform.InstanceDiff{ + "foo": &terraform.InstanceDiff{ + Destroy: true, + }, + "bar": &terraform.InstanceDiff{}, + "lorem": &terraform.InstanceDiff{ + Destroy: false, + Attributes: map[string]*terraform.ResourceAttrDiff{ + "foo": &terraform.ResourceAttrDiff{}, + }, + }, + "ipsum": &terraform.InstanceDiff{Destroy: true}, + } + + n := &terraform.InstanceInfo{} + + for _, d := range resources { + h.PostDiff(n, d) + } + + expected := new(CountHook) + expected.ToAdd = 0 + expected.ToChange = 1 + expected.ToRemoveAndAdd = 0 + expected.ToRemove = 2 + + if !reflect.DeepEqual(expected, h) { + t.Fatalf("Expected %#v, got %#v instead.", + expected, h) + } +} + +func TestCountHookPostDiff_NoChange(t *testing.T) { + h := new(CountHook) + + resources := map[string]*terraform.InstanceDiff{ + "foo": &terraform.InstanceDiff{}, + "bar": &terraform.InstanceDiff{}, + "lorem": &terraform.InstanceDiff{}, + "ipsum": &terraform.InstanceDiff{}, + } + + n := &terraform.InstanceInfo{} + + for _, d := range resources { + h.PostDiff(n, d) + } + + expected := new(CountHook) + expected.ToAdd = 0 + expected.ToChange = 0 + expected.ToRemoveAndAdd = 0 + expected.ToRemove = 0 + + if !reflect.DeepEqual(expected, h) { + t.Fatalf("Expected %#v, got %#v instead.", + expected, h) + } +} From 007ab6e5039d13a86b7b302ddcb56dbc2c5c0b92 Mon Sep 17 00:00:00 2001 From: Jeroen de Korte Date: Fri, 3 Jul 2015 15:04:58 +0200 Subject: [PATCH 5/8] Fixed the http_proxy --- builtin/provisioners/chef/linux_provisioner.go | 2 +- builtin/provisioners/chef/linux_provisioner_test.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/builtin/provisioners/chef/linux_provisioner.go b/builtin/provisioners/chef/linux_provisioner.go index e142884379..d8cce95aeb 100644 --- a/builtin/provisioners/chef/linux_provisioner.go +++ b/builtin/provisioners/chef/linux_provisioner.go @@ -20,7 +20,7 @@ func (p *Provisioner) linuxInstallChefClient( // Build up the command prefix prefix := "" if p.HTTPProxy != "" { - prefix += fmt.Sprintf("proxy_http='%s' ", p.HTTPProxy) + prefix += fmt.Sprintf("http_proxy='%s' ", p.HTTPProxy) } if p.NOProxy != nil { prefix += fmt.Sprintf("no_proxy='%s' ", strings.Join(p.NOProxy, ",")) diff --git a/builtin/provisioners/chef/linux_provisioner_test.go b/builtin/provisioners/chef/linux_provisioner_test.go index e41c5b8daf..d50ae1a507 100644 --- a/builtin/provisioners/chef/linux_provisioner_test.go +++ b/builtin/provisioners/chef/linux_provisioner_test.go @@ -58,9 +58,9 @@ func TestResourceProvider_linuxInstallChefClient(t *testing.T) { }), Commands: map[string]bool{ - "proxy_http='http://proxy.local' curl -LO https://www.chef.io/chef/install.sh": true, - "proxy_http='http://proxy.local' bash ./install.sh -v \"\"": true, - "proxy_http='http://proxy.local' rm -f install.sh": true, + "http_proxy='http://proxy.local' curl -LO https://www.chef.io/chef/install.sh": true, + "http_proxy='http://proxy.local' bash ./install.sh -v \"\"": true, + "http_proxy='http://proxy.local' rm -f install.sh": true, }, }, @@ -77,11 +77,11 @@ func TestResourceProvider_linuxInstallChefClient(t *testing.T) { }), Commands: map[string]bool{ - "proxy_http='http://proxy.local' no_proxy='http://local.local,http://local.org' " + + "http_proxy='http://proxy.local' no_proxy='http://local.local,http://local.org' " + "curl -LO https://www.chef.io/chef/install.sh": true, - "proxy_http='http://proxy.local' no_proxy='http://local.local,http://local.org' " + + "http_proxy='http://proxy.local' no_proxy='http://local.local,http://local.org' " + "bash ./install.sh -v \"\"": true, - "proxy_http='http://proxy.local' no_proxy='http://local.local,http://local.org' " + + "http_proxy='http://proxy.local' no_proxy='http://local.local,http://local.org' " + "rm -f install.sh": true, }, }, From 1c14bfd04d5a6db2dc8b81d796cfba8397552813 Mon Sep 17 00:00:00 2001 From: Jeroen de Korte Date: Fri, 3 Jul 2015 16:27:52 +0200 Subject: [PATCH 6/8] Added the HTTPS proxy option --- builtin/provisioners/chef/linux_provisioner.go | 3 +++ .../chef/linux_provisioner_test.go | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/builtin/provisioners/chef/linux_provisioner.go b/builtin/provisioners/chef/linux_provisioner.go index d8cce95aeb..2a1e92eab5 100644 --- a/builtin/provisioners/chef/linux_provisioner.go +++ b/builtin/provisioners/chef/linux_provisioner.go @@ -22,6 +22,9 @@ func (p *Provisioner) linuxInstallChefClient( if p.HTTPProxy != "" { prefix += fmt.Sprintf("http_proxy='%s' ", p.HTTPProxy) } + if p.HTTPSProxy != "" { + prefix += fmt.Sprintf("https_proxy='%s' ", p.HTTPSProxy) + } if p.NOProxy != nil { prefix += fmt.Sprintf("no_proxy='%s' ", strings.Join(p.NOProxy, ",")) } diff --git a/builtin/provisioners/chef/linux_provisioner_test.go b/builtin/provisioners/chef/linux_provisioner_test.go index d50ae1a507..d55b4c31a4 100644 --- a/builtin/provisioners/chef/linux_provisioner_test.go +++ b/builtin/provisioners/chef/linux_provisioner_test.go @@ -64,6 +64,24 @@ func TestResourceProvider_linuxInstallChefClient(t *testing.T) { }, }, + "HTTPSProxy": { + Config: testConfig(t, map[string]interface{}{ + "https_proxy": "https://proxy.local", + "node_name": "nodename1", + "prevent_sudo": true, + "run_list": []interface{}{"cookbook::recipe"}, + "server_url": "https://chef.local", + "validation_client_name": "validator", + "validation_key_path": "validator.pem", + }), + + Commands: map[string]bool{ + "https_proxy='https://proxy.local' curl -LO https://www.chef.io/chef/install.sh": true, + "https_proxy='https://proxy.local' bash ./install.sh -v \"\"": true, + "https_proxy='https://proxy.local' rm -f install.sh": true, + }, + }, + "NOProxy": { Config: testConfig(t, map[string]interface{}{ "http_proxy": "http://proxy.local", From bba53d46a659839779b476ee401c0e8c9a9bc9bb Mon Sep 17 00:00:00 2001 From: Nathan Sullivan Date: Sat, 4 Jul 2015 03:41:44 +1000 Subject: [PATCH 7/8] oops :) --- .../aws/r/ecs_task_definition.html.markdown | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/website/source/docs/providers/aws/r/ecs_task_definition.html.markdown b/website/source/docs/providers/aws/r/ecs_task_definition.html.markdown index ac47f847e0..3c761aa62b 100644 --- a/website/source/docs/providers/aws/r/ecs_task_definition.html.markdown +++ b/website/source/docs/providers/aws/r/ecs_task_definition.html.markdown @@ -12,6 +12,18 @@ Provides an ECS task definition to be used in `aws_ecs_service`. ## Example Usage +``` +resource "aws_ecs_task_definition" "jenkins" { + family = "jenkins" + container_definitions = "${file("task-definitions/jenkins.json")}" + + volume { + name = "jenkins-home" + host_path = "/ecs/jenkins-home" + } +} +``` + ### task-definitions/jenkins.json The below would be passed into the `container_definitions` attribute. This is a small subset of the available parameters, see the [AWS docs](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html) for a full list. From 94bc96d3de7bbc78bcf0df6a7fc8db71260d49aa Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Sat, 4 Jul 2015 07:09:47 +0200 Subject: [PATCH 8/8] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index af5b1bdb6f..6126eeb3bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ BUG FIXES: preventing `key_file` from being read without explicitly setting `agent = false` [GH-2615] * core: don't prompt for variables with defaults [GH-2613] + * core: Return correct number of planned updates [GH-2620] * providers/aws: Allow uppercase characters in `aws_elb.name` [GH-2580] * providers/aws: Allow underscores in `aws_db_subnet_group.name` (undocumented by AWS) [GH-2604]