Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(apigateway): deployOptions.description is not used for deployment's description #26149

Merged
merged 15 commits into from
Aug 22, 2023
Merged
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ export abstract class RestApiBase extends Resource implements IRestApi {
if (deploy) {

this._latestDeployment = new Deployment(this, 'Deployment', {
description: props.description? props.description :'Automatically created by the RestApi construct',
description: props.deployOptions?.description ? props.deployOptions?.description : 'Automatically created by the RestApi construct',
api: this,
retainDeployments: props.retainDeployments,
});
Expand Down
18 changes: 18 additions & 0 deletions packages/aws-cdk-lib/aws-apigateway/test/restapi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,24 @@ describe('restapi', () => {
})).toThrow(/Cannot set 'deployOptions' if 'deploy' is disabled/);
});

test('uses correct description for Deployment from "deployOptions"', () => {
// GIVEN
const stack = new Stack();
const api = new apigw.RestApi(stack, 'restapi', {
description: 'Api description',
deployOptions: { description: 'Deployment description' },
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::ApiGateway::Deployment', {
Description: 'Deployment description',
});

Template.fromStack(stack).hasResourceProperties('AWS::ApiGateway::RestApi', {
Description: 'Api description',
});
});

test('CloudWatch role is created for API Gateway', () => {
// GIVEN
const stack = new Stack();
Expand Down