-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws.go
58 lines (54 loc) · 1.94 KB
/
aws.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
cip "github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider"
cipTypes "github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider/types"
)
func (app *application) createCognitoUserPool(ctx context.Context, name string) (*cip.CreateUserPoolOutput, error) {
return app.cognitoClient.CreateUserPool(ctx, &cip.CreateUserPoolInput{
PoolName: aws.String(name),
AccountRecoverySetting: &cipTypes.AccountRecoverySettingType{
RecoveryMechanisms: []cipTypes.RecoveryOptionType{{
Name: cipTypes.RecoveryOptionNameTypeVerifiedEmail,
Priority: 1,
}},
},
AdminCreateUserConfig: &cipTypes.AdminCreateUserConfigType{
AllowAdminCreateUserOnly: true,
},
AutoVerifiedAttributes: []cipTypes.VerifiedAttributeType{
cipTypes.VerifiedAttributeTypeEmail,
},
MfaConfiguration: "",
Policies: &cipTypes.UserPoolPolicyType{
PasswordPolicy: &cipTypes.PasswordPolicyType{
MinimumLength: 12,
RequireLowercase: true,
RequireNumbers: true,
RequireSymbols: true,
RequireUppercase: true,
TemporaryPasswordValidityDays: 1,
},
},
UsernameAttributes: []cipTypes.UsernameAttributeType{
cipTypes.UsernameAttributeTypeEmail,
},
UsernameConfiguration: &cipTypes.UsernameConfigurationType{
CaseSensitive: aws.Bool(false),
},
})
}
func (app *application) createCognitoUserPoolClient(ctx context.Context, name string, poolID string) (*cip.CreateUserPoolClientOutput, error) {
return app.cognitoClient.CreateUserPoolClient(ctx, &cip.CreateUserPoolClientInput{
ClientName: aws.String(name),
UserPoolId: aws.String(poolID),
GenerateSecret: false,
})
}
func (app *application) deleteCognitoUserPool(ctx context.Context, poolID string) error {
_, err := app.cognitoClient.DeleteUserPool(ctx, &cip.DeleteUserPoolInput{
UserPoolId: aws.String(poolID),
})
return err
}