How can pulumi create users with access keys or bu...
# getting-started
s
How can pulumi create users with access keys or buckets which were filled? - for the users destroy instead of down was suggested by pulumi AI - for the full buckets:
Copy code
python
import pulumi
from pulumi_aws import s3

# Define the S3 bucket
bucket = s3.Bucket('mybucket')

# List all objects in the S3 bucket
objs = {}
bucket_list = s3.Bucket("bucketList", bucket = bucket.id)
for obj in bucket_list.objects:
    objs[obj.key] = s3.BucketObject(obj.key,
                                    bucket = bucket.id, 
                                    source = pulumi.FileAsset(obj.key))

# Export the name of the bucket
pulumi.export('BucketName', bucket.id)

# Register all objects for deletion
pulumi.Resource.register_outputs(**objs)
it suggested this for loop. But this seems to be insensibly slow in case the bucket has many elements - and should call the empty command instead. How can I tear down no longer needed resources including the side effects?
s
Setting
force_destroy
on the bucket will delete it even if it has objects in it. The synced folder package will give you functionality like
aws s3 sync
and should be a lot faster than a for loop for a large number of bucket objects. https://www.pulumi.com/registry/packages/synced-folder/
s
thanks