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

[email protected] and Computed,Optional,ForceNew #246

Closed
wants to merge 3 commits into from

Conversation

ewbankkit
Copy link
Contributor

@ewbankkit ewbankkit commented Oct 14, 2021

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request
  • The resources and data sources in this provider are generated from the CloudFormation schema, so they can only support the actions that the underlying schema supports. For this reason submitted bugs should be limited to defects in the generation and runtime code of the provider. Customizing behavior of the resource, or noting a gap in behavior are not valid bugs and should be submitted as enhancements to AWS via the Cloudformation Open Coverage Roadmap.

Relates #208.
Closes #222.
Closes #218.
Closes #242.
Closes #219.

dependabot bot and others added 3 commits October 14, 2021 09:11
Bumps [github.com/hashicorp/terraform-plugin-framework](https://github.com/hashicorp/terraform-plugin-framework) from 0.4.1 to 0.4.2.
- [Release notes](https://github.com/hashicorp/terraform-plugin-framework/releases)
- [Changelog](https://github.com/hashicorp/terraform-plugin-framework/blob/main/CHANGELOG.md)
- [Commits](hashicorp/terraform-plugin-framework@v0.4.1...v0.4.2)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-plugin-framework
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
@ewbankkit
Copy link
Contributor Author

ewbankkit commented Oct 14, 2021

The problem is that now arn (a Computed-only attribute) shows a continual diff: hashicorp/terraform-plugin-framework#189.

  # awscc_logs_log_group.test will be updated in-place
  ~ resource "awscc_logs_log_group" "test" {
      ~ arn               = "arn:aws:logs:us-east-1:187416307283:log-group:ewbankkit-test:*" -> (known after apply)
      ~ id                = "ewbankkit-test" -> (known after apply)
      ~ retention_in_days = 30 -> 60
        # (1 unchanged attribute hidden)
    }

and terraform apply will fail:

% TF_LOG=WARN make testacc PKG_NAME=internal/aws/logs TESTARGS='-run=TestAccAWSLogsLogGroup_'
TF_ACC=1 go test ./internal/aws/logs -v -count 1 -parallel 20 -run=TestAccAWSLogsLogGroup_ -timeout 180m
=== RUN   TestAccAWSLogsLogGroup_basic
=== PAUSE TestAccAWSLogsLogGroup_basic
=== RUN   TestAccAWSLogsLogGroup_disappears
=== PAUSE TestAccAWSLogsLogGroup_disappears
=== RUN   TestAccAWSLogsLogGroup_update
=== PAUSE TestAccAWSLogsLogGroup_update
=== CONT  TestAccAWSLogsLogGroup_basic
=== CONT  TestAccAWSLogsLogGroup_update
=== CONT  TestAccAWSLogsLogGroup_disappears
2021/10/14 11:15:52 [WARN] Got error running Terraform: exit status 1

Error: AWS SDK Go Service Operation Unsuccessful

  with awscc_logs_log_group.test,
  on terraform_plugin_test.tf line 2, in resource "awscc_logs_log_group" "test":
   2: resource "awscc_logs_log_group" "test" {

Calling Cloud Control API service UpdateResource operation returned:
operation error CloudControl: UpdateResource, https response error
StatusCode: 400, RequestID: f1b24f45-bfd2-42e6-9f41-85a10c169110, api error
ValidationException: Invalid patch update: readOnlyProperties
[/properties/Arn] cannot be updated
=== CONT  TestAccAWSLogsLogGroup_update
    testcases.go:30: Step 3/3 error: Error running apply: exit status 1
        
        Error: AWS SDK Go Service Operation Unsuccessful
        
          with awscc_logs_log_group.test,
          on terraform_plugin_test.tf line 2, in resource "awscc_logs_log_group" "test":
           2: resource "awscc_logs_log_group" "test" {
        
        Calling Cloud Control API service UpdateResource operation returned:
        operation error CloudControl: UpdateResource, https response error
        StatusCode: 400, RequestID: f1b24f45-bfd2-42e6-9f41-85a10c169110, api error
        ValidationException: Invalid patch update: readOnlyProperties
        [/properties/Arn] cannot be updated
--- PASS: TestAccAWSLogsLogGroup_disappears (18.25s)
--- PASS: TestAccAWSLogsLogGroup_basic (20.11s)
--- FAIL: TestAccAWSLogsLogGroup_update (23.82s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-awscc/internal/aws/logs	24.831s
FAIL
make: *** [testacc] Error 1
2021-10-14T12:10:59.975-0400 [DEBUG] provider.terraform-provider-awscc: Cloud Control API PatchDocument: value=[{"op":"replace","path":"/RetentionInDays","value":60},{"op":"remove","path":"/Arn"},{"op":"remove","path":"/ID"}] timestamp=2021-10-14T12:10:59.975-0400

@bflad
Copy link
Contributor

bflad commented Oct 14, 2021

Plan modifiers like hashicorp/terraform-plugin-framework#180 should help resolve Computed attributes that are continually showing a difference, when another attribute is changing. In particular, hashicorp/terraform-plugin-framework#180 (comment) should be fairly close to what should be applied to readOnlyProperties to enhance the plan output. It should also theoretically prevent this error:

ValidationException: Invalid patch update: readOnlyProperties
[/properties/Arn] cannot be updated

Since there will be no difference in values for those attributes.

However, even without those, an additional safety measure the provider could do during Update is to strip out any readOnlyProperties from the update API request, since it seems they will always generate this type of API error. That might obfuscate certain other problems though, unless there's some warning logs as well.

@ewbankkit
Copy link
Contributor Author

Relates:

This was referenced Dec 1, 2021
@ewbankkit
Copy link
Contributor Author

Superseded by #306.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants