You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Document all Pulumi YAML built-in functions (#20312)
The YAML language reference was missing several built-in functions
implemented by the language host. Add documentation for fn::unsecret,
fn::filebase64, fn::filebase64sha256, fn::sha1, fn::length,
fn::singleOrNone, fn::pulumiResourceName, fn::pulumiResourceType, and
the deprecated fn::stackReference.
Copy file name to clipboardExpand all lines: content/docs/iac/languages-sdks/yaml/yaml-language-reference.md
+117Lines changed: 117 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -599,6 +599,16 @@ variables:
599
599
function: my:pkg:GetSecretValue
600
600
```
601
601
602
+
### `fn::unsecret`
603
+
604
+
Unwraps a [Secret](/docs/concepts/secrets/), returning the underlying value with the secret marking removed.
605
+
606
+
``` yaml
607
+
variables:
608
+
plaintext:
609
+
fn::unsecret: ${someSecretValue}
610
+
```
611
+
602
612
### `fn::readFile`
603
613
604
614
Reads a file from disk and returns the contents as a string, must be utf-8. This function has
@@ -630,6 +640,113 @@ forbidden to prevent path traversals.
630
640
* `fn::readFile: ${pulumi.cwd}/../../.ssh/id_rsa.pub`, an expression that returns an absolute path
631
641
that escapes the project
632
642
643
+
### `fn::filebase64`
644
+
645
+
Reads a file from disk and returns the contents as a Base64 encoded string using the [standard encoding](https://pkg.go.dev/encoding/base64#pkg-variables).
646
+
647
+
``` yaml
648
+
variables:
649
+
encoded:
650
+
fn::filebase64: ./file.txt
651
+
```
652
+
653
+
### `fn::filebase64sha256`
654
+
655
+
Reads a file from disk and returns the SHA-256 hash of its contents as a Base64 encoded string.
656
+
657
+
``` yaml
658
+
variables:
659
+
fileHash:
660
+
fn::filebase64sha256: ./file.txt
661
+
```
662
+
663
+
### `fn::sha1`
664
+
665
+
Computes the SHA-1 hash of a string and returns it as a hexadecimal string.
666
+
667
+
```yaml
668
+
variables:
669
+
hashed:
670
+
fn::sha1: "Hello, world!"
671
+
```
672
+
673
+
The expression `${hashed}` will return `943a702d06f34599aee1f8da8ef9f7296031d699`.
674
+
675
+
### `fn::length`
676
+
677
+
Returns the length of a list, map, or string as a number. For a list or map, this is the number of elements. For a string, this is the number of characters.
678
+
679
+
```yaml
680
+
variables:
681
+
fruits:
682
+
- apple
683
+
- orange
684
+
- banana
685
+
fruitCount:
686
+
fn::length: ${fruits}
687
+
```
688
+
689
+
The expression `${fruitCount}` will return `3`.
690
+
691
+
### `fn::singleOrNone`
692
+
693
+
Takes a list and returns its single element, or `null` if the list is empty. It is an error if the list contains more than one element.
694
+
695
+
```yaml
696
+
variables:
697
+
single:
698
+
fn::singleOrNone:
699
+
- v1
700
+
```
701
+
702
+
The expression `${single}` will return `v1`.
703
+
704
+
### `fn::pulumiResourceName`
705
+
706
+
Returns the name a resource was registered with. This is the resource's logical name unless it was overridden with the `name` resource option.
707
+
708
+
```yaml
709
+
resources:
710
+
bucket:
711
+
type: aws:s3:BucketV2
712
+
variables:
713
+
bucketName:
714
+
fn::pulumiResourceName: ${bucket}
715
+
```
716
+
717
+
The expression `${bucketName}` will return `bucket`.
718
+
719
+
### `fn::pulumiResourceType`
720
+
721
+
Returns the type token of a resource declared in the program.
722
+
723
+
```yaml
724
+
resources:
725
+
bucket:
726
+
type: aws:s3:BucketV2
727
+
variables:
728
+
bucketType:
729
+
fn::pulumiResourceType: ${bucket}
730
+
```
731
+
732
+
The expression `${bucketType}` will return `aws:s3/bucketV2:BucketV2`.
733
+
734
+
### `fn::stackReference`
735
+
736
+
{{% notes type="warning" %}}
737
+
`fn::stackReference`is deprecated. Declare a resource of type [`pulumi:pulumi:StackReference`](/docs/concepts/stack/#stackreferences) instead.
738
+
{{% /notes %}}
739
+
740
+
Reads an output from another Pulumi stack. Arguments are passed as a list, with the first item being the fully qualified stack name and the second item the name of the output to read.
741
+
742
+
```yaml
743
+
variables:
744
+
otherOutput:
745
+
fn::stackReference:
746
+
- org/project/stack
747
+
- someOutput
748
+
```
749
+
633
750
## Built-in variables
634
751
635
752
Built-in variables accessible within any Pulumi YAML program.
0 commit comments