Is there an existing issue for this?
Current Behavior
When deleting a CloudFormation stack that contains conditional resources (Condition: attribute) where the condition evaluated to false during creation, the v2 engine fails with:
Template format error: Unresolved resource dependencies [MyQueue] in the Resources block of the template
The stack was created successfully, but deletion fails even though the referenced resource (MyQueue) was never created.
Expected Behavior
Stack should delete successfully since the conditional resource was never created. The legacy engine (PROVIDER_OVERRIDE_CLOUDFORMATION=engine-legacy) handles this correctly.
How are you starting LocalStack?
With a docker run command
Steps To Reproduce
- Start LocalStack (v2 engine - default):
docker run -d -p 4566:4566 \
-e SERVICES=cloudformation,sqs \
localstack/localstack
- Save this template as
template.yaml:
AWSTemplateFormatVersion: '2010-09-09'
Description: Minimal reproduction of CloudFormation v2 deletion bug
Parameters:
DeployQueue:
Type: String
Default: 'true'
AllowedValues:
- 'true'
- 'false'
Conditions:
ShouldDeployQueue: !Equals [!Ref DeployQueue, 'true']
Resources:
# This resource is conditionally created
MyQueue:
Type: AWS::SQS::Queue
Condition: ShouldDeployQueue
Properties:
QueueName: conditional-queue
# This resource always exists but references the conditional resource
AlwaysCreatedResource:
Type: AWS::SQS::Queue
Properties:
QueueName: always-created-queue
Tags:
- Key: ConditionalQueueArn
Value: !If
- ShouldDeployQueue
- !GetAtt MyQueue.Arn
- "not-deployed"
Outputs:
AlwaysCreatedQueueUrl:
Value: !Ref AlwaysCreatedResource
- Create the stack with
DeployQueue=false (so MyQueue is NOT created):
awslocal cloudformation create-stack \
--stack-name repro-bug \
--template-body file://template.yaml \
--parameters ParameterKey=DeployQueue,ParameterValue=false
awslocal cloudformation wait stack-create-complete --stack-name repro-bug
- Delete the stack:
awslocal cloudformation delete-stack --stack-name repro-bug
Result: Deletion fails with "Unresolved resource dependencies [MyQueue]"
Environment
- OS: macOS / Linux
- LocalStack version: 4.12.1
Anything else?
The v2 engine incorrectly resolves !GetAtt MyQueue.Arn during deletion even when MyQueue was never created (because ShouldDeployQueue condition was false).
Workaround: Use PROVIDER_OVERRIDE_CLOUDFORMATION=engine-legacy
Related: zeroae/zae-limiter#85
Is there an existing issue for this?
Current Behavior
When deleting a CloudFormation stack that contains conditional resources (
Condition:attribute) where the condition evaluated tofalseduring creation, the v2 engine fails with:The stack was created successfully, but deletion fails even though the referenced resource (
MyQueue) was never created.Expected Behavior
Stack should delete successfully since the conditional resource was never created. The legacy engine (
PROVIDER_OVERRIDE_CLOUDFORMATION=engine-legacy) handles this correctly.How are you starting LocalStack?
With a
docker runcommandSteps To Reproduce
template.yaml:DeployQueue=false(soMyQueueis NOT created):awslocal cloudformation create-stack \ --stack-name repro-bug \ --template-body file://template.yaml \ --parameters ParameterKey=DeployQueue,ParameterValue=false awslocal cloudformation wait stack-create-complete --stack-name repro-bugResult: Deletion fails with "Unresolved resource dependencies [MyQueue]"
Environment
Anything else?
The v2 engine incorrectly resolves
!GetAtt MyQueue.Arnduring deletion even whenMyQueuewas never created (becauseShouldDeployQueuecondition wasfalse).Workaround: Use
PROVIDER_OVERRIDE_CLOUDFORMATION=engine-legacyRelated: zeroae/zae-limiter#85