From 352924475c526d4e3d533c5bc25c8b10b5ed5569 Mon Sep 17 00:00:00 2001 From: zhewang Date: Fri, 27 Sep 2024 15:44:46 +0800 Subject: [PATCH] OCM-11486 | test: Add prepare resource share function --- pkg/aws/aws_client/ram.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/aws/aws_client/ram.go b/pkg/aws/aws_client/ram.go index 8e0e105..e5f7090 100644 --- a/pkg/aws/aws_client/ram.go +++ b/pkg/aws/aws_client/ram.go @@ -30,3 +30,16 @@ func (awsClient AWSClient) DeleteResourceShare(resourceShareArn string) error { _, err := awsClient.RamClient.DeleteResourceShare(context.TODO(), input) return err } + +func (awsClient AWSClient) PrepareResourceShare(resourceShareName string, resourceArns []string, accountID string) (string, error) { + var principles []string + principles = append(principles, accountID) + + sharedResourceOutput, err := awsClient.CreateResourceShare(resourceShareName, resourceArns, principles) + if err != nil { + return "", err + } + resourceShareArn := *sharedResourceOutput.ResourceShare.ResourceShareArn + + return resourceShareArn, err +}