local 2.5.2 published on Thursday, Feb 6, 2025 by hashicorp
local.getSensitiveFile
Explore with Pulumi AI
Reads a file that contains sensitive data, from the local filesystem.
The attributes exposed by this data source are marked as sensitive.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as local from "@pulumi/local";
const foo = local.getSensitiveFile({
filename: `${path.module}/foo.bar`,
});
const sharedZip = new aws.index.Aws_s3_object("sharedZip", {
bucket: "my-bucket",
key: "my-key",
content: foo.content,
});
import pulumi
import pulumi_aws as aws
import pulumi_local as local
foo = local.get_sensitive_file(filename=f"{path['module']}/foo.bar")
shared_zip = aws.index.Aws_s3_object("sharedZip",
bucket=my-bucket,
key=my-key,
content=foo.content)
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/go/aws"
"github.com/pulumi/pulumi-terraform-provider/sdks/go/local/v2/local"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
foo, err := local.LookupSensitiveFile(ctx, &local.LookupSensitiveFileArgs{
Filename: fmt.Sprintf("%v/foo.bar", path.Module),
}, nil)
if err != nil {
return err
}
_, err = aws.NewAws_s3_object(ctx, "sharedZip", &aws.Aws_s3_objectArgs{
Bucket: "my-bucket",
Key: "my-key",
Content: foo.Content,
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
using Local = Pulumi.Local;
return await Deployment.RunAsync(() =>
{
var foo = Local.GetSensitiveFile.Invoke(new()
{
Filename = $"{path.Module}/foo.bar",
});
var sharedZip = new Aws.Index.Aws_s3_object("sharedZip", new()
{
Bucket = "my-bucket",
Key = "my-key",
Content = foo.Apply(getSensitiveFileResult => getSensitiveFileResult.Content),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.local.LocalFunctions;
import com.pulumi.local.inputs.GetSensitiveFileArgs;
import com.pulumi.aws.aws_s3_object;
import com.pulumi.aws.Aws_s3_objectArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var foo = LocalFunctions.getSensitiveFile(GetSensitiveFileArgs.builder()
.filename(String.format("%s/foo.bar", path.module()))
.build());
var sharedZip = new Aws_s3_object("sharedZip", Aws_s3_objectArgs.builder()
.bucket("my-bucket")
.key("my-key")
.content(foo.applyValue(getSensitiveFileResult -> getSensitiveFileResult.content()))
.build());
}
}
resources:
sharedZip:
type: aws:aws_s3_object
properties:
bucket: my-bucket
key: my-key
content: ${foo.content}
variables:
foo:
fn::invoke:
function: local:getSensitiveFile
arguments:
filename: ${path.module}/foo.bar
Using getSensitiveFile
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getSensitiveFile(args: GetSensitiveFileArgs, opts?: InvokeOptions): Promise<GetSensitiveFileResult>
function getSensitiveFileOutput(args: GetSensitiveFileOutputArgs, opts?: InvokeOptions): Output<GetSensitiveFileResult>
def get_sensitive_file(filename: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetSensitiveFileResult
def get_sensitive_file_output(filename: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetSensitiveFileResult]
func LookupSensitiveFile(ctx *Context, args *LookupSensitiveFileArgs, opts ...InvokeOption) (*LookupSensitiveFileResult, error)
func LookupSensitiveFileOutput(ctx *Context, args *LookupSensitiveFileOutputArgs, opts ...InvokeOption) LookupSensitiveFileResultOutput
> Note: This function is named LookupSensitiveFile
in the Go SDK.
public static class GetSensitiveFile
{
public static Task<GetSensitiveFileResult> InvokeAsync(GetSensitiveFileArgs args, InvokeOptions? opts = null)
public static Output<GetSensitiveFileResult> Invoke(GetSensitiveFileInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetSensitiveFileResult> getSensitiveFile(GetSensitiveFileArgs args, InvokeOptions options)
public static Output<GetSensitiveFileResult> getSensitiveFile(GetSensitiveFileArgs args, InvokeOptions options)
fn::invoke:
function: local:index/getSensitiveFile:getSensitiveFile
arguments:
# arguments dictionary
The following arguments are supported:
- Filename string
- Path to the file that will be read. The data source will return an error if the file does not exist.
- Filename string
- Path to the file that will be read. The data source will return an error if the file does not exist.
- filename String
- Path to the file that will be read. The data source will return an error if the file does not exist.
- filename string
- Path to the file that will be read. The data source will return an error if the file does not exist.
- filename str
- Path to the file that will be read. The data source will return an error if the file does not exist.
- filename String
- Path to the file that will be read. The data source will return an error if the file does not exist.
getSensitiveFile Result
The following output properties are available:
- Content string
- Raw content of the file that was read, as UTF-8 encoded string. Files that do not contain UTF-8 text will have invalid UTF-8 sequences in
content
replaced with the Unicode replacement character. - Content
Base64 string - Base64 encoded version of the file content (use this when dealing with binary data).
- Content
Base64sha256 string - Base64 encoded SHA256 checksum of file content.
- Content
Base64sha512 string - Base64 encoded SHA512 checksum of file content.
- Content
Md5 string - MD5 checksum of file content.
- Content
Sha1 string - SHA1 checksum of file content.
- Content
Sha256 string - SHA256 checksum of file content.
- Content
Sha512 string - SHA512 checksum of file content.
- Filename string
- Path to the file that will be read. The data source will return an error if the file does not exist.
- Id string
- The hexadecimal encoding of the SHA1 checksum of the file content.
- Content string
- Raw content of the file that was read, as UTF-8 encoded string. Files that do not contain UTF-8 text will have invalid UTF-8 sequences in
content
replaced with the Unicode replacement character. - Content
Base64 string - Base64 encoded version of the file content (use this when dealing with binary data).
- Content
Base64sha256 string - Base64 encoded SHA256 checksum of file content.
- Content
Base64sha512 string - Base64 encoded SHA512 checksum of file content.
- Content
Md5 string - MD5 checksum of file content.
- Content
Sha1 string - SHA1 checksum of file content.
- Content
Sha256 string - SHA256 checksum of file content.
- Content
Sha512 string - SHA512 checksum of file content.
- Filename string
- Path to the file that will be read. The data source will return an error if the file does not exist.
- Id string
- The hexadecimal encoding of the SHA1 checksum of the file content.
- content String
- Raw content of the file that was read, as UTF-8 encoded string. Files that do not contain UTF-8 text will have invalid UTF-8 sequences in
content
replaced with the Unicode replacement character. - content
Base64 String - Base64 encoded version of the file content (use this when dealing with binary data).
- content
Base64sha256 String - Base64 encoded SHA256 checksum of file content.
- content
Base64sha512 String - Base64 encoded SHA512 checksum of file content.
- content
Md5 String - MD5 checksum of file content.
- content
Sha1 String - SHA1 checksum of file content.
- content
Sha256 String - SHA256 checksum of file content.
- content
Sha512 String - SHA512 checksum of file content.
- filename String
- Path to the file that will be read. The data source will return an error if the file does not exist.
- id String
- The hexadecimal encoding of the SHA1 checksum of the file content.
- content string
- Raw content of the file that was read, as UTF-8 encoded string. Files that do not contain UTF-8 text will have invalid UTF-8 sequences in
content
replaced with the Unicode replacement character. - content
Base64 string - Base64 encoded version of the file content (use this when dealing with binary data).
- content
Base64sha256 string - Base64 encoded SHA256 checksum of file content.
- content
Base64sha512 string - Base64 encoded SHA512 checksum of file content.
- content
Md5 string - MD5 checksum of file content.
- content
Sha1 string - SHA1 checksum of file content.
- content
Sha256 string - SHA256 checksum of file content.
- content
Sha512 string - SHA512 checksum of file content.
- filename string
- Path to the file that will be read. The data source will return an error if the file does not exist.
- id string
- The hexadecimal encoding of the SHA1 checksum of the file content.
- content str
- Raw content of the file that was read, as UTF-8 encoded string. Files that do not contain UTF-8 text will have invalid UTF-8 sequences in
content
replaced with the Unicode replacement character. - content_
base64 str - Base64 encoded version of the file content (use this when dealing with binary data).
- content_
base64sha256 str - Base64 encoded SHA256 checksum of file content.
- content_
base64sha512 str - Base64 encoded SHA512 checksum of file content.
- content_
md5 str - MD5 checksum of file content.
- content_
sha1 str - SHA1 checksum of file content.
- content_
sha256 str - SHA256 checksum of file content.
- content_
sha512 str - SHA512 checksum of file content.
- filename str
- Path to the file that will be read. The data source will return an error if the file does not exist.
- id str
- The hexadecimal encoding of the SHA1 checksum of the file content.
- content String
- Raw content of the file that was read, as UTF-8 encoded string. Files that do not contain UTF-8 text will have invalid UTF-8 sequences in
content
replaced with the Unicode replacement character. - content
Base64 String - Base64 encoded version of the file content (use this when dealing with binary data).
- content
Base64sha256 String - Base64 encoded SHA256 checksum of file content.
- content
Base64sha512 String - Base64 encoded SHA512 checksum of file content.
- content
Md5 String - MD5 checksum of file content.
- content
Sha1 String - SHA1 checksum of file content.
- content
Sha256 String - SHA256 checksum of file content.
- content
Sha512 String - SHA512 checksum of file content.
- filename String
- Path to the file that will be read. The data source will return an error if the file does not exist.
- id String
- The hexadecimal encoding of the SHA1 checksum of the file content.
Package Details
- Repository
- local hashicorp/terraform-provider-local
- License
- Notes
- This Pulumi package is based on the
local
Terraform Provider.