From 739a411b4d867bf7036a38f3fd4feeca867cd939 Mon Sep 17 00:00:00 2001 From: Alexander Dupuy Date: Mon, 18 May 2015 21:45:50 +0200 Subject: [PATCH 01/22] debug security group ids --- .../resource_openstack_compute_instance_v2.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/builtin/providers/openstack/resource_openstack_compute_instance_v2.go b/builtin/providers/openstack/resource_openstack_compute_instance_v2.go index 44fca923f..066fa637f 100644 --- a/builtin/providers/openstack/resource_openstack_compute_instance_v2.go +++ b/builtin/providers/openstack/resource_openstack_compute_instance_v2.go @@ -557,13 +557,6 @@ func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Security groups to remove: %v", secgroupsToRemove) - for _, g := range secgroupsToAdd.List() { - err := secgroups.AddServerToGroup(computeClient, d.Id(), g.(string)).ExtractErr() - if err != nil { - return fmt.Errorf("Error adding security group to OpenStack server (%s): %s", d.Id(), err) - } - log.Printf("[DEBUG] Added security group (%s) to instance (%s)", g.(string), d.Id()) - } for _, g := range secgroupsToRemove.List() { err := secgroups.RemoveServerFromGroup(computeClient, d.Id(), g.(string)).ExtractErr() @@ -581,6 +574,14 @@ func resourceComputeInstanceV2Update(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Removed security group (%s) from instance (%s)", g.(string), d.Id()) } } + for _, g := range secgroupsToAdd.List() { + err := secgroups.AddServerToGroup(computeClient, d.Id(), g.(string)).ExtractErr() + if err != nil { + return fmt.Errorf("Error adding security group to OpenStack server (%s): %s", d.Id(), err) + } + log.Printf("[DEBUG] Added security group (%s) to instance (%s)", g.(string), d.Id()) + } + } if d.HasChange("admin_pass") { From b928777cace13e4e1cc322e5688708f3a26d4e5b Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Tue, 11 Aug 2015 11:36:56 -0500 Subject: [PATCH 02/22] core: don't error on computed value during input walk fixes #2987 --- terraform/context_input_test.go | 59 +++++++++++++++++++ terraform/interpolate.go | 16 ++++- .../child/main.tf | 5 ++ .../input-var-partially-computed/main.tf | 7 +++ 4 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 terraform/test-fixtures/input-var-partially-computed/child/main.tf create mode 100644 terraform/test-fixtures/input-var-partially-computed/main.tf diff --git a/terraform/context_input_test.go b/terraform/context_input_test.go index 155f4c72f..404ef0ffc 100644 --- a/terraform/context_input_test.go +++ b/terraform/context_input_test.go @@ -510,3 +510,62 @@ aws_instance.foo: t.Fatalf("expected: \n%s\ngot: \n%s\n", expectedStr, actualStr) } } + +func TestContext2Input_varPartiallyComputed(t *testing.T) { + input := new(MockUIInput) + m := testModule(t, "input-var-partially-computed") + p := testProvider("aws") + p.ApplyFn = testApplyFn + p.DiffFn = testDiffFn + ctx := testContext2(t, &ContextOpts{ + Module: m, + Providers: map[string]ResourceProviderFactory{ + "aws": testProviderFuncFixed(p), + }, + Variables: map[string]string{ + "foo": "foovalue", + }, + UIInput: input, + State: &State{ + Modules: []*ModuleState{ + &ModuleState{ + Path: rootModulePath, + Resources: map[string]*ResourceState{ + "aws_instance.foo": &ResourceState{ + Type: "aws_instance", + Primary: &InstanceState{ + ID: "i-abc123", + Attributes: map[string]string{ + "id": "i-abc123", + }, + }, + }, + }, + }, + &ModuleState{ + Path: append(rootModulePath, "child"), + Resources: map[string]*ResourceState{ + "aws_instance.mod": &ResourceState{ + Type: "aws_instance", + Primary: &InstanceState{ + ID: "i-bcd345", + Attributes: map[string]string{ + "id": "i-bcd345", + "value": "one,i-abc123", + }, + }, + }, + }, + }, + }, + }, + }) + + if err := ctx.Input(InputModeStd); err != nil { + t.Fatalf("err: %s", err) + } + + if _, err := ctx.Plan(); err != nil { + t.Fatalf("err: %s", err) + } +} diff --git a/terraform/interpolate.go b/terraform/interpolate.go index 6d103cd80..0197c0e42 100644 --- a/terraform/interpolate.go +++ b/terraform/interpolate.go @@ -370,7 +370,13 @@ MISSING: // be unknown. Instead, we return that the value is computed so // that the graph can continue to refresh other nodes. It doesn't // matter because the config isn't interpolated anyways. - if i.Operation == walkRefresh || i.Operation == walkPlanDestroy { + // + // For a Destroy, we're also fine with computed values, since our goal is + // only to get destroy nodes for existing resources. + // + // For an input walk, computed values are okay to return because we're only + // looking for missing variables to prompt the user for. + if i.Operation == walkRefresh || i.Operation == walkPlanDestroy || i.Operation == walkInput { return config.UnknownVariableValue, nil } @@ -446,7 +452,13 @@ func (i *Interpolater) computeResourceMultiVariable( // be unknown. Instead, we return that the value is computed so // that the graph can continue to refresh other nodes. It doesn't // matter because the config isn't interpolated anyways. - if i.Operation == walkRefresh || i.Operation == walkPlanDestroy { + // + // For a Destroy, we're also fine with computed values, since our goal is + // only to get destroy nodes for existing resources. + // + // For an input walk, computed values are okay to return because we're only + // looking for missing variables to prompt the user for. + if i.Operation == walkRefresh || i.Operation == walkPlanDestroy || i.Operation == walkInput { return config.UnknownVariableValue, nil } diff --git a/terraform/test-fixtures/input-var-partially-computed/child/main.tf b/terraform/test-fixtures/input-var-partially-computed/child/main.tf new file mode 100644 index 000000000..a11cc5e83 --- /dev/null +++ b/terraform/test-fixtures/input-var-partially-computed/child/main.tf @@ -0,0 +1,5 @@ +variable "in" {} + +resource "aws_instance" "mod" { + value = "${var.in}" +} diff --git a/terraform/test-fixtures/input-var-partially-computed/main.tf b/terraform/test-fixtures/input-var-partially-computed/main.tf new file mode 100644 index 000000000..ada6f0cea --- /dev/null +++ b/terraform/test-fixtures/input-var-partially-computed/main.tf @@ -0,0 +1,7 @@ +resource "aws_instance" "foo" { } +resource "aws_instance" "bar" { } + +module "child" { + source = "./child" + in = "one,${aws_instance.foo.id},${aws_instance.bar.id}" +} From 4fd5c7254046bd7ef3d1b6872dcefe45f15fcbc2 Mon Sep 17 00:00:00 2001 From: Lars Wander Date: Tue, 15 Sep 2015 15:52:43 -0400 Subject: [PATCH 03/22] Fix "malformed url" bug in instance template when using network name --- .../providers/google/resource_compute_instance_template.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/builtin/providers/google/resource_compute_instance_template.go b/builtin/providers/google/resource_compute_instance_template.go index 060f4bb39..ce2c72734 100644 --- a/builtin/providers/google/resource_compute_instance_template.go +++ b/builtin/providers/google/resource_compute_instance_template.go @@ -305,11 +305,9 @@ func buildNetworks(d *schema.ResourceData, meta interface{}) (error, []*compute. for i := 0; i < networksCount; i++ { prefix := fmt.Sprintf("network_interface.%d", i) - source := "global/networks/default" + source := "global/networks/" if v, ok := d.GetOk(prefix + ".network"); ok { - if v.(string) != "default" { - source = v.(string) - } + source += v.(string) } // Build the networkInterface From 7884fb805e9e2991c299bff6045445dadac10209 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 23 Sep 2015 17:31:38 -0700 Subject: [PATCH 04/22] Corrected example on rundeck provider index page. An earlier version of the provider implementation accepted key_material_file instead of key_material. This was updated in the resource-specific docs but not in this provider-wide example. --- website/source/docs/providers/rundeck/index.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/source/docs/providers/rundeck/index.html.markdown b/website/source/docs/providers/rundeck/index.html.markdown index e948ca4e3..529f4f44b 100644 --- a/website/source/docs/providers/rundeck/index.html.markdown +++ b/website/source/docs/providers/rundeck/index.html.markdown @@ -70,6 +70,6 @@ resource "rundeck_public_key" "anvils" { resource "rundeck_private_key" "anvils" { path = "anvils/id_rsa" - key_material_file = "${path.module}/id_rsa.pub" + key_material = "${file(\"id_rsa.pub\")}" } ``` From f85fc866fe9a29de5eafc785c85f24450d247d53 Mon Sep 17 00:00:00 2001 From: Sam Handler Date: Wed, 23 Sep 2015 18:51:34 -0700 Subject: [PATCH 05/22] Put "Edit this page" link in footer --- website/source/layouts/_footer.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/source/layouts/_footer.erb b/website/source/layouts/_footer.erb index df095a820..d2ea893fc 100644 --- a/website/source/layouts/_footer.erb +++ b/website/source/layouts/_footer.erb @@ -7,6 +7,9 @@
  • Intro
  • Docs
  • Community
  • + <% if current_page.url != '/' %> +
  • Edit this page
  • + <% end %>