silly-fireman-6851
03/19/2024, 9:22 PMimport pulumi
import pulumi_aws as aws
existing_bucket = aws.s3.get_bucket(bucket="my-bucket")
modified_or_new_bucket = aws.s3.Bucket(
"997911f256644644a1cc1c6d93d75e4fer",
bucket="my-bucket",
acl="private",
opts=pulumi.ResourceOptions(import_=existing_bucket.id),
)
pulumi.export("Bucket", modified_or_new_bucket.arn)
This throws an error if bucket is not present. which is valid. but how to deal with this scenariolittle-cartoon-10569
03/19/2024, 9:54 PMlittle-cartoon-10569
03/19/2024, 9:55 PMpulumi up
and you're re-running it to deploy changes), then your get-or-create code won't help: you know that the bucket is already managed.little-cartoon-10569
03/19/2024, 9:55 PMpulumi up
) then you are at the right point to decide whether or not to import the bucket. Pulumi doesn't do that bit: you do.