gcp.serviceaccount.Account
Explore with Pulumi AI
Allows management of a Google Cloud service account.
- API documentation
- How-to Guides
Warning: If you delete and recreate a service account, you must reapply any IAM roles that it had before.
Creation of service accounts is eventually consistent, and that can lead to errors when you try to apply ACLs to service accounts immediately after creation.
Example Usage
This snippet creates a service account in a project.
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const serviceAccount = new gcp.serviceaccount.Account("service_account", {
accountId: "service-account-id",
displayName: "Service Account",
});
import pulumi
import pulumi_gcp as gcp
service_account = gcp.serviceaccount.Account("service_account",
account_id="service-account-id",
display_name="Service Account")
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/serviceaccount"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := serviceaccount.NewAccount(ctx, "service_account", &serviceaccount.AccountArgs{
AccountId: pulumi.String("service-account-id"),
DisplayName: pulumi.String("Service Account"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var serviceAccount = new Gcp.ServiceAccount.Account("service_account", new()
{
AccountId = "service-account-id",
DisplayName = "Service Account",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.serviceaccount.Account;
import com.pulumi.gcp.serviceaccount.AccountArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var serviceAccount = new Account("serviceAccount", AccountArgs.builder()
.accountId("service-account-id")
.displayName("Service Account")
.build());
}
}
resources:
serviceAccount:
type: gcp:serviceaccount:Account
name: service_account
properties:
accountId: service-account-id
displayName: Service Account
Create Account Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Account(name: string, args?: AccountArgs, opts?: CustomResourceOptions);
@overload
def Account(resource_name: str,
args: Optional[AccountArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
def Account(resource_name: str,
opts: Optional[ResourceOptions] = None,
account_id: Optional[str] = None,
create_ignore_already_exists: Optional[bool] = None,
description: Optional[str] = None,
disabled: Optional[bool] = None,
display_name: Optional[str] = None,
project: Optional[str] = None)
func NewAccount(ctx *Context, name string, args *AccountArgs, opts ...ResourceOption) (*Account, error)
public Account(string name, AccountArgs? args = null, CustomResourceOptions? opts = null)
public Account(String name, AccountArgs args)
public Account(String name, AccountArgs args, CustomResourceOptions options)
type: gcp:serviceaccount:Account
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args AccountArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args AccountArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args AccountArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args AccountArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args AccountArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var accountResource = new Gcp.ServiceAccount.Account("accountResource", new()
{
AccountId = "string",
CreateIgnoreAlreadyExists = false,
Description = "string",
Disabled = false,
DisplayName = "string",
Project = "string",
});
example, err := serviceaccount.NewAccount(ctx, "accountResource", &serviceaccount.AccountArgs{
AccountId: pulumi.String("string"),
CreateIgnoreAlreadyExists: pulumi.Bool(false),
Description: pulumi.String("string"),
Disabled: pulumi.Bool(false),
DisplayName: pulumi.String("string"),
Project: pulumi.String("string"),
})
var accountResource = new Account("accountResource", AccountArgs.builder()
.accountId("string")
.createIgnoreAlreadyExists(false)
.description("string")
.disabled(false)
.displayName("string")
.project("string")
.build());
account_resource = gcp.serviceaccount.Account("accountResource",
account_id="string",
create_ignore_already_exists=False,
description="string",
disabled=False,
display_name="string",
project="string")
const accountResource = new gcp.serviceaccount.Account("accountResource", {
accountId: "string",
createIgnoreAlreadyExists: false,
description: "string",
disabled: false,
displayName: "string",
project: "string",
});
type: gcp:serviceaccount:Account
properties:
accountId: string
createIgnoreAlreadyExists: false
description: string
disabled: false
displayName: string
project: string
Account Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Account resource accepts the following input properties:
- Account
Id string - The account id that is used to generate the service
account email address and a stable unique id. It is unique within a project,
must be 6-30 characters long, and match the regular expression
a-z
to comply with RFC1035. Changing this forces a new service account to be created. - Create
Ignore boolAlready Exists - If set to true, skip service account creation if a service account with the same email already exists.
- Description string
- A text description of the service account. Must be less than or equal to 256 UTF-8 bytes.
- Disabled bool
- Whether a service account is disabled or not. Defaults to
false
. This field has no effect during creation. Must be set after creation to disable a service account. - Display
Name string - The display name for the service account. Can be updated without creating a new resource.
- Project string
- The ID of the project that the service account will be created in. Defaults to the provider project configuration.
- Account
Id string - The account id that is used to generate the service
account email address and a stable unique id. It is unique within a project,
must be 6-30 characters long, and match the regular expression
a-z
to comply with RFC1035. Changing this forces a new service account to be created. - Create
Ignore boolAlready Exists - If set to true, skip service account creation if a service account with the same email already exists.
- Description string
- A text description of the service account. Must be less than or equal to 256 UTF-8 bytes.
- Disabled bool
- Whether a service account is disabled or not. Defaults to
false
. This field has no effect during creation. Must be set after creation to disable a service account. - Display
Name string - The display name for the service account. Can be updated without creating a new resource.
- Project string
- The ID of the project that the service account will be created in. Defaults to the provider project configuration.
- account
Id String - The account id that is used to generate the service
account email address and a stable unique id. It is unique within a project,
must be 6-30 characters long, and match the regular expression
a-z
to comply with RFC1035. Changing this forces a new service account to be created. - create
Ignore BooleanAlready Exists - If set to true, skip service account creation if a service account with the same email already exists.
- description String
- A text description of the service account. Must be less than or equal to 256 UTF-8 bytes.
- disabled Boolean
- Whether a service account is disabled or not. Defaults to
false
. This field has no effect during creation. Must be set after creation to disable a service account. - display
Name String - The display name for the service account. Can be updated without creating a new resource.
- project String
- The ID of the project that the service account will be created in. Defaults to the provider project configuration.
- account
Id string - The account id that is used to generate the service
account email address and a stable unique id. It is unique within a project,
must be 6-30 characters long, and match the regular expression
a-z
to comply with RFC1035. Changing this forces a new service account to be created. - create
Ignore booleanAlready Exists - If set to true, skip service account creation if a service account with the same email already exists.
- description string
- A text description of the service account. Must be less than or equal to 256 UTF-8 bytes.
- disabled boolean
- Whether a service account is disabled or not. Defaults to
false
. This field has no effect during creation. Must be set after creation to disable a service account. - display
Name string - The display name for the service account. Can be updated without creating a new resource.
- project string
- The ID of the project that the service account will be created in. Defaults to the provider project configuration.
- account_
id str - The account id that is used to generate the service
account email address and a stable unique id. It is unique within a project,
must be 6-30 characters long, and match the regular expression
a-z
to comply with RFC1035. Changing this forces a new service account to be created. - create_
ignore_ boolalready_ exists - If set to true, skip service account creation if a service account with the same email already exists.
- description str
- A text description of the service account. Must be less than or equal to 256 UTF-8 bytes.
- disabled bool
- Whether a service account is disabled or not. Defaults to
false
. This field has no effect during creation. Must be set after creation to disable a service account. - display_
name str - The display name for the service account. Can be updated without creating a new resource.
- project str
- The ID of the project that the service account will be created in. Defaults to the provider project configuration.
- account
Id String - The account id that is used to generate the service
account email address and a stable unique id. It is unique within a project,
must be 6-30 characters long, and match the regular expression
a-z
to comply with RFC1035. Changing this forces a new service account to be created. - create
Ignore BooleanAlready Exists - If set to true, skip service account creation if a service account with the same email already exists.
- description String
- A text description of the service account. Must be less than or equal to 256 UTF-8 bytes.
- disabled Boolean
- Whether a service account is disabled or not. Defaults to
false
. This field has no effect during creation. Must be set after creation to disable a service account. - display
Name String - The display name for the service account. Can be updated without creating a new resource.
- project String
- The ID of the project that the service account will be created in. Defaults to the provider project configuration.
Outputs
All input properties are implicitly available as output properties. Additionally, the Account resource produces the following output properties:
- Email string
- The e-mail address of the service account. This value
should be referenced from any
gcp.organizations.getIAMPolicy
data sources that would grant the service account privileges. - Id string
- The provider-assigned unique ID for this managed resource.
- Member string
- The Identity of the service account in the form
serviceAccount:{email}
. This value is often used to refer to the service account in order to grant IAM permissions. - Name string
- The fully-qualified name of the service account.
- Unique
Id string - The unique id of the service account.
- Email string
- The e-mail address of the service account. This value
should be referenced from any
gcp.organizations.getIAMPolicy
data sources that would grant the service account privileges. - Id string
- The provider-assigned unique ID for this managed resource.
- Member string
- The Identity of the service account in the form
serviceAccount:{email}
. This value is often used to refer to the service account in order to grant IAM permissions. - Name string
- The fully-qualified name of the service account.
- Unique
Id string - The unique id of the service account.
- email String
- The e-mail address of the service account. This value
should be referenced from any
gcp.organizations.getIAMPolicy
data sources that would grant the service account privileges. - id String
- The provider-assigned unique ID for this managed resource.
- member String
- The Identity of the service account in the form
serviceAccount:{email}
. This value is often used to refer to the service account in order to grant IAM permissions. - name String
- The fully-qualified name of the service account.
- unique
Id String - The unique id of the service account.
- email string
- The e-mail address of the service account. This value
should be referenced from any
gcp.organizations.getIAMPolicy
data sources that would grant the service account privileges. - id string
- The provider-assigned unique ID for this managed resource.
- member string
- The Identity of the service account in the form
serviceAccount:{email}
. This value is often used to refer to the service account in order to grant IAM permissions. - name string
- The fully-qualified name of the service account.
- unique
Id string - The unique id of the service account.
- email str
- The e-mail address of the service account. This value
should be referenced from any
gcp.organizations.getIAMPolicy
data sources that would grant the service account privileges. - id str
- The provider-assigned unique ID for this managed resource.
- member str
- The Identity of the service account in the form
serviceAccount:{email}
. This value is often used to refer to the service account in order to grant IAM permissions. - name str
- The fully-qualified name of the service account.
- unique_
id str - The unique id of the service account.
- email String
- The e-mail address of the service account. This value
should be referenced from any
gcp.organizations.getIAMPolicy
data sources that would grant the service account privileges. - id String
- The provider-assigned unique ID for this managed resource.
- member String
- The Identity of the service account in the form
serviceAccount:{email}
. This value is often used to refer to the service account in order to grant IAM permissions. - name String
- The fully-qualified name of the service account.
- unique
Id String - The unique id of the service account.
Look up Existing Account Resource
Get an existing Account resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: AccountState, opts?: CustomResourceOptions): Account
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
account_id: Optional[str] = None,
create_ignore_already_exists: Optional[bool] = None,
description: Optional[str] = None,
disabled: Optional[bool] = None,
display_name: Optional[str] = None,
email: Optional[str] = None,
member: Optional[str] = None,
name: Optional[str] = None,
project: Optional[str] = None,
unique_id: Optional[str] = None) -> Account
func GetAccount(ctx *Context, name string, id IDInput, state *AccountState, opts ...ResourceOption) (*Account, error)
public static Account Get(string name, Input<string> id, AccountState? state, CustomResourceOptions? opts = null)
public static Account get(String name, Output<String> id, AccountState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Account
Id string - The account id that is used to generate the service
account email address and a stable unique id. It is unique within a project,
must be 6-30 characters long, and match the regular expression
a-z
to comply with RFC1035. Changing this forces a new service account to be created. - Create
Ignore boolAlready Exists - If set to true, skip service account creation if a service account with the same email already exists.
- Description string
- A text description of the service account. Must be less than or equal to 256 UTF-8 bytes.
- Disabled bool
- Whether a service account is disabled or not. Defaults to
false
. This field has no effect during creation. Must be set after creation to disable a service account. - Display
Name string - The display name for the service account. Can be updated without creating a new resource.
- Email string
- The e-mail address of the service account. This value
should be referenced from any
gcp.organizations.getIAMPolicy
data sources that would grant the service account privileges. - Member string
- The Identity of the service account in the form
serviceAccount:{email}
. This value is often used to refer to the service account in order to grant IAM permissions. - Name string
- The fully-qualified name of the service account.
- Project string
- The ID of the project that the service account will be created in. Defaults to the provider project configuration.
- Unique
Id string - The unique id of the service account.
- Account
Id string - The account id that is used to generate the service
account email address and a stable unique id. It is unique within a project,
must be 6-30 characters long, and match the regular expression
a-z
to comply with RFC1035. Changing this forces a new service account to be created. - Create
Ignore boolAlready Exists - If set to true, skip service account creation if a service account with the same email already exists.
- Description string
- A text description of the service account. Must be less than or equal to 256 UTF-8 bytes.
- Disabled bool
- Whether a service account is disabled or not. Defaults to
false
. This field has no effect during creation. Must be set after creation to disable a service account. - Display
Name string - The display name for the service account. Can be updated without creating a new resource.
- Email string
- The e-mail address of the service account. This value
should be referenced from any
gcp.organizations.getIAMPolicy
data sources that would grant the service account privileges. - Member string
- The Identity of the service account in the form
serviceAccount:{email}
. This value is often used to refer to the service account in order to grant IAM permissions. - Name string
- The fully-qualified name of the service account.
- Project string
- The ID of the project that the service account will be created in. Defaults to the provider project configuration.
- Unique
Id string - The unique id of the service account.
- account
Id String - The account id that is used to generate the service
account email address and a stable unique id. It is unique within a project,
must be 6-30 characters long, and match the regular expression
a-z
to comply with RFC1035. Changing this forces a new service account to be created. - create
Ignore BooleanAlready Exists - If set to true, skip service account creation if a service account with the same email already exists.
- description String
- A text description of the service account. Must be less than or equal to 256 UTF-8 bytes.
- disabled Boolean
- Whether a service account is disabled or not. Defaults to
false
. This field has no effect during creation. Must be set after creation to disable a service account. - display
Name String - The display name for the service account. Can be updated without creating a new resource.
- email String
- The e-mail address of the service account. This value
should be referenced from any
gcp.organizations.getIAMPolicy
data sources that would grant the service account privileges. - member String
- The Identity of the service account in the form
serviceAccount:{email}
. This value is often used to refer to the service account in order to grant IAM permissions. - name String
- The fully-qualified name of the service account.
- project String
- The ID of the project that the service account will be created in. Defaults to the provider project configuration.
- unique
Id String - The unique id of the service account.
- account
Id string - The account id that is used to generate the service
account email address and a stable unique id. It is unique within a project,
must be 6-30 characters long, and match the regular expression
a-z
to comply with RFC1035. Changing this forces a new service account to be created. - create
Ignore booleanAlready Exists - If set to true, skip service account creation if a service account with the same email already exists.
- description string
- A text description of the service account. Must be less than or equal to 256 UTF-8 bytes.
- disabled boolean
- Whether a service account is disabled or not. Defaults to
false
. This field has no effect during creation. Must be set after creation to disable a service account. - display
Name string - The display name for the service account. Can be updated without creating a new resource.
- email string
- The e-mail address of the service account. This value
should be referenced from any
gcp.organizations.getIAMPolicy
data sources that would grant the service account privileges. - member string
- The Identity of the service account in the form
serviceAccount:{email}
. This value is often used to refer to the service account in order to grant IAM permissions. - name string
- The fully-qualified name of the service account.
- project string
- The ID of the project that the service account will be created in. Defaults to the provider project configuration.
- unique
Id string - The unique id of the service account.
- account_
id str - The account id that is used to generate the service
account email address and a stable unique id. It is unique within a project,
must be 6-30 characters long, and match the regular expression
a-z
to comply with RFC1035. Changing this forces a new service account to be created. - create_
ignore_ boolalready_ exists - If set to true, skip service account creation if a service account with the same email already exists.
- description str
- A text description of the service account. Must be less than or equal to 256 UTF-8 bytes.
- disabled bool
- Whether a service account is disabled or not. Defaults to
false
. This field has no effect during creation. Must be set after creation to disable a service account. - display_
name str - The display name for the service account. Can be updated without creating a new resource.
- email str
- The e-mail address of the service account. This value
should be referenced from any
gcp.organizations.getIAMPolicy
data sources that would grant the service account privileges. - member str
- The Identity of the service account in the form
serviceAccount:{email}
. This value is often used to refer to the service account in order to grant IAM permissions. - name str
- The fully-qualified name of the service account.
- project str
- The ID of the project that the service account will be created in. Defaults to the provider project configuration.
- unique_
id str - The unique id of the service account.
- account
Id String - The account id that is used to generate the service
account email address and a stable unique id. It is unique within a project,
must be 6-30 characters long, and match the regular expression
a-z
to comply with RFC1035. Changing this forces a new service account to be created. - create
Ignore BooleanAlready Exists - If set to true, skip service account creation if a service account with the same email already exists.
- description String
- A text description of the service account. Must be less than or equal to 256 UTF-8 bytes.
- disabled Boolean
- Whether a service account is disabled or not. Defaults to
false
. This field has no effect during creation. Must be set after creation to disable a service account. - display
Name String - The display name for the service account. Can be updated without creating a new resource.
- email String
- The e-mail address of the service account. This value
should be referenced from any
gcp.organizations.getIAMPolicy
data sources that would grant the service account privileges. - member String
- The Identity of the service account in the form
serviceAccount:{email}
. This value is often used to refer to the service account in order to grant IAM permissions. - name String
- The fully-qualified name of the service account.
- project String
- The ID of the project that the service account will be created in. Defaults to the provider project configuration.
- unique
Id String - The unique id of the service account.
Import
Service accounts can be imported using their URI, e.g.
projects/{{project_id}}/serviceAccounts/{{email}}
When using the pulumi import
command, service accounts can be imported using one of the formats above. For example:
$ pulumi import gcp:serviceaccount/account:Account default projects/{{project_id}}/serviceAccounts/{{email}}
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Google Cloud (GCP) Classic pulumi/pulumi-gcp
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
google-beta
Terraform Provider.