get Service Principal
Use this data source to create a Service Principal Name for a service in a given region. Service Principal Names should always end in the standard global format: {servicename}.amazonaws.com
. However, in some AWS partitions, AWS may expect a different format.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const current = aws.getServicePrincipal({
serviceName: "s3",
});
const test = aws.getServicePrincipal({
serviceName: "s3",
region: "us-iso-east-1",
});
Content copied to clipboard
import pulumi
import pulumi_aws as aws
current = aws.get_service_principal(service_name="s3")
test = aws.get_service_principal(service_name="s3",
region="us-iso-east-1")
Content copied to clipboard
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var current = Aws.GetServicePrincipal.Invoke(new()
{
ServiceName = "s3",
});
var test = Aws.GetServicePrincipal.Invoke(new()
{
ServiceName = "s3",
Region = "us-iso-east-1",
});
});
Content copied to clipboard
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := aws.GetServicePrincipal(ctx, &aws.GetServicePrincipalArgs{
ServiceName: "s3",
}, nil)
if err != nil {
return err
}
_, err = aws.GetServicePrincipal(ctx, &aws.GetServicePrincipalArgs{
ServiceName: "s3",
Region: pulumi.StringRef("us-iso-east-1"),
}, nil)
if err != nil {
return err
}
return nil
})
}
Content copied to clipboard
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.AwsFunctions;
import com.pulumi.aws.inputs.GetServicePrincipalArgs;
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 current = AwsFunctions.getServicePrincipal(GetServicePrincipalArgs.builder()
.serviceName("s3")
.build());
final var test = AwsFunctions.getServicePrincipal(GetServicePrincipalArgs.builder()
.serviceName("s3")
.region("us-iso-east-1")
.build());
}
}
Content copied to clipboard
variables:
current:
fn::invoke:
function: aws:getServicePrincipal
arguments:
serviceName: s3
test:
fn::invoke:
function: aws:getServicePrincipal
arguments:
serviceName: s3
region: us-iso-east-1
Content copied to clipboard
Return
A collection of values returned by getServicePrincipal.
Parameters
argument
A collection of arguments for invoking getServicePrincipal.
suspend fun getServicePrincipal(region: String? = null, serviceName: String): GetServicePrincipalResult
Return
A collection of values returned by getServicePrincipal.
Parameters
region
Region you'd like the SPN for. By default, uses the current region.
service Name
Name of the service you want to generate a Service Principal Name for.
See also
suspend fun getServicePrincipal(argument: suspend GetServicePrincipalPlainArgsBuilder.() -> Unit): GetServicePrincipalResult
Return
A collection of values returned by getServicePrincipal.
Parameters
argument
Builder for com.pulumi.aws.kotlin.inputs.GetServicePrincipalPlainArgs.