Skip to content

Commit

Permalink
fix(cfnspec): make EndpointConfiguration of AWS::Serverless::Api a un…
Browse files Browse the repository at this point in the history
…ion type

A recent update to the SAM spec (#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.
  • Loading branch information
skinny85 committed Jul 13, 2021
1 parent 94f81c4 commit 3cd8b7e
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
44 changes: 44 additions & 0 deletions packages/@aws-cdk/aws-sam/test/api.test.ts
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',
});
});
});
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"
}
]
}
}
}
}
}
}

0 comments on commit 3cd8b7e

Please sign in to comment.