terraform-cdk icon indicating copy to clipboard operation
terraform-cdk copied to clipboard

cdktf destroy with wildcard characters tries to destroy stacks that has not been deployed and can cause error

Open aadhikary opened this issue 1 year ago • 1 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

cdktf & Language Versions

cdktf v0.12.1 typescript

Affected Resource(s)

Deployed stacks cannot be easily torn down

Expected Behavior

CDKTF should look into the state file and if notthing is deployed for a stack then it should gracefully get out and proceed to next stack on the dependency hierarchy list

Actual Behavior

CDKTF tries to destroy stacks that do not exists and in some cases specially for Data constructs throws errors as : data.terraform_remote_state.cross-stack-reference-input-SiteBNetworking.outputs is object with no attributes Eventhough this stack has not been deployed at all.

I have seend this issue specially with Data construct for references

aadhikary avatar Aug 19 '22 08:08 aadhikary

Yeah, that is a good idea to improve the UX this way! We currently don't track if a deploy happened or not in CDKTF and therefore treat the stack selection as the complete truth of which stacks to destroy. Checking for an existing state and filtering out stacks without an existing state would be a good idea, I agree!

DanielMSchmidt avatar Aug 26 '22 08:08 DanielMSchmidt