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

Deployment Lambda Hooks #75

Closed
eladb opened this issue Mar 4, 2019 · 9 comments
Closed

Deployment Lambda Hooks #75

eladb opened this issue Mar 4, 2019 · 9 comments

Comments

@eladb
Copy link
Contributor

eladb commented Mar 4, 2019

It should not be too hard to add support for executing a lambda function pre/post deployment of CDK apps. Basically, a custom resource with a changing logical ID that only reacts to "CREATE" and automatically takes a dependency on everything (or everything takes a dependency on it)

This can be used, for example, to implement "live" integration tests where you deploy a stack and then asserts some things against it at the end of the deployment. If your assertions fail, the stack is rolled backed.

@dnagir
Copy link

dnagir commented Mar 23, 2019

Another use case in support of this - using AWS CLI to manage the resources that are not supported by CloudFormation (one such example is Cognito client integration OAuth details).

It would be great to be able to say something like this in terms of the API:

        new hooks.Function(this, `updateCognitoClient`, {
            runtime: l.Runtime.NodeJS810,
            code: l.Code.directory('functions'),
            handler: 'updateCognitoClient.handler'
        });

It would be great if this was designed well in conjunction with client-side hooks/events to have a coherent and easy to use API.

@eladb
Copy link
Contributor Author

eladb commented Mar 24, 2019

@dnagir you should look into Custom Resources for this use case and also aws/aws-cdk#1897

@rob-gonz
Copy link

rob-gonz commented May 7, 2019

Use Case in support of this:

After each stack is deployed/destroyed the CloudFormation output of the completed stack is provided to the lambda function called by the hook. In my particular use, I would like to be able to output the name of the staging environment, ELB/ALB endpoints, and URL's to be created. With that information, I can leverage Cloudflare/Godaddy/name.com API's to create CNAME records for new environments or update existing.

In general, this would really be useful to automate things further and make it much easier to have fully disposable environments.

@eladb eladb self-assigned this Aug 12, 2019
@btotharye
Copy link

btotharye commented Sep 3, 2019

Another example external Atlas Mongo VPC peering that is created from the Mongo end and then accepted from the AWS side, I already have mongo code working but obviously now this has to be a custom resource instead of just being able to run conditionals in my code whether a deploy or destroy was ran.

Also it appears custom resources are expecting SDK calls not external code or 3rd party api calls like I am doing.

I guess we are forced into creating custom resources for this but that kinda defeats the purpose of having re-usable code and other external packages I've written that I would like to use.

@shurmanidze
Copy link

Use case: I'd like to seed a DB with some initial data on stack deployment complete.

@agalazis
Copy link

agalazis commented Jan 2, 2020

haha! @shurmanidze exactly my case

@binarythinktank
Copy link

Love this, some usecases that i would use it for:

  1. I would like to create a codecommit repo, deploy it, get the information then automatically add the local git to it (add origin)

  2. i would like to do similar for git submodules (on each of my lambda and s3 gui sources in the project)

  3. add some initial data to databases and an initial user to cognito

  4. create and deploy a config file to s3 gui (currently doing it with a custom resource)

  5. a bunch of other stuff through api calls (cdn invalidation, domain management, etc.)

@agalazis
Copy link

agalazis commented Jan 17, 2020

also consider fargate hooks since database restore might hit some lambda limitations. eg.spin a fargate task (from an ecr image for example) and exit

@eladb eladb transferred this issue from aws/aws-cdk Jan 23, 2020
@eladb eladb removed their assignment Jan 23, 2020
@eladb
Copy link
Contributor Author

eladb commented Apr 7, 2020

Duplicate #46

@eladb eladb closed this as completed Apr 7, 2020
@eladb eladb mentioned this issue Apr 7, 2020
7 tasks
@mneil mneil mentioned this issue Jun 23, 2020
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants