@@ -93,6 +93,14 @@ The first rotation will take place after the specified period. The rotation peri
9393the format of a decimal number with up to 9 fractional digits, followed by the
9494letter 's' (seconds). It must be greater than a day (ie, 86400).` ,
9595 },
96+ "skip_initial_version_creation" : {
97+ Type : schema .TypeBool ,
98+ Optional : true ,
99+ ForceNew : true ,
100+ Description : `If set to true, the request will create a CryptoKey without any CryptoKeyVersions.
101+ You must use the 'google_kms_key_ring_import_job' resource to import the CryptoKeyVersion.` ,
102+ Default : false ,
103+ },
96104 "version_template" : {
97105 Type : schema .TypeList ,
98106 Computed : true ,
@@ -164,7 +172,7 @@ func resourceKMSCryptoKeyCreate(d *schema.ResourceData, meta interface{}) error
164172 return err
165173 }
166174
167- url , err := replaceVars (d , config , "{{KMSBasePath}}{{key_ring}}/cryptoKeys?cryptoKeyId={{name}}" )
175+ url , err := replaceVars (d , config , "{{KMSBasePath}}{{key_ring}}/cryptoKeys?cryptoKeyId={{name}}&skipInitialVersionCreation={{skip_initial_version_creation}} " )
168176 if err != nil {
169177 return err
170178 }
@@ -348,7 +356,7 @@ func resourceKMSCryptoKeyDelete(d *schema.ResourceData, meta interface{}) error
348356
349357 log .Printf (`
350358[WARNING] KMS CryptoKey resources cannot be deleted from GCP. The CryptoKey %s will be removed from Terraform state,
351- and all its CryptoKeyVersions will be destroyed, but it will still be present on the server .` , cryptoKeyId .cryptoKeyId ())
359+ and all its CryptoKeyVersions will be destroyed, but it will still be present in the project .` , cryptoKeyId .cryptoKeyId ())
352360
353361 // Delete all versions of the key
354362 if err := clearCryptoKeyVersions (cryptoKeyId , userAgent , config ); err != nil {
@@ -384,6 +392,10 @@ func resourceKMSCryptoKeyImport(d *schema.ResourceData, meta interface{}) ([]*sc
384392 return nil , fmt .Errorf ("Error setting name: %s" , err )
385393 }
386394
395+ if err := d .Set ("skip_initial_version_creation" , false ); err != nil {
396+ return nil , fmt .Errorf ("Error setting skip_initial_version_creation: %s" , err )
397+ }
398+
387399 return []* schema.ResourceData {d }, nil
388400}
389401
0 commit comments