Abe Mused
Abe Mused

Reputation: 65

AWS Cloudformation: How do I check if a bucket exists from within the Cloudformation template?

In my CloudFormation template, I'm trying to create an S3 Bucket only if S3 doesn't already have a bucket that includes a certain keyword in it's name. For example, if my keyword is 'picture', I only want this S3 bucket to be created if no bucket in S3 contains the word 'picture' in its name.

    "Resources": {
        "myBucket": {
            "Condition" : "<NO_S3_BUCKET_WITH_'picture'_IN_ITS_NAME_IN_THIS_ACCOUNT>",
            "Type": "AWS::S3::Bucket",
            "Properties": {
                <SOME_PROPERTIES>
            }
        },
        <OTHER_RESOURCES>
    }

Is this possible? if so, can it be done with other AWS resources (CloudFront Distribution etc.)?

Upvotes: 1

Views: 1657

Answers (1)

Marcin
Marcin

Reputation: 238319

Is this possible?

Not with plain CloudFormation. You would have to develop a custom resource to do this.

Upvotes: 1

Related Questions