shalupov / idea-cloudformation

AWS CloudFormation plugin for IntelliJ-based IDEs (IntelliJ IDEA, RubyMine, WebStorm, PhpStorm, PyCharm, AppCode, Android Studio, DataGrip, CLion)
https://teamcity.jetbrains.com/viewType.html?buildTypeId=IdeaAwsCloudFormation_Master_Build&guest=1
Apache License 2.0
136 stars 27 forks source link

rename refactor works but not as expected #88

Open sdole opened 7 years ago

sdole commented 7 years ago

I have a property like so: VolumeId: Ref: ApplicationDataVolume ApplicationDataVoume is a resource.

When I refactor ApplicationDataVolume with shift F6 key combo, it renames the resource, but the ref is renamed as so: VolumeId: Ref: "RenamedResource"

Those double quotes are not needed.

edthorne commented 6 years ago

If you're using the shorthand function syntax like so:

VolumeId: !Ref ApplicationDataVolume

The refactor results in:

VolumeId: "RenamedResource"

The shorthand function reference is lost during refactoring.

bamapookie commented 5 years ago

I have encountered this as well with the current version (0.6.11). In addition, References in a !Sub function are not replaced. Here is a small example:

AWSTemplateFormatVersion: '2010-09-09'

Parameters:
  OldName:
    Type: String

Resources:
  Resource:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: sample.yaml
      Parameters:
        SampleRef:
          Ref: OldName
        SampleShorthandRef: !Ref OldName
        SampleSub: !Sub ${OldName}

Renaming OldName to NewName, one would expect

AWSTemplateFormatVersion: '2010-09-09'

Parameters:
  NewName:
    Type: String

Resources:
  Resource:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: sample.yaml
      Parameters:
        SampleRef:
          Ref: NewName
        SampleShorthandRef: !Ref NewName
        SampleSub: !Sub ${NewName}

But instead, you get the following

AWSTemplateFormatVersion: '2010-09-09'

Parameters:
  NewName:
    Type: String

Resources:
  Resource:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: sample.yaml
      Parameters:
        SampleRef:
          Ref: "NewName" // Invalid quotes
        SampleShorthandRef: "NewName" // Missing !Ref and invalid quotes
        SampleSub: !Sub ${OldName} // No replacement