The Go SDK is currently in experimental status. If you would like to provide feedback, please reach out to us with your suggestions and comments on our Discord.
Go - NewSecret()
Creates a reference to a secret in the secrets manager.
import (
"fmt"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
secret, err := nitric.NewSecret("secret-name").Allow(nitric.SecretPut, nitric.SecretAccess)
if err != nil {
return
}
if err := nitric.Run(); err != nil {
fmt.Println(err)
}
}
Parameters
- Name
name
- Required
- Required
- Type
- string
- Description
The unique name of this secret within the secrets manager. Subsequent calls to
NewSecret
with the same name will return the same object.
Access
All Nitric resources provide access permissions you can use to specify the level of access your code needs to the resource. See here for details Access Control documentation.
Available permissions:
SecretPut
This permission allows your code to set a new latest value for a secret.
SecretAccess
This permission allows your code to retrieve secret values.
Examples
Create a reference to a secret
import (
"fmt"
"github.com/nitrictech/go-sdk/nitric"
)
func main() {
secret, err := nitric.NewSecret("secret-name").Allow(nitric.SecretPut, nitric.SecretAccess)
if err != nil {
return
}
if err := nitric.Run(); err != nil {
fmt.Println(err)
}
}