Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update broken in AWS Inspector Resource Group (trivial, with fix) #12112

Closed
jtsaito opened this issue Feb 20, 2017 · 3 comments · Fixed by #12115
Closed

Update broken in AWS Inspector Resource Group (trivial, with fix) #12112

jtsaito opened this issue Feb 20, 2017 · 3 comments · Fixed by #12115

Comments

@jtsaito
Copy link
Contributor

jtsaito commented Feb 20, 2017

Terraform Version

v0.9.0-beta1 (and previous versions)

Affected Resource(s)

  • aws_inspector_resource_group
  • aws_inspector_assessment_target

Important note

Please read the section entitled Important Factoids first!

Terraform Configuration Files

Error occurred on updating the tags in the aws_inspector_resource_group.

resource "aws_inspector_resource_group" "inspector" {
  tags {
    "babbel:name" = "bookshelf-other"
  }
}

resource "aws_inspector_assessment_target" "inspector" {
  name               = "foo"
  resource_group_arn = "${aws_inspector_resource_group.inspector.arn}"
}

Debug Output

https://gist.github.com/jtsaito/0b880647f6a53a37a7d5f7748e88c96d (slightly modified)

Panic Output

None. Please see fix below instead.

Expected Behavior

The resource should be updated without terminating with an error and the attribute tag should be set too `"babbel:name" = "bookshelf-other" in the JSON.

Actual Behavior

Fails to update with error message.

* aws_inspector_assessment_target.inspector: InvalidParameter: 1 validation error(s) found.
- missing required field, UpdateAssessmentTargetInput.ResourceGroupArn.

Steps to Reproduce

Trivial.
(1) Create aws_inspector_resource_group and resource_group_arn resources pointing to the first.
(2) Change the tags attribute in the aws_inspector_resource_group and apply again.

Important Factoids

The bug is obvious in the terraform source for resourceAwsInspectorAssessmentTargetUpdate :

input.AssessmentTargetName = aws.String(n.(string))

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

The function call is updating the wrong attribute:AssessmentTargetName instead of AssessmentTargetArn. The fix should trivial and as follows.

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

References

The required AssessmentTargetArnis not updated because the AssessmentTargetName is overwritten instead by mistake, c.f.: AWS Go SDK.

@stack72
Copy link
Contributor

stack72 commented Feb 20, 2017

Hi @jtsaito

Thanks for raising the issue here - also, thanks for investigating the cause :) PR being tested to fix this right now

Thanks

Paul

stack72 added a commit that referenced this issue Feb 20, 2017
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
```
stack72 added a commit that referenced this issue Feb 20, 2017
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
```
stack72 added a commit that referenced this issue Feb 20, 2017
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
```
stack72 added a commit that referenced this issue Feb 20, 2017
#12115)

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
```
stack72 added a commit that referenced this issue Feb 20, 2017
#12115)

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
```
@jtsaito
Copy link
Contributor Author

jtsaito commented Feb 20, 2017

@stack72 Great, thanks!

@ghost
Copy link

ghost commented Apr 16, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants