AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.10.0 published on Monday, Jul 11, 2022 by Pulumi

getBucketPolicy

The bucket policy data source returns IAM policy of an S3 bucket.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var example = Output.Create(Aws.S3.GetBucketPolicy.InvokeAsync(new Aws.S3.GetBucketPolicyArgs
        {
            Bucket = "example-bucket-name",
        }));
        this.Foo = example.Apply(example => example.Policy);
    }

    [Output("foo")]
    public Output<string> Foo { get; set; }
}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/s3"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := s3.LookupBucketPolicy(ctx, &s3.LookupBucketPolicyArgs{
			Bucket: "example-bucket-name",
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("foo", example.Policy)
		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 example = Output.of(S3Functions.getBucketPolicy(GetBucketPolicyArgs.builder()
            .bucket("example-bucket-name")
            .build()));

        ctx.export("foo", example.apply(getBucketPolicyResult -> getBucketPolicyResult.policy()));
    }
}
import pulumi
import pulumi_aws as aws

example = aws.s3.get_bucket_policy(bucket="example-bucket-name")
pulumi.export("foo", example.policy)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = aws.s3.getBucketPolicy({
    bucket: "example-bucket-name",
});
export const foo = example.then(example => example.policy);
variables:
  example:
    Fn::Invoke:
      Function: aws:s3:getBucketPolicy
      Arguments:
        bucket: example-bucket-name
outputs:
  foo: ${example.policy}

Using getBucketPolicy

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 getBucketPolicy(args: GetBucketPolicyArgs, opts?: InvokeOptions): Promise<GetBucketPolicyResult>
function getBucketPolicyOutput(args: GetBucketPolicyOutputArgs, opts?: InvokeOptions): Output<GetBucketPolicyResult>
def get_bucket_policy(bucket: Optional[str] = None,
                      opts: Optional[InvokeOptions] = None) -> GetBucketPolicyResult
def get_bucket_policy_output(bucket: Optional[pulumi.Input[str]] = None,
                      opts: Optional[InvokeOptions] = None) -> Output[GetBucketPolicyResult]
func LookupBucketPolicy(ctx *Context, args *LookupBucketPolicyArgs, opts ...InvokeOption) (*LookupBucketPolicyResult, error)
func LookupBucketPolicyOutput(ctx *Context, args *LookupBucketPolicyOutputArgs, opts ...InvokeOption) LookupBucketPolicyResultOutput

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

public static class GetBucketPolicy 
{
    public static Task<GetBucketPolicyResult> InvokeAsync(GetBucketPolicyArgs args, InvokeOptions? opts = null)
    public static Output<GetBucketPolicyResult> Invoke(GetBucketPolicyInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetBucketPolicyResult> getBucketPolicy(GetBucketPolicyArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: aws:s3/getBucketPolicy:getBucketPolicy
  Arguments:
    # Arguments dictionary

The following arguments are supported:

Bucket string

The bucket name.

Bucket string

The bucket name.

bucket String

The bucket name.

bucket string

The bucket name.

bucket str

The bucket name.

bucket String

The bucket name.

getBucketPolicy Result

The following output properties are available:

Bucket string
Id string

The provider-assigned unique ID for this managed resource.

Policy string

IAM bucket policy.

Bucket string
Id string

The provider-assigned unique ID for this managed resource.

Policy string

IAM bucket policy.

bucket String
id String

The provider-assigned unique ID for this managed resource.

policy String

IAM bucket policy.

bucket string
id string

The provider-assigned unique ID for this managed resource.

policy string

IAM bucket policy.

bucket str
id str

The provider-assigned unique ID for this managed resource.

policy str

IAM bucket policy.

bucket String
id String

The provider-assigned unique ID for this managed resource.

policy String

IAM bucket policy.

Package Details

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

This Pulumi package is based on the aws Terraform Provider.