AWS Classic

v4.30.0 published on Tuesday, Nov 30, 2021 by Pulumi

getPartition

Use this data source to lookup current AWS partition in which this provider is working

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var current = Output.Create(Aws.GetPartition.InvokeAsync());
        var s3Policy = current.Apply(current => Output.Create(Aws.Iam.GetPolicyDocument.InvokeAsync(new Aws.Iam.GetPolicyDocumentArgs
        {
            Statements = 
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementArgs
                {
                    Actions = 
                    {
                        "s3:ListBucket",
                    },
                    Resources = 
                    {
                        $"arn:{current.Partition}:s3:::my-bucket",
                    },
                    Sid = "1",
                },
            },
        })));
    }

}
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-aws/sdk/v4/go/aws"
	"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/iam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		current, err := aws.GetPartition(ctx, nil, nil)
		if err != nil {
			return err
		}
		_, err = iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				iam.GetPolicyDocumentStatement{
					Actions: []string{
						"s3:ListBucket",
					},
					Resources: []string{
						fmt.Sprintf("%v%v%v", "arn:", current.Partition, ":s3:::my-bucket"),
					},
					Sid: "1",
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_aws as aws

current = aws.get_partition()
s3_policy = aws.iam.get_policy_document(statements=[aws.iam.GetPolicyDocumentStatementArgs(
    actions=["s3:ListBucket"],
    resources=[f"arn:{current.partition}:s3:::my-bucket"],
    sid="1",
)])
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const current = pulumi.output(aws.getPartition());
const s3Policy = current.apply(current => aws.iam.getPolicyDocument({
    statements: [{
        actions: ["s3:ListBucket"],
        resources: [`arn:${current.partition}:s3:::my-bucket`],
        sid: "1",
    }],
}));

Using getPartition

function getPartition(opts?: InvokeOptions): Promise<GetPartitionResult>
def get_partition(opts: Optional[InvokeOptions] = None) -> GetPartitionResult
func GetPartition(ctx *Context, opts ...InvokeOption) (*GetPartitionResult, error)

> Note: This function is named GetPartition in the Go SDK.

public static class GetPartition 
{
    public static Task<GetPartitionResult> InvokeAsync(InvokeOptions? opts = null)
}

getPartition Result

The following output properties are available:

DnsSuffix string
Base DNS domain name for the current partition (e.g., amazonaws.com in AWS Commercial, amazonaws.com.cn in AWS China).
Id string
The provider-assigned unique ID for this managed resource.
Partition string
Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
ReverseDnsPrefix string
Prefix of service names (e.g., com.amazonaws in AWS Commercial, cn.com.amazonaws in AWS China).
DnsSuffix string
Base DNS domain name for the current partition (e.g., amazonaws.com in AWS Commercial, amazonaws.com.cn in AWS China).
Id string
The provider-assigned unique ID for this managed resource.
Partition string
Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
ReverseDnsPrefix string
Prefix of service names (e.g., com.amazonaws in AWS Commercial, cn.com.amazonaws in AWS China).
dnsSuffix string
Base DNS domain name for the current partition (e.g., amazonaws.com in AWS Commercial, amazonaws.com.cn in AWS China).
id string
The provider-assigned unique ID for this managed resource.
partition string
Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
reverseDnsPrefix string
Prefix of service names (e.g., com.amazonaws in AWS Commercial, cn.com.amazonaws in AWS China).
dns_suffix str
Base DNS domain name for the current partition (e.g., amazonaws.com in AWS Commercial, amazonaws.com.cn in AWS China).
id str
The provider-assigned unique ID for this managed resource.
partition str
Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
reverse_dns_prefix str
Prefix of service names (e.g., com.amazonaws in AWS Commercial, cn.com.amazonaws in AWS China).

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.