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

r/aws_msk_cluster - new storage_info arg #24767

Merged
merged 22 commits into from
May 18, 2022

Conversation

GlennChia
Copy link
Collaborator

@GlennChia GlennChia commented May 13, 2022

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

Closes #24464

Output from acceptance testing:

$  make testacc TESTARGS='-run=TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolume\|TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo\|TestAccKafkaCluster_BrokerNodeGroupInfo_ebsVolumeSize' PKG=kafka
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/kafka/... -v -count 1 -parallel 20  -run=TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolume\|TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo\|TestAccKafkaCluster_BrokerNodeGroupInfo_ebsVolumeSize -timeout 180m
=== RUN   TestAccKafkaCluster_BrokerNodeGroupInfo_ebsVolumeSize
=== PAUSE TestAccKafkaCluster_BrokerNodeGroupInfo_ebsVolumeSize
=== RUN   TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo
=== PAUSE TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo
=== RUN   TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo
=== PAUSE TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo
=== CONT  TestAccKafkaCluster_BrokerNodeGroupInfo_ebsVolumeSize
=== CONT  TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo
=== CONT  TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo (2134.04s)
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_ebsVolumeSize (2138.68s)
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo (5049.87s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/kafka      5049.916s
...

@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. service/kafka Issues and PRs that pertain to the kafka service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. needs-triage Waiting for first response or review from a maintainer. size/XL Managed by automation to categorize the size of a PR. labels May 13, 2022
@GlennChia GlennChia force-pushed the f-aws_msk_cluster-storage-info-arg branch from c0068d0 to daedf01 Compare May 13, 2022 05:18
@GlennChia GlennChia marked this pull request as ready for review May 13, 2022 06:51
@justinretzolk justinretzolk added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels May 13, 2022
@AdamTylerLynch
Copy link
Collaborator

make testacc TESTS=TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo PKG=kafka 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/kafka/... -v -count 1 -parallel 20 -run='TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo'  -timeout 180m
=== RUN   TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo
=== PAUSE TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo
=== CONT  TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo (1591.54s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/kafka	1596.532s
make testacc TESTS=TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo PKG=kafka 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/kafka/... -v -count 1 -parallel 20 -run='TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo'  -timeout 180m
=== RUN   TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo
=== PAUSE TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo
=== CONT  TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo (4886.87s)
PASS

@AdamTylerLynch
Copy link
Collaborator

LGTM 🚀

@gdavison gdavison self-assigned this May 16, 2022
Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @GlennChia. It's looking good. I have a few suggestions for updates

website/docs/r/msk_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/r/msk_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/r/msk_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/r/msk_cluster.html.markdown Show resolved Hide resolved
CheckDestroy: testAccCheckClusterDestroy,
Steps: []resource.TestStep{
{
Config: testAccClusterBrokerNodeGroupInfoStorageInfoConfig2(rName, original_volume_size, "kafka.m5.4xlarge"),
Copy link
Contributor

Choose a reason for hiding this comment

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

testAccClusterBrokerNodeGroupInfoStorageInfoConfig1, testAccClusterBrokerNodeGroupInfoStorageInfoConfig2, and testAccClusterBrokerNodeGroupInfoStorageInfoConfig3 should have more descriptive names identifying which parameters are set

Copy link
Collaborator Author

@GlennChia GlennChia May 17, 2022

Choose a reason for hiding this comment

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

Resolved in 4cc2c44

Comment on lines 228 to 235
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"current_version",
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

This import isn't needed, since other tests cover importing a configuration using the deprecated broker_node_group_info. ebs_volume_size

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved in 3158ad8

Comment on lines 247 to 254
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"current_version",
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

This import isn't needed, since other tests cover importing a configuration using broker_node_group_info.storage_info.ebs_storage_info.volume_size

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved in 3158ad8

}
}

if d.HasChange("broker_node_group_info.0.storage_info") {
Copy link
Contributor

Choose a reason for hiding this comment

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

The way these conditionals are ordered could lead to two UpdateBrokerStorageWithContext requests to the API. The top-level conditional could instead be if d.HasChanges("broker_node_group_info.0.ebs_volume_size", "broker_node_group_info.0.storage_info"). From there you could build the kafka.UpdateBrokerStorageInput based on what parameters are set

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved in 917a661

Comment on lines 703 to 723
input := &kafka.UpdateBrokerStorageInput{
ClusterArn: aws.String(d.Id()),
CurrentVersion: aws.String(d.Get("current_version").(string)),
}
if v, ok := d.GetOk("broker_node_group_info.0.storage_info.0.ebs_storage_info.0.provisioned_throughput"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
input.TargetBrokerEBSVolumeInfo = []*kafka.BrokerEBSVolumeInfo{
{
KafkaBrokerNodeId: aws.String("All"),
ProvisionedThroughput: expandProvisionedThroughput(v.([]interface{})[0].(map[string]interface{})),
VolumeSizeGB: aws.Int64(int64(d.Get("broker_node_group_info.0.storage_info.0.ebs_storage_info.0.volume_size").(int))),
},
}

} else {
input.TargetBrokerEBSVolumeInfo = []*kafka.BrokerEBSVolumeInfo{
{
KafkaBrokerNodeId: aws.String("All"),
VolumeSizeGB: aws.Int64(int64(d.Get("broker_node_group_info.0.storage_info.0.ebs_storage_info.0.volume_size").(int))),
},
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be simplified to something like the following

Suggested change
input := &kafka.UpdateBrokerStorageInput{
ClusterArn: aws.String(d.Id()),
CurrentVersion: aws.String(d.Get("current_version").(string)),
}
if v, ok := d.GetOk("broker_node_group_info.0.storage_info.0.ebs_storage_info.0.provisioned_throughput"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
input.TargetBrokerEBSVolumeInfo = []*kafka.BrokerEBSVolumeInfo{
{
KafkaBrokerNodeId: aws.String("All"),
ProvisionedThroughput: expandProvisionedThroughput(v.([]interface{})[0].(map[string]interface{})),
VolumeSizeGB: aws.Int64(int64(d.Get("broker_node_group_info.0.storage_info.0.ebs_storage_info.0.volume_size").(int))),
},
}
} else {
input.TargetBrokerEBSVolumeInfo = []*kafka.BrokerEBSVolumeInfo{
{
KafkaBrokerNodeId: aws.String("All"),
VolumeSizeGB: aws.Int64(int64(d.Get("broker_node_group_info.0.storage_info.0.ebs_storage_info.0.volume_size").(int))),
},
}
}
input := &kafka.UpdateBrokerStorageInput{
ClusterArn: aws.String(d.Id()),
CurrentVersion: aws.String(d.Get("current_version").(string)),
}
ebsVolumeInfo := &kafka.BrokerEBSVolumeInfo{
KafkaBrokerNodeId: aws.String("All"),
VolumeSizeGB: aws.Int64(int64(d.Get("broker_node_group_info.0.storage_info.0.ebs_storage_info.0.volume_size").(int))),
}
if v, ok := d.GetOk("broker_node_group_info.0.storage_info.0.ebs_storage_info.0.provisioned_throughput"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil {
ebsVolumeInfo.ProvisionedThroughput: expandProvisionedThroughput(v.([]interface{})[0].(map[string]interface{}))
}
input.TargetBrokerEBSVolumeInfo = []*kafka.BrokerEBSVolumeInfo{ebsVolumeInfo}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved in 9766872

internal/service/kafka/cluster_test.go Show resolved Hide resolved
@GlennChia GlennChia force-pushed the f-aws_msk_cluster-storage-info-arg branch from 353d2b0 to 9766872 Compare May 17, 2022 04:50
@GlennChia
Copy link
Collaborator Author

GlennChia commented May 17, 2022

Thanks for the review @gdavison. In addition, I also removed the import test in 6e7218a after upgrading the instance type. This is because TestAccKafkaCluster_BrokerNodeGroupInfo_instanceType also does that import check. Re-ran the test cases (just for the BrokerNodeGroupInfo ones) gives the following

$ make testacc TESTARGS='-run=TestAccKafkaCluster_BrokerNodeGroupInfo' PKG=kafka
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/kafka/... -v -count 1 -parallel 20  -run=TestAccKafkaCluster_BrokerNodeGroupInfo -timeout 180m
=== RUN   TestAccKafkaCluster_BrokerNodeGroupInfo_ebsVolumeSize
=== PAUSE TestAccKafkaCluster_BrokerNodeGroupInfo_ebsVolumeSize
=== RUN   TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo
=== PAUSE TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo
=== RUN   TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo
=== PAUSE TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo
=== RUN   TestAccKafkaCluster_BrokerNodeGroupInfo_instanceType
=== PAUSE TestAccKafkaCluster_BrokerNodeGroupInfo_instanceType
=== RUN   TestAccKafkaCluster_BrokerNodeGroupInfo_publicAccessSaslIam
=== PAUSE TestAccKafkaCluster_BrokerNodeGroupInfo_publicAccessSaslIam
=== CONT  TestAccKafkaCluster_BrokerNodeGroupInfo_ebsVolumeSize
=== CONT  TestAccKafkaCluster_BrokerNodeGroupInfo_instanceType
=== CONT  TestAccKafkaCluster_BrokerNodeGroupInfo_publicAccessSaslIam
=== CONT  TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo
=== CONT  TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo (2226.55s)
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_ebsVolumeSize (2230.19s)
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo (4659.47s)
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_publicAccessSaslIam (6049.81s)
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_instanceType (6664.00s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/kafka      6664.050s

Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

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

Looks good, @GlennChia! 🚀

--- PASS: TestAccKafkaCluster_enhancedMonitoring (1517.86s)
--- PASS: TestAccKafkaCluster_EncryptionInfo_encryptionAtRestKMSKeyARN (1522.11s)
--- PASS: TestAccKafkaCluster_EncryptionInfoEncryptionInTransit_inCluster (1523.78s)
--- PASS: TestAccKafkaCluster_EncryptionInfoEncryptionInTransit_clientBroker (1524.23s)
--- PASS: TestAccKafkaCluster_tags (1525.65s)
--- PASS: TestAccKafkaClusterDataSource_basic (1581.76s)
--- PASS: TestAccKafkaCluster_ClientAuthenticationTLS_certificateAuthorityARNs (1608.87s)
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_storageInfo (1713.09s)
--- PASS: TestAccKafkaCluster_loggingInfo (1758.40s)
--- PASS: TestAccKafkaCluster_openMonitoring (1786.87s)
--- PASS: TestAccKafkaCluster_Info_revision (1947.46s)
--- PASS: TestAccKafkaCluster_numberOfBrokerNodes (2520.16s)
--- PASS: TestAccKafkaCluster_kafkaVersionDowngrade (2993.91s)
--- PASS: TestAccKafkaCluster_basic (1478.53s)
--- PASS: TestAccKafkaCluster_ClientAuthenticationSASL_scram (3024.41s)
--- PASS: TestAccKafkaCluster_ClientAuthenticationSASL_iam (3170.76s)
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_ebsVolumeSize (1765.18s)
--- PASS: TestAccKafkaCluster_ClientAuthenticationTLS_initiallyNoAuthentication (3449.99s)
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_modifyEbsVolumeSizeToStorageInfo (4556.84s)
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_publicAccessSaslIam (5109.58s)
--- PASS: TestAccKafkaCluster_kafkaVersionUpgradeWithInfo (5676.89s)
--- PASS: TestAccKafkaCluster_BrokerNodeGroupInfo_instanceType (6346.58s)
--- PASS: TestAccKafkaCluster_kafkaVersionUpgrade (5588.27s)

@gdavison gdavison merged commit 2fbf08c into hashicorp:main May 18, 2022
@github-actions github-actions bot added this to the v4.15.0 milestone May 18, 2022
@GlennChia GlennChia deleted the f-aws_msk_cluster-storage-info-arg branch May 19, 2022 06:57
@github-actions
Copy link

This functionality has been released in v4.15.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 26, 2022
@justinretzolk justinretzolk added the partner Contribution from a partner. label May 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. partner Contribution from a partner. service/kafka Issues and PRs that pertain to the kafka service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for provisioned throughput in aws_msk_cluster
4 participants