diff --git a/CHANGELOG.md b/CHANGELOG.md index ffc504d..138842d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Merge PR #150, allow AWS::CloudFormation::Stack to return custom attributes when used in Fn::GetAtt ## [1.6.1] - 2018-04-25 ### Fixed 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) diff --git a/testData/valid/yaml/issue-149-valid-fngetatt-aws_cloudformation_stack.yaml b/testData/valid/yaml/issue-149-valid-fngetatt-aws_cloudformation_stack.yaml new file mode 100644 index 0000000..8a12e92 --- /dev/null +++ b/testData/valid/yaml/issue-149-valid-fngetatt-aws_cloudformation_stack.yaml @@ -0,0 +1,10 @@ +AWSTemplateFormatVersion: '2010-09-09' +Resources: + InfrastructurePipeline: + Type: "AWS::CloudFormation::Stack" + Properties: + TemplateURL: "https://s3.amazonaws.com/templates/myTemplate.template?versionId=123ab1cdeKdOW5IH4GAcYbEngcpTJTDW" +Outputs: + InfrastructurePipelineUrl: + Description: The continuous deployment pipeline in the AWS Management Console. + Value: !GetAtt InfrastructurePipeline.Outputs.PipelineUrl