Class DefaultServiceAccounts


  • public class DefaultServiceAccounts
    extends com.pulumi.resources.CustomResource
    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](https://cloud.google.com/iam/docs/service-accounts#default). See the [Organization documentation](https://cloud.google.com/resource-manager/docs/quickstarts) 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](https://www.terraform.io/docs/providers/google/r/google_organization_policy.html) 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 ```java 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()); } } ``` To enable the default service accounts on the resource destroy: ```java 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 This resource does not support import
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.lang.String> action()  
      static DefaultServiceAccounts get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, DefaultServiceAccountsState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.lang.String> project()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> restorePolicy()  
      com.pulumi.core.Output<java.util.Map<java.lang.String,​java.lang.Object>> serviceAccounts()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultServiceAccounts

        public DefaultServiceAccounts​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • DefaultServiceAccounts

        public DefaultServiceAccounts​(java.lang.String name,
                                      DefaultServiceAccountsArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • DefaultServiceAccounts

        public DefaultServiceAccounts​(java.lang.String name,
                                      DefaultServiceAccountsArgs args,
                                      @Nullable
                                      com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • action

        public com.pulumi.core.Output<java.lang.String> action()
        Returns:
        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

        public com.pulumi.core.Output<java.lang.String> project()
        Returns:
        The project ID where service accounts are created.
      • restorePolicy

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> restorePolicy()
        Returns:
        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

        public com.pulumi.core.Output<java.util.Map<java.lang.String,​java.lang.Object>> serviceAccounts()
        Returns:
        The Service Accounts changed by this resource. It is used for `REVERT` the `action` on the destroy.
      • get

        public static DefaultServiceAccounts get​(java.lang.String name,
                                                 com.pulumi.core.Output<java.lang.String> id,
                                                 @Nullable
                                                 DefaultServiceAccountsState state,
                                                 @Nullable
                                                 com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.