@@ -86,6 +86,14 @@ func ResourceApikeysKey() *schema.Resource {
8686 Elem : ApikeysKeyRestrictionsSchema (),
8787 },
8888
89+ "service_account_email" : {
90+ Type : schema .TypeString ,
91+ Optional : true ,
92+ ForceNew : true ,
93+ DiffSuppressFunc : tpgresource .CompareSelfLinkOrResourceName ,
94+ Description : "The email of the service account the key is bound to. If this field is specified, the key is a service account bound key and auth enabled. See [Documentation](https://cloud.devsite.corp.google.com/docs/authentication/api-keys?#api-keys-bound-sa) for more details." ,
95+ },
96+
8997 "key_string" : {
9098 Type : schema .TypeString ,
9199 Computed : true ,
@@ -244,10 +252,11 @@ func resourceApikeysKeyCreate(d *schema.ResourceData, meta interface{}) error {
244252 }
245253
246254 obj := & apikeys.Key {
247- Name : dcl .String (d .Get ("name" ).(string )),
248- DisplayName : dcl .String (d .Get ("display_name" ).(string )),
249- Project : dcl .String (project ),
250- Restrictions : expandApikeysKeyRestrictions (d .Get ("restrictions" )),
255+ Name : dcl .String (d .Get ("name" ).(string )),
256+ DisplayName : dcl .String (d .Get ("display_name" ).(string )),
257+ Project : dcl .String (project ),
258+ Restrictions : expandApikeysKeyRestrictions (d .Get ("restrictions" )),
259+ ServiceAccountEmail : dcl .String (d .Get ("service_account_email" ).(string )),
251260 }
252261
253262 id , err := obj .ID ()
@@ -295,10 +304,11 @@ func resourceApikeysKeyRead(d *schema.ResourceData, meta interface{}) error {
295304 }
296305
297306 obj := & apikeys.Key {
298- Name : dcl .String (d .Get ("name" ).(string )),
299- DisplayName : dcl .String (d .Get ("display_name" ).(string )),
300- Project : dcl .String (project ),
301- Restrictions : expandApikeysKeyRestrictions (d .Get ("restrictions" )),
307+ Name : dcl .String (d .Get ("name" ).(string )),
308+ DisplayName : dcl .String (d .Get ("display_name" ).(string )),
309+ Project : dcl .String (project ),
310+ Restrictions : expandApikeysKeyRestrictions (d .Get ("restrictions" )),
311+ ServiceAccountEmail : dcl .String (d .Get ("service_account_email" ).(string )),
302312 }
303313
304314 userAgent , err := tpgresource .GenerateUserAgentString (d , config .UserAgent )
@@ -335,6 +345,9 @@ func resourceApikeysKeyRead(d *schema.ResourceData, meta interface{}) error {
335345 if err = d .Set ("restrictions" , flattenApikeysKeyRestrictions (res .Restrictions )); err != nil {
336346 return fmt .Errorf ("error setting restrictions in state: %s" , err )
337347 }
348+ if err = d .Set ("service_account_email" , res .ServiceAccountEmail ); err != nil {
349+ return fmt .Errorf ("error setting service_account_email in state: %s" , err )
350+ }
338351 if err = d .Set ("key_string" , res .KeyString ); err != nil {
339352 return fmt .Errorf ("error setting key_string in state: %s" , err )
340353 }
@@ -352,10 +365,11 @@ func resourceApikeysKeyUpdate(d *schema.ResourceData, meta interface{}) error {
352365 }
353366
354367 obj := & apikeys.Key {
355- Name : dcl .String (d .Get ("name" ).(string )),
356- DisplayName : dcl .String (d .Get ("display_name" ).(string )),
357- Project : dcl .String (project ),
358- Restrictions : expandApikeysKeyRestrictions (d .Get ("restrictions" )),
368+ Name : dcl .String (d .Get ("name" ).(string )),
369+ DisplayName : dcl .String (d .Get ("display_name" ).(string )),
370+ Project : dcl .String (project ),
371+ Restrictions : expandApikeysKeyRestrictions (d .Get ("restrictions" )),
372+ ServiceAccountEmail : dcl .String (d .Get ("service_account_email" ).(string )),
359373 }
360374 directive := tpgdclresource .UpdateDirective
361375 userAgent , err := tpgresource .GenerateUserAgentString (d , config .UserAgent )
@@ -398,10 +412,11 @@ func resourceApikeysKeyDelete(d *schema.ResourceData, meta interface{}) error {
398412 }
399413
400414 obj := & apikeys.Key {
401- Name : dcl .String (d .Get ("name" ).(string )),
402- DisplayName : dcl .String (d .Get ("display_name" ).(string )),
403- Project : dcl .String (project ),
404- Restrictions : expandApikeysKeyRestrictions (d .Get ("restrictions" )),
415+ Name : dcl .String (d .Get ("name" ).(string )),
416+ DisplayName : dcl .String (d .Get ("display_name" ).(string )),
417+ Project : dcl .String (project ),
418+ Restrictions : expandApikeysKeyRestrictions (d .Get ("restrictions" )),
419+ ServiceAccountEmail : dcl .String (d .Get ("service_account_email" ).(string )),
405420 }
406421
407422 log .Printf ("[DEBUG] Deleting Key %q" , d .Id ())
0 commit comments