Try AWS Native preview for resources not in the classic version.
AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi
aws.getPartition
Explore with Pulumi AI
Try AWS Native preview for resources not in the classic version.
AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi
Use this data source to lookup information about the current AWS partition in which the provider is working.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const current = aws.getPartition({});
const s3Policy = current.then(current => aws.iam.getPolicyDocument({
statements: [{
sid: "1",
actions: ["s3:ListBucket"],
resources: [`arn:${current.partition}:s3:::my-bucket`],
}],
}));
import pulumi
import pulumi_aws as aws
current = aws.get_partition()
s3_policy = aws.iam.get_policy_document(statements=[{
"sid": "1",
"actions": ["s3:ListBucket"],
"resources": [f"arn:{current.partition}:s3:::my-bucket"],
}])
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
"github.com/pulumi/pulumi-aws/sdk/v6/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{
{
Sid: pulumi.StringRef("1"),
Actions: []string{
"s3:ListBucket",
},
Resources: []string{
fmt.Sprintf("arn:%v:s3:::my-bucket", current.Partition),
},
},
},
}, nil)
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var current = Aws.GetPartition.Invoke();
var s3Policy = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Sid = "1",
Actions = new[]
{
"s3:ListBucket",
},
Resources = new[]
{
$"arn:{current.Apply(getPartitionResult => getPartitionResult.Partition)}:s3:::my-bucket",
},
},
},
});
});
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.GetPartitionArgs;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
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.getPartition();
final var s3Policy = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.sid("1")
.actions("s3:ListBucket")
.resources(String.format("arn:%s:s3:::my-bucket", current.applyValue(getPartitionResult -> getPartitionResult.partition())))
.build())
.build());
}
}
variables:
current:
fn::invoke:
Function: aws:getPartition
Arguments: {}
s3Policy:
fn::invoke:
Function: aws:iam:getPolicyDocument
Arguments:
statements:
- sid: '1'
actions:
- s3:ListBucket
resources:
- arn:${current.partition}:s3:::my-bucket
Using getPartition
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getPartition(args: GetPartitionArgs, opts?: InvokeOptions): Promise<GetPartitionResult>
function getPartitionOutput(args: GetPartitionOutputArgs, opts?: InvokeOptions): Output<GetPartitionResult>
def get_partition(id: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetPartitionResult
def get_partition_output(id: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetPartitionResult]
func GetPartition(ctx *Context, args *GetPartitionArgs, opts ...InvokeOption) (*GetPartitionResult, error)
func GetPartitionOutput(ctx *Context, args *GetPartitionOutputArgs, opts ...InvokeOption) GetPartitionResultOutput
> Note: This function is named GetPartition
in the Go SDK.
public static class GetPartition
{
public static Task<GetPartitionResult> InvokeAsync(GetPartitionArgs args, InvokeOptions? opts = null)
public static Output<GetPartitionResult> Invoke(GetPartitionInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetPartitionResult> getPartition(GetPartitionArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: aws:index/getPartition:getPartition
arguments:
# arguments dictionary
The following arguments are supported:
- Id string
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China).
- Id string
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China).
- id String
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China).
- id string
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China).
- id str
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China).
- id String
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China).
getPartition Result
The following output properties are available:
- Dns
Suffix string - Base DNS domain name for the current partition (e.g.,
amazonaws.com
in AWS Commercial,amazonaws.com.cn
in AWS China). - Id string
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China). - Partition string
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China). - Reverse
Dns stringPrefix - Prefix of service names (e.g.,
com.amazonaws
in AWS Commercial,cn.com.amazonaws
in AWS China).
- Dns
Suffix string - Base DNS domain name for the current partition (e.g.,
amazonaws.com
in AWS Commercial,amazonaws.com.cn
in AWS China). - Id string
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China). - Partition string
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China). - Reverse
Dns stringPrefix - Prefix of service names (e.g.,
com.amazonaws
in AWS Commercial,cn.com.amazonaws
in AWS China).
- dns
Suffix String - Base DNS domain name for the current partition (e.g.,
amazonaws.com
in AWS Commercial,amazonaws.com.cn
in AWS China). - id String
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China). - partition String
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China). - reverse
Dns StringPrefix - Prefix of service names (e.g.,
com.amazonaws
in AWS Commercial,cn.com.amazonaws
in AWS China).
- dns
Suffix string - Base DNS domain name for the current partition (e.g.,
amazonaws.com
in AWS Commercial,amazonaws.com.cn
in AWS China). - id string
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China). - partition string
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China). - reverse
Dns stringPrefix - 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
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China). - partition str
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China). - reverse_
dns_ strprefix - Prefix of service names (e.g.,
com.amazonaws
in AWS Commercial,cn.com.amazonaws
in AWS China).
- dns
Suffix String - Base DNS domain name for the current partition (e.g.,
amazonaws.com
in AWS Commercial,amazonaws.com.cn
in AWS China). - id String
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China). - partition String
- Identifier of the current partition (e.g.,
aws
in AWS Commercial,aws-cn
in AWS China). - reverse
Dns StringPrefix - Prefix of service names (e.g.,
com.amazonaws
in AWS Commercial,cn.com.amazonaws
in AWS China).
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.
Try AWS Native preview for resources not in the classic version.
AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi