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_apigateway: cloudWatchRole update in unrelated APIs #22954

Closed
rumesh-athu opened this issue Nov 17, 2022 · 8 comments
Closed

aws_apigateway: cloudWatchRole update in unrelated APIs #22954

rumesh-athu opened this issue Nov 17, 2022 · 8 comments
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway bug This issue is a bug.

Comments

@rumesh-athu
Copy link

Describe the bug

The last created stack's cloudWatchRole is getting updated across all the API Gateways settings. If the last stack is deleted, it belongs cloudWatchRole also delete. Which impact all other API Gateways logs that are not being pushed to CloudWatch Log Groups.

Expected Behavior

All API Gateways should not be updated with the last stack cloudWatchRole.

Current Behavior

The last created stack's cloudWatchRole is getting updated across all the API Gateways settings.

Reproduction Steps

Create a new API Gateway (cdk deploy).
Check the old API Gateway Settings. The new cloudWatchRole is updated.
Delete the last create API Gateway (cdk destroy).
Other API Gateways are still having deleted cloudWatchRole.

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.35.0

Framework Version

No response

Node.js Version

v18.6.0

OS

MacOS

Language

Typescript

Language Version

Typescript (3.9.7)

Other information

No response

@rumesh-athu rumesh-athu added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 17, 2022
@github-actions github-actions bot added the @aws-cdk/aws-apigateway Related to Amazon API Gateway label Nov 17, 2022
@peterwoodworth
Copy link
Contributor

Can you clarify exactly what the behavior is you're experiencing? I think sharing some reproduction code would help.

@peterwoodworth peterwoodworth added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Nov 18, 2022
@rumesh-athu
Copy link
Author

interface ApiGwProps extends StackProps {
  environment: string;
  appName: string;
  lambdahandler: any;
  whitelistedIps?: string[];
  stageName: string;
}

export class ApiGwStack extends Stack {

  constructor(scope: Construct, id: string, props?: ApiGwProps) {
    super(scope, id, props);

    const apiResourcePolicy = new iam.PolicyDocument({
      statements: [
        new iam.PolicyStatement({
          actions: ['execute-api:Invoke'],
          principals: [new iam.AnyPrincipal()],
          resources: ['execute-api:/*/*/*'],
        }),
        new iam.PolicyStatement({
          effect: iam.Effect.DENY,
          principals: [new iam.AnyPrincipal()],
          actions: ['execute-api:Invoke'],
          resources: ['execute-api:/*/*/*'],
          conditions: {
            'NotIpAddress': {
              "aws:SourceIp": props?.whitelistedIps
            }
          }
        })
      ]
    })

    const api = new apigateway.RestApi(this, 'api', {
      restApiName: `${props?.appName}-${props?.environment}`,
      endpointTypes: [apigateway.EndpointType.PRIVATE],
      policy: apiResourcePolicy,
      deployOptions: {
        stageName: props?.stageName,
      },
    });

    const lambda = new apigateway.LambdaIntegration(props?.lambdahandler);

    const apiRoot = api.root.addMethod('ANY', lambda);
  }
}

@rumesh-athu
Copy link
Author

Although the role is being used by other API Gateways, the role got deleted. APIGW logs are not pushed to CloudWatch LogGroups due to this.

image

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Nov 18, 2022
@otaviomacedo otaviomacedo removed their assignment Nov 18, 2022
@hutchy2570
Copy link

Some details on this are on the docs here: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigateway-readme.html#deployments. The cloudwatch role should be retained following the release of CDK 2.38.0. See #22020

@peterwoodworth
Copy link
Contributor

Good detail behind what exactly changed is found in the PR description. This should clear everything up and let you know the direction to move to avoid this error

@peterwoodworth peterwoodworth added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Nov 18, 2022
@github-actions
Copy link

This issue has not received a response in a while. 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 Nov 21, 2022
@rumesh-athu
Copy link
Author

The issue no longer exists with CDK version 2.51.1

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Nov 21, 2022
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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 bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants