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

Support Condition Functions #222

Merged
merged 13 commits into from
Nov 19, 2024
Merged

Support Condition Functions #222

merged 13 commits into from
Nov 19, 2024

Conversation

t0yv0
Copy link
Member

@t0yv0 t0yv0 commented Nov 15, 2024

Support Condition Functions.

Fixes #206

With this change, if CDK emits CF templates with Condition Functions, pulumi-cdk evaluates these. This unlocks support for new constructs such as the Kinesis Stream construct.

@t0yv0
Copy link
Member Author

t0yv0 commented Nov 15, 2024

I'm running into casing problems here now:

{
  "method": "/pulumirpc.ResourceProvider/Check",
  "request": {
    "urn": "urn:pulumi:cdk-kinesis-test-1::pulumi-kinesis::cdk:index:App$cdk:construct:teststack$cdk:construct:aws-cdk-lib/aws_kinesis:Stream$aws-native:kinesis:Stream::mystreamF3EDC6B7",
    "olds": {},
    "news": {
      "name": "my-stream",
      "retentionPeriodHours": 24,
      "shardCount": 3,
      "streamEncryption": {
        "EncryptionType": "KMS",
        "KeyId": "alias/aws/kinesis"
      }
    },
    "randomSeed": "o0Ct4XOAo2WKrbNOCMK+NEErwjdWTNaIIhT8jsOFk0Q="
  },
  "response": {
    "failures": [
      {
        "property": "streamEncryption.EncryptionType",
        "reason": "unknown property streamEncryption.EncryptionType"
      },
      {
        "property": "streamEncryption.KeyId",
        "reason": "unknown property streamEncryption.KeyId"
      }
    ]
  },
  "metadata": {
    "kind": "resource",
    "mode": "client",
    "name": "aws-native"
  }
}

I think we're sending incorrect-cased sub-properties to aws-native. Digging in a bit, not sure if preexisting problem or something introduced just here.

@t0yv0
Copy link
Member Author

t0yv0 commented Nov 18, 2024

This depends on #228 but once that is in hopefully can pass integration tests here.

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.

This looks much better than what we have, love the separate functions for each intrinsic!

My only nit comments are around adding docstrings to the methods that are missing them. I've commented on a couple, but it applies to all of them.

src/converters/app-converter.ts Show resolved Hide resolved
src/converters/intrinsics.ts Show resolved Hide resolved
src/converters/intrinsics.ts Show resolved Hide resolved
@t0yv0 t0yv0 changed the title Toward Fn::If intrinsic Support conditions and conditional intrinsic functions Nov 19, 2024
@t0yv0 t0yv0 changed the title Support conditions and conditional intrinsic functions Support Condition Functions Nov 19, 2024
@t0yv0 t0yv0 requested a review from corymhall November 19, 2024 17:02
@t0yv0 t0yv0 marked this pull request as ready for review November 19, 2024 17:02
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.

🚀

@t0yv0 t0yv0 enabled auto-merge (squash) November 19, 2024 17:11
@t0yv0 t0yv0 merged commit c61bf5c into main Nov 19, 2024
13 checks passed
@t0yv0 t0yv0 deleted the t0yv0/toward-if-intrinsic branch November 19, 2024 18:02
Copy link
Contributor

@flostadler flostadler left a comment

Choose a reason for hiding this comment

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

Love it!

@@ -543,6 +544,18 @@ export class StackConverter extends ArtifactConverter {
}, this.processIntrinsics(params));
}

case 'Fn::Equals': {
return intrinsics.fnEquals.evaluate(this, params);
Copy link
Contributor

Choose a reason for hiding this comment

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

Having separate functions for each intrinsic is much more understandable. Love it!


/**
* Production code may have intermediate values occasionally wrapped in pulumi.Output<T>; this is currently somewhat
* difficult to test, so the essentials of pulumi.Output<T> are abstracted into a Result<T>.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite understand this. Right now it's just any, isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's pulumi.Output<T> in prod, but TestResult<T> in test. I could have used pulumi.Output<T> but currently testing failing scenarios there is very annoying.

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.

Support Fn::If Intrinsic
3 participants