title | cloud | service | description | library | brand | og | ||||
---|---|---|---|---|---|---|---|---|---|---|
How to create an AWS S3 bucket with Pulumi |
AWS |
S3 |
is object storage built to store and retrieve any amount of data from anywhere |
@pulumi/aws |
aws |
|
This reference shows how to use Pulumi to define an {{ page.cloud }} {{ page.service }} resource using pure code which can then be deployed to {{ page.cloud }} and managed as infrastructure as code.

{{ page.cloud }} {{ page.service }} {{ page.description }}. Find out more at AWS here.
The {{ page.library }}
library enables fine-grained control over the {{ page.cloud }} {{ page.service }} resource meaning it can be coded, deployed, and managed entirely in code.
const aws = require("@pulumi/aws");
const bucket = new aws.s3.Bucket("my-bucket");
const bucketMetric = new aws.s3.BucketMetric("my-bucket-metric", {
bucket: bucket.bucket
});
const bucketNotification = new aws.s3.BucketNotification("my-bucket-notification", {
bucket: bucket.bucket
});
const bucketObject = new aws.s3.BucketObject("my-bucket-object", {
bucket: bucket.bucket,
content: "hello world"
});
const bucketPolicy = new aws.s3.BucketPolicy("my-bucket-policy", {
bucket: bucket.bucket,
policy: bucket.bucket.apply(publicReadPolicyForBucket)
})
function publicReadPolicyForBucket(bucketName: string) {
return JSON.stringify({
Version: "2012-10-17",
Statement: [{
Effect: "Allow",
Principal: "*",
Action: [
"s3:GetObject"
],
Resource: [
`arn:aws:s3:::${bucketName}/*` // policy refers to bucket name explicitly
]
}]
});
}
The @pulumi/cloud
library provides a high-level abstraction over the {{ page.cloud }} {{ page.service }} resource ensuring the same code can be used in multi-cloud environments.
const cloud = require("@pulumi/cloud-aws");
const aws = require("@pulumi/aws");
// A new bucket that will work in any cloud
const bucket = new cloud.Bucket("bucket");