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

Commit

Permalink
Fixes validation of AWS::URLSuffix (#174)
Browse files Browse the repository at this point in the history
* Add AWS::URLSuffix to reference value overrides

This adds the AWS::URLSuffix to the reference value overrides reference
data, as well as to the type used for this value in code.

This is a perfectly valid pseudo parameter (as per
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html#cfn-pseudo-param-urlsuffix)
but was causing an error at
https://github.com/nskoufis/cfn-lint/blob/master/src/validator.ts#L680

* Removing package-lock - not decided upon yet

* Add a test that ensures that the new pseudo param parses correctly

This adds a very simple test that ensures that my minimum working broken
example now passes.
  • Loading branch information
nskoufis authored and martysweet committed Jun 30, 2018
1 parent a6fad27 commit 0f6f1b5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion data/aws_ref_override.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"AWS::NotificationARNs": ["arn:aws:sns:us-east-1:123456789012:MyTopic"],
"AWS::Region": "eu-west-1",
"AWS::StackId": "AWSREFSTACKID",
"AWS::StackName": "AWSREFSTACKNAME"
"AWS::StackName": "AWSREFSTACKNAME",
"AWS::URLSuffix": "amazonaws.com"
}
1 change: 1 addition & 0 deletions src/awsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ type RefOverrides = {
"AWS::Region": string,
"AWS::StackId": string,
"AWS::StackName": string,
"AWS::URLSuffix": string,
[refOverride: string]: any
};

Expand Down
8 changes: 8 additions & 0 deletions src/test/validatorTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,14 @@ describe('validator', () => {
expect(result['errors']['crit']).to.have.lengthOf(0);
expect(result['errors']['warn']).to.have.lengthOf(0);
});

it('using the pseudo parameter AWS::URLSuffix should result in validTemplate = true, no crit errors, no warnings', () => {
const input = 'testData/valid/yaml/issue-173-url-suffix-pseudo-parameter.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('custom-resource-attributes', () => {
Expand Down
12 changes: 12 additions & 0 deletions testData/valid/yaml/issue-173-url-suffix-pseudo-parameter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Resources:
TestLambdaPermissionEventsRuleSchedule1:
Type: AWS::Lambda::Permission
Properties:
FunctionName: test
Action: lambda:InvokeFunction
Principal:
Fn::Join:
- ''
- - events.
- Ref: AWS::URLSuffix
SourceArn: arn:aws:lambda:us-east-1:123456789012:function:Test

0 comments on commit 0f6f1b5

Please sign in to comment.