1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. projects
  5. DefaultServiceAccounts
Google Cloud Classic v8.3.1 published on Wednesday, Sep 25, 2024 by Pulumi

gcp.projects.DefaultServiceAccounts

Explore with Pulumi AI

gcp logo
Google Cloud Classic v8.3.1 published on Wednesday, Sep 25, 2024 by Pulumi

    Allows management of Google Cloud Platform project default service accounts.

    When certain service APIs are enabled, Google Cloud Platform automatically creates service accounts to help get started, but this is not recommended for production environments as per Google’s documentation. See the Organization documentation for more details.

    WARNING Some Google Cloud products do not work if the default service accounts are deleted so it is better to DEPRIVILEGE as Google CAN NOT recover service accounts that have been deleted for more than 30 days. Also Google recommends using the constraints/iam.automaticIamGrantsForDefaultServiceAccounts constraint to disable automatic IAM Grants to default service accounts.

    This resource works on a best-effort basis, as no API formally describes the default service accounts and it is for users who are unable to use constraints. If the default service accounts change their name or additional service accounts are added, this resource will need to be updated.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const myProject = new gcp.projects.DefaultServiceAccounts("my_project", {
        project: "my-project-id",
        action: "DELETE",
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    my_project = gcp.projects.DefaultServiceAccounts("my_project",
        project="my-project-id",
        action="DELETE")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/projects"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := projects.NewDefaultServiceAccounts(ctx, "my_project", &projects.DefaultServiceAccountsArgs{
    			Project: pulumi.String("my-project-id"),
    			Action:  pulumi.String("DELETE"),
    		})
    		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 myProject = new Gcp.Projects.DefaultServiceAccounts("my_project", new()
        {
            Project = "my-project-id",
            Action = "DELETE",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.projects.DefaultServiceAccounts;
    import com.pulumi.gcp.projects.DefaultServiceAccountsArgs;
    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 myProject = new DefaultServiceAccounts("myProject", DefaultServiceAccountsArgs.builder()
                .project("my-project-id")
                .action("DELETE")
                .build());
    
        }
    }
    
    resources:
      myProject:
        type: gcp:projects:DefaultServiceAccounts
        name: my_project
        properties:
          project: my-project-id
          action: DELETE
    

    To enable the default service accounts on the resource destroy:

    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    const myProject = new gcp.projects.DefaultServiceAccounts("my_project", {
        project: "my-project-id",
        action: "DISABLE",
        restorePolicy: "REVERT",
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    my_project = gcp.projects.DefaultServiceAccounts("my_project",
        project="my-project-id",
        action="DISABLE",
        restore_policy="REVERT")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/projects"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := projects.NewDefaultServiceAccounts(ctx, "my_project", &projects.DefaultServiceAccountsArgs{
    			Project:       pulumi.String("my-project-id"),
    			Action:        pulumi.String("DISABLE"),
    			RestorePolicy: pulumi.String("REVERT"),
    		})
    		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 myProject = new Gcp.Projects.DefaultServiceAccounts("my_project", new()
        {
            Project = "my-project-id",
            Action = "DISABLE",
            RestorePolicy = "REVERT",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gcp.projects.DefaultServiceAccounts;
    import com.pulumi.gcp.projects.DefaultServiceAccountsArgs;
    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 myProject = new DefaultServiceAccounts("myProject", DefaultServiceAccountsArgs.builder()
                .project("my-project-id")
                .action("DISABLE")
                .restorePolicy("REVERT")
                .build());
    
        }
    }
    
    resources:
      myProject:
        type: gcp:projects:DefaultServiceAccounts
        name: my_project
        properties:
          project: my-project-id
          action: DISABLE
          restorePolicy: REVERT
    

    Create DefaultServiceAccounts Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new DefaultServiceAccounts(name: string, args: DefaultServiceAccountsArgs, opts?: CustomResourceOptions);
    @overload
    def DefaultServiceAccounts(resource_name: str,
                               args: DefaultServiceAccountsArgs,
                               opts: Optional[ResourceOptions] = None)
    
    @overload
    def DefaultServiceAccounts(resource_name: str,
                               opts: Optional[ResourceOptions] = None,
                               action: Optional[str] = None,
                               project: Optional[str] = None,
                               restore_policy: Optional[str] = None)
    func NewDefaultServiceAccounts(ctx *Context, name string, args DefaultServiceAccountsArgs, opts ...ResourceOption) (*DefaultServiceAccounts, error)
    public DefaultServiceAccounts(string name, DefaultServiceAccountsArgs args, CustomResourceOptions? opts = null)
    public DefaultServiceAccounts(String name, DefaultServiceAccountsArgs args)
    public DefaultServiceAccounts(String name, DefaultServiceAccountsArgs args, CustomResourceOptions options)
    
    type: gcp:projects:DefaultServiceAccounts
    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 DefaultServiceAccountsArgs
    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 DefaultServiceAccountsArgs
    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 DefaultServiceAccountsArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args DefaultServiceAccountsArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args DefaultServiceAccountsArgs
    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 defaultServiceAccountsResource = new Gcp.Projects.DefaultServiceAccounts("defaultServiceAccountsResource", new()
    {
        Action = "string",
        Project = "string",
        RestorePolicy = "string",
    });
    
    example, err := projects.NewDefaultServiceAccounts(ctx, "defaultServiceAccountsResource", &projects.DefaultServiceAccountsArgs{
    	Action:        pulumi.String("string"),
    	Project:       pulumi.String("string"),
    	RestorePolicy: pulumi.String("string"),
    })
    
    var defaultServiceAccountsResource = new DefaultServiceAccounts("defaultServiceAccountsResource", DefaultServiceAccountsArgs.builder()
        .action("string")
        .project("string")
        .restorePolicy("string")
        .build());
    
    default_service_accounts_resource = gcp.projects.DefaultServiceAccounts("defaultServiceAccountsResource",
        action="string",
        project="string",
        restore_policy="string")
    
    const defaultServiceAccountsResource = new gcp.projects.DefaultServiceAccounts("defaultServiceAccountsResource", {
        action: "string",
        project: "string",
        restorePolicy: "string",
    });
    
    type: gcp:projects:DefaultServiceAccounts
    properties:
        action: string
        project: string
        restorePolicy: string
    

    DefaultServiceAccounts Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The DefaultServiceAccounts resource accepts the following input properties:

    Action string
    The action to be performed in the default service accounts. Valid values are: DEPRIVILEGE, DELETE, DISABLE. Note that DEPRIVILEGE action will ignore the REVERT configuration in the restore_policy
    Project string
    The project ID where service accounts are created.
    RestorePolicy string
    The action to be performed in the default service accounts on the resource destroy. Valid values are NONE, REVERT and REVERT_AND_IGNORE_FAILURE. It is applied for any action but in the DEPRIVILEGE. If set to REVERT it attempts to restore all default SAs but the DEPRIVILEGE action. If set to REVERT_AND_IGNORE_FAILURE it is the same behavior as REVERT but ignores errors returned by the API.
    Action string
    The action to be performed in the default service accounts. Valid values are: DEPRIVILEGE, DELETE, DISABLE. Note that DEPRIVILEGE action will ignore the REVERT configuration in the restore_policy
    Project string
    The project ID where service accounts are created.
    RestorePolicy string
    The action to be performed in the default service accounts on the resource destroy. Valid values are NONE, REVERT and REVERT_AND_IGNORE_FAILURE. It is applied for any action but in the DEPRIVILEGE. If set to REVERT it attempts to restore all default SAs but the DEPRIVILEGE action. If set to REVERT_AND_IGNORE_FAILURE it is the same behavior as REVERT but ignores errors returned by the API.
    action String
    The action to be performed in the default service accounts. Valid values are: DEPRIVILEGE, DELETE, DISABLE. Note that DEPRIVILEGE action will ignore the REVERT configuration in the restore_policy
    project String
    The project ID where service accounts are created.
    restorePolicy String
    The action to be performed in the default service accounts on the resource destroy. Valid values are NONE, REVERT and REVERT_AND_IGNORE_FAILURE. It is applied for any action but in the DEPRIVILEGE. If set to REVERT it attempts to restore all default SAs but the DEPRIVILEGE action. If set to REVERT_AND_IGNORE_FAILURE it is the same behavior as REVERT but ignores errors returned by the API.
    action string
    The action to be performed in the default service accounts. Valid values are: DEPRIVILEGE, DELETE, DISABLE. Note that DEPRIVILEGE action will ignore the REVERT configuration in the restore_policy
    project string
    The project ID where service accounts are created.
    restorePolicy string
    The action to be performed in the default service accounts on the resource destroy. Valid values are NONE, REVERT and REVERT_AND_IGNORE_FAILURE. It is applied for any action but in the DEPRIVILEGE. If set to REVERT it attempts to restore all default SAs but the DEPRIVILEGE action. If set to REVERT_AND_IGNORE_FAILURE it is the same behavior as REVERT but ignores errors returned by the API.
    action str
    The action to be performed in the default service accounts. Valid values are: DEPRIVILEGE, DELETE, DISABLE. Note that DEPRIVILEGE action will ignore the REVERT configuration in the restore_policy
    project str
    The project ID where service accounts are created.
    restore_policy str
    The action to be performed in the default service accounts on the resource destroy. Valid values are NONE, REVERT and REVERT_AND_IGNORE_FAILURE. It is applied for any action but in the DEPRIVILEGE. If set to REVERT it attempts to restore all default SAs but the DEPRIVILEGE action. If set to REVERT_AND_IGNORE_FAILURE it is the same behavior as REVERT but ignores errors returned by the API.
    action String
    The action to be performed in the default service accounts. Valid values are: DEPRIVILEGE, DELETE, DISABLE. Note that DEPRIVILEGE action will ignore the REVERT configuration in the restore_policy
    project String
    The project ID where service accounts are created.
    restorePolicy String
    The action to be performed in the default service accounts on the resource destroy. Valid values are NONE, REVERT and REVERT_AND_IGNORE_FAILURE. It is applied for any action but in the DEPRIVILEGE. If set to REVERT it attempts to restore all default SAs but the DEPRIVILEGE action. If set to REVERT_AND_IGNORE_FAILURE it is the same behavior as REVERT but ignores errors returned by the API.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the DefaultServiceAccounts resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    ServiceAccounts Dictionary<string, string>
    The Service Accounts changed by this resource. It is used for REVERT the action on the destroy.
    Id string
    The provider-assigned unique ID for this managed resource.
    ServiceAccounts map[string]string
    The Service Accounts changed by this resource. It is used for REVERT the action on the destroy.
    id String
    The provider-assigned unique ID for this managed resource.
    serviceAccounts Map<String,String>
    The Service Accounts changed by this resource. It is used for REVERT the action on the destroy.
    id string
    The provider-assigned unique ID for this managed resource.
    serviceAccounts {[key: string]: string}
    The Service Accounts changed by this resource. It is used for REVERT the action on the destroy.
    id str
    The provider-assigned unique ID for this managed resource.
    service_accounts Mapping[str, str]
    The Service Accounts changed by this resource. It is used for REVERT the action on the destroy.
    id String
    The provider-assigned unique ID for this managed resource.
    serviceAccounts Map<String>
    The Service Accounts changed by this resource. It is used for REVERT the action on the destroy.

    Look up Existing DefaultServiceAccounts Resource

    Get an existing DefaultServiceAccounts 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?: DefaultServiceAccountsState, opts?: CustomResourceOptions): DefaultServiceAccounts
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            action: Optional[str] = None,
            project: Optional[str] = None,
            restore_policy: Optional[str] = None,
            service_accounts: Optional[Mapping[str, str]] = None) -> DefaultServiceAccounts
    func GetDefaultServiceAccounts(ctx *Context, name string, id IDInput, state *DefaultServiceAccountsState, opts ...ResourceOption) (*DefaultServiceAccounts, error)
    public static DefaultServiceAccounts Get(string name, Input<string> id, DefaultServiceAccountsState? state, CustomResourceOptions? opts = null)
    public static DefaultServiceAccounts get(String name, Output<String> id, DefaultServiceAccountsState 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.
    The following state arguments are supported:
    Action string
    The action to be performed in the default service accounts. Valid values are: DEPRIVILEGE, DELETE, DISABLE. Note that DEPRIVILEGE action will ignore the REVERT configuration in the restore_policy
    Project string
    The project ID where service accounts are created.
    RestorePolicy string
    The action to be performed in the default service accounts on the resource destroy. Valid values are NONE, REVERT and REVERT_AND_IGNORE_FAILURE. It is applied for any action but in the DEPRIVILEGE. If set to REVERT it attempts to restore all default SAs but the DEPRIVILEGE action. If set to REVERT_AND_IGNORE_FAILURE it is the same behavior as REVERT but ignores errors returned by the API.
    ServiceAccounts Dictionary<string, string>
    The Service Accounts changed by this resource. It is used for REVERT the action on the destroy.
    Action string
    The action to be performed in the default service accounts. Valid values are: DEPRIVILEGE, DELETE, DISABLE. Note that DEPRIVILEGE action will ignore the REVERT configuration in the restore_policy
    Project string
    The project ID where service accounts are created.
    RestorePolicy string
    The action to be performed in the default service accounts on the resource destroy. Valid values are NONE, REVERT and REVERT_AND_IGNORE_FAILURE. It is applied for any action but in the DEPRIVILEGE. If set to REVERT it attempts to restore all default SAs but the DEPRIVILEGE action. If set to REVERT_AND_IGNORE_FAILURE it is the same behavior as REVERT but ignores errors returned by the API.
    ServiceAccounts map[string]string
    The Service Accounts changed by this resource. It is used for REVERT the action on the destroy.
    action String
    The action to be performed in the default service accounts. Valid values are: DEPRIVILEGE, DELETE, DISABLE. Note that DEPRIVILEGE action will ignore the REVERT configuration in the restore_policy
    project String
    The project ID where service accounts are created.
    restorePolicy String
    The action to be performed in the default service accounts on the resource destroy. Valid values are NONE, REVERT and REVERT_AND_IGNORE_FAILURE. It is applied for any action but in the DEPRIVILEGE. If set to REVERT it attempts to restore all default SAs but the DEPRIVILEGE action. If set to REVERT_AND_IGNORE_FAILURE it is the same behavior as REVERT but ignores errors returned by the API.
    serviceAccounts Map<String,String>
    The Service Accounts changed by this resource. It is used for REVERT the action on the destroy.
    action string
    The action to be performed in the default service accounts. Valid values are: DEPRIVILEGE, DELETE, DISABLE. Note that DEPRIVILEGE action will ignore the REVERT configuration in the restore_policy
    project string
    The project ID where service accounts are created.
    restorePolicy string
    The action to be performed in the default service accounts on the resource destroy. Valid values are NONE, REVERT and REVERT_AND_IGNORE_FAILURE. It is applied for any action but in the DEPRIVILEGE. If set to REVERT it attempts to restore all default SAs but the DEPRIVILEGE action. If set to REVERT_AND_IGNORE_FAILURE it is the same behavior as REVERT but ignores errors returned by the API.
    serviceAccounts {[key: string]: string}
    The Service Accounts changed by this resource. It is used for REVERT the action on the destroy.
    action str
    The action to be performed in the default service accounts. Valid values are: DEPRIVILEGE, DELETE, DISABLE. Note that DEPRIVILEGE action will ignore the REVERT configuration in the restore_policy
    project str
    The project ID where service accounts are created.
    restore_policy str
    The action to be performed in the default service accounts on the resource destroy. Valid values are NONE, REVERT and REVERT_AND_IGNORE_FAILURE. It is applied for any action but in the DEPRIVILEGE. If set to REVERT it attempts to restore all default SAs but the DEPRIVILEGE action. If set to REVERT_AND_IGNORE_FAILURE it is the same behavior as REVERT but ignores errors returned by the API.
    service_accounts Mapping[str, str]
    The Service Accounts changed by this resource. It is used for REVERT the action on the destroy.
    action String
    The action to be performed in the default service accounts. Valid values are: DEPRIVILEGE, DELETE, DISABLE. Note that DEPRIVILEGE action will ignore the REVERT configuration in the restore_policy
    project String
    The project ID where service accounts are created.
    restorePolicy String
    The action to be performed in the default service accounts on the resource destroy. Valid values are NONE, REVERT and REVERT_AND_IGNORE_FAILURE. It is applied for any action but in the DEPRIVILEGE. If set to REVERT it attempts to restore all default SAs but the DEPRIVILEGE action. If set to REVERT_AND_IGNORE_FAILURE it is the same behavior as REVERT but ignores errors returned by the API.
    serviceAccounts Map<String>
    The Service Accounts changed by this resource. It is used for REVERT the action on the destroy.

    Import

    This resource does not support import

    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.
    gcp logo
    Google Cloud Classic v8.3.1 published on Wednesday, Sep 25, 2024 by Pulumi