CfnApi and GatewayResponses list #19868
-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
UPDATE: merged a fix for this, you should be able to use json for this property next version release #19885 Original body: Since you asked this again, I decided to try deploying a stack and yeah you're right, you can do this with CloudFormation. I'm curious what the serverless docs are trying to indicate when they reference how certain properties aren't compatible with CloudFormation. Anyway, the typing the CDK forces doesn't allow you to directly input the GatewayResponses property. You can get around this by using escape hatches to override the generated template. Here's an example which works 🙂 const cfnApi = new CfnApi(this, 'api', {
stageName: 'test',
methodSettings: [
{
ResourcePath: '/',
HttpMethod: 'GET'
}
]
});
cfnApi.addPropertyOverride('GatewayResponses', {
UNAUTHORIZED: {
StatusCode: 401,
ResponseParameters: {
Headers: {
"Access-Control-Allow-Origin": "'*'"
}
}
}
}); I've created a bug report here so that CDK can address this to natively use these properties without workarounds |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
UPDATE: merged a fix for this, you should be able to use json for this property next version release #19885
Original body: Since you asked this again, I decided to try deploying a stack and yeah you're right, you can do this with CloudFormation. I'm curious what the serverless docs are trying to indicate when they reference how certain properties aren't compatible with CloudFormation.
Anyway, the typing the CDK forces doesn't allow you to directly input the GatewayResponses property. You can get around this by using escape hatches to override the generated template. Here's an example which works 🙂