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.

[ApiGateway] RestApi updates account level role used for ApiGateway CloudWatch logging

See original GitHub issue

This code in RestApi

https://github.com/aws/aws-cdk/blob/71aa4b61363ad43af34bcc83d11fa80490e48eac/packages/%40aws-cdk/aws-apigateway/lib/restapi.ts#L485

will update the account level role for cloudwatch logging used for all ApiGateways.

The problem we are seeing is that each new API we create will replace the role used for the account with the new role created.

If the stack that last updated the account level role gets deleted for some reason then the account level role will no longer exist and all apigateway cloudwatch logging is broken for the account 😱

Reproduction Steps

  1. create a new RestApi without passing a cloudWatchRole prop
  2. Deploy the new API - see the account level role change to the role associated with this new API
  3. Delete the stack
  4. All account level API logging no longer works because the role is deleted.

What did you expect to happen?

I would expect each apigateway logging role to be only used for a given API Gateway

or I would want the apigateway account level role to be rolled back to the previous role on deletion

What actually happened?

Described above

Environment

  • CLI Version :
  • Framework Version:
  • Node.js Version:
  • OS :
  • Language (Version):

Other

Is passing a role into each API the best option to resolve this?


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:22
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
straygarcommented, Aug 27, 2021

Any chance this could be made the default behavior for CDK v2? There have been so many times I accidentally and silently broke logs for all my API Gateways this way.

5reactions
adrian-skybakercommented, Dec 22, 2021

Just to echo this - have we missed the window to fix this for v2?

Really hoping this isn’t going to be a replay of https://github.com/aws/aws-cdk/issues/7140#issuecomment-610979959 ( “Since the API has been out there for a long time and our API Gateway module is stable, we cannot change this default”).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting up CloudWatch logging for a REST API in API Gateway
Set up CloudWatch API logging using the API Gateway console · Choose a logging level from the CloudWatch Logs dropdown menu. Warning. Full...
Read more >
APIs CloudWatch Logs - Trend Micro
Ensure that CloudWatch logging is enabled for all your Amazon API Gateway APIs in order to track and analyze execution behavior at the...
Read more >
The Missing Guide to AWS API Gateway Access Logs
API Gateway CloudWatch Logs Role ARN settings ... it won't update the value in AWS::ApiGateway::Account because, from CloudFormation's view, ...
Read more >
AWS::ApiGateway::Account - Amazon CloudFormation
The AWS::ApiGateway::Account resource specifies the IAM role that Amazon API Gateway uses to write API logs to Amazon CloudWatch Logs. Important.
Read more >
Enable API Gateway CloudWatch Logs - CloudNamaste
Execution Logs vs Access Logs · Step 1: Create an IAM role for logging to CloudWatch · Step 2: Add the IAM role...
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