gcp.projects.ServiceIdentity
Explore with Pulumi AI
Generate 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 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
to verify if an API supports this.
To get more information about Service Identity, see:
Example Usage
Service Identity Basic
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const project = gcp.organizations.getProject({});
const hcSa = new gcp.projects.ServiceIdentity("hc_sa", {
project: project.then(project => project.projectId),
service: "healthcare.googleapis.com",
});
const hcSaBqJobuser = new gcp.projects.IAMMember("hc_sa_bq_jobuser", {
project: project.then(project => project.projectId),
role: "roles/bigquery.jobUser",
member: hcSa.member,
});
import pulumi
import pulumi_gcp as gcp
project = gcp.organizations.get_project()
hc_sa = gcp.projects.ServiceIdentity("hc_sa",
project=project.project_id,
service="healthcare.googleapis.com")
hc_sa_bq_jobuser = gcp.projects.IAMMember("hc_sa_bq_jobuser",
project=project.project_id,
role="roles/bigquery.jobUser",
member=hc_sa.member)
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/organizations"
"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 {
project, err := organizations.LookupProject(ctx, &organizations.LookupProjectArgs{}, nil)
if err != nil {
return err
}
hcSa, err := projects.NewServiceIdentity(ctx, "hc_sa", &projects.ServiceIdentityArgs{
Project: pulumi.String(project.ProjectId),
Service: pulumi.String("healthcare.googleapis.com"),
})
if err != nil {
return err
}
_, err = projects.NewIAMMember(ctx, "hc_sa_bq_jobuser", &projects.IAMMemberArgs{
Project: pulumi.String(project.ProjectId),
Role: pulumi.String("roles/bigquery.jobUser"),
Member: hcSa.Member,
})
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 project = Gcp.Organizations.GetProject.Invoke();
var hcSa = new Gcp.Projects.ServiceIdentity("hc_sa", new()
{
Project = project.Apply(getProjectResult => getProjectResult.ProjectId),
Service = "healthcare.googleapis.com",
});
var hcSaBqJobuser = new Gcp.Projects.IAMMember("hc_sa_bq_jobuser", new()
{
Project = project.Apply(getProjectResult => getProjectResult.ProjectId),
Role = "roles/bigquery.jobUser",
Member = hcSa.Member,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.organizations.OrganizationsFunctions;
import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
import com.pulumi.gcp.projects.ServiceIdentity;
import com.pulumi.gcp.projects.ServiceIdentityArgs;
import com.pulumi.gcp.projects.IAMMember;
import com.pulumi.gcp.projects.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) {
final var project = OrganizationsFunctions.getProject();
var hcSa = new ServiceIdentity("hcSa", ServiceIdentityArgs.builder()
.project(project.applyValue(getProjectResult -> getProjectResult.projectId()))
.service("healthcare.googleapis.com")
.build());
var hcSaBqJobuser = new IAMMember("hcSaBqJobuser", IAMMemberArgs.builder()
.project(project.applyValue(getProjectResult -> getProjectResult.projectId()))
.role("roles/bigquery.jobUser")
.member(hcSa.member())
.build());
}
}
resources:
hcSa:
type: gcp:projects:ServiceIdentity
name: hc_sa
properties:
project: ${project.projectId}
service: healthcare.googleapis.com
hcSaBqJobuser:
type: gcp:projects:IAMMember
name: hc_sa_bq_jobuser
properties:
project: ${project.projectId}
role: roles/bigquery.jobUser
member: ${hcSa.member}
variables:
project:
fn::invoke:
Function: gcp:organizations:getProject
Arguments: {}
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,
service: Optional[str] = None,
project: 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:projects:ServiceIdentity
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 ServiceIdentityArgs
- 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 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 string
- The unique name of the resource.
- args ServiceIdentityArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ServiceIdentityArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args 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.Projects.ServiceIdentity("serviceIdentityResource", new()
{
Service = "string",
Project = "string",
});
example, err := projects.NewServiceIdentity(ctx, "serviceIdentityResource", &projects.ServiceIdentityArgs{
Service: pulumi.String("string"),
Project: pulumi.String("string"),
})
var serviceIdentityResource = new ServiceIdentity("serviceIdentityResource", ServiceIdentityArgs.builder()
.service("string")
.project("string")
.build());
service_identity_resource = gcp.projects.ServiceIdentity("serviceIdentityResource",
service="string",
project="string")
const serviceIdentityResource = new gcp.projects.ServiceIdentity("serviceIdentityResource", {
service: "string",
project: "string",
});
type: gcp:projects:ServiceIdentity
properties:
project: string
service: string
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:
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,
member: Optional[str] = None,
project: 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)
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.
- Email string
- The email address of the Google managed service account.
- 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.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Service string
- The service to generate identity for.
- Email string
- The email address of the Google managed service account.
- 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.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Service string
- The service to generate identity for.
- email String
- The email address of the Google managed service account.
- 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.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- service String
- The service to generate identity for.
- email string
- The email address of the Google managed service account.
- 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.
- project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- service string
- The service to generate identity for.
- email str
- The email address of the Google managed service account.
- 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.
- project str
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- service str
- The service to generate identity for.
- email String
- The email address of the Google managed service account.
- 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.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- service 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.