@@ -80,6 +80,66 @@ data "google_compute_network" "lustre-network" {
8080` , context )
8181}
8282
83+ func TestAccLustreInstance_withKmsKey (t * testing.T ) {
84+ t .Parallel ()
85+
86+ context := map [string ]interface {}{
87+ "network_name" : acctest .BootstrapSharedTestNetwork (t , "default-vpc" ),
88+ "random_suffix" : acctest .RandString (t , 10 ),
89+ "kms" : acctest .BootstrapKMSKeyInLocation (t , "us-central1" ).CryptoKey .Name ,
90+ }
91+
92+ acctest .VcrTest (t , resource.TestCase {
93+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
94+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
95+ Steps : []resource.TestStep {
96+ {
97+ Config : testAccLustreInstance_withKmsKey (context ),
98+ },
99+ {
100+ ResourceName : "google_lustre_instance.instance" ,
101+ ImportState : true ,
102+ ImportStateVerify : true ,
103+ ImportStateVerifyIgnore : []string {"instance_id" , "labels" , "gke_support_enabled" , "location" , "terraform_labels" },
104+ },
105+ },
106+ })
107+ }
108+
109+ func testAccLustreInstance_withKmsKey (context map [string ]interface {}) string {
110+ return acctest .Nprintf (`
111+ resource "google_lustre_instance" "instance" {
112+ instance_id = "tf-test-my-instance%{random_suffix}"
113+ location = "us-central1-a"
114+ filesystem = "testfs"
115+ network = data.google_compute_network.lustre-network.id
116+ gke_support_enabled = false
117+ capacity_gib = 18000
118+ per_unit_storage_throughput = 1000
119+ kms_key = "%{kms}"
120+
121+ timeouts {
122+ create = "120m"
123+ }
124+
125+ depends_on = [google_kms_crypto_key_iam_member.lustre_sa_encrypter_decrypter]
126+ }
127+
128+ resource "google_kms_crypto_key_iam_member" "lustre_sa_encrypter_decrypter" {
129+ crypto_key_id = "%{kms}"
130+ role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
131+ member = "serviceAccount:service-${data.google_project.project.number}@gcp-sa-lustre.iam.gserviceaccount.com"
132+ }
133+
134+ data "google_compute_network" "lustre-network" {
135+ name = "%{network_name}"
136+ }
137+
138+ data "google_project" "project" {
139+ }
140+ ` , context )
141+ }
142+
83143func testAccLustreInstance_update (context map [string ]interface {}) string {
84144 return acctest .Nprintf (`
85145resource "google_lustre_instance" "instance" {
0 commit comments