Skip to content

Commit afc703b

Browse files
Add skip_initial_version_creation to kms crypto key (#3907) (#2645)
Signed-off-by: Modular Magician <[email protected]>
1 parent d2c3941 commit afc703b

15 files changed

+51
-25
lines changed

.changelog/3907.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
kms: added `skip_initial_version_creation` to `google_kms_crypto_key`
3+
```

google-beta/resource_app_engine_service_split_traffic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ func resourceAppEngineServiceSplitTrafficUpdate(d *schema.ResourceData, meta int
284284

285285
func resourceAppEngineServiceSplitTrafficDelete(d *schema.ResourceData, meta interface{}) error {
286286
log.Printf("[WARNING] AppEngine ServiceSplitTraffic resources"+
287-
" cannot be deleted from GCP. The resource %s will be removed from Terraform"+
288-
" state, but will still be present on the server.", d.Id())
287+
" cannot be deleted from Google Cloud. The resource %s will be removed from Terraform"+
288+
" state, but will still be present on Google Cloud.", d.Id())
289289
d.SetId("")
290290

291291
return nil

google-beta/resource_big_query_job.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,8 +1032,8 @@ func resourceBigQueryJobRead(d *schema.ResourceData, meta interface{}) error {
10321032

10331033
func resourceBigQueryJobDelete(d *schema.ResourceData, meta interface{}) error {
10341034
log.Printf("[WARNING] BigQuery Job resources"+
1035-
" cannot be deleted from GCP. The resource %s will be removed from Terraform"+
1036-
" state, but will still be present on the server.", d.Id())
1035+
" cannot be deleted from Google Cloud. The resource %s will be removed from Terraform"+
1036+
" state, but will still be present on Google Cloud.", d.Id())
10371037
d.SetId("")
10381038

10391039
return nil

google-beta/resource_compute_network_peering_routes_config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ func resourceComputeNetworkPeeringRoutesConfigUpdate(d *schema.ResourceData, met
296296

297297
func resourceComputeNetworkPeeringRoutesConfigDelete(d *schema.ResourceData, meta interface{}) error {
298298
log.Printf("[WARNING] Compute NetworkPeeringRoutesConfig resources"+
299-
" cannot be deleted from GCP. The resource %s will be removed from Terraform"+
300-
" state, but will still be present on the server.", d.Id())
299+
" cannot be deleted from Google Cloud. The resource %s will be removed from Terraform"+
300+
" state, but will still be present on Google Cloud.", d.Id())
301301
d.SetId("")
302302

303303
return nil

google-beta/resource_firebase_project.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ func resourceFirebaseProjectRead(d *schema.ResourceData, meta interface{}) error
159159

160160
func resourceFirebaseProjectDelete(d *schema.ResourceData, meta interface{}) error {
161161
log.Printf("[WARNING] Firebase Project resources"+
162-
" cannot be deleted from GCP. The resource %s will be removed from Terraform"+
163-
" state, but will still be present on the server.", d.Id())
162+
" cannot be deleted from Google Cloud. The resource %s will be removed from Terraform"+
163+
" state, but will still be present on Google Cloud.", d.Id())
164164
d.SetId("")
165165

166166
return nil

google-beta/resource_firebase_project_location.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ func resourceFirebaseProjectLocationRead(d *schema.ResourceData, meta interface{
172172

173173
func resourceFirebaseProjectLocationDelete(d *schema.ResourceData, meta interface{}) error {
174174
log.Printf("[WARNING] Firebase ProjectLocation resources"+
175-
" cannot be deleted from GCP. The resource %s will be removed from Terraform"+
176-
" state, but will still be present on the server.", d.Id())
175+
" cannot be deleted from Google Cloud. The resource %s will be removed from Terraform"+
176+
" state, but will still be present on Google Cloud.", d.Id())
177177
d.SetId("")
178178

179179
return nil

google-beta/resource_firebase_web_app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ func resourceFirebaseWebAppUpdate(d *schema.ResourceData, meta interface{}) erro
251251

252252
func resourceFirebaseWebAppDelete(d *schema.ResourceData, meta interface{}) error {
253253
log.Printf("[WARNING] Firebase WebApp resources"+
254-
" cannot be deleted from GCP. The resource %s will be removed from Terraform"+
255-
" state, but will still be present on the server.", d.Id())
254+
" cannot be deleted from Google Cloud. The resource %s will be removed from Terraform"+
255+
" state, but will still be present on Google Cloud.", d.Id())
256256
d.SetId("")
257257

258258
return nil

google-beta/resource_iap_brand.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ func resourceIapBrandRead(d *schema.ResourceData, meta interface{}) error {
249249

250250
func resourceIapBrandDelete(d *schema.ResourceData, meta interface{}) error {
251251
log.Printf("[WARNING] Iap Brand resources"+
252-
" cannot be deleted from GCP. The resource %s will be removed from Terraform"+
253-
" state, but will still be present on the server.", d.Id())
252+
" cannot be deleted from Google Cloud. The resource %s will be removed from Terraform"+
253+
" state, but will still be present on Google Cloud.", d.Id())
254254
d.SetId("")
255255

256256
return nil

google-beta/resource_kms_crypto_key.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ The first rotation will take place after the specified period. The rotation peri
9393
the format of a decimal number with up to 9 fractional digits, followed by the
9494
letter '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

google-beta/resource_kms_key_ring.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ func resourceKMSKeyRingRead(d *schema.ResourceData, meta interface{}) error {
183183

184184
func resourceKMSKeyRingDelete(d *schema.ResourceData, meta interface{}) error {
185185
log.Printf("[WARNING] KMS KeyRing resources"+
186-
" cannot be deleted from GCP. The resource %s will be removed from Terraform"+
187-
" state, but will still be present on the server.", d.Id())
186+
" cannot be deleted from Google Cloud. The resource %s will be removed from Terraform"+
187+
" state, but will still be present on Google Cloud.", d.Id())
188188
d.SetId("")
189189

190190
return nil

0 commit comments

Comments
 (0)