Viewing docs for AWS v6.83.1 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
published on Monday, Mar 9, 2026 by Pulumi
Viewing docs for AWS v6.83.1 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
published on Monday, Mar 9, 2026 by Pulumi
Provides details about a specific S3 bucket.
This resource may prove useful when setting up a Route53 record, or an origin for a CloudFront Distribution.
Example Usage
Route53 Record
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const selected = aws.s3.getBucket({
bucket: "bucket.test.com",
});
const testZone = aws.route53.getZone({
name: "test.com.",
});
const example = new aws.route53.Record("example", {
zoneId: testZone.then(testZone => testZone.id),
name: "bucket",
type: aws.route53.RecordType.A,
aliases: [{
name: selected.then(selected => selected.websiteDomain),
zoneId: selected.then(selected => selected.hostedZoneId),
}],
});
import pulumi
import pulumi_aws as aws
selected = aws.s3.get_bucket(bucket="bucket.test.com")
test_zone = aws.route53.get_zone(name="test.com.")
example = aws.route53.Record("example",
zone_id=test_zone.id,
name="bucket",
type=aws.route53.RecordType.A,
aliases=[{
"name": selected.website_domain,
"zone_id": selected.hosted_zone_id,
}])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/route53"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
selected, err := s3.LookupBucket(ctx, &s3.LookupBucketArgs{
Bucket: "bucket.test.com",
}, nil)
if err != nil {
return err
}
testZone, err := route53.LookupZone(ctx, &route53.LookupZoneArgs{
Name: pulumi.StringRef("test.com."),
}, nil)
if err != nil {
return err
}
_, err = route53.NewRecord(ctx, "example", &route53.RecordArgs{
ZoneId: pulumi.String(testZone.Id),
Name: pulumi.String("bucket"),
Type: pulumi.String(route53.RecordTypeA),
Aliases: route53.RecordAliasArray{
&route53.RecordAliasArgs{
Name: pulumi.String(selected.WebsiteDomain),
ZoneId: pulumi.String(selected.HostedZoneId),
},
},
})
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 selected = Aws.S3.GetBucket.Invoke(new()
{
Bucket = "bucket.test.com",
});
var testZone = Aws.Route53.GetZone.Invoke(new()
{
Name = "test.com.",
});
var example = new Aws.Route53.Record("example", new()
{
ZoneId = testZone.Apply(getZoneResult => getZoneResult.Id),
Name = "bucket",
Type = Aws.Route53.RecordType.A,
Aliases = new[]
{
new Aws.Route53.Inputs.RecordAliasArgs
{
Name = selected.Apply(getBucketResult => getBucketResult.WebsiteDomain),
ZoneId = selected.Apply(getBucketResult => getBucketResult.HostedZoneId),
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.S3Functions;
import com.pulumi.aws.s3.inputs.GetBucketArgs;
import com.pulumi.aws.route53.Route53Functions;
import com.pulumi.aws.route53.inputs.GetZoneArgs;
import com.pulumi.aws.route53.Record;
import com.pulumi.aws.route53.RecordArgs;
import com.pulumi.aws.route53.inputs.RecordAliasArgs;
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 selected = S3Functions.getBucket(GetBucketArgs.builder()
.bucket("bucket.test.com")
.build());
final var testZone = Route53Functions.getZone(GetZoneArgs.builder()
.name("test.com.")
.build());
var example = new Record("example", RecordArgs.builder()
.zoneId(testZone.id())
.name("bucket")
.type("A")
.aliases(RecordAliasArgs.builder()
.name(selected.websiteDomain())
.zoneId(selected.hostedZoneId())
.build())
.build());
}
}
resources:
example:
type: aws:route53:Record
properties:
zoneId: ${testZone.id}
name: bucket
type: A
aliases:
- name: ${selected.websiteDomain}
zoneId: ${selected.hostedZoneId}
variables:
selected:
fn::invoke:
function: aws:s3:getBucket
arguments:
bucket: bucket.test.com
testZone:
fn::invoke:
function: aws:route53:getZone
arguments:
name: test.com.
CloudFront Origin
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const selected = aws.s3.getBucket({
bucket: "a-test-bucket",
});
const test = new aws.cloudfront.Distribution("test", {origins: [{
domainName: selected.then(selected => selected.bucketDomainName),
originId: "s3-selected-bucket",
}]});
import pulumi
import pulumi_aws as aws
selected = aws.s3.get_bucket(bucket="a-test-bucket")
test = aws.cloudfront.Distribution("test", origins=[{
"domain_name": selected.bucket_domain_name,
"origin_id": "s3-selected-bucket",
}])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudfront"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
selected, err := s3.LookupBucket(ctx, &s3.LookupBucketArgs{
Bucket: "a-test-bucket",
}, nil)
if err != nil {
return err
}
_, err = cloudfront.NewDistribution(ctx, "test", &cloudfront.DistributionArgs{
Origins: cloudfront.DistributionOriginArray{
&cloudfront.DistributionOriginArgs{
DomainName: pulumi.String(selected.BucketDomainName),
OriginId: pulumi.String("s3-selected-bucket"),
},
},
})
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 selected = Aws.S3.GetBucket.Invoke(new()
{
Bucket = "a-test-bucket",
});
var test = new Aws.CloudFront.Distribution("test", new()
{
Origins = new[]
{
new Aws.CloudFront.Inputs.DistributionOriginArgs
{
DomainName = selected.Apply(getBucketResult => getBucketResult.BucketDomainName),
OriginId = "s3-selected-bucket",
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.S3Functions;
import com.pulumi.aws.s3.inputs.GetBucketArgs;
import com.pulumi.aws.cloudfront.Distribution;
import com.pulumi.aws.cloudfront.DistributionArgs;
import com.pulumi.aws.cloudfront.inputs.DistributionOriginArgs;
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 selected = S3Functions.getBucket(GetBucketArgs.builder()
.bucket("a-test-bucket")
.build());
var test = new Distribution("test", DistributionArgs.builder()
.origins(DistributionOriginArgs.builder()
.domainName(selected.bucketDomainName())
.originId("s3-selected-bucket")
.build())
.build());
}
}
resources:
test:
type: aws:cloudfront:Distribution
properties:
origins:
- domainName: ${selected.bucketDomainName}
originId: s3-selected-bucket
variables:
selected:
fn::invoke:
function: aws:s3:getBucket
arguments:
bucket: a-test-bucket
Using getBucket
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 getBucket(args: GetBucketArgs, opts?: InvokeOptions): Promise<GetBucketResult>
function getBucketOutput(args: GetBucketOutputArgs, opts?: InvokeOptions): Output<GetBucketResult>def get_bucket(bucket: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetBucketResult
def get_bucket_output(bucket: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetBucketResult]func LookupBucket(ctx *Context, args *LookupBucketArgs, opts ...InvokeOption) (*LookupBucketResult, error)
func LookupBucketOutput(ctx *Context, args *LookupBucketOutputArgs, opts ...InvokeOption) LookupBucketResultOutput> Note: This function is named LookupBucket in the Go SDK.
public static class GetBucket
{
public static Task<GetBucketResult> InvokeAsync(GetBucketArgs args, InvokeOptions? opts = null)
public static Output<GetBucketResult> Invoke(GetBucketInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetBucketResult> getBucket(GetBucketArgs args, InvokeOptions options)
public static Output<GetBucketResult> getBucket(GetBucketArgs args, InvokeOptions options)
fn::invoke:
function: aws:s3/getBucket:getBucket
arguments:
# arguments dictionaryThe following arguments are supported:
- Bucket string
- Name of the bucket
- Bucket string
- Name of the bucket
- bucket String
- Name of the bucket
- bucket string
- Name of the bucket
- bucket str
- Name of the bucket
- bucket String
- Name of the bucket
getBucket Result
The following output properties are available:
- Arn string
- ARN of the bucket. Will be of format
arn:aws:s3:::bucketname. - Bucket string
- Bucket
Domain stringName - Bucket domain name. Will be of format
bucketname.s3.amazonaws.com. - Bucket
Regional stringDomain Name - The bucket region-specific domain name. The bucket domain name including the region name. Please refer to the S3 endpoints reference for format. Note: AWS CloudFront allows specifying an S3 region-specific endpoint when creating an S3 origin. This will prevent redirect issues from CloudFront to the S3 Origin URL. For more information, see the Virtual Hosted-Style Requests for Other Regions section in the AWS S3 User Guide.
- Hosted
Zone stringId - The Route 53 Hosted Zone ID for this bucket's region.
- Id string
- The provider-assigned unique ID for this managed resource.
- Region string
- AWS region this bucket resides in.
- Website
Domain string - Domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records.
- Website
Endpoint string - Website endpoint, if the bucket is configured with a website. If not, this will be an empty string.
- Arn string
- ARN of the bucket. Will be of format
arn:aws:s3:::bucketname. - Bucket string
- Bucket
Domain stringName - Bucket domain name. Will be of format
bucketname.s3.amazonaws.com. - Bucket
Regional stringDomain Name - The bucket region-specific domain name. The bucket domain name including the region name. Please refer to the S3 endpoints reference for format. Note: AWS CloudFront allows specifying an S3 region-specific endpoint when creating an S3 origin. This will prevent redirect issues from CloudFront to the S3 Origin URL. For more information, see the Virtual Hosted-Style Requests for Other Regions section in the AWS S3 User Guide.
- Hosted
Zone stringId - The Route 53 Hosted Zone ID for this bucket's region.
- Id string
- The provider-assigned unique ID for this managed resource.
- Region string
- AWS region this bucket resides in.
- Website
Domain string - Domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records.
- Website
Endpoint string - Website endpoint, if the bucket is configured with a website. If not, this will be an empty string.
- arn String
- ARN of the bucket. Will be of format
arn:aws:s3:::bucketname. - bucket String
- bucket
Domain StringName - Bucket domain name. Will be of format
bucketname.s3.amazonaws.com. - bucket
Regional StringDomain Name - The bucket region-specific domain name. The bucket domain name including the region name. Please refer to the S3 endpoints reference for format. Note: AWS CloudFront allows specifying an S3 region-specific endpoint when creating an S3 origin. This will prevent redirect issues from CloudFront to the S3 Origin URL. For more information, see the Virtual Hosted-Style Requests for Other Regions section in the AWS S3 User Guide.
- hosted
Zone StringId - The Route 53 Hosted Zone ID for this bucket's region.
- id String
- The provider-assigned unique ID for this managed resource.
- region String
- AWS region this bucket resides in.
- website
Domain String - Domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records.
- website
Endpoint String - Website endpoint, if the bucket is configured with a website. If not, this will be an empty string.
- arn string
- ARN of the bucket. Will be of format
arn:aws:s3:::bucketname. - bucket string
- bucket
Domain stringName - Bucket domain name. Will be of format
bucketname.s3.amazonaws.com. - bucket
Regional stringDomain Name - The bucket region-specific domain name. The bucket domain name including the region name. Please refer to the S3 endpoints reference for format. Note: AWS CloudFront allows specifying an S3 region-specific endpoint when creating an S3 origin. This will prevent redirect issues from CloudFront to the S3 Origin URL. For more information, see the Virtual Hosted-Style Requests for Other Regions section in the AWS S3 User Guide.
- hosted
Zone stringId - The Route 53 Hosted Zone ID for this bucket's region.
- id string
- The provider-assigned unique ID for this managed resource.
- region string
- AWS region this bucket resides in.
- website
Domain string - Domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records.
- website
Endpoint string - Website endpoint, if the bucket is configured with a website. If not, this will be an empty string.
- arn str
- ARN of the bucket. Will be of format
arn:aws:s3:::bucketname. - bucket str
- bucket_
domain_ strname - Bucket domain name. Will be of format
bucketname.s3.amazonaws.com. - bucket_
regional_ strdomain_ name - The bucket region-specific domain name. The bucket domain name including the region name. Please refer to the S3 endpoints reference for format. Note: AWS CloudFront allows specifying an S3 region-specific endpoint when creating an S3 origin. This will prevent redirect issues from CloudFront to the S3 Origin URL. For more information, see the Virtual Hosted-Style Requests for Other Regions section in the AWS S3 User Guide.
- hosted_
zone_ strid - The Route 53 Hosted Zone ID for this bucket's region.
- id str
- The provider-assigned unique ID for this managed resource.
- region str
- AWS region this bucket resides in.
- website_
domain str - Domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records.
- website_
endpoint str - Website endpoint, if the bucket is configured with a website. If not, this will be an empty string.
- arn String
- ARN of the bucket. Will be of format
arn:aws:s3:::bucketname. - bucket String
- bucket
Domain StringName - Bucket domain name. Will be of format
bucketname.s3.amazonaws.com. - bucket
Regional StringDomain Name - The bucket region-specific domain name. The bucket domain name including the region name. Please refer to the S3 endpoints reference for format. Note: AWS CloudFront allows specifying an S3 region-specific endpoint when creating an S3 origin. This will prevent redirect issues from CloudFront to the S3 Origin URL. For more information, see the Virtual Hosted-Style Requests for Other Regions section in the AWS S3 User Guide.
- hosted
Zone StringId - The Route 53 Hosted Zone ID for this bucket's region.
- id String
- The provider-assigned unique ID for this managed resource.
- region String
- AWS region this bucket resides in.
- website
Domain String - Domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records.
- website
Endpoint String - Website endpoint, if the bucket is configured with a website. If not, this will be an empty string.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.
Viewing docs for AWS v6.83.1 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
published on Monday, Mar 9, 2026 by Pulumi
