1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. folder
  5. ServiceIdentity
Google Cloud v8.26.0 published on Thursday, Apr 10, 2025 by Pulumi

gcp.folder.ServiceIdentity

Explore with Pulumi AI

Generate folder service identity for a service.

Note: Once created, this resource cannot be updated or destroyed. These actions are a no-op.

Note: This resource can be used to retrieve the emails of the Google-managed folder service accounts of the APIs that Google has configured with a Service Identity. You can run gcloud beta services identity create --service SERVICE_NAME.googleapis.com --folder FOLDER to verify if an API supports this.

To get more information about Service Identity, see:

Example Usage

Folder Service Identity Basic

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const myFolder = new gcp.organizations.Folder("my_folder", {
    parent: "organizations/1234567",
    displayName: "my-folder",
});
const osconfigSa = new gcp.folder.ServiceIdentity("osconfig_sa", {
    folder: myFolder.folderId,
    service: "osconfig.googleapis.com",
});
const admin = new gcp.folder.IAMMember("admin", {
    folder: myFolder.name,
    role: "roles/osconfig.serviceAgent",
    member: osconfigSa.member,
});
Copy
import pulumi
import pulumi_gcp as gcp

my_folder = gcp.organizations.Folder("my_folder",
    parent="organizations/1234567",
    display_name="my-folder")
osconfig_sa = gcp.folder.ServiceIdentity("osconfig_sa",
    folder=my_folder.folder_id,
    service="osconfig.googleapis.com")
admin = gcp.folder.IAMMember("admin",
    folder=my_folder.name,
    role="roles/osconfig.serviceAgent",
    member=osconfig_sa.member)
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/folder"
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/organizations"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		myFolder, err := organizations.NewFolder(ctx, "my_folder", &organizations.FolderArgs{
			Parent:      pulumi.String("organizations/1234567"),
			DisplayName: pulumi.String("my-folder"),
		})
		if err != nil {
			return err
		}
		osconfigSa, err := folder.NewServiceIdentity(ctx, "osconfig_sa", &folder.ServiceIdentityArgs{
			Folder:  myFolder.FolderId,
			Service: pulumi.String("osconfig.googleapis.com"),
		})
		if err != nil {
			return err
		}
		_, err = folder.NewIAMMember(ctx, "admin", &folder.IAMMemberArgs{
			Folder: myFolder.Name,
			Role:   pulumi.String("roles/osconfig.serviceAgent"),
			Member: osconfigSa.Member,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var myFolder = new Gcp.Organizations.Folder("my_folder", new()
    {
        Parent = "organizations/1234567",
        DisplayName = "my-folder",
    });

    var osconfigSa = new Gcp.Folder.ServiceIdentity("osconfig_sa", new()
    {
        Folder = myFolder.FolderId,
        Service = "osconfig.googleapis.com",
    });

    var admin = new Gcp.Folder.IAMMember("admin", new()
    {
        Folder = myFolder.Name,
        Role = "roles/osconfig.serviceAgent",
        Member = osconfigSa.Member,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.organizations.Folder;
import com.pulumi.gcp.organizations.FolderArgs;
import com.pulumi.gcp.folder.ServiceIdentity;
import com.pulumi.gcp.folder.ServiceIdentityArgs;
import com.pulumi.gcp.folder.IAMMember;
import com.pulumi.gcp.folder.IAMMemberArgs;
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 myFolder = new Folder("myFolder", FolderArgs.builder()
            .parent("organizations/1234567")
            .displayName("my-folder")
            .build());

        var osconfigSa = new ServiceIdentity("osconfigSa", ServiceIdentityArgs.builder()
            .folder(myFolder.folderId())
            .service("osconfig.googleapis.com")
            .build());

        var admin = new IAMMember("admin", IAMMemberArgs.builder()
            .folder(myFolder.name())
            .role("roles/osconfig.serviceAgent")
            .member(osconfigSa.member())
            .build());

    }
}
Copy
resources:
  myFolder:
    type: gcp:organizations:Folder
    name: my_folder
    properties:
      parent: organizations/1234567
      displayName: my-folder
  osconfigSa:
    type: gcp:folder:ServiceIdentity
    name: osconfig_sa
    properties:
      folder: ${myFolder.folderId}
      service: osconfig.googleapis.com
  admin:
    type: gcp:folder:IAMMember
    properties:
      folder: ${myFolder.name}
      role: roles/osconfig.serviceAgent
      member: ${osconfigSa.member}
Copy

Create ServiceIdentity Resource

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

Constructor syntax

new ServiceIdentity(name: string, args: ServiceIdentityArgs, opts?: CustomResourceOptions);
@overload
def ServiceIdentity(resource_name: str,
                    args: ServiceIdentityArgs,
                    opts: Optional[ResourceOptions] = None)

@overload
def ServiceIdentity(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    folder: Optional[str] = None,
                    service: Optional[str] = None)
func NewServiceIdentity(ctx *Context, name string, args ServiceIdentityArgs, opts ...ResourceOption) (*ServiceIdentity, error)
public ServiceIdentity(string name, ServiceIdentityArgs args, CustomResourceOptions? opts = null)
public ServiceIdentity(String name, ServiceIdentityArgs args)
public ServiceIdentity(String name, ServiceIdentityArgs args, CustomResourceOptions options)
type: gcp:folder:ServiceIdentity
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ServiceIdentityArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ServiceIdentityArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ServiceIdentityArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ServiceIdentityArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ServiceIdentityArgs
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 serviceIdentityResource = new Gcp.Folder.ServiceIdentity("serviceIdentityResource", new()
{
    Folder = "string",
    Service = "string",
});
Copy
example, err := folder.NewServiceIdentity(ctx, "serviceIdentityResource", &folder.ServiceIdentityArgs{
	Folder:  pulumi.String("string"),
	Service: pulumi.String("string"),
})
Copy
var serviceIdentityResource = new ServiceIdentity("serviceIdentityResource", ServiceIdentityArgs.builder()
    .folder("string")
    .service("string")
    .build());
Copy
service_identity_resource = gcp.folder.ServiceIdentity("serviceIdentityResource",
    folder="string",
    service="string")
Copy
const serviceIdentityResource = new gcp.folder.ServiceIdentity("serviceIdentityResource", {
    folder: "string",
    service: "string",
});
Copy
type: gcp:folder:ServiceIdentity
properties:
    folder: string
    service: string
Copy

ServiceIdentity 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 ServiceIdentity resource accepts the following input properties:

Folder
This property is required.
Changes to this property will trigger replacement.
string
The folder in which the resource belongs.
Service
This property is required.
Changes to this property will trigger replacement.
string
The service to generate identity for.


Folder
This property is required.
Changes to this property will trigger replacement.
string
The folder in which the resource belongs.
Service
This property is required.
Changes to this property will trigger replacement.
string
The service to generate identity for.


folder
This property is required.
Changes to this property will trigger replacement.
String
The folder in which the resource belongs.
service
This property is required.
Changes to this property will trigger replacement.
String
The service to generate identity for.


folder
This property is required.
Changes to this property will trigger replacement.
string
The folder in which the resource belongs.
service
This property is required.
Changes to this property will trigger replacement.
string
The service to generate identity for.


folder
This property is required.
Changes to this property will trigger replacement.
str
The folder in which the resource belongs.
service
This property is required.
Changes to this property will trigger replacement.
str
The service to generate identity for.


folder
This property is required.
Changes to this property will trigger replacement.
String
The folder in which the resource belongs.
service
This property is required.
Changes to this property will trigger replacement.
String
The service to generate identity for.


Outputs

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

Email string
The email address of the Google managed service account.
Id string
The provider-assigned unique ID for this managed resource.
Member string
The Identity of the Google managed service account in the form 'serviceAccount:{email}'. This value is often used to refer to the service account in order to grant IAM permissions.
Email string
The email address of the Google managed service account.
Id string
The provider-assigned unique ID for this managed resource.
Member string
The Identity of the Google managed service account in the form 'serviceAccount:{email}'. This value is often used to refer to the service account in order to grant IAM permissions.
email String
The email address of the Google managed service account.
id String
The provider-assigned unique ID for this managed resource.
member String
The Identity of the Google managed service account in the form 'serviceAccount:{email}'. This value is often used to refer to the service account in order to grant IAM permissions.
email string
The email address of the Google managed service account.
id string
The provider-assigned unique ID for this managed resource.
member string
The Identity of the Google managed service account in the form 'serviceAccount:{email}'. This value is often used to refer to the service account in order to grant IAM permissions.
email str
The email address of the Google managed service account.
id str
The provider-assigned unique ID for this managed resource.
member str
The Identity of the Google managed service account in the form 'serviceAccount:{email}'. This value is often used to refer to the service account in order to grant IAM permissions.
email String
The email address of the Google managed service account.
id String
The provider-assigned unique ID for this managed resource.
member String
The Identity of the Google managed service account in the form 'serviceAccount:{email}'. This value is often used to refer to the service account in order to grant IAM permissions.

Look up Existing ServiceIdentity Resource

Get an existing ServiceIdentity 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?: ServiceIdentityState, opts?: CustomResourceOptions): ServiceIdentity
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        email: Optional[str] = None,
        folder: Optional[str] = None,
        member: Optional[str] = None,
        service: Optional[str] = None) -> ServiceIdentity
func GetServiceIdentity(ctx *Context, name string, id IDInput, state *ServiceIdentityState, opts ...ResourceOption) (*ServiceIdentity, error)
public static ServiceIdentity Get(string name, Input<string> id, ServiceIdentityState? state, CustomResourceOptions? opts = null)
public static ServiceIdentity get(String name, Output<String> id, ServiceIdentityState state, CustomResourceOptions options)
resources:  _:    type: gcp:folder:ServiceIdentity    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
Email string
The email address of the Google managed service account.
Folder Changes to this property will trigger replacement. string
The folder in which the resource belongs.
Member string
The Identity of the Google managed service account in the form 'serviceAccount:{email}'. This value is often used to refer to the service account in order to grant IAM permissions.
Service Changes to this property will trigger replacement. string
The service to generate identity for.


Email string
The email address of the Google managed service account.
Folder Changes to this property will trigger replacement. string
The folder in which the resource belongs.
Member string
The Identity of the Google managed service account in the form 'serviceAccount:{email}'. This value is often used to refer to the service account in order to grant IAM permissions.
Service Changes to this property will trigger replacement. string
The service to generate identity for.


email String
The email address of the Google managed service account.
folder Changes to this property will trigger replacement. String
The folder in which the resource belongs.
member String
The Identity of the Google managed service account in the form 'serviceAccount:{email}'. This value is often used to refer to the service account in order to grant IAM permissions.
service Changes to this property will trigger replacement. String
The service to generate identity for.


email string
The email address of the Google managed service account.
folder Changes to this property will trigger replacement. string
The folder in which the resource belongs.
member string
The Identity of the Google managed service account in the form 'serviceAccount:{email}'. This value is often used to refer to the service account in order to grant IAM permissions.
service Changes to this property will trigger replacement. string
The service to generate identity for.


email str
The email address of the Google managed service account.
folder Changes to this property will trigger replacement. str
The folder in which the resource belongs.
member str
The Identity of the Google managed service account in the form 'serviceAccount:{email}'. This value is often used to refer to the service account in order to grant IAM permissions.
service Changes to this property will trigger replacement. str
The service to generate identity for.


email String
The email address of the Google managed service account.
folder Changes to this property will trigger replacement. String
The folder in which the resource belongs.
member String
The Identity of the Google managed service account in the form 'serviceAccount:{email}'. This value is often used to refer to the service account in order to grant IAM permissions.
service Changes to this property will trigger replacement. String
The service to generate identity for.


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.