Skip to content

Commit

Permalink
provider/aws: Update of inspector_assessment_target should use ARN not
Browse files Browse the repository at this point in the history
Name

fixes: #12112

```
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSInspectorTarget_basic'                                                  ✚
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/02/20 19:08:18 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSInspectorTarget_basic -timeout 120m
=== RUN   TestAccAWSInspectorTarget_basic
--- PASS: TestAccAWSInspectorTarget_basic (33.58s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	33.607s
```
  • Loading branch information
stack72 committed Feb 20, 2017
1 parent 8ea8588 commit 744ba06
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
20 changes: 6 additions & 14 deletions builtin/providers/aws/resource_aws_inspector_assessment_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ func resourceAWSInspectorAssessmentTarget() *schema.Resource {
Delete: resourceAwsInspectorAssessmentTargetDelete,

Schema: map[string]*schema.Schema{
"name": &schema.Schema{
"name": {
Type: schema.TypeString,
ForceNew: true,
Required: true,
},
"arn": &schema.Schema{
"arn": {
Type: schema.TypeString,
Computed: true,
},
"resource_group_arn": &schema.Schema{
"resource_group_arn": {
Type: schema.TypeString,
Required: true,
},
Expand Down Expand Up @@ -86,17 +86,9 @@ func resourceAwsInspectorAssessmentTargetUpdate(d *schema.ResourceData, meta int
conn := meta.(*AWSClient).inspectorconn

input := inspector.UpdateAssessmentTargetInput{
AssessmentTargetArn: aws.String(d.Id()),
}

if d.HasChange("name") {
_, n := d.GetChange("name")
input.AssessmentTargetName = aws.String(n.(string))
}

if d.HasChange("resource_group_arn") {
_, n := d.GetChange("resource_group_arn")
input.AssessmentTargetName = aws.String(n.(string))
AssessmentTargetArn: aws.String(d.Id()),
AssessmentTargetName: aws.String(d.Get("name").(string)),
ResourceGroupArn: aws.String(d.Get("resource_group_arn").(string)),
}

_, err := conn.UpdateAssessmentTarget(&input)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,24 @@ func TestAccAWSInspectorTarget_basic(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSInspectorTargetAssessmentDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccAWSInspectorTargetAssessment,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSInspectorTargetExists("aws_inspector_assessment_target.foo"),
),
},
resource.TestStep{
{
Config: testAccCheckAWSInspectorTargetAssessmentModified,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSInspectorTargetExists("aws_inspector_assessment_target.foo"),
),
},
{
Config: testAccCheckAWSInspectorTargetAssessmentUpdatedResourceGroup,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSInspectorTargetExists("aws_inspector_assessment_target.foo"),
),
},
},
})
}
Expand Down Expand Up @@ -99,3 +105,22 @@ resource "aws_inspector_assessment_target" "foo" {
name = "bar"
resource_group_arn = "${aws_inspector_resource_group.foo.arn}"
}`

var testAccCheckAWSInspectorTargetAssessmentUpdatedResourceGroup = `
resource "aws_inspector_resource_group" "foo" {
tags {
Name = "bar"
}
}
resource "aws_inspector_resource_group" "bar" {
tags {
Name = "test"
}
}
resource "aws_inspector_assessment_target" "foo" {
name = "bar"
resource_group_arn = "${aws_inspector_resource_group.bar.arn}"
}`

0 comments on commit 744ba06

Please sign in to comment.