cloudformation-coverage-roadmap icon indicating copy to clipboard operation
cloudformation-coverage-roadmap copied to clipboard

[Resource Type] - [BUG] - aws cloudformation create-stack-refactor does not allow logicalID rename in the same stack

Open emakunin opened this issue 5 months ago • 1 comments

Name of the resource

AWS::CloudFormation::Stack

Resource Name

No response

Issue Description

Hello,

I'm not 100% sure this is the right place to open a bug report, but I haven't found any better ones.

I'm using CDK to define my AWS infrastructure and as many other devs struggle with refactorings when my construct IDs change. I'm trying to follow the new cloudformation-stack-refactoring tutorial and docs to just change a resourceId in my stack name. But apparently it doesn't work or lacks documentation.

  1. The guide and the doc provided does not really address a simple and common case where I just want to change the resource ID without moving resources
  2. It seems there's a bug in the process of renaming.

I do the following

  1. env AWS_PROFILE=beta aws cloudformation get-template --stack-name BETA-Stack > stack.json (the stack was deployed by CDK)
  2. I replace resourceIds in the template and uppload it to s3
  3. Create refactor.json. (!) I tried with this file and without it. The failure is the same
     [
       {
         "Source": {
           "StackName": "BETA-Stack",
           "LogicalResourceId": "DbBETAB7A059FA"
         },
         "Destination": {
           "StackName": "BETA-Stack",
           "LogicalResourceId": "DbBETATableA5856A01"
         }
       }
     ]
    
  4.  env AWS_PROFILE=beta aws cloudformation create-stack-refactor \
         --stack-definitions 'StackName=BETA-Stack,TemplateURL=https://my-bucket-beta.s3.eu-west-1.amazonaws.com/stack.json' \
         --no-enable-stack-creation \
         --resource-mappings [file://refactor.json](file:///refactor.json)  ### Tried with and without this line
    
  5. env AWS_PROFILE=beta aws cloudformation describe-stack-refactor --stack-refactor-id 634564be-7c49-416a-9f59-96f2232c4b0d
"StackRefactorId": "9124e18c-7de0-4b54-98c7-e601ad7eeb3b",
"StackIds": [
    "arn:aws:cloudformation:eu-west-1:741448951753:stack/BETA-Stack/724e1900-d267-11ef-9091-02bf3a1c4d63"
],
"ExecutionStatus": "UNAVAILABLE",
"Status": "CREATE_FAILED",
"StatusReason": "arn:aws:cloudformation:eu-west-1:741448951753:stack/BETA-Stack/724e1900-d267-11ef-9091-02bf3a1c4d63: Parameter values specified for a template which does not require them."

}

Expected Behavior

  1. Refactor should suceed
  2. It's the basic (possible the most simple and common) case. It should be documented

Observed Behavior

"StackRefactorId": "9124e18c-7de0-4b54-98c7-e601ad7eeb3b",
"StackIds": [
    "arn:aws:cloudformation:eu-west-1:741448951753:stack/BETA-Stack/724e1900-d267-11ef-9091-02bf3a1c4d63"
],
"ExecutionStatus": "UNAVAILABLE",
"Status": "CREATE_FAILED",
"StatusReason": "arn:aws:cloudformation:eu-west-1:741448951753:stack/BETA-Stack/724e1900-d267-11ef-9091-02bf3a1c4d63: Parameter values specified for a template which does not require them."

Test Cases

N/A

Other Details

No response

emakunin avatar May 23 '25 08:05 emakunin