I have created an S3 bucket to use with a <MWAA> e...
# aws
m
I have created an S3 bucket to use with a MWAA environment. When I run pulumi up, pulumi wants to delete and recreate the bucket:
Copy code
+  aws:s3:Bucket aaa creating
+  aws:s3:Bucket aaa creating error: 1 error occurred:
+  aws:s3:Bucket aaa **creating failed** error: 1 error occurred:

Diagnostics:
  aws:s3:Bucket (aaa):
    error: 1 error occurred:
    	* Error creating S3 bucket: BucketAlreadyOwnedByYou: Your previous request to create the named bucket succeeded and you already own it.
    	status code: 409, request id: Q3A6YB3N22Y5T7WW, host id: huiDWKeYcWdOUbIIjq/h4RlUSNCXA1yQG0l85af5uXLaZpVFsnHXVD5lUkP0QRmGTiPFLajBiwo=
How can I tell pulumi to recognise the existing bucket so that it doesn’t try to delete and recreate it? I get the same error when I run pulumi locally (v3.32.1) and through a github action (v3.31.0)
v
did you create the bucket with pulumi?
m
Yes
v
hmm, maybe try running a
pulumi refresh
m
I tried that already
v
can you send the full log trace? where it says its deleting and recreating it? i’ve never experienced anything like this with pulumi before tbh
if its just trying to create, and not delete it, then its indicative that the bucket was created with another pulumi stack or by other means, and its trying to recreate the bucket. if thats the case then i’d recommend importing the resource in to pulumi
m
It is trying to delete it as well - I’ll send the preview log trace one sec
Copy code
~  aws:s3:Bucket aaa refreshing 

@ previewing update.....
+  aws:s3:Bucket aaa create  
-  aws:s3:Bucket aaa delete
Note that I haven’t included the full log because the stack is quite large
v
so its trying to create it before it deletes it? thats a bit strange. have you tried removing the resource definition altogether and putting it back in
m
Resource definition ?
Sorry I’m not familiar with that
b
@most-state-94104 can you show the diff from pulumi preview ?
👀 1
This usually happens because the resource name is changing on each run, also sharing the code you're using to define the bucket helps
m
The name is the same (it doesn’t include a sha)
Unfortunately the repo is internal, so I’ll have to post the details here. Give me a minute
b
The diff output will help as well
m
Sorry the bucket is created through another internal repo and is quite complex (it includes various optional settings) so not the easiest to share. Will post this afternoon (along with the diff) 🙂
v
if the bucket is created by another repo, then thats why you’re getting the error
you’re trying to create a bucket with the same name twice
S3 buckets’ names are globally defined, therefor each bucket name has to be unique, if you’re trying to reference the same bucket from another stack, I’d recommend using pulumi stack references to achieve this: https://www.pulumi.com/learn/building-with-pulumi/stack-references/
m
Sorry what I meant is that the function for creating the bucket is defined in another repo and packaged as a library
v
ah right ok
m
We create the bucket by calling the function in the repo where the rest of the stack is created
v
if you could send some snippets over that would be really helpful
m
I’m going to ask my manager why the repo is internal - I can’t see anything sensitive
Reached out to my colleague and turns out the problem is because I reset the PULUMI_CONFIG_PASSPHRASE. This meant pulumi was trying to recreate the stack, so the solution is to revert the stack from a backup
👍 2