Reputation: 551
How to set condition in CloudFormation template that it should use a certain S3 bucket if it exists (bucket will have DeletionPolicy: Retain) or should create it if it doesn't exist.
Importing resources won't work because bucket won't be there during the first stack creation.
Upvotes: 2
Views: 1265
Reputation: 238269
There is no such functionality in plain CloudFormation. The only choice is to use custom resource.
This is a special type of resource which you have to develop yourself. This is mostly done by means of Lambda Function. So your template would use lambda function in the form of a custom resource to create/check if a given bucket exist or not.
Upvotes: 1