forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cfnspec): make EndpointConfiguration of AWS::Serverless::Api a un…
…ion type (aws#15526) A recent update to the SAM spec (aws#15311) changed the EndpointConfiguration property of AWS::Serverless::Api to have a complex type. However, that is a breaking change compared to the previous, string, type. I consulted with the SAM team, and it turns out the property accepts both a string and the complex type. Given that, patch our SAM spec to make EndpointConfiguration a union type. ---- *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
7 changed files
with
138 additions
and
2 deletions.
There are no files selected for viewing
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,44 @@ | ||
import '@aws-cdk/assert-internal/jest'; | ||
import * as cdk from '@aws-cdk/core'; | ||
import * as sam from '../lib'; | ||
|
||
describe('AWS::Serverless::Api', () => { | ||
let stack: cdk.Stack; | ||
beforeEach(() => { | ||
stack = new cdk.Stack(); | ||
}); | ||
|
||
test('can be created by passing a complex type to EndpointConfiguration', () => { | ||
new sam.CfnApi(stack, 'Api', { | ||
stageName: 'prod', | ||
definitionBody: { | ||
body: 'definitionBody', | ||
}, | ||
endpointConfiguration: { | ||
type: 'GLOBAL', | ||
}, | ||
}); | ||
|
||
expect(stack).toHaveResourceLike('AWS::Serverless::Api', { | ||
StageName: 'prod', | ||
EndpointConfiguration: { | ||
Type: 'GLOBAL', | ||
}, | ||
}); | ||
}); | ||
|
||
test('can be created by passing a string to EndpointConfiguration', () => { | ||
new sam.CfnApi(stack, 'Api', { | ||
stageName: 'prod', | ||
definitionBody: { | ||
body: 'definitionBody', | ||
}, | ||
endpointConfiguration: 'GLOBAL', | ||
}); | ||
|
||
expect(stack).toHaveResourceLike('AWS::Serverless::Api', { | ||
StageName: 'prod', | ||
EndpointConfiguration: 'GLOBAL', | ||
}); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
packages/@aws-cdk/cfnspec/spec-source/901_SAM_Api_EndpointConfiguration_patch.json
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,29 @@ | ||
{ | ||
"ResourceTypes": { | ||
"AWS::Serverless::Api": { | ||
"Properties": { | ||
"EndpointConfiguration": { | ||
"patch": { | ||
"description": "Make the EndpointConfiguration property of AWS::Serverless::Api have a union type", | ||
"operations": [ | ||
{ | ||
"op": "add", | ||
"path": "/PrimitiveTypes", | ||
"value": ["String"] | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/Types", | ||
"value": ["EndpointConfiguration"] | ||
}, | ||
{ | ||
"op": "remove", | ||
"path": "/Type" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
...s/@aws-cdk/cloudformation-include/test/test-templates/sam/api-endpoint-config-object.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,11 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
Resources: | ||
Api: | ||
Type: AWS::Serverless::Api | ||
Properties: | ||
StageName: prod | ||
DefinitionBody: | ||
Body: DefinitionBody | ||
EndpointConfiguration: | ||
Type: GLOBAL |
10 changes: 10 additions & 0 deletions
10
...-cdk/cloudformation-include/test/test-templates/sam/api-endpoint-config-string-empty.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,10 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
Resources: | ||
Api: | ||
Type: AWS::Serverless::Api | ||
Properties: | ||
StageName: prod | ||
DefinitionBody: | ||
Body: DefinitionBody | ||
EndpointConfiguration: '' # empty string |
10 changes: 10 additions & 0 deletions
10
...s/@aws-cdk/cloudformation-include/test/test-templates/sam/api-endpoint-config-string.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,10 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
Resources: | ||
Api: | ||
Type: AWS::Serverless::Api | ||
Properties: | ||
StageName: prod | ||
DefinitionBody: | ||
Body: DefinitionBody | ||
EndpointConfiguration: GLOBAL |
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