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

Add vpcEndpointIds as an option on SpecRestApi #33295

Closed
1 task
acwatson opened this issue Feb 4, 2025 · 3 comments · Fixed by #33514
Closed
1 task

Add vpcEndpointIds as an option on SpecRestApi #33295

acwatson opened this issue Feb 4, 2025 · 3 comments · Fixed by #33514
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@acwatson
Copy link

acwatson commented Feb 4, 2025

Describe the bug

The SpecRestApiProps interface (https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.SpecRestApiProps.html) is missing the property called "endpointConfiguration". This property got added to the plain RestApi construct, but not the SpecRestApi construct. You can see the endpointConfiguration property is defined in the RestApiProps interface (https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway.RestApiProps.html).

The endpointConfiguration property is needed so that the API GW can be configured to reference VPC endpoint IDs.

I think what happened is that when this issue was fixed for RestApi (#6038), the implementers did not realize they should also update the SpecRestApi.

I looked at the SpecRestApi code and I see that it actually does support the endpointConfiguration configuration, its just that this property is not defined in the SpecRestApiProps interface. I was able to get the SpecRestApi to use my VPC endpoint IDs by hacking the props input like so:

const endpointConfiguration: apigw.EndpointConfiguration = {
types: [apigw.EndpointType.PRIVATE],
vpcEndpoints: [props.apiGwVpcEndpoint]
};

// Add the missing "endpointConfiguration" property
const apiPropsExtensions = {
endpointConfiguration
};

const specApiProps: apigw.SpecRestApiProps = {
apiDefinition,
...
}

// Hacking type-safety and passing in the endpointConfiguration using the spread operator
const api = new apigw.SpecRestApi(this, "MyAPI", {...specApiProps, ...apiPropsExtensions});

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

2.177.0

Expected Behavior

The SpecRestApiProps interface should have a "endpointConfiguration" property just like the RestApiProps interface does. It is needed so that the API GW can be configured with VPC endpoint IDs.

Current Behavior

The SpecRestApiProps interface does not have a "endpointConfiguration" property, so it is necessary to use an "escape hatch" approach and set VPC endpoint IDS using the L1 construct or using the spread operator like I did in my bug description.

Reproduction Steps

//This will not compile due to the endpointConfiguration property not being in the interface

const specApiProps: apigw.SpecRestApiProps = {
apiDefinition,
restApiName: ${apiIdentifier},
deploy: true,
description: My API,
endpointConfiguration: {
types: [apigw.EndpointType.PRIVATE],
vpcEndpoints: [props.apiGwVpcEndpoint]
}
}

Possible Solution

Update the SpecRestApiProps to have an endpointConfiguration property, just like RestApiProps.

Additional Information/Context

No response

CDK CLI Version

2.177.0

Framework Version

No response

Node.js Version

v18.20.4

OS

MacOS

Language

TypeScript

Language Version

No response

Other information

No response

@acwatson acwatson added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 4, 2025
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Feb 4, 2025
@ashishdhingra ashishdhingra self-assigned this Feb 5, 2025
@ashishdhingra ashishdhingra added p2 investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Feb 5, 2025
@ashishdhingra
Copy link
Contributor

Appears to be a miss. SpecRestApi construct appears to set endpointConfiguration here while defining CfnRestApi resource. Looks like endpointConfiguration was added in 31014ca#diff-f760fab4d8b6e6dbbad8f304d52d86eb555abd8e68ca667f177a4507af142289 directly on RestApiProps which extends from RestApiOptions > RestApiBaseProps. Whereas, SpecRestApiProps extend from RestApiBaseProps and hence doesn't inherit endpointConfiguration property.

Moving endpointConfiguration to RestApiBaseProps should not be a breaking change since RestApiProps would still inherit it.

Could not find any CloudFormation documentation where it states that EndpointConfiguration should not be defined for AWS::ApiGateway::RestApi, which represents a REST API in Amazon API Gateway, created with an OpenAPI specification.

@acwatson Feel free to contribute PR for the fix, if possible.

@ashishdhingra ashishdhingra added effort/small Small work item – less than a day of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Feb 5, 2025
@ashishdhingra ashishdhingra removed their assignment Feb 5, 2025
@mergify mergify bot closed this as completed in #33514 Mar 2, 2025
@mergify mergify bot closed this as completed in e07a89c Mar 2, 2025
Copy link

github-actions bot commented Mar 2, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

1 similar comment
Copy link

github-actions bot commented Mar 2, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2025
hwum pushed a commit to hwum/aws-cdk that referenced this issue Mar 3, 2025
…33514)

### Issue # (if applicable)

Closes aws#33295

### Reason for this change
SpecRestApi support `endpointConfiguration`

### Description of changes
Move endpointConfiguration to RestApiBaseProps

### Description of how you validated changes
Unit + integ

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants