-
Notifications
You must be signed in to change notification settings - Fork 0
/
serviceAccount.ts
44 lines (40 loc) · 1.09 KB
/
serviceAccount.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Input, Config } from '@pulumi/pulumi'
import { Account } from '@pulumi/gcp/serviceaccount/account'
import { getAccount, GetAccountResult } from '@pulumi/gcp/serviceaccount/getAccount'
/* Pulumi Config */
let gcpConfig = new Config('gcp')
/**
* Create Account Struct
*/
export interface CreateAccountStruct {
name: string
description: Input<string>
accountId: Input<string>
displayName: Input<string>
}
/**
* Get Service Account
*
* @param id string
* @return GetAccountResult (@pulumi/gcp/serviceaccount/getAccount)
*/
export const GetAccount = (id: string): Promise<GetAccountResult> => {
return getAccount({
accountId: id,
project: gcpConfig.require('project')
})
}
/**
* Create Service Account
*
* @param struct CreateAccountStruct
* @return Account (@pulumi/gcp/serviceaccount/account)
*/
export const CreateAccount = (struct: CreateAccountStruct): Account => {
return new Account(struct.name, {
description: struct.description,
accountId: struct.accountId,
displayName: struct.displayName,
project: gcpConfig.require('project')
})
}