private scrutinizableResourceChanges()

in packages/@aws-cdk/cloudformation-diff/lib/diff/types.ts [182:239]


  private scrutinizableResourceChanges(scrutinyTypes: ResourceScrutinyType[]): ResourceChange[] {
    const ret = new Array<ResourceChange>();

    for (const [resourceLogicalId, resourceChange] of Object.entries(this.resources.changes)) {
      if (!resourceChange) {
        continue;
      }

      const commonProps = {
        oldProperties: resourceChange.oldProperties,
        newProperties: resourceChange.newProperties,
        resourceLogicalId,
      };

      // changes to the Type of resources can happen when migrating from CFN templates that use Transforms
      if (resourceChange.resourceTypeChanged) {
        // Treat as DELETE+ADD
        if (resourceChange.oldResourceType) {
          const oldResourceModel = loadResourceModel(resourceChange.oldResourceType);
          if (oldResourceModel && this.resourceIsScrutinizable(oldResourceModel, scrutinyTypes)) {
            ret.push({
              ...commonProps,
              newProperties: undefined,
              resourceType: resourceChange.oldResourceType!,
              scrutinyType: oldResourceModel.scrutinizable!,
            });
          }
        }

        if (resourceChange.newResourceType) {
          const newResourceModel = loadResourceModel(resourceChange.newResourceType);
          if (newResourceModel && this.resourceIsScrutinizable(newResourceModel, scrutinyTypes)) {
            ret.push({
              ...commonProps,
              oldProperties: undefined,
              resourceType: resourceChange.newResourceType!,
              scrutinyType: newResourceModel.scrutinizable!,
            });
          }
        }
      } else {
        if (!resourceChange.resourceType) {
          continue;
        }

        const resourceModel = loadResourceModel(resourceChange.resourceType);
        if (resourceModel && this.resourceIsScrutinizable(resourceModel, scrutinyTypes)) {
          ret.push({
            ...commonProps,
            resourceType: resourceChange.resourceType,
            scrutinyType: resourceModel.scrutinizable!,
          });
        }
      }
    }

    return ret;
  }