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] diff --git a/builtin/provisioners/chef/linux_provisioner.go b/builtin/provisioners/chef/linux_provisioner.go index e142884379..2a1e92eab5 100644 --- a/builtin/provisioners/chef/linux_provisioner.go +++ b/builtin/provisioners/chef/linux_provisioner.go @@ -20,7 +20,10 @@ 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.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 e41c5b8daf..d55b4c31a4 100644 --- a/builtin/provisioners/chef/linux_provisioner_test.go +++ b/builtin/provisioners/chef/linux_provisioner_test.go @@ -58,9 +58,27 @@ 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, + }, + }, + + "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, }, }, @@ -77,11 +95,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, }, }, 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) + } +} 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..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 @@ -24,12 +24,34 @@ resource "aws_ecs_task_definition" "jenkins" { } ``` +### 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. + +``` +[ + { + "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, not the parent hash including the family and volumes keys. * `volume` - (Optional) A volume block. Volumes documented below. Volumes support the following: 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.