0
votes

I am building my Cloudformation template to create an S3 Bucket.

I wanted to create folders in the bucket at the same time but I have read that I need to use a lambda backed resource.

So I've prepared the lambda part of my template but I need to add a condition :

  • If the lambda refers to a bucket which already exists

  • The bucket already exists and it has been created in this ( everything has to reside in one cloudformation stack) file

  • Call the lambda to create my folders.

I do not want to check if my bucket exists in S3 or if my folders already exist as S3 objects in the bucket.

I would like the lambda backed resource to be created after the bucket has been created.

1

1 Answers

0
votes

First of all - why you need directories at all? S3 is in fact a key-value store, "paths" are just prefixes. Usually there is no benefit of doing so other than human-friendly presentation.

Secondly - you can either use DependsOn to enforce proper order or resources provisioning, or (that would be a good practice I think) if you make Lambda generic and accept bucket name in your custom resource parameter, you just do it by using the Ref function, which implicitly creates dependency.