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

Made kms crypto key import set id correctly #6305

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions mmv1/templates/terraform/custom_import/kms_crypto_key.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@
return nil, fmt.Errorf("Error setting skip_initial_version_creation: %s", err)
}

id, err := replaceVars(d, config, "<%= id_format(object) -%>")
if err != nil {
return nil, fmt.Errorf("Error constructing id: %s", err)
}
d.SetId(id)

return []*schema.ResourceData{d}, nil
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ func TestAccKmsCryptoKey_basic(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
// Test importing with a short id
{
ResourceName: "google_kms_crypto_key.crypto_key",
ImportState: true,
ImportStateId: fmt.Sprintf("%s/%s/%s/%s", projectId, location, keyRingName, cryptoKeyName),
ImportStateVerify: true,
},
// Use a separate TestStep rather than a CheckDestroy because we need the project to still exist.
{
Config: testGoogleKmsCryptoKey_removed(projectId, projectOrg, projectBillingAccount, keyRingName),
Expand Down