DefaultServiceAccounts

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

using System.Collections.Generic;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var myProject = new Gcp.Projects.DefaultServiceAccounts("myProject", new()
    {
        Action = "DELETE",
        Project = "my-project-id",
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/projects"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := projects.NewDefaultServiceAccounts(ctx, "myProject", &projects.DefaultServiceAccountsArgs{
			Action:  pulumi.String("DELETE"),
			Project: pulumi.String("my-project-id"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
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()        
            .action("DELETE")
            .project("my-project-id")
            .build());

    }
}
import pulumi
import pulumi_gcp as gcp

my_project = gcp.projects.DefaultServiceAccounts("myProject",
    action="DELETE",
    project="my-project-id")
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const myProject = new gcp.projects.DefaultServiceAccounts("my_project", {
    action: "DELETE",
    project: "my-project-id",
});
resources:
  myProject:
    type: gcp:projects:DefaultServiceAccounts
    properties:
      action: DELETE
      project: my-project-id

To enable the default service accounts on the resource destroy

using System.Collections.Generic;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var myProject = new Gcp.Projects.DefaultServiceAccounts("myProject", new()
    {
        Action = "DISABLE",
        Project = "my-project-id",
        RestorePolicy = "REVERT",
    });

});
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/projects"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := projects.NewDefaultServiceAccounts(ctx, "myProject", &projects.DefaultServiceAccountsArgs{
			Action:        pulumi.String("DISABLE"),
			Project:       pulumi.String("my-project-id"),
			RestorePolicy: pulumi.String("REVERT"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
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()        
            .action("DISABLE")
            .project("my-project-id")
            .restorePolicy("REVERT")
            .build());

    }
}
import pulumi
import pulumi_gcp as gcp

my_project = gcp.projects.DefaultServiceAccounts("myProject",
    action="DISABLE",
    project="my-project-id",
    restore_policy="REVERT")
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const myProject = new gcp.projects.DefaultServiceAccounts("my_project", {
    action: "DISABLE",
    project: "my-project-id",
    restorePolicy: "REVERT",
});
resources:
  myProject:
    type: gcp:projects:DefaultServiceAccounts
    properties:
      action: DISABLE
      project: my-project-id
      restorePolicy: REVERT

Create DefaultServiceAccounts Resource

new DefaultServiceAccounts(name: string, args: DefaultServiceAccountsArgs, opts?: CustomResourceOptions);
@overload
def DefaultServiceAccounts(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           action: Optional[str] = None,
                           project: Optional[str] = None,
                           restore_policy: Optional[str] = None)
@overload
def DefaultServiceAccounts(resource_name: str,
                           args: DefaultServiceAccountsArgs,
                           opts: Optional[ResourceOptions] = 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.

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.

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, object>

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]interface{}

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,Object>

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]: any}

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, Any]

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<Any>

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, Any]] = 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, object>

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]interface{}

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,Object>

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]: any}

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, Any]

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<Any>

The Service Accounts changed by this resource. It is used for REVERT the action on the destroy.

Import

This resource does not support import

Package Details

Repository
https://github.com/pulumi/pulumi-gcp
License
Apache-2.0
Notes

This Pulumi package is based on the google-beta Terraform Provider.