From f9183da2e305aff284eb87523967ebff4622b37f Mon Sep 17 00:00:00 2001 From: stack72 Date: Fri, 2 Sep 2016 17:04:43 +0300 Subject: [PATCH] provider/aws: Changing the tests for `aws_ssm_association` to align with us-west-2 ``` % make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSSSMAssociation_' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2016/09/02 16:56:09 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSSSMAssociation_ -timeout 120m === RUN TestAccAWSSSMAssociation_basic --- PASS: TestAccAWSSSMAssociation_basic (136.23s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 136.246s ``` --- .../aws/resource_aws_ssm_association.go | 26 ++++++++----------- .../aws/resource_aws_ssm_association_test.go | 7 +++-- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/builtin/providers/aws/resource_aws_ssm_association.go b/builtin/providers/aws/resource_aws_ssm_association.go index afcac8453..cb3af1d68 100644 --- a/builtin/providers/aws/resource_aws_ssm_association.go +++ b/builtin/providers/aws/resource_aws_ssm_association.go @@ -48,21 +48,20 @@ func resourceAwsSsmAssociationCreate(d *schema.ResourceData, meta interface{}) e } if v, ok := d.GetOk("parameters"); ok { - assosciationInput.Parameters = expandDocumentParameters(v.(map[string]interface{})) + assosciationInput.Parameters = expandSSMDocumentParameters(v.(map[string]interface{})) } resp, err := ssmconn.CreateAssociation(assosciationInput) - if err != nil { return errwrap.Wrapf("[ERROR] Error creating SSM association: {{err}}", err) } - if resp.AssociationDescription != nil { - d.SetId(*resp.AssociationDescription.Name) - } else { + if resp.AssociationDescription == nil { return fmt.Errorf("[ERROR] AssociationDescription was nil") } + d.SetId(*resp.AssociationDescription.Name) + return resourceAwsSsmAssociationRead(d, meta) } @@ -81,18 +80,15 @@ func resourceAwsSsmAssociationRead(d *schema.ResourceData, meta interface{}) err if err != nil { return errwrap.Wrapf("[ERROR] Error reading SSM association: {{err}}", err) } - - if resp.AssociationDescription != nil { - association := resp.AssociationDescription - - d.Set("instance_id", association.InstanceId) - d.Set("name", association.Name) - d.Set("parameters", association.Parameters) - - } else { + if resp.AssociationDescription == nil { return fmt.Errorf("[ERROR] AssociationDescription was nil") } + association := resp.AssociationDescription + d.Set("instance_id", association.InstanceId) + d.Set("name", association.Name) + d.Set("parameters", association.Parameters) + return nil } @@ -115,7 +111,7 @@ func resourceAwsSsmAssociationDelete(d *schema.ResourceData, meta interface{}) e return nil } -func expandDocumentParameters(params map[string]interface{}) map[string][]*string { +func expandSSMDocumentParameters(params map[string]interface{}) map[string][]*string { var docParams = make(map[string][]*string) for k, v := range params { var values []*string diff --git a/builtin/providers/aws/resource_aws_ssm_association_test.go b/builtin/providers/aws/resource_aws_ssm_association_test.go index 3a8e1ec89..42454cd39 100644 --- a/builtin/providers/aws/resource_aws_ssm_association_test.go +++ b/builtin/providers/aws/resource_aws_ssm_association_test.go @@ -98,10 +98,9 @@ resource "aws_security_group" "tf_test_foo" { } resource "aws_instance" "foo" { - # eu-west-1 - ami = "ami-f77ac884" - availability_zone = "eu-west-1a" - instance_type = "t2.small" + ami = "ami-4fccb37f" + availability_zone = "us-west-2a" + instance_type = "m1.small" security_groups = ["${aws_security_group.tf_test_foo.name}"] }