aws-cloudformation / rain

A development workflow tool for working with AWS CloudFormation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tree command misses some resource dependencies

dhx-mike-palandra opened this issue · comments

$ rain --version
Rain v1.8.1 linux/amd64

Consider the following template:

Parameters:
  BackupPlanId:
    Type: String

Resources:
  BackupSelection:
    Type: AWS::Backup::BackupSelection
    Properties:
      BackupPlanId: !Ref BackupPlanId
      BackupSelection:
        IamRoleArn: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/service-role/AWSBackupDefaultServiceRole
        Resources:
          - !Sub arn:${AWS::Partition}:elasticfilesystem:${AWS::Region}:${AWS::AccountId}:file-system/${EfsFileSystem}
        SelectionName: !Sub ${AWS::StackName}

  EfsFileSystem:
    Type: AWS::EFS::FileSystem

rain tree outputs the following:

Resources:
  BackupSelection:
    DependsOn:
      Parameters:
        - AWS::Partition
        - AWS::StackName
        - BackupPlanId

Notice that the following dependencies are missing:

  1. Parameter AWS::AccountId (referenced in Resources.BackupSelection.Properties.BackupSelection.IamRoleArn)
  2. Resource EfsFileSystem (referenced in property Resources.BackupSelection.Properties.BackupSelection.Resources[0])

If Resources.BackupSelection.Properties.BackupSelection.Resources[0] is changed to !Sub ${EfsFileSystem.Arn}, the resource dependency is found:

Resources:
  BackupSelection:
    DependsOn:
      Parameters:
        - AWS::Partition
        - AWS::StackName
        - BackupPlanId
      Resources:
        - EfsFileSystem

Looks like it misses a dependency on AWS::Region too.

I have a feeling that the current code does not look past the first interpolation in a Fn::Sub string.