-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(apigateway): feature flag to disable the default endpoint Output #17239
feat(apigateway): feature flag to disable the default endpoint Output #17239
Conversation
…(under feature flag)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the effort to do this.
This is excellent!
Just a couple of small comments.
new CfnOutput(this, 'Endpoint', { exportName: props.endpointExportName, value: this.urlForPath() }); | ||
// If the context is true, don't create an unnamed output. | ||
// If false - or the endpointExportName is set, do create a CfnOutput. | ||
const avoidEmptyExport: boolean | undefined = Node.of(this).tryGetContext(APIGATEWAY_REST_API_NO_CFN_OUTPUT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you should use the FeatureFlags
API - https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/core/lib/feature-flags.ts#L11 - instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, nice spot!
@@ -160,6 +160,15 @@ export const LAMBDA_RECOGNIZE_VERSION_PROPS = '@aws-cdk/aws-lambda:recognizeVers | |||
*/ | |||
export const CLOUDFRONT_DEFAULT_SECURITY_POLICY_TLS_V1_2_2021 = '@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021'; | |||
|
|||
/** | |||
* API Gateway's REST API construct always creates a CfnOutput with a blank exportName. That name can be overridden |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* API Gateway's REST API construct always creates a CfnOutput with a blank exportName. That name can be overridden | |
* API Gateway's RestApi construct always creates a CfnOutput with a blank exportName. That name can be overridden |
2796584
to
bf96867
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious about one thing - why did you pick the feature flag option, rather than just provide an option to disable this (enabled by default)?
That's an excellent question! I'll be honest and say I didn't think about doing that 🤦♂️ An extra boolean prop like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesorlakin - feels to me like the simpler solution than introducing a feature flag.
I can see you've put in a considerable amount of work to get the feature flag going, especially given that this is a tricky part of our code base, but would you consider switching up the solution?
Hey @nija-at, that's honestly fine and no worries - good thinking of a much simpler solution! I'll close this one and maybe make something similar to the |
@jamesorlakin you have not got around it in the end, haven`t you?... |
...nope, it fell off my radar. You can always open a PR if you're that passionate about it. 👀 Otherwise a one-liner |
The
RestApi
construct creates a CfnOutput by default with no exportName. This seems slightly peculiar, and in stacks of my own I've often resorted tomyApi.node.tryRemoveChild('Endpoint')
to avoid confusion when the deployed APIs are private (and need accessing via a VPC endpoint instead of the normally public HTTPS URL).It was contemplated in #3662 (comment) to remove this entirely. With CDK v2 providing an opportunity to allow breaking behaviours I've created a new feature flag to gradually introduce this new behaviour. I appreciate breaking changes are never desired, so I'm not disheartened if this is unwanted (feel free to close!).
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license