curious if anyone has a good example TS code for c...
# typescript
curious if anyone has a good example TS code for creating resources if param was passed in or not and returning either the string returned, or the pulumi equivalent. For example, if in a config file a certificate arn is passed in, then use that cert arn when creating a cloudfront resource, but if the cert isn’t passed in, then create the cert and pass in the cert arn
Something like this?
I tend to wrap all the infra in classes, init all the infra in the constructor and then have readonly fields to pass things between different stacks/classes/pieces of infra
If that works 👍 I’m attaching what is (perhaps) a cleaner implementation.
will return
if that key isn’t there, so the
|| "";
is probably unnecessary. Undefined also lets you use the ternary operator in line 14 of this snippet. This lets the
function to remain pretty simple.
Just note, the
function uses the same resource name every time. So if you need to call it more than once, you’ll need to come up with a way to make
unique each call.