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

Improve the Ref intrinsic implementation #243

Merged
merged 14 commits into from
Nov 25, 2024
Merged

Improve the Ref intrinsic implementation #243

merged 14 commits into from
Nov 25, 2024

Conversation

t0yv0
Copy link
Member

@t0yv0 t0yv0 commented Nov 21, 2024

This change adds some tests and comments around the Ref intrinsic implementation and moves it to intrinsics.ts. The one change in behavior is that now Ref is able to consult Pulumi metadata from the aws-native provider. The metadata helps it resolve to the same values as it would in CloudFormation for resources that have non-standard Ref behavior. The correctness of this process is up to the correctness of the metadata tables. Entries not found in the metadata tables default to using Pulumi id for most cases should do the right thing.

Fixes #173

Needs pulumi/pulumi-aws-native#1836

@t0yv0 t0yv0 changed the title Sketch out metadata-aware Ref intrinsic Improve the Ref intrinsic implementation Nov 22, 2024
@t0yv0 t0yv0 marked this pull request as ready for review November 22, 2024 21:31
@t0yv0
Copy link
Member Author

t0yv0 commented Nov 22, 2024

Acceptance tests catching something, excellent, I'll have a look.

Copy link
Contributor

@corymhall corymhall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

return ctx.getRegion();
case 'AWS::URLSuffix':
return ctx.getURLSuffix();
case 'AWS::NotificationARNs':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was actually a bug I introduced when I enabled use of StackId & StackName. AWS::NotificationARNs should still throw an error because it is not supported.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix that!


return ctx.apply(ctx.succeed(propValues), (resolvedValues) => {
let i = 0;
for (const v of resolvedValues) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

resolvedValues.forEach((v, idx) => {
	...
})

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forEach wouldn't have the early return. To express this functionally this would be a reduce, but perhaps having written too much Go since my FP days I prefer the imperative version now for readability.

src/converters/intrinsics.ts Outdated Show resolved Hide resolved
@t0yv0 t0yv0 enabled auto-merge (squash) November 25, 2024 14:25
@t0yv0 t0yv0 merged commit aa35dfb into main Nov 25, 2024
13 checks passed
@t0yv0 t0yv0 deleted the t0yv0/ref-intrinsic branch November 25, 2024 15:23
@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v1.0.0.

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

Successfully merging this pull request may close these issues.

CloudFormation Refs do not always map to the CCAPI id
4 participants