-
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
aws_apigateway: remove auto-generated CfnOutput
for RestApi
#25373
Comments
Making this a p2 feature request. Please help us prioritize by giving upvotes on this issue. |
Why is this an antipattern / why doesn't it make sense? |
Because AWS documentation defines |
Our L2 constructs often do a lot of things that are optional when using CloudFormation, I don't think I understand the reasoning here. Are you hitting limits, do you have security concerns, is it just unwanted extra noise in the output?
|
Keep in mind, if we were to outright remove this CfnOutput it would more than likely break some customers who have come to rely on it. I think the most we would do here is provide an option to remove the output, which you can do now already by removing the resource from the construct tree |
It would be indeed nice to have a parameter called |
It is definitely surprising as an end user to have an There is a fairly limited set of places that create a
|
Thanks for the feedback, and for the context @kylelaker. This is something we'd need a contributor to help us with since this is a p2 issue with workarounds available; we'd be happy to review a PR
I'm not sure we'd set any "standard" for this unless we opt to not use CfnOutputs at all when not required because...
I tend to agree with this |
@peterwoodworth I was unable to get this workaround to work. What should the "childName" be? I've tried the name of the output but that doesn't work. I've also tried to iterate over all nodes using findAll() but it doesn't show the output, which makes me think it is not possible to remove it from the tree in this way. In that case the priority for this might be higher because there is no workaround. I agree with the arguments of @kylelaker , it is akin to a function deep in your code modifying global state. Besides, I think it is possible that a role/user HAS been biven permission to read a Cloudformation's outputs, but NOT the resources in the stack. In that case it could lead to unexpected permission escalation because all of a sudden this user can now see the gateway's endpoint. |
@advanderveer The The docs are a bit unclear about what is a "name", but apparently the name is just Example (Kotlin via Java CDK): import software.amazon.awscdk.services.apigateway.RestApi
import software.amazon.awscdk.CfnOutput
val restApi = RestApi(this, "Api", RestApiProps.builder().restApiName("some-name").build())
restApi.node.tryRemoveChild("Endpoint")
// add your own output
CfnOutput(this, "ApiUrlOutput", CfnOutputProps.builder().key("api-url").value(restApi.url).build()) Btw, I figured the name out via simple iteration over the children nodes of for (child in restApi.node.children) {
println(child)
println(child.javaClass.name)
} |
Describe the feature
There's an inconsistency in how CDK handles deployments for API constructs in the two API Gateway modules:
RestApi
, CDK automatically generates aCfnOutput
during deployment. This behavior is unexpected.HttpApi
orWebSocketApi
, no such output is generated.Expectation
I expected the
RestApi
fromaws_apigateway
to function similarly toHttpApi
andWebSocketApi
fromaws_apigatewayv2
.Proposed Solution
I propose aligning the behavior of all API constructs. Ideally, the
RestApi
construct fromaws_apigateway
module should not generate aCfnOutput
by default, mirroring the behaviour ofHttpApi
andWebSocketApi
constructs fromaws_apigatewayv2
module. This would provide a more consistent development experience when using CDK with different API types.Other Information
No response
Acknowledgements
CDK version used
2.77
Environment details (OS name and version, etc.)
Ubuntu 22.04 LTS
The text was updated successfully, but these errors were encountered: