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

Changing a CustomResource resourceType or lambdaProvider requires deleting and recreating the custom resource #1061

Closed
ccurrie-amzn opened this issue Oct 31, 2018 · 6 comments
Assignees
Labels
@aws-cdk/aws-cloudformation Related to AWS CloudFormation feature-request A feature should be added or improved.

Comments

@ccurrie-amzn
Copy link
Contributor

ccurrie-amzn commented Oct 31, 2018

#943 added support for custom resource types, which is great. However, updating the custom resource type is a destructive action that requires replacement; the CDK tries to show this as a "Replace" action, but CloudFormation doesn't allow it for the same logical ID.

The workaround is to change the name of the Resource in the CDK script, but it would better if the CDK was able to detect this and change the hash of the generated Logical ID accordingly.

The same is also true for the ServiceToken key from the lambda provider. This is a more common use case where the Lambda implementation of the custom resource has changed, which redeploys the Lambda under a new ARN. The workaround here is to change the Lambda to have specify a functionName, which will prevent the ARN from changing when the Lambda changes, though moving from an unnamed to a named Lambda still requires deletion and recreation as above.

@ccurrie-amzn ccurrie-amzn changed the title Changing a CustomResource resourceType requires deleting and recreating the custom resource Changing a CustomResource resourceType or lambdaProvider requires deleting and recreating the custom resource Oct 31, 2018
@rix0rrr
Copy link
Contributor

rix0rrr commented Nov 1, 2018

Somewhat related to #847

@eladb
Copy link
Contributor

eladb commented Nov 1, 2018

I think tying the resource id to its type makes sense. Should be straightforward to incorporate the type into the logical ID.

It might be trickier to do that with the service token because it is resolved at deploy time. For the specific case where users pass in a lambda that uses local assets, we might be able to incorporate the asset hash into the logical ID which will achieve a similar affect I think.

@ccurrie-amzn
Copy link
Contributor Author

The specific use case of local-asset lambdas is what broke for me, so fixing that use case would be sufficient for now.

@rix0rrr
Copy link
Contributor

rix0rrr commented Nov 6, 2018

I'm a little confused though. I'm changing the source and redeploying all the time, feels like, and I've never run into this. Updating the source of a Lambda doesn't change its ARN.

If you change the resourceType or something immutable about the Lambda... sure, but that should be a rare occasion. Does the common case really give trouble as well?

@ccurrie-amzn
Copy link
Contributor Author

No, source redeploys don't trigger this; I was simply saying that if the detection for ServiceToken was supported for local source lambdas only (as @eladb describe) that it would meet my needs.

In my specific case, I was refactoring my Constructs to create the lambda in a different part of the construct tree, which changed its generated name, and therefore it's ARN.

@srchase srchase added feature-request A feature should be added or improved. and removed enhancement labels Jan 3, 2019
@SomayaB SomayaB added the @aws-cdk/aws-cloudformation Related to AWS CloudFormation label Sep 10, 2019
@eladb
Copy link
Contributor

eladb commented Oct 2, 2019

This is not something we are able to fix given how custom resources work.

@eladb eladb closed this as completed Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudformation Related to AWS CloudFormation feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

5 participants