In a CFT, how to create a resource only if doesn't already exist

0

I have searched and searched, but can't find an answer to this. If I create a CFT, run it, then want to add more resources and update it, how do I configure it so that it won't gack when it tries to recreate the existing resoures?

  • "how do I configure it so that it won't gack when it tries to recreate the existing resoures?" Can you explain more?

    1. Please tell what you are doing?
    2. Please tell what you wanted to achive?
    3. Please tell your problem you are facing
    4. Past an error it will help more. You said, you are creating CFT and addimg more resources, make sense its normal, then you are saying it won't back or roll back when it tries to recreate existing resources. Its not possible for CFT to re-create existing resources untill unless you are touching those parameteres or attributes which needs resoruce replacment.
kkohut
demandé il y a 2 ans2899 vues
1 réponse
1

Hi, @kkohut.

It is not provided as a basic function.
So you need to think of another workaround according to the failure case you assume.

If you fail to create a resource due to conflicting names due to some conditions when creating it in a stack (for example, RDS Identifier), even if you want to create a new stack or resource so that existing resources are not affected For example, resource names can be made unique by including the AWS::StackName and AWS::StackId variables.

If you need more complex conditions than that, you can use custom resources to check existing resources in your Lambda function.
However, using a custom resource does not associate an existing resource with your stack.
Notice that the CloudFormation resource is relative to his stack.

profile picture
EXPERT
iwasa
répondu il y a 2 ans
profile pictureAWS
EXPERT
Chris_G
vérifié il y a 2 ans
  • I don't think you understand what I am trying to do. I have a CFT that creates resources. One of the resources is an S3 bucket. I want to modify the CFT to create some additional resources. SO I add those additional resources to the CFT, and run it again. But it fails, because it tries to create the S3 bucket again. I thought there was a way to indicate in the CFT to only create the resource if it doesn't already exist.

  • Are you creating new when you add resources to the stack? Why no stack update?

  • I guess you are not using CFT update option, you are creating new stack and that is why it is creating new resources. Can you share your error or screenshot?

  • @hash thank you for following me

    @kkohut If you want to add another resource to the stack without affecting existing resources, you should change the template and update the stack.

    It is possible to create a new stack, but since it will all be created with different resources, it is necessary to devise ways to make parameters with unique restrictions unique as described above.

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions