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
```
This commit is contained in:
stack72 2016-09-02 17:04:43 +03:00
parent e98e5fb017
commit f9183da2e3
No known key found for this signature in database
GPG Key ID: 8619A619B085CB16
2 changed files with 14 additions and 19 deletions

View File

@ -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 {
return fmt.Errorf("[ERROR] AssociationDescription was nil")
}
if resp.AssociationDescription != nil {
association := resp.AssociationDescription
d.Set("instance_id", association.InstanceId)
d.Set("name", association.Name)
d.Set("parameters", association.Parameters)
} else {
return fmt.Errorf("[ERROR] AssociationDescription was nil")
}
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

View File

@ -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}"]
}