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

Issue #149 - Allow AWS::CloudFormation::Stack to return custom attributes when used in Fn::GetAtt #150

Merged
merged 2 commits into from
Apr 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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