Skip to main content

Pulumi - S3 Buckets

Resources

📘 Pulumi Docs > aws.s3.Bucket

Creating Buckets

Creating a bucket:

import * as pulumi from '@pulumi/pulumi';
import * as aws from '@pulumi/aws';

const bucket = new aws.s3.Bucket('BUCKET_NAME');
// export bucket id for later reference
export const bucketName = bucket.id;

Creating a bucket with options:

import * as pulumi from '@pulumi/pulumi';
import * as aws from '@pulumi/aws';

const bucket = new aws.s3.Bucket('BUCKET_NAME', {
website: {
indexDocument: 'index.html',
},
});

// export bucket id for later reference
export const bucketName = bucket.id;

Bucket Policies

To make the contents of a bucket public use the following:

const ownershipControls = new aws.s3.BucketOwnershipControls(
'ownership-controls',
{
bucket: bucket.id,
rule: {
objectOwnership: 'ObjectWriter',
},
},
);

const publicAccessBlock = new aws.s3.BucketPublicAccessBlock(
'public-access-block',
{
bucket: bucket.id,
blockPublicAcls: false,
},
);

Bucket Endpoint

If the bucket is configured as a website you can get the endpoint like this:

export const bucketEndpoint = pulumi.interpolate`http://${bucket.websiteEndpoint}`;

Comments

Recent Work

Free desktop AI Chat client, designed for developers and businesses. Unlocks advanced model settings only available in the API. Includes quality of life features like custom syntax highlighting.

Learn More

BidBear

bidbear.io

Bidbear is a report automation tool. It downloads Amazon Seller and Advertising reports, daily, to a private database. It then merges and formats the data into beautiful, on demand, exportable performance reports.

Learn More