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

aws_elasticache_replication_group: Implement noop MigrateState for v0..v1 #8887

Merged
merged 4 commits into from
Jun 11, 2019

Conversation

akatrevorjay
Copy link
Contributor

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" comments, they generate extra noise for pull request followers and do not help prioritize the request

Fixes #8828

Release note for CHANGELOG:

aws_elasticache_replication_group will now migrate v0 resources to v1 in state.

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'
==> Checking that code complies with gofmt requirements...
gofmt needs running on the following files:
./aws/config.go
./aws/data_source_aws_cloudformation_export_test.go
./aws/opsworks_layers.go
./aws/provider.go
./aws/resource_aws_api_gateway_integration.go
./aws/resource_aws_appmesh_virtual_node_migrate_test.go
./aws/resource_aws_cloudfront_origin_access_identity.go
./aws/resource_aws_codedeploy_deployment_group_test.go
./aws/resource_aws_db_instance.go
./aws/resource_aws_db_security_group.go
./aws/resource_aws_dms_replication_instance.go
./aws/resource_aws_docdb_cluster_instance.go
./aws/resource_aws_docdb_cluster_parameter_group.go
./aws/resource_aws_ec2_fleet.go
./aws/resource_aws_emr_security_configuration.go
./aws/resource_aws_gamelift_fleet.go
./aws/resource_aws_glue_security_configuration.go
./aws/resource_aws_guardduty_detector.go
./aws/resource_aws_instance.go
./aws/resource_aws_instance_migrate_test.go
./aws/resource_aws_kinesis_analytics_application.go
./aws/resource_aws_lb_listener.go
./aws/resource_aws_lb_listener_rule.go
./aws/resource_aws_licensemanager_license_configuration.go
./aws/resource_aws_neptune_cluster_instance.go
./aws/resource_aws_neptune_cluster_parameter_group.go
./aws/resource_aws_organizations_test.go
./aws/resource_aws_ram_resource_share.go
./aws/resource_aws_rds_cluster_instance.go
./aws/resource_aws_rds_cluster_parameter_group.go
./aws/resource_aws_redshift_cluster.go
./aws/resource_aws_route53_record.go
./aws/resource_aws_s3_bucket.go
./aws/resource_aws_s3_bucket_inventory.go
./aws/resource_aws_s3_bucket_notification.go
./aws/resource_aws_security_group_migrate_test.go
./aws/resource_aws_sns_topic.go
./aws/resource_aws_spot_fleet_request.go
./aws/resource_aws_spot_instance_request.go
./aws/resource_aws_ssm_maintenance_window.go
./aws/resource_aws_ssm_patch_baseline.go
./aws/resource_aws_swf_domain.go
./aws/resource_aws_vpc.go
./aws/validators_test.go
./aws/resource_aws_acmpca_certificate_authority.go
You can use the command: `make fmt` to reformat code.
make: *** [GNUmakefile:28: fmtcheck] Error 1
...

* upstream/master: (39 commits)
  Update CHANGELOG for hashicorp#8850
  tests/provider: Add tfproviderlint and enable S001-S005 checks
  service/kafka: Changes for General Availability Release
  chore(deps): update module hashicorp/terraform to v0.12.1
  deps: github.com/golangci/golangci-lint/cmd/golangci-lint@de1d1ad903cd
  Update CHANGELOG.md
  Update CHANGELOG for hashicorp#6322
  Retry timeout error for acmpca cert authority
  Add nil check for S3 bucket metric filter
  Update cloudwatch_event_target.html.markdown
  Update module aws/aws-sdk-go to v1.19.42
  Add a nil check for reading spot options
  Update waf_sql_injection_match_set.html.markdown
  Document the aws_ssm_activation "id" attribute
  aws_subnet: Increase timeout for delete to 20 mins
  Secure basic CloudTrail example
  docs/resource/aws_route53_record: Add NS and SOA Record Management example
  Update default example to use json instead of form
  tests/service/waf: Add PreCheck for service availability
  tests/service/transfer: Add PreCheck for service availability
  ...
@ghost ghost added size/XS Managed by automation to categorize the size of a PR. service/elasticache Issues and PRs that pertain to the elasticache service. labels Jun 6, 2019
@akatrevorjay
Copy link
Contributor Author

akatrevorjay commented Jun 6, 2019

Hey so, I /think/ that this is fine as a no-op (from TypeSet to TypeList), but please let me know if it's not and I'll update it.

@bflad bflad added the bug Addresses a defect in current functionality. label Jun 6, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @akatrevorjay 👋 Thanks so much for reporting the original issue and submitting this pull request! This is definitely something worth fixing up in the resource. Other than simplifying this a little bit, this seems like the right implementation here!

@@ -223,6 +225,7 @@ func resourceAwsElasticacheReplicationGroup() *schema.Resource {
},
},
SchemaVersion: 1,
MigrateState: resourceAwsElasticacheReplicationGroupMigrateState,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an exceptional case and we want to perform the simplest possible upgrade for compatibility, can you please inline this with the following comments?

Suggested change
MigrateState: resourceAwsElasticacheReplicationGroupMigrateState,
// SchemaVersion: 1 did not include any state changes via MigrateState.
// Perform a no-operation state upgrade for Terraform 0.12 compatibility.
// Future state migrations should be performed with StateUpgraders.
MigrateState: func(v int, inst *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) {
return inst, nil
},

I verified this successfully with a Terraform AWS Provider 1.13.0 aws_elasticache_replication_group resource on Terraform 0.12.1. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll swap over. I do find the replacement more error prone, but either way is fine by me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @akatrevorjay, the passthrough implementation is not more error prone -- MigrateState and dealing with flatmap state migrations in of the Terraform v0.12's Provider SDK has been superseded with JSON state migrations via StateUpgraders. In this case, we do not need to worry about doing anything other than passing through the existing InstanceState to bypass the Terraform runtime error, which matches the Terraform v0.11 Provider SDK in this situation where MigrateState was not implemented alongside a SchemaVersion update. We'll be removing the upstream runtime error in the next version of Terraform v0.12 (hashicorp/terraform#21625) to match the old Terraform v0.11 behavior.

Copy link
Contributor Author

@akatrevorjay akatrevorjay Jun 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha! I didn't see any mention of StateUpgraders in the docs at the time of writing this, I'm guessing I must have missed it! Thanks so much for the explanation!

@bflad bflad added this to the v2.15.0 milestone Jun 10, 2019
@bflad bflad merged commit 9f7859d into hashicorp:master Jun 11, 2019
bflad added a commit that referenced this pull request Jun 11, 2019
@ghost
Copy link

ghost commented Nov 3, 2019

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/elasticache Issues and PRs that pertain to the elasticache service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_elasticache_replication_group: Error: cannot upgrade state, missing MigrateState function
2 participants