-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(yaml-cfn): do not deserialize year-month-date as strings (#13745)
Currently, we are using the `yaml-1.1` schema when de-serializing YAML documents, Unfortunately, this has the side effect of treating unquoted parts of the template like '2010-09-09' as Date objects, instead of just simple strings. This has been noted by a customer using the cloudformation-include module, but I assume a very similar problem exists for other places we parse YAML, like cloudformation-diff. Switch to the `core` schema from `yaml-1.1`, where those are treated as strings, instead of dates. Fixes #13709 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
6 changed files
with
84 additions
and
6 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
.../@aws-cdk/cloudformation-include/test/test-templates/yaml/year-month-date-as-strings.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
AWSTemplateFormatVersion: 2010-09-09 | ||
Resources: | ||
Role: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
AssumeRolePolicyDocument: | ||
Version: 2012-10-17 | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: | ||
- ec2.amazonaws.com | ||
Action: | ||
- sts:AssumeRole |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import '@aws-cdk/assert/jest'; | ||
import * as yaml_cfn from '../lib'; | ||
|
||
test('Unquoted year-month-day is treated as a string, not a Date', () => { | ||
const value = yaml_cfn.deserialize('Key: 2020-12-31'); | ||
|
||
expect(value).toEqual({ | ||
Key: '2020-12-31', | ||
}); | ||
}); | ||
|
||
test("Unquoted 'No' is treated as a string, not a boolean", () => { | ||
const value = yaml_cfn.deserialize('Key: No'); | ||
|
||
expect(value).toEqual({ | ||
Key: 'No', | ||
}); | ||
}); | ||
|
||
test("Short-form 'Ref' is deserialized correctly", () => { | ||
const value = yaml_cfn.deserialize('!Ref Resource'); | ||
|
||
expect(value).toEqual({ | ||
Ref: 'Resource', | ||
}); | ||
}); | ||
|
||
test("Short-form 'Fn::GetAtt' is deserialized correctly", () => { | ||
const value = yaml_cfn.deserialize('!GetAtt Resource.Attribute'); | ||
|
||
expect(value).toEqual({ | ||
'Fn::GetAtt': 'Resource.Attribute', | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import '@aws-cdk/assert/jest'; | ||
import * as yaml_cfn from '../lib'; | ||
|
||
test('An object with a single string value is serialized as a simple string', () => { | ||
const value = yaml_cfn.serialize({ key: 'some string' }); | ||
|
||
expect(value).toEqual('key: some string\n'); | ||
}); |
This file was deleted.
Oops, something went wrong.