https://pulumi.com logo
Title
m

mysterious-hairdresser-82060

04/17/2023, 7:26 PM
Is there a way to use Pulumi (Typescript) to make an S3 bucket in a particular region? Looking at the documentation (https://www.pulumi.com/registry/packages/aws/api-docs/s3/bucket/#inputs) I only see region as an output, not an input. If I were to manually create an S3 bucket, I get an option to select the region; is that option available in Pulumi as well? I tried using the
hostedZoneId
, but when I ran
pulumi up
, it seemed like it ignored that parameter and created the bucket in
us-west-2
instead of
us-east-1
const unitBucket = new aws.s3.Bucket("<my-bucket-name>", {
    hostedZoneId: "us-east-1",
});
r

red-match-15116

04/17/2023, 8:00 PM
You'll need to create a provider with the correct region and use that explicit provider in the s3 bucket call. https://www.pulumi.com/registry/packages/aws/api-docs/provider/
Like this:
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// Create an AWS provider for the us-east-1 region
const eastProvider = new aws.Provider("eastProvider", {
    region: "us-east-1",
});

// Create an S3 bucket in the us-east-1 region using the custom provider
const s3Bucket = new aws.s3.Bucket("myS3Bucket", {}, { provider: eastProvider });
m

mysterious-hairdresser-82060

04/17/2023, 9:20 PM
Thanks Komal! Let me try this out