From 9176b42ec3f026d971671408d72c53226f3b8322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalle=20Ahlstr=C3=B6m?= Date: Sat, 25 Nov 2023 15:57:14 +0200 Subject: [PATCH] Go: Add FromCloudFormationParams initializer function --- go/nvault/vault.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/go/nvault/vault.go b/go/nvault/vault.go index aeb453a5..c24c7195 100644 --- a/go/nvault/vault.go +++ b/go/nvault/vault.go @@ -72,7 +72,17 @@ func LoadVault(stackNameOpt ...string) (Vault, error) { return res, nil } - +func FromCloudFormationParams(params CloudFormationParams) (*Vault, error) { + cfg, err := config.LoadDefaultConfig(context.TODO()) + if err != nil { + return nil, fmt.Errorf("error creating config: %v", err) + } + return &Vault{ + cloudformationParams: params, + s3Client: *s3.NewFromConfig(cfg), + kmsClient: *kms.NewFromConfig(cfg), + }, nil +} func getCloudformationParams(cfg *aws.Config, stackName string) (CloudFormationParams, error) { res := CloudFormationParams{} cfnClient := cloudformation.NewFromConfig(*cfg)