AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.5.0 published on Wednesday, May 25, 2022 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/v5/go/aws"
	"github.com/pulumi/pulumi-aws/sdk/v5/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: pulumi.StringRef("1"),
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var current = Output.of(AwsFunctions.getPartition());

        final var s3Policy = Output.of(IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .actions("s3:ListBucket")
                .resources(String.format("arn:%s:s3:::my-bucket", current.apply(getPartitionResult -> getPartitionResult.partition())))
                .sid("1")
                .build())
            .build()));

    }
}
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",
    }],
}));
variables:
  current:
    Fn::Invoke:
      Function: aws:getPartition
      Arguments: {}
  s3Policy:
    Fn::Invoke:
      Function: aws:iam:getPolicyDocument
      Arguments:
        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)
}
public static CompletableFuture<GetPartitionResult> getPartition(InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: aws:index/getPartition:getPartition
  Arguments:
    # Arguments dictionary

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).

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).

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).

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.