Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Commit

Permalink
Force validation for "AWS::CloudFormation::Stack" attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
RazzM13 committed Apr 26, 2018
1 parent ae2ac8c commit 97065ce
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/test/validatorTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
5 changes: 4 additions & 1 deletion src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 97065ce

Please sign in to comment.