MCPcopy Create free account
hub / github.com/google/go-cloud / ExampleOpenVariable

Function ExampleOpenVariable

runtimevar/awssecretsmanager/example_test.go:27–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25)
26
27func ExampleOpenVariable() {
28 // PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored.
29
30 // Establish a AWS V2 Config.
31 // See https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/ for more info.
32 ctx := context.Background()
33 cfg, err := config.LoadDefaultConfig(ctx)
34 if err != nil {
35 log.Fatal(err)
36 }
37
38 // Construct a *runtimevar.Variable that watches the variable.
39 // `secret-variable-name` must be a friendly name of the secret, NOT the Amazon Resource Name (ARN).
40 client := secretsmanager.NewFromConfig(cfg)
41 v, err := awssecretsmanager.OpenVariable(client, "secret-variable-name", runtimevar.StringDecoder, nil)
42 if err != nil {
43 log.Fatal(err)
44 }
45 defer v.Close()
46}
47
48func Example_openVariableFromURL() {
49 // PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored.

Callers

nothing calls this directly

Calls 2

OpenVariableFunction · 0.92
CloseMethod · 0.65

Tested by

no test coverage detected