question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow AWS HTTP API logs to be permissioned via external IAM role

See original GitHub issue

Is there an existing issue for this?

  • I have searched existing issues, it hasn’t been reported yet

Use case description

the Rest API has provider.logs.restApi.role which allows and externally managed role to be used for logging to CloudWatch.

However, provider.logs.httpApi.role does not. This is causing a problem for me as I have a large number of HTTP API G/Ws in a single account and so CF/sls adds an additional resource entry to the policy for each API.

As a result, I’ve hit an AWS limit here, reported by this error:

`Cannot enable logging. Policy document length breaking Cloudwatch Logs Constraints, either < 1 or > 5120 (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: 60e2fc0c-2971-48b0-8e41-0bf37fb016c6; Proxy: null)`

If there is a workaround for this, I’d be grateful to hear it, failing that, it would be good to add this support to httpAPI logging.

Proposed solution (optional)

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
bradwoodcommented, Jan 8, 2022

Hi @pgrzesik

It’s a good question – this doesn’t seem to be visible in IAM, Cloudwatch, or API GW AWS Console UIs. I was only able to find it via the aws logs CLI.

Here is the full output of that command (now truncated to only a few Resource entries since I deleted it)

image

UPDATE: After further googling, I found this StackOverflow article which seems to shed some light.

Given this, I think you are probably correct and this is an AWS thing, rather than a Framework thing…

2reactions
pgrzesikcommented, Jan 14, 2022

Thanks @bradwood - setting anything via SDK is something that we usually try to avoid unless there’s a really good reason to do so. Thanks for sharing your workaround. If we get more reports about this being a major issue, we might revisit implementing a robust solution as a part of the Framework, but for now I think we should postpone it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Control access to an API with IAM permissions
Learn how to provide access permissions to IAM users for Amazon API Gateway actions and resources.
Read more >
Control access for invoking an API - Amazon API Gateway
In this section you will learn how to write up IAM policy statements to control who can call a deployed API in API...
Read more >
Creating an IAM policy to access CloudWatch Logs resources
Open the IAM console . ... For Actions, choose Expand all (on the right), and then choose the Amazon CloudWatch Logs permissions needed...
Read more >
How Amazon API Gateway works with IAM
An IAM role is an entity within your AWS account that has specific permissions. Using temporary credentials with API Gateway. You can use...
Read more >
Configuring logging for an HTTP API - Amazon API Gateway
Ensure that your IAM user has the required permissions to enable logging. · Create a CloudWatch Logs log group. · Provide the ARN...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found