本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/kms.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Configure
//Configure ... configures using global settings
func Configure(cfg *GlobalConfig) {
svc = kms.New(session.New(
&aws.Config{
Region: aws.String(cfg.AWSRegion),
},
))
}
开发者ID:mickelsonm,项目名称:go-confidant,代码行数:8,代码来源:confidant.go
示例2: stackConfig
func (c Cluster) stackConfig(opts StackTemplateOptions, compressUserData bool) (*stackConfig, error) {
assets, err := ReadTLSAssets(opts.TLSAssetsDir)
if err != nil {
return nil, err
}
stackConfig := stackConfig{}
if stackConfig.Config, err = c.Config(); err != nil {
return nil, err
}
awsConfig := aws.NewConfig()
awsConfig = awsConfig.WithRegion(stackConfig.Config.Region)
kmsSvc := kms.New(session.New(awsConfig))
compactAssets, err := assets.compact(stackConfig.Config, kmsSvc)
if err != nil {
return nil, fmt.Errorf("failed to compress TLS assets: %v", err)
}
stackConfig.Config.TLSConfig = compactAssets
if stackConfig.UserDataWorker, err = execute(opts.WorkerTmplFile, stackConfig.Config, compressUserData); err != nil {
return nil, fmt.Errorf("failed to render worker cloud config: %v", err)
}
if stackConfig.UserDataController, err = execute(opts.ControllerTmplFile, stackConfig.Config, compressUserData); err != nil {
return nil, fmt.Errorf("failed to render controller cloud config: %v", err)
}
return &stackConfig, nil
}
开发者ID:endocode,项目名称:coreos-kubernetes,代码行数:31,代码来源:config.go
示例3: loadSneakerManager
// loadSneakerManager returns a sneaker manager if one is configured on the env.
func loadSneakerManager() *sneaker.Manager {
path := String("SNEAKER_S3_PATH")
if path == "" {
return nil
}
u, err := url.Parse(path)
if err != nil {
log.WithField("path", path).Fatal("Invalid SNEAKER_S3_PATH")
return nil
}
if u.Path != "" && u.Path[0] == '/' {
u.Path = u.Path[1:]
}
sess := session.New()
config := aws.NewConfig().WithRegion(String("SNEAKER_S3_REGION", "us-west-2")).WithMaxRetries(3)
return &sneaker.Manager{
Objects: s3.New(sess, config),
Envelope: sneaker.Envelope{
KMS: kms.New(sess, config),
},
Bucket: u.Host,
Prefix: u.Path,
KeyId: String("SNEAKER_MASTER_KEY"),
}
}
开发者ID:snikch,项目名称:api,代码行数:27,代码来源:sneaker.go
示例4: getAliasInformation
func getAliasInformation(alias, region string) (string, error) {
arn := ""
svc := kms.New(session.New(&aws.Config{
Region: ®ion,
}))
truncated := true
var marker *string
for truncated {
out, err := svc.ListAliases(&kms.ListAliasesInput{
Marker: marker,
})
if err != nil {
return arn, err
}
for _, aliasEntry := range out.Aliases {
if *aliasEntry.AliasName == "alias/"+alias {
return *aliasEntry.AliasArn, nil
}
}
truncated = *out.Truncated
marker = out.NextMarker
}
return "", errors.New("The alias " + alias + " does not exist in your account. Please add the proper alias to a key")
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:26,代码来源:stepdef.go
示例5: ExampleKMS_RetireGrant
func ExampleKMS_RetireGrant() {
svc := kms.New(nil)
params := &kms.RetireGrantInput{
GrantId: aws.String("GrantIdType"),
GrantToken: aws.String("GrantTokenType"),
KeyId: aws.String("KeyIdType"),
}
resp, err := svc.RetireGrant(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
开发者ID:strife25,项目名称:aws-sdk-go,代码行数:28,代码来源:examples_test.go
示例6: ExampleKMS_CreateAlias
func ExampleKMS_CreateAlias() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := kms.New(sess)
params := &kms.CreateAliasInput{
AliasName: aws.String("AliasNameType"), // Required
TargetKeyId: aws.String("KeyIdType"), // Required
}
resp, err := svc.CreateAlias(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:25,代码来源:examples_test.go
示例7: ExampleKMS_CreateKey
func ExampleKMS_CreateKey() {
svc := kms.New(nil)
params := &kms.CreateKeyInput{
Description: aws.String("DescriptionType"),
KeyUsage: aws.String("KeyUsageType"),
Policy: aws.String("PolicyType"),
}
resp, err := svc.CreateKey(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS Error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
开发者ID:jasonmoo,项目名称:aws-sdk-go,代码行数:28,代码来源:examples_test.go
示例8: ExampleKMS_ScheduleKeyDeletion
func ExampleKMS_ScheduleKeyDeletion() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := kms.New(sess)
params := &kms.ScheduleKeyDeletionInput{
KeyId: aws.String("KeyIdType"), // Required
PendingWindowInDays: aws.Int64(1),
}
resp, err := svc.ScheduleKeyDeletion(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:25,代码来源:examples_test.go
示例9: ExampleKMS_PutKeyPolicy
func ExampleKMS_PutKeyPolicy() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := kms.New(sess)
params := &kms.PutKeyPolicyInput{
KeyId: aws.String("KeyIdType"), // Required
Policy: aws.String("PolicyType"), // Required
PolicyName: aws.String("PolicyNameType"), // Required
BypassPolicyLockoutSafetyCheck: aws.Bool(true),
}
resp, err := svc.PutKeyPolicy(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:27,代码来源:examples_test.go
示例10: ExampleKMS_RetireGrant
func ExampleKMS_RetireGrant() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := kms.New(sess)
params := &kms.RetireGrantInput{
GrantId: aws.String("GrantIdType"),
GrantToken: aws.String("GrantTokenType"),
KeyId: aws.String("KeyIdType"),
}
resp, err := svc.RetireGrant(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:26,代码来源:examples_test.go
示例11: ExampleKMS_Encrypt
func ExampleKMS_Encrypt() {
svc := kms.New(nil)
params := &kms.EncryptInput{
KeyID: aws.String("KeyIdType"), // Required
Plaintext: []byte("PAYLOAD"), // Required
EncryptionContext: map[string]*string{
"Key": aws.String("EncryptionContextValue"), // Required
// More values...
},
GrantTokens: []*string{
aws.String("GrantTokenType"), // Required
// More values...
},
}
resp, err := svc.Encrypt(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS Error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
开发者ID:jasonmoo,项目名称:aws-sdk-go,代码行数:35,代码来源:examples_test.go
示例12: ExampleKMS_ListRetirableGrants
func ExampleKMS_ListRetirableGrants() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := kms.New(sess)
params := &kms.ListRetirableGrantsInput{
RetiringPrincipal: aws.String("PrincipalIdType"), // Required
Limit: aws.Int64(1),
Marker: aws.String("MarkerType"),
}
resp, err := svc.ListRetirableGrants(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:26,代码来源:examples_test.go
示例13: loadManager
func loadManager() *sneaker.Manager {
u, err := url.Parse(os.Getenv("SNEAKER_S3_PATH"))
if err != nil {
log.Fatalf("bad SNEAKER_S3_PATH: %s", err)
}
if u.Path != "" && u.Path[0] == '/' {
u.Path = u.Path[1:]
}
ctxt, err := parseContext(os.Getenv("SNEAKER_MASTER_CONTEXT"))
if err != nil {
log.Fatalf("bad SNEAKER_MASTER_CONTEXT: %s", err)
}
return &sneaker.Manager{
Objects: s3.New(nil),
Envelope: sneaker.Envelope{
KMS: kms.New(nil),
},
Bucket: u.Host,
Prefix: u.Path,
EncryptionContext: ctxt,
KeyID: os.Getenv("SNEAKER_MASTER_KEY"),
}
}
开发者ID:reactiveops,项目名称:sneaker,代码行数:25,代码来源:main.go
示例14: ExampleKMS_GetParametersForImport
func ExampleKMS_GetParametersForImport() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := kms.New(sess)
params := &kms.GetParametersForImportInput{
KeyId: aws.String("KeyIdType"), // Required
WrappingAlgorithm: aws.String("AlgorithmSpec"), // Required
WrappingKeySpec: aws.String("WrappingKeySpec"), // Required
}
resp, err := svc.GetParametersForImport(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:26,代码来源:examples_test.go
示例15: ExampleKMS_Encrypt
func ExampleKMS_Encrypt() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := kms.New(sess)
params := &kms.EncryptInput{
KeyId: aws.String("KeyIdType"), // Required
Plaintext: []byte("PAYLOAD"), // Required
EncryptionContext: map[string]*string{
"Key": aws.String("EncryptionContextValue"), // Required
// More values...
},
GrantTokens: []*string{
aws.String("GrantTokenType"), // Required
// More values...
},
}
resp, err := svc.Encrypt(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:33,代码来源:examples_test.go
示例16: ExampleKMS_GenerateRandom
func ExampleKMS_GenerateRandom() {
svc := kms.New(nil)
params := &kms.GenerateRandomInput{
NumberOfBytes: aws.Long(1),
}
resp, err := svc.GenerateRandom(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS Error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
开发者ID:jasonmoo,项目名称:aws-sdk-go,代码行数:26,代码来源:examples_test.go
示例17: ExampleKMS_CreateKey
func ExampleKMS_CreateKey() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := kms.New(sess)
params := &kms.CreateKeyInput{
BypassPolicyLockoutSafetyCheck: aws.Bool(true),
Description: aws.String("DescriptionType"),
KeyUsage: aws.String("KeyUsageType"),
Origin: aws.String("OriginType"),
Policy: aws.String("PolicyType"),
}
resp, err := svc.CreateKey(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:28,代码来源:examples_test.go
示例18: ExampleKMS_DescribeKey
func ExampleKMS_DescribeKey() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := kms.New(sess)
params := &kms.DescribeKeyInput{
KeyId: aws.String("KeyIdType"), // Required
GrantTokens: []*string{
aws.String("GrantTokenType"), // Required
// More values...
},
}
resp, err := svc.DescribeKey(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:28,代码来源:examples_test.go
示例19: ExampleKMS_ReEncrypt
func ExampleKMS_ReEncrypt() {
svc := kms.New(session.New())
params := &kms.ReEncryptInput{
CiphertextBlob: []byte("PAYLOAD"), // Required
DestinationKeyId: aws.String("KeyIdType"), // Required
DestinationEncryptionContext: map[string]*string{
"Key": aws.String("EncryptionContextValue"), // Required
// More values...
},
GrantTokens: []*string{
aws.String("GrantTokenType"), // Required
// More values...
},
SourceEncryptionContext: map[string]*string{
"Key": aws.String("EncryptionContextValue"), // Required
// More values...
},
}
resp, err := svc.ReEncrypt(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:CNDonny,项目名称:scope,代码行数:31,代码来源:examples_test.go
示例20: ExampleKMS_UpdateAlias
func ExampleKMS_UpdateAlias() {
svc := kms.New(nil)
params := &kms.UpdateAliasInput{
AliasName: aws.String("AliasNameType"), // Required
TargetKeyID: aws.String("KeyIdType"), // Required
}
resp, err := svc.UpdateAlias(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS Error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
开发者ID:jasonmoo,项目名称:aws-sdk-go,代码行数:27,代码来源:examples_test.go
注:本文中的github.com/aws/aws-sdk-go/service/kms.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论