--- title: "Creating an AWS S3 Bucket with Pulumi" meta_desc: "Learn how to use Pulumi to define an AWS S3 resource which can then be deployed to AWS and managed as infrastructure as code." meta_image: "/images/docs/service/aws-s3.png" service: "S3" description: "is object storage built to store and retrieve any amount of data from anywhere" aws_here: "https://aws.amazon.com/s3" menu: aws: name: S3 parent: aws-guides aliases: - /docs/aws/s3/ --- ## Create an AWS S3 resource using `@pulumi/aws` The `@pulumi/aws` library enables fine-grained control over the AWS S3 resource meaning it can be coded, deployed, and managed entirely in code. ```javascript 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 ] }] }); } ``` ## Create an AWS S3 bucket using `@pulumi/cloud` The `@pulumi/cloud` library provides a high-level abstraction over the AWS S3 resource ensuring the same code can be used in multi-cloud environments. ```javascript 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"); ```