DefaultServiceAccounts class
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")
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 main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/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
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_projects_defaultserviceaccounts" "my_project" {
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.ArrayList;
import java.util.Arrays;
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")
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 main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/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
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
}
}
resource "gcp_projects_defaultserviceaccounts" "my_project" {
project = "my-project-id"
action = "DISABLE"
restore_policy = "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.ArrayList;
import java.util.Arrays;
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
Import
This resource does not support import
Constructors
- DefaultServiceAccounts(String name, {DefaultServiceAccountsArgs? args, CustomResourceOptions? options})
-
Creates a new DefaultServiceAccounts.
nameThe Pulumi resource name.argsArguments used to configure this DefaultServiceAccounts. The set of arguments for DefaultServiceAccounts.optionsResource options controlling this resource's behavior. - DefaultServiceAccounts.reference(String urn)
- Creates a typed reference to an existing DefaultServiceAccounts resource.
Properties
-
action
↔ Output<
String> -
The action to be performed in the default service accounts. Valid values are:
DEPRIVILEGE,DELETE,DISABLE. Note thatDEPRIVILEGEaction will ignore the REVERT configuration in the restore_policylatefinal -
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
project
↔ Output<
String> -
The project ID where service accounts are created.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
-
restorePolicy
↔ Output<
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.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
serviceAccounts
↔ Output<
Map< String, String> > -
The Service Accounts changed by this resource. It is used for
REVERTtheactionon the destroy.latefinal -
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {DefaultServiceAccountsState? state, CustomResourceOptions? options}) → DefaultServiceAccounts -
Gets an existing DefaultServiceAccounts resource's state with the given
nameandid.