Cybex
Cybex

Reputation: 551

How to force CloudFormation to use specific S3 bucket if it exists or create it otherwise?

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

Answers (1)

Marcin
Marcin

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

Related Questions