How to reuse a created resource in CloudFormation

18 Views Asked by At

In my stack, I need to use some loggroup. I create it like this.

   MyLog:
     Type: AWS::Logs::LogGroup
     Properties:
       LogGroupName: !Sub "/aws/logs/abc-loggroup"

But when I make some changes and rerun the stack. I receive error messages like this: /aws/logs/abc-loggroup already exists in stack arn:aws:cloudformation:xxxxxxx

Because the loggroup was already created in the first run. But I cannot remove the code of creating it, because it needs to be pushed and run in the higher environment.

Is there a way that I can reuse the created resource or create it conditionally by checking the existence of the resource first?

0

There are 0 best solutions below