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

"cdk diff" should take assets into account #395

Closed
eladb opened this issue Jul 24, 2018 · 5 comments · Fixed by #2821 or #4454
Closed

"cdk diff" should take assets into account #395

eladb opened this issue Jul 24, 2018 · 5 comments · Fixed by #2821 or #4454
Assignees
Labels
feature-request A feature should be added or improved. package/tools Related to AWS CDK Tools or CLI ui Related to CLI User Interface issues

Comments

@eladb
Copy link
Contributor

eladb commented Jul 24, 2018

When running cdk diff, the toolkit should take assets into account. At the moment, if only assets change, "cdk diff" will show no differences, but "cdk deploy" will update the stack since the asset's md5 changes.

@brad-jones
Copy link

For a quick and dirty hack I just inject a hash of the asset into the stack somewhere, in the case of a lambda just set an environment variable. Then when running cdk diff it's obvious what will update.

new lambda.Function(this, 'SomeLambda', {
	code: lambda.Code.asset('/path/to/zip'),
	environment: {
		HASH: HashFuncOfYourChoice('/path/to/zip'),
	},
	etc...
});

@eladb
Copy link
Contributor Author

eladb commented Mar 24, 2019

Copy @sam-goodwin

@barroij
Copy link

barroij commented Apr 15, 2019

Having the same issue, but as I'm not referencing a zip file but a directory, I cannot use @brad-jones workaround.

The zip md5 could be made available so that I can put its value an an output value (supposing that different output values buiolt with new Cdk.CfnOutput sould cause the stack to be deployed)

@shivlaks shivlaks added the feature-request A feature should be added or improved. label Aug 29, 2019
@jeffsee55
Copy link

Wonder if this could be achieved by using a checksum? That would have the benefit of #395 (comment) 's comment without having to zip beforehand.

Since the lambda.Code.fromAsset(..., would know the directory it may even be possible to perform automatically and store in metadata?

@eladb
Copy link
Contributor Author

eladb commented Oct 2, 2019

will be fixed by #2821

eladb pushed a commit that referenced this issue Oct 3, 2019
The `NestedStack` construct is a special kind of `Stack`. Any resource defined within its scope will be included in a separate template from the parent stack. 

The template for the nested stack is synthesized into the cloud assembly but not treated as a deployable unit but rather as a file asset. This will cause the CLI to upload it to S3 and wire it's coordinates to the parent stack so we can reference its S3 URL.

To support references between the parent stack and the nested stack, we abstracted the concept of preparing cross references by inverting the control of `consumeReference` from the reference object itself to the `Stack` object. This allows us to override it at the `NestedStack` level (through `prepareCrossReference`) and mutate the token accordingly. 

When an outside resource is referenced within the nested stack, it is wired through a synthesized CloudFormation parameter. When a resource inside the nested stack is referenced from outside, it will be wired through a synthesized CloudFormation output. This works for arbitrarily deep nesting.

When an asset is referenced within a nested stack, it will be added to the top-level stack and wired through the asset parameter reference (like any other reference).

Fixes #239
Fixes #395
Related #3437 
Related #1439 
Related #3463
eladb pushed a commit that referenced this issue Oct 10, 2019
Since source hash is now used to identify assets, if an asset changes,
the diff will show it (yey!).

Resolves #395
eladb pushed a commit that referenced this issue Oct 10, 2019
Since source hash is now used to identify assets, if an asset changes,
the diff will show it (yey!).

Resolves #395
mergify bot pushed a commit that referenced this issue Oct 10, 2019
Since source hash is now used to identify assets, if an asset changes,
the diff will show it (yey!).

Resolves #395
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. package/tools Related to AWS CDK Tools or CLI ui Related to CLI User Interface issues
Projects
None yet
6 participants