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

@aws-cdk/aws-apigateway module: Add ability to reference execution log group ARN or Name #15816

Open
2 tasks
covertbert opened this issue Jul 29, 2021 · 10 comments
Open
2 tasks
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@covertbert
Copy link

covertbert commented Jul 29, 2021

Adding the ability to reference the log group ARN or name that is generated by the RestApi construct.

Use Case

To be able to do anything at all with the log group that gets generated (e.g. add a subscription filter) you need to be able to dynamically reference the name or ARN.

Proposed Solution

Either:

  • Create a readonly property on the instantiated RestApi class called logGroupName or logGroupArn that can be referenced by other constructs.

  • Or, add the ability to set the execution log group name (like you can with access logs) so that you can have a consistent name to reference the log group by.

  • 👋 I may be able to implement this feature request

  • ⚠️ This feature might incur a breaking change


This is a 🚀 Feature Request

@covertbert covertbert added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Jul 29, 2021
@github-actions github-actions bot added the @aws-cdk/aws-apigateway Related to Amazon API Gateway label Jul 29, 2021
@nija-at
Copy link
Contributor

nija-at commented Sep 1, 2021

As far as I am aware, the RestApi construct does not create any log groups.
Which logs are you talking about?

@nija-at nija-at added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Sep 1, 2021
@covertbert
Copy link
Author

@nija-at it does create log groups for execution logs. If you want access logs then you create the log group yourself and pass it to RestApi

@nija-at
Copy link
Contributor

nija-at commented Sep 3, 2021

@covertbert - unfortunately, the CDK does not create these execution logs. They are created automatically by the API Gateway service.

It seems that the log group is always of the format API-Gateway-Execution-Logs_${RestApiId}/${Stage}.
We could apply a logic similar to what we do in the aws-lambda module using the LogRetention construct to get you the execution logs, applied on the Stage construct -

public get logGroup(): logs.ILogGroup {
if (!this._logGroup) {
const logRetention = new logs.LogRetention(this, 'LogRetention', {
logGroupName: `/aws/lambda/${this.functionName}`,
retention: logs.RetentionDays.INFINITE,
});
this._logGroup = logs.LogGroup.fromLogGroupArn(this, `${this.node.id}-LogGroup`, logRetention.logGroupArn);
}
return this._logGroup;
}
.

A workaround is to simply refer the log group by using LogGroup.fromLogGroupId() API in the format presented above.

I am unassigning and marking this issue as p2, which means that we are unable to work on this immediately.

We use +1s to help prioritize our work, and are happy to revaluate this issue based on community feedback. We accept pull requests if you are interested in contributing this feature.

@nija-at nija-at added effort/small Small work item – less than a day of effort p2 and removed response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. needs-triage This issue or PR still needs to be triaged. labels Sep 3, 2021
@nija-at nija-at removed their assignment Sep 3, 2021
@covertbert
Copy link
Author

covertbert commented Sep 3, 2021

@nija-at makes sense. The only problem with referencing by a hard-coded ID is that IDs can change when resources are recreated. I was kinda hoping that you'd be able to expose the current ID dynamically. Appreciate this is low priority though, thanks for looking into it.

@nija-at
Copy link
Contributor

nija-at commented Sep 3, 2021

You should not hardcode the id. Instead, you use restApi.restApiId

@covertbert
Copy link
Author

covertbert commented Sep 3, 2021

Ahh that makes sense, thanks!

Edit: But surely the restApiId is not the same as log group id needed in fromLogGroupId?

@shellscape
Copy link

Worth noting for anyone stopping by here, that LogGroup.fromLogGroupId is no longer an available static method.

@github-actions
Copy link

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 11, 2023
@shellscape
Copy link

yup

@github-actions github-actions bot removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 11, 2023
@rmontoya12
Copy link

It would be nice to specify execution log group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

4 participants