mirror of
https://github.com/storytold/irsa-manager.git
synced 2026-10-17 00:23:52 +00:00
create Idp
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/service/iam"
|
||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||
)
|
||||
|
||||
@@ -24,6 +25,12 @@ func NewAwsClient(ctx context.Context, region string) (*AwsConfig, error) {
|
||||
return &AwsConfig{config: cfg}, nil
|
||||
}
|
||||
|
||||
func (a *AwsConfig) IamCient() *AwsIamClient {
|
||||
return &AwsIamClient{
|
||||
iam.NewFromConfig(a.config),
|
||||
}
|
||||
}
|
||||
|
||||
func (a *AwsConfig) S3Cient(bucketName string) *AwsS3Client {
|
||||
return &AwsS3Client{
|
||||
bucketName,
|
||||
@@ -51,3 +58,31 @@ func (a *AwsS3Client) CreateBucket(ctx context.Context) error {
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *AwsS3Client) BucketName() string {
|
||||
return a.bucketName
|
||||
}
|
||||
|
||||
func (a *AwsS3Client) Region() string {
|
||||
return a.client.Options().Region
|
||||
}
|
||||
|
||||
type AwsIamClient struct {
|
||||
client *iam.Client
|
||||
}
|
||||
|
||||
func (a *AwsIamClient) CreateOIDCProvider(ctx context.Context, providerUrl string) (string, error) {
|
||||
result, err := a.client.CreateOpenIDConnectProvider(ctx, &iam.CreateOpenIDConnectProviderInput{
|
||||
Url: &providerUrl,
|
||||
ClientIDList: []string{"sts.amazonaws.com"},
|
||||
ThumbprintList: []string{},
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return *result.OpenIDConnectProviderArn, nil
|
||||
}
|
||||
|
||||
func (a *AwsIamClient) Region() string {
|
||||
return a.client.Options().Region
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user