Skip to content

Commit

Permalink
Rewrite a warning to avoid printing sub-properties as outputs (#1395)
Browse files Browse the repository at this point in the history
Another fix for #1372 while
#1374 only partially
succeeded.

The previous attempt was successful in resolving the top-level output
but child outputs were still unresolved. I was a bit surprised that was
the case... outputs are hard!

The new attempt relies on `pulumi.jsonStringify` which is made exactly
for this purpose. This drops JSON formatting but hopefully that not too
bad for a small JSON. Example of the result:

```
 warning: The default subnetStrategy will change from "Legacy" to "Auto" in the next major version. Please specify the subnetStrategy explicitly. The current subnet layout can be specified via "Auto" as:
    
    [{"cidrMask":20,"type":"Public"}]
```
  • Loading branch information
mikhailshilkov authored Oct 15, 2024
1 parent 85bd30d commit 01c654f
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions awsx/ec2/vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,23 +489,19 @@ export class Vpc extends schema.Vpc<VpcData> {
.output(parsedSpecs?.normalizedSpecs)
.apply(vpcConverters.toResolvedSubnetSpecOutputs);

const verifiedSubnetLayout = subnetLayout.apply((sl) => {
const verifiedSubnetLayout = pulumi.jsonStringify(subnetLayout).apply((sl) => {
// Only warn if they're using a custom, non-explicit layout and haven't specified a strategy.
if (
args.subnetStrategy === undefined &&
parsedSpecs !== undefined &&
parsedSpecs.isExplicitLayout === false
) {
pulumi.log.warn(
`The default subnetStrategy will change from "Legacy" to "Auto" in the next major version. Please specify the subnetStrategy explicitly. The current subnet layout can be specified via "Auto" as:\n\n${JSON.stringify(
sl,
undefined,
2,
)}`,
`The default subnetStrategy will change from "Legacy" to "Auto" in the next major version. Please specify the subnetStrategy explicitly. The current subnet layout can be specified via "Auto" as:\n\n${sl}`,
this,
);
}
return sl;
return subnetLayout;
});

return { subnetLayout: verifiedSubnetLayout, subnetSpecs };
Expand Down

0 comments on commit 01c654f

Please sign in to comment.