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): No Deployment for imported RestAPI after adding resources or methods #12589

Closed
Adiotastic opened this issue Jan 19, 2021 · 4 comments
Assignees
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged.

Comments

@Adiotastic
Copy link

❓ General Issue

The Question

I have created an api gateway like:

const restAPI = newRestApi(this, 'APIGateway', { deploy: true, deployOptions: { stageName: 'dev', description: 'dev stage', }, });

In a different stack I want to use the gateway to add new resources and methods from lambda functions, like deploying different separated lambda applications to the same gateway.

I imported the RestApi like this:
const restApi = RestApi.fromRestApiAttributes(this, 'RestApi', { ... });

I add a new resource and method for the lambda I want to add as a gateway endpoint:
const integration = restApi.root.addResource('test').addMethod('GET', new LambdaIntegration(testLambda));

Issue
In the aws console I can see the new resource 'test' as well as the new method, but there is no new deployment in the DEV Stage.
MIght this be in issue with the CDK or am I doing this wrong?

Environment

  • CDK CLI Version: 1.85
  • Module Version: 1.85
  • Node.js Version: 10.14.1
  • OS: macOS Catalina
  • Language (Version): TypeScript
@Adiotastic Adiotastic added guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged. labels Jan 19, 2021
@Adiotastic Adiotastic changed the title (aws-cdk/aws-apigateway): No Deployment for imported RestAPI after adding resources or methods (aws-apigateway): No Deployment for imported RestAPI after adding resources or methods Jan 19, 2021
@github-actions github-actions bot added the @aws-cdk/aws-apigateway Related to Amazon API Gateway label Jan 19, 2021
@achamwada
Copy link

Hi @Adiotastic ,

Have you tried to set deploy to false remove deployOptions so you can manually create your deployment for your stages

deploy: true creates a deployment to a prod stage

const method = restApi.root.addResource('test').addMethod('GET', new LambdaIntegration(testLambda));

const deployment = new Deployment(this, 'api-gateway-deployment', {
        api: restApi,
        retainDeployments: true,
      });

deployment.node.addDependency(method);

 new Stage(this, `${stageName}_stage`, {
        deployment,
        stageName,
      });

@Adiotastic
Copy link
Author

Hi @achamwada ,
i tried that once, but cannot remember if I used "addDependency" for this.
Since this was a blocker, I solved it this way:

I extracted the creation of new resources and methods to the gateway stack and generated the arn for the Integration Lambdas there. This was the way a lot of other guys handle problems like this.

Even if this is more like strong coupling between the lambda names/arn and the integration, and also not the way i would prefer to go, it guarantees that I can add multiple separated lambda applications to the same gateway.

Thank you anyway. If I have some time to spend, I will try to implement your idea to check if it works.

@nija-at
Copy link
Contributor

nija-at commented Feb 19, 2021

This is currently unsupported. You will have to add your own deployment to imported RestApis.

Tracking this issue here - #12417

@nija-at nija-at closed this as completed Feb 19, 2021
@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 guidance Question that needs advice or information. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants