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

Commit

Permalink
Add support for AWS::Partition pseudo parameter (#179)
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

* Adding build artifacts so we can use them directly.

* Remove checked in lib directory

Accidentally included

* 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.

* Add AWS::Partition pseudo parameter to ref overrides

This is a valid pseudo parameter as documented here:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html#cfn-pseudo-param-partition

This adds support for it, because at the moment it causes critical
validation failures. Tests to follow.

* Add test for AWS::Partition pseudo parameter

This adds a simple test that ensures that the AWS::Partition pseudo
parameter is correctly handled and parsed as valid.

* Update CHANGELOG.md
  • Loading branch information
nskoufis authored and martysweet committed Jul 18, 2018
1 parent 89b899f commit 1567397
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic
Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Merge PR #179, fixing support for AWS::Partition pseudo parameter

## [1.7.3] - 2018-06-30
### Fixed
Expand Down
5 changes: 3 additions & 2 deletions data/aws_ref_override.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"AWS::Region": "eu-west-1",
"AWS::StackId": "AWSREFSTACKID",
"AWS::StackName": "AWSREFSTACKNAME",
"AWS::URLSuffix": "amazonaws.com"
}
"AWS::URLSuffix": "amazonaws.com",
"AWS::Partition": "aws"
}
3 changes: 2 additions & 1 deletion src/awsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ type RefOverrides = {
"AWS::StackId": string,
"AWS::StackName": string,
"AWS::URLSuffix": string,
"AWS::Partition": string,
[refOverride: string]: any
};

export const awsRefOverrides = require('../data/aws_ref_override.json') as RefOverrides;
awsRefOverrides["AWS::NoValue"] = undefined;
awsRefOverrides["AWS::NoValue"] = undefined;
8 changes: 8 additions & 0 deletions src/test/validatorTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,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::Partition should result in validTemplate = true, no crit errors, no warnings', () => {
const input = 'testData/valid/yaml/issue-178-aws-partition.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
26 changes: 26 additions & 0 deletions testData/valid/yaml/issue-178-aws-partition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
Resources:
GatewayMethodGet:
Type: AWS::ApiGateway::Method
Properties:
HttpMethod: GET
RequestParameters:
method.request.path.sample: true
ResourceId: abc123
RestApiId: abc123
ApiKeyRequired: true
AuthorizationType: NONE
Integration:
IntegrationHttpMethod: POST
Type: AWS_PROXY
Uri:
Fn::Join:
- ''
- - 'arn:'
- Ref: AWS::Partition
- ":apigateway:"
- Ref: AWS::Region
- ":lambda:path/2015-03-31/functions/"
- someFunctionName
- "/invocations"
MethodResponses: []

0 comments on commit 1567397

Please sign in to comment.