From 7f692216559028a223e4bdf4cc79f16604629f9a Mon Sep 17 00:00:00 2001 From: RazzM13 <34776591+RazzM13@users.noreply.github.com> Date: Thu, 26 Apr 2018 12:10:16 +0300 Subject: [PATCH] Force validation for "AWS::CloudFormation::Stack" attributes. --- src/test/validatorTest.ts | 8 ++++++++ src/validator.ts | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/test/validatorTest.ts b/src/test/validatorTest.ts index da5acf0..195e450 100644 --- a/src/test/validatorTest.ts +++ b/src/test/validatorTest.ts @@ -480,6 +480,14 @@ describe('validator', () => { expect(result['errors']['crit'][1]).to.have.property('message', "Expecting a list, got 'INVALID_REFERENCE_OR_ATTR_ON_GET_ATT'"); expect(result['errors']['warn']).to.have.lengthOf(0); }); + + it("should pass validation where !GetAtt returns some unexpected attribute for AWS::CloudFormation::Stack", () => { + const input = 'testData/valid/yaml/issue-149-valid-fngetatt-aws_cloudformation_stack.yaml'; + let result = validator.validateFile(input); + expect(result).to.have.deep.property('templateValid', true); + expect(result['errors']['crit']).to.have.lengthOf(0); + expect(result['errors']['warn']).to.have.lengthOf(0); + }); }) describe('conditions', () => { diff --git a/src/validator.ts b/src/validator.ts index 0ebefc8..e766267 100644 --- a/src/validator.ts +++ b/src/validator.ts @@ -1085,7 +1085,10 @@ export function fnGetAtt(reference: string, attributeName: string){ return `mockAttr_${reference}_${attributeName}`; } else if (resource['Type'] === 'AWS::CloudFormation::CustomResource') { return `mockAttr_${reference}_${attributeName}`; - } else { + } else if (resource['Type'] === 'AWS::CloudFormation::Stack') { + return `mockAttr_${reference}_${attributeName}`; + } + else { try { // Lookup attribute const attribute = resourcesSpec.getResourceTypeAttribute(resource['Type'], attributeName)