예제 #1
0
파일: main.go 프로젝트: kunday/shush
func makeKmsHandle(region string, contextString string) (ops *kmsHandle, err error) {
	encryptionContext, err := parseEncryptionContext(contextString)
	if err != nil {
		return
	}
	if region == "" {
		region = awsmeta.GetRegion()
		if region == "" {
			err = errors.New("please specify region (--region or $AWS_DEFAULT_REGION)")
			return
		}
	}
	ops = &kmsHandle{
		Client:  kms.New(&aws.Config{Region: &region}),
		Context: encryptionContext,
	}
	return
}
예제 #2
0
func makeKmsHandle(region string, context []string) (ops *kmsHandle, err error) {
	encryptionContext, err := parseEncryptionContext(context)
	if err != nil {
		return nil, fmt.Errorf("could not parse encryption context: %v", err)
	}
	if region == "" {
		region = awsmeta.GetRegion()
		if region == "" {
			err = errors.New("please specify region (--region or $AWS_DEFAULT_REGION)")
			return
		}
	}
	client := kms.New(session.New(), aws.NewConfig().WithRegion(region))
	ops = &kmsHandle{
		Client:  client,
		Context: encryptionContext,
	}
	return
}