Skip to content

Commit 5091a85

Browse files
committed
Update: Add example for cdk diff command
1 parent cbdc054 commit 5091a85

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

v2/ref-cli-cmd-diff.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,50 @@ The path to the CloudFormation template to compare a CDK stack with\.
6363

6464
### Diff against the currently deployed stack named MyStackName<a name="ref-cli-cmd-diff-examples-1"></a>
6565

66+
The CDK CLI uses the following symbols in the diff output:
67+
+ `[+]` – Identifies code or resources that will be added if you deploy your changes\.
68+
+ `[-]` – Identifies code or resources that will be removed if you deploy your changes\.
69+
+ `[~]` – Identifies a resource or property that will be modified if you deploy your changes\.
70+
71+
The following is an example that shows a diff of local changes to a Lambda function:
72+
6673
```
67-
$ cdk diff MyStackName --app='node bin/main.js'
74+
$ cdk diff MyStackName
75+
start: Building asset-hash:account-Region
76+
success: Built asset-hash:account-Region
77+
start: Publishing asset-hash:account-Region
78+
success: Published asset-hash:account-Region
79+
Hold on while we create a read-only change set to get a diff with accurate replacement information (use --no-change-set to use a less accurate but faster template-only diff)
80+
Stack MyStackName
81+
Resources
82+
[~] AWS::Lambda::Function HelloWorldFunction resource-logical-ID
83+
└─ [~] Code
84+
└─ [~] .ZipFile:
85+
├─ [-]
86+
exports.handler = async function(event) {
87+
return {
88+
statusCode: 200,
89+
body: JSON.stringify('Hello World!'),
90+
};
91+
};
92+
93+
└─ [+]
94+
exports.handler = async function(event) {
95+
return {
96+
statusCode: 200,
97+
body: JSON.stringify('Hello from CDK!'),
98+
};
99+
};
100+
101+
102+
103+
✨ Number of stacks with differences: 1
68104
```
69105

106+
A `[~]` indicator for resources that will be modified does not always mean a full resource replacement:
107+
+ Some resource properties, like `Code`, will update the resource\.
108+
+ Some resource properties, like `FunctionName`, may cause a full resource replacement\.
109+
70110
### Diff against a specific CloudFormation template<a name="ref-cli-cmd-diff-examples-2"></a>
71111

72112
```

0 commit comments

Comments
 (0)