Vendor aws-sdk-go (dep ensure) (#178)
This commit is contained in:
4459
vendor/github.com/aws/aws-sdk-go/service/secretsmanager/api.go
generated
vendored
Normal file
4459
vendor/github.com/aws/aws-sdk-go/service/secretsmanager/api.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
87
vendor/github.com/aws/aws-sdk-go/service/secretsmanager/doc.go
generated
vendored
Normal file
87
vendor/github.com/aws/aws-sdk-go/service/secretsmanager/doc.go
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package secretsmanager provides the client and types for making API
|
||||
// requests to AWS Secrets Manager.
|
||||
//
|
||||
// AWS Secrets Manager is a web service that enables you to store, manage, and
|
||||
// retrieve, secrets.
|
||||
//
|
||||
// This guide provides descriptions of the Secrets Manager API. For more information
|
||||
// about using this service, see the AWS Secrets Manager User Guide (http://docs.aws.amazon.com/secretsmanager/latest/userguide/introduction.html).
|
||||
//
|
||||
// API Version
|
||||
//
|
||||
// This version of the Secrets Manager API Reference documents the Secrets Manager
|
||||
// API version 2017-10-17.
|
||||
//
|
||||
// As an alternative to using the API directly, you can use one of the AWS SDKs,
|
||||
// which consist of libraries and sample code for various programming languages
|
||||
// and platforms (such as Java, Ruby, .NET, iOS, and Android). The SDKs provide
|
||||
// a convenient way to create programmatic access to AWS Secrets Manager. For
|
||||
// example, the SDKs take care of cryptographically signing requests, managing
|
||||
// errors, and retrying requests automatically. For more information about the
|
||||
// AWS SDKs, including how to download and install them, see Tools for Amazon
|
||||
// Web Services (http://aws.amazon.com/tools/).
|
||||
//
|
||||
// We recommend that you use the AWS SDKs to make programmatic API calls to
|
||||
// Secrets Manager. However, you also can use the Secrets Manager HTTP Query
|
||||
// API to make direct calls to the Secrets Manager web service. To learn more
|
||||
// about the Secrets Manager HTTP Query API, see Making Query Requests (http://docs.aws.amazon.com/secretsmanager/latest/userguide/query-requests.html)
|
||||
// in the AWS Secrets Manager User Guide.
|
||||
//
|
||||
// Secrets Manager supports GET and POST requests for all actions. That is,
|
||||
// the API doesn't require you to use GET for some actions and POST for others.
|
||||
// However, GET requests are subject to the limitation size of a URL. Therefore,
|
||||
// for operations that require larger sizes, use a POST request.
|
||||
//
|
||||
// Support and Feedback for AWS Secrets Manager
|
||||
//
|
||||
// We welcome your feedback. Send your comments to awssecretsmanager-feedback@amazon.com
|
||||
// (mailto:awssecretsmanager-feedback@amazon.com), or post your feedback and
|
||||
// questions in the AWS Secrets Manager Discussion Forum (http://forums.aws.amazon.com/forum.jspa?forumID=296).
|
||||
// For more information about the AWS Discussion Forums, see Forums Help (http://forums.aws.amazon.com/help.jspa).
|
||||
//
|
||||
// How examples are presented
|
||||
//
|
||||
// The JSON that AWS Secrets Manager expects as your request parameters and
|
||||
// that the service returns as a response to HTTP query requests are single,
|
||||
// long strings without line breaks or white space formatting. The JSON shown
|
||||
// in the examples is formatted with both line breaks and white space to improve
|
||||
// readability. When example input parameters would also result in long strings
|
||||
// that extend beyond the screen, we insert line breaks to enhance readability.
|
||||
// You should always submit the input as a single JSON text string.
|
||||
//
|
||||
// Logging API Requests
|
||||
//
|
||||
// AWS Secrets Manager supports AWS CloudTrail, a service that records AWS API
|
||||
// calls for your AWS account and delivers log files to an Amazon S3 bucket.
|
||||
// By using information that's collected by AWS CloudTrail, you can determine
|
||||
// which requests were successfully made to Secrets Manager, who made the request,
|
||||
// when it was made, and so on. For more about AWS Secrets Manager and its support
|
||||
// for AWS CloudTrail, see Logging AWS Secrets Manager Events with AWS CloudTrail
|
||||
// (http://docs.aws.amazon.com/secretsmanager/latest/userguide/monitoring.html#monitoring_cloudtrail)
|
||||
// in the AWS Secrets Manager User Guide. To learn more about CloudTrail, including
|
||||
// how to turn it on and find your log files, see the AWS CloudTrail User Guide
|
||||
// (http://docs.aws.amazon.com/awscloudtrail/latest/userguide/what_is_cloud_trail_top_level.html).
|
||||
//
|
||||
// See https://docs.aws.amazon.com/goto/WebAPI/secretsmanager-2017-10-17 for more information on this service.
|
||||
//
|
||||
// See secretsmanager package documentation for more information.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/secretsmanager/
|
||||
//
|
||||
// Using the Client
|
||||
//
|
||||
// To contact AWS Secrets Manager with the SDK use the New function to create
|
||||
// a new service client. With that client you can make API requests to the service.
|
||||
// These clients are safe to use concurrently.
|
||||
//
|
||||
// See the SDK's documentation for more information on how to use the SDK.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/
|
||||
//
|
||||
// See aws.Config documentation for more information on configuring SDK clients.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config
|
||||
//
|
||||
// See the AWS Secrets Manager client SecretsManager for more
|
||||
// information on creating client for this service.
|
||||
// https://docs.aws.amazon.com/sdk-for-go/api/service/secretsmanager/#New
|
||||
package secretsmanager
|
||||
74
vendor/github.com/aws/aws-sdk-go/service/secretsmanager/errors.go
generated
vendored
Normal file
74
vendor/github.com/aws/aws-sdk-go/service/secretsmanager/errors.go
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package secretsmanager
|
||||
|
||||
const (
|
||||
|
||||
// ErrCodeDecryptionFailure for service response error code
|
||||
// "DecryptionFailure".
|
||||
//
|
||||
// Secrets Manager can't decrypt the protected secret text using the provided
|
||||
// KMS key.
|
||||
ErrCodeDecryptionFailure = "DecryptionFailure"
|
||||
|
||||
// ErrCodeEncryptionFailure for service response error code
|
||||
// "EncryptionFailure".
|
||||
//
|
||||
// Secrets Manager can't encrypt the protected secret text using the provided
|
||||
// KMS key. Check that the customer master key (CMK) is available, enabled,
|
||||
// and not in an invalid state. For more information, see How Key State Affects
|
||||
// Use of a Customer Master Key (http://docs.aws.amazon.com/kms/latest/developerguide/key-state.html).
|
||||
ErrCodeEncryptionFailure = "EncryptionFailure"
|
||||
|
||||
// ErrCodeInternalServiceError for service response error code
|
||||
// "InternalServiceError".
|
||||
//
|
||||
// An error occurred on the server side.
|
||||
ErrCodeInternalServiceError = "InternalServiceError"
|
||||
|
||||
// ErrCodeInvalidNextTokenException for service response error code
|
||||
// "InvalidNextTokenException".
|
||||
//
|
||||
// You provided an invalid NextToken value.
|
||||
ErrCodeInvalidNextTokenException = "InvalidNextTokenException"
|
||||
|
||||
// ErrCodeInvalidParameterException for service response error code
|
||||
// "InvalidParameterException".
|
||||
//
|
||||
// You provided an invalid value for a parameter.
|
||||
ErrCodeInvalidParameterException = "InvalidParameterException"
|
||||
|
||||
// ErrCodeInvalidRequestException for service response error code
|
||||
// "InvalidRequestException".
|
||||
//
|
||||
// You provided a parameter value that is not valid for the current state of
|
||||
// the resource. For example, if you try to enable rotation on a secret, you
|
||||
// must already have a Lambda function ARN configured or included as a parameter
|
||||
// in this call.
|
||||
ErrCodeInvalidRequestException = "InvalidRequestException"
|
||||
|
||||
// ErrCodeLimitExceededException for service response error code
|
||||
// "LimitExceededException".
|
||||
//
|
||||
// The request failed because it would exceed one of the Secrets Manager internal
|
||||
// limits.
|
||||
ErrCodeLimitExceededException = "LimitExceededException"
|
||||
|
||||
// ErrCodeMalformedPolicyDocumentException for service response error code
|
||||
// "MalformedPolicyDocumentException".
|
||||
//
|
||||
// The policy document that you provided isn't valid.
|
||||
ErrCodeMalformedPolicyDocumentException = "MalformedPolicyDocumentException"
|
||||
|
||||
// ErrCodeResourceExistsException for service response error code
|
||||
// "ResourceExistsException".
|
||||
//
|
||||
// A resource with the ID you requested already exists.
|
||||
ErrCodeResourceExistsException = "ResourceExistsException"
|
||||
|
||||
// ErrCodeResourceNotFoundException for service response error code
|
||||
// "ResourceNotFoundException".
|
||||
//
|
||||
// We can't find the resource that you asked for.
|
||||
ErrCodeResourceNotFoundException = "ResourceNotFoundException"
|
||||
)
|
||||
827
vendor/github.com/aws/aws-sdk-go/service/secretsmanager/examples_test.go
generated
vendored
Normal file
827
vendor/github.com/aws/aws-sdk-go/service/secretsmanager/examples_test.go
generated
vendored
Normal file
@@ -0,0 +1,827 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package secretsmanager_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/secretsmanager"
|
||||
)
|
||||
|
||||
var _ time.Duration
|
||||
var _ strings.Reader
|
||||
var _ aws.Config
|
||||
|
||||
func parseTime(layout, value string) *time.Time {
|
||||
t, err := time.Parse(layout, value)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &t
|
||||
}
|
||||
|
||||
// To cancel scheduled rotation for a secret
|
||||
//
|
||||
// The following example shows how to cancel rotation for a secret. The operation sets
|
||||
// the RotationEnabled field to false and cancels all scheduled rotations. To resume
|
||||
// scheduled rotations, you must re-enable rotation by calling the rotate-secret operation.
|
||||
func ExampleSecretsManager_CancelRotateSecret_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.CancelRotateSecretInput{
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
}
|
||||
|
||||
result, err := svc.CancelRotateSecret(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To create a basic secret
|
||||
//
|
||||
// The following example shows how to create a secret. The credentials stored in the
|
||||
// encrypted secret value are retrieved from a file on disk named mycreds.json.
|
||||
func ExampleSecretsManager_CreateSecret_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.CreateSecretInput{
|
||||
ClientRequestToken: aws.String("EXAMPLE1-90ab-cdef-fedc-ba987SECRET1"),
|
||||
Description: aws.String("My test database secret created with the CLI"),
|
||||
Name: aws.String("MyTestDatabaseSecret"),
|
||||
SecretString: aws.String("{\"username\":\"david\",\"password\":\"BnQw!XDWgaEeT9XGTT29\"}"),
|
||||
}
|
||||
|
||||
result, err := svc.CreateSecret(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
case secretsmanager.ErrCodeLimitExceededException:
|
||||
fmt.Println(secretsmanager.ErrCodeLimitExceededException, aerr.Error())
|
||||
case secretsmanager.ErrCodeEncryptionFailure:
|
||||
fmt.Println(secretsmanager.ErrCodeEncryptionFailure, aerr.Error())
|
||||
case secretsmanager.ErrCodeResourceExistsException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceExistsException, aerr.Error())
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeMalformedPolicyDocumentException:
|
||||
fmt.Println(secretsmanager.ErrCodeMalformedPolicyDocumentException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To delete a secret
|
||||
//
|
||||
// The following example shows how to delete a secret. The secret stays in your account
|
||||
// in a deprecated and inaccessible state until the recovery window ends. After the
|
||||
// date and time in the DeletionDate response field has passed, you can no longer recover
|
||||
// this secret with restore-secret.
|
||||
func ExampleSecretsManager_DeleteSecret_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.DeleteSecretInput{
|
||||
RecoveryWindowInDays: aws.Int64(7),
|
||||
SecretId: aws.String("MyTestDatabaseSecret1"),
|
||||
}
|
||||
|
||||
result, err := svc.DeleteSecret(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To retrieve the details of a secret
|
||||
//
|
||||
// The following example shows how to get the details about a secret.
|
||||
func ExampleSecretsManager_DescribeSecret_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.DescribeSecretInput{
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
}
|
||||
|
||||
result, err := svc.DescribeSecret(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To generate a random password
|
||||
//
|
||||
// The following example shows how to request a randomly generated password. This example
|
||||
// includes the optional flags to require spaces and at least one character of each
|
||||
// included type. It specifies a length of 20 characters.
|
||||
func ExampleSecretsManager_GetRandomPassword_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.GetRandomPasswordInput{
|
||||
IncludeSpace: aws.Bool(true),
|
||||
PasswordLength: aws.Int64(20),
|
||||
RequireEachIncludedType: aws.Bool(true),
|
||||
}
|
||||
|
||||
result, err := svc.GetRandomPassword(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To retrieve the encrypted secret value of a secret
|
||||
//
|
||||
// The following example shows how to retrieve the secret string value from the version
|
||||
// of the secret that has the AWSPREVIOUS staging label attached. If you want to retrieve
|
||||
// the AWSCURRENT version of the secret, then you can omit the VersionStage parameter
|
||||
// because it defaults to AWSCURRENT.
|
||||
func ExampleSecretsManager_GetSecretValue_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.GetSecretValueInput{
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
VersionStage: aws.String("AWSPREVIOUS"),
|
||||
}
|
||||
|
||||
result, err := svc.GetSecretValue(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
case secretsmanager.ErrCodeDecryptionFailure:
|
||||
fmt.Println(secretsmanager.ErrCodeDecryptionFailure, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To list all of the secret versions associated with a secret
|
||||
//
|
||||
// The following example shows how to retrieve a list of all of the versions of a secret,
|
||||
// including those without any staging labels.
|
||||
func ExampleSecretsManager_ListSecretVersionIds_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.ListSecretVersionIdsInput{
|
||||
IncludeDeprecated: aws.Bool(true),
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
}
|
||||
|
||||
result, err := svc.ListSecretVersionIds(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeInvalidNextTokenException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidNextTokenException, aerr.Error())
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To list the secrets in your account
|
||||
//
|
||||
// The following example shows how to list all of the secrets in your account.
|
||||
func ExampleSecretsManager_ListSecrets_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.ListSecretsInput{}
|
||||
|
||||
result, err := svc.ListSecrets(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidNextTokenException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidNextTokenException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To store a secret value in a new version of a secret
|
||||
//
|
||||
// The following example shows how to create a new version of the secret. Alternatively,
|
||||
// you can use the update-secret command.
|
||||
func ExampleSecretsManager_PutSecretValue_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.PutSecretValueInput{
|
||||
ClientRequestToken: aws.String("EXAMPLE2-90ab-cdef-fedc-ba987EXAMPLE"),
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
SecretString: aws.String("{\"username\":\"david\",\"password\":\"BnQw!XDWgaEeT9XGTT29\"}"),
|
||||
}
|
||||
|
||||
result, err := svc.PutSecretValue(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
case secretsmanager.ErrCodeLimitExceededException:
|
||||
fmt.Println(secretsmanager.ErrCodeLimitExceededException, aerr.Error())
|
||||
case secretsmanager.ErrCodeEncryptionFailure:
|
||||
fmt.Println(secretsmanager.ErrCodeEncryptionFailure, aerr.Error())
|
||||
case secretsmanager.ErrCodeResourceExistsException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceExistsException, aerr.Error())
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To restore a previously deleted secret
|
||||
//
|
||||
// The following example shows how to restore a secret that you previously scheduled
|
||||
// for deletion.
|
||||
func ExampleSecretsManager_RestoreSecret_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.RestoreSecretInput{
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
}
|
||||
|
||||
result, err := svc.RestoreSecret(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To configure rotation for a secret
|
||||
//
|
||||
// The following example configures rotation for a secret by providing the ARN of a
|
||||
// Lambda rotation function (which must already exist) and the number of days between
|
||||
// rotation. The first rotation happens immediately upon completion of this command.
|
||||
// The rotation function runs asynchronously in the background.
|
||||
func ExampleSecretsManager_RotateSecret_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.RotateSecretInput{
|
||||
RotationLambdaARN: aws.String("arn:aws:lambda:us-west-2:123456789012:function:MyTestDatabaseRotationLambda"),
|
||||
RotationRules: &secretsmanager.RotationRulesType{
|
||||
AutomaticallyAfterDays: aws.Int64(30),
|
||||
},
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
}
|
||||
|
||||
result, err := svc.RotateSecret(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To request an immediate rotation for a secret
|
||||
//
|
||||
// The following example requests an immediate invocation of the secret's Lambda rotation
|
||||
// function. It assumes that the specified secret already has rotation configured. The
|
||||
// rotation function runs asynchronously in the background.
|
||||
func ExampleSecretsManager_RotateSecret_shared01() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.RotateSecretInput{
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
}
|
||||
|
||||
result, err := svc.RotateSecret(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To add tags to a secret
|
||||
//
|
||||
// The following example shows how to attach two tags each with a Key and Value to a
|
||||
// secret. There is no output from this API. To see the result, use the DescribeSecret
|
||||
// operation.
|
||||
func ExampleSecretsManager_TagResource_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.TagResourceInput{
|
||||
SecretId: aws.String("MyExampleSecret"),
|
||||
Tags: []*secretsmanager.Tag{
|
||||
{
|
||||
Key: aws.String("FirstTag"),
|
||||
Value: aws.String("SomeValue"),
|
||||
},
|
||||
{
|
||||
Key: aws.String("SecondTag"),
|
||||
Value: aws.String("AnotherValue"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
result, err := svc.TagResource(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To remove tags from a secret
|
||||
//
|
||||
// The following example shows how to remove two tags from a secret's metadata. For
|
||||
// each, both the tag and the associated value are removed. There is no output from
|
||||
// this API. To see the result, use the DescribeSecret operation.
|
||||
func ExampleSecretsManager_UntagResource_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.UntagResourceInput{
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
TagKeys: []*string{
|
||||
aws.String("FirstTag"),
|
||||
aws.String("SecondTag"),
|
||||
},
|
||||
}
|
||||
|
||||
result, err := svc.UntagResource(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To update the description of a secret
|
||||
//
|
||||
// The following example shows how to modify the description of a secret.
|
||||
func ExampleSecretsManager_UpdateSecret_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.UpdateSecretInput{
|
||||
ClientRequestToken: aws.String("EXAMPLE1-90ab-cdef-fedc-ba987EXAMPLE"),
|
||||
Description: aws.String("This is a new description for the secret."),
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
}
|
||||
|
||||
result, err := svc.UpdateSecret(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
case secretsmanager.ErrCodeLimitExceededException:
|
||||
fmt.Println(secretsmanager.ErrCodeLimitExceededException, aerr.Error())
|
||||
case secretsmanager.ErrCodeEncryptionFailure:
|
||||
fmt.Println(secretsmanager.ErrCodeEncryptionFailure, aerr.Error())
|
||||
case secretsmanager.ErrCodeResourceExistsException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceExistsException, aerr.Error())
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeMalformedPolicyDocumentException:
|
||||
fmt.Println(secretsmanager.ErrCodeMalformedPolicyDocumentException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To update the KMS key associated with a secret
|
||||
//
|
||||
// This example shows how to update the KMS customer managed key (CMK) used to encrypt
|
||||
// the secret value. The KMS CMK must be in the same region as the secret.
|
||||
func ExampleSecretsManager_UpdateSecret_shared01() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.UpdateSecretInput{
|
||||
KmsKeyId: aws.String("arn:aws:kms:us-west-2:123456789012:key/EXAMPLE2-90ab-cdef-fedc-ba987EXAMPLE"),
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
}
|
||||
|
||||
result, err := svc.UpdateSecret(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
case secretsmanager.ErrCodeLimitExceededException:
|
||||
fmt.Println(secretsmanager.ErrCodeLimitExceededException, aerr.Error())
|
||||
case secretsmanager.ErrCodeEncryptionFailure:
|
||||
fmt.Println(secretsmanager.ErrCodeEncryptionFailure, aerr.Error())
|
||||
case secretsmanager.ErrCodeResourceExistsException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceExistsException, aerr.Error())
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeMalformedPolicyDocumentException:
|
||||
fmt.Println(secretsmanager.ErrCodeMalformedPolicyDocumentException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To create a new version of the encrypted secret value
|
||||
//
|
||||
// The following example shows how to create a new version of the secret by updating
|
||||
// the SecretString field. Alternatively, you can use the put-secret-value operation.
|
||||
func ExampleSecretsManager_UpdateSecret_shared02() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.UpdateSecretInput{
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
SecretString: aws.String("{JSON STRING WITH CREDENTIALS}"),
|
||||
}
|
||||
|
||||
result, err := svc.UpdateSecret(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
case secretsmanager.ErrCodeLimitExceededException:
|
||||
fmt.Println(secretsmanager.ErrCodeLimitExceededException, aerr.Error())
|
||||
case secretsmanager.ErrCodeEncryptionFailure:
|
||||
fmt.Println(secretsmanager.ErrCodeEncryptionFailure, aerr.Error())
|
||||
case secretsmanager.ErrCodeResourceExistsException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceExistsException, aerr.Error())
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeMalformedPolicyDocumentException:
|
||||
fmt.Println(secretsmanager.ErrCodeMalformedPolicyDocumentException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To add a staging label attached to a version of a secret
|
||||
//
|
||||
// The following example shows you how to add a staging label to a version of a secret.
|
||||
// You can review the results by running the operation ListSecretVersionIds and viewing
|
||||
// the VersionStages response field for the affected version.
|
||||
func ExampleSecretsManager_UpdateSecretVersionStage_shared00() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.UpdateSecretVersionStageInput{
|
||||
MoveToVersionId: aws.String("EXAMPLE1-90ab-cdef-fedc-ba987SECRET1"),
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
VersionStage: aws.String("STAGINGLABEL1"),
|
||||
}
|
||||
|
||||
result, err := svc.UpdateSecretVersionStage(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
case secretsmanager.ErrCodeLimitExceededException:
|
||||
fmt.Println(secretsmanager.ErrCodeLimitExceededException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To delete a staging label attached to a version of a secret
|
||||
//
|
||||
// The following example shows you how to delete a staging label that is attached to
|
||||
// a version of a secret. You can review the results by running the operation ListSecretVersionIds
|
||||
// and viewing the VersionStages response field for the affected version.
|
||||
func ExampleSecretsManager_UpdateSecretVersionStage_shared01() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.UpdateSecretVersionStageInput{
|
||||
RemoveFromVersionId: aws.String("EXAMPLE1-90ab-cdef-fedc-ba987SECRET1"),
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
VersionStage: aws.String("STAGINGLABEL1"),
|
||||
}
|
||||
|
||||
result, err := svc.UpdateSecretVersionStage(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
case secretsmanager.ErrCodeLimitExceededException:
|
||||
fmt.Println(secretsmanager.ErrCodeLimitExceededException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
// To move a staging label from one version of a secret to another
|
||||
//
|
||||
// The following example shows you how to move a staging label that is attached to one
|
||||
// version of a secret to a different version. You can review the results by running
|
||||
// the operation ListSecretVersionIds and viewing the VersionStages response field for
|
||||
// the affected version.
|
||||
func ExampleSecretsManager_UpdateSecretVersionStage_shared02() {
|
||||
svc := secretsmanager.New(session.New())
|
||||
input := &secretsmanager.UpdateSecretVersionStageInput{
|
||||
MoveToVersionId: aws.String("EXAMPLE2-90ab-cdef-fedc-ba987SECRET2"),
|
||||
RemoveFromVersionId: aws.String("EXAMPLE1-90ab-cdef-fedc-ba987SECRET1"),
|
||||
SecretId: aws.String("MyTestDatabaseSecret"),
|
||||
VersionStage: aws.String("AWSCURRENT"),
|
||||
}
|
||||
|
||||
result, err := svc.UpdateSecretVersionStage(input)
|
||||
if err != nil {
|
||||
if aerr, ok := err.(awserr.Error); ok {
|
||||
switch aerr.Code() {
|
||||
case secretsmanager.ErrCodeResourceNotFoundException:
|
||||
fmt.Println(secretsmanager.ErrCodeResourceNotFoundException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidParameterException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidParameterException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInvalidRequestException:
|
||||
fmt.Println(secretsmanager.ErrCodeInvalidRequestException, aerr.Error())
|
||||
case secretsmanager.ErrCodeLimitExceededException:
|
||||
fmt.Println(secretsmanager.ErrCodeLimitExceededException, aerr.Error())
|
||||
case secretsmanager.ErrCodeInternalServiceError:
|
||||
fmt.Println(secretsmanager.ErrCodeInternalServiceError, aerr.Error())
|
||||
default:
|
||||
fmt.Println(aerr.Error())
|
||||
}
|
||||
} else {
|
||||
// Print the error, cast err to awserr.Error to get the Code and
|
||||
// Message from an error.
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(result)
|
||||
}
|
||||
130
vendor/github.com/aws/aws-sdk-go/service/secretsmanager/secretsmanageriface/interface.go
generated
vendored
Normal file
130
vendor/github.com/aws/aws-sdk-go/service/secretsmanager/secretsmanageriface/interface.go
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
// Package secretsmanageriface provides an interface to enable mocking the AWS Secrets Manager service client
|
||||
// for testing your code.
|
||||
//
|
||||
// It is important to note that this interface will have breaking changes
|
||||
// when the service model is updated and adds new API operations, paginators,
|
||||
// and waiters.
|
||||
package secretsmanageriface
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/service/secretsmanager"
|
||||
)
|
||||
|
||||
// SecretsManagerAPI provides an interface to enable mocking the
|
||||
// secretsmanager.SecretsManager service client's API operation,
|
||||
// paginators, and waiters. This make unit testing your code that calls out
|
||||
// to the SDK's service client's calls easier.
|
||||
//
|
||||
// The best way to use this interface is so the SDK's service client's calls
|
||||
// can be stubbed out for unit testing your code with the SDK without needing
|
||||
// to inject custom request handlers into the SDK's request pipeline.
|
||||
//
|
||||
// // myFunc uses an SDK service client to make a request to
|
||||
// // AWS Secrets Manager.
|
||||
// func myFunc(svc secretsmanageriface.SecretsManagerAPI) bool {
|
||||
// // Make svc.CancelRotateSecret request
|
||||
// }
|
||||
//
|
||||
// func main() {
|
||||
// sess := session.New()
|
||||
// svc := secretsmanager.New(sess)
|
||||
//
|
||||
// myFunc(svc)
|
||||
// }
|
||||
//
|
||||
// In your _test.go file:
|
||||
//
|
||||
// // Define a mock struct to be used in your unit tests of myFunc.
|
||||
// type mockSecretsManagerClient struct {
|
||||
// secretsmanageriface.SecretsManagerAPI
|
||||
// }
|
||||
// func (m *mockSecretsManagerClient) CancelRotateSecret(input *secretsmanager.CancelRotateSecretInput) (*secretsmanager.CancelRotateSecretOutput, error) {
|
||||
// // mock response/functionality
|
||||
// }
|
||||
//
|
||||
// func TestMyFunc(t *testing.T) {
|
||||
// // Setup Test
|
||||
// mockSvc := &mockSecretsManagerClient{}
|
||||
//
|
||||
// myfunc(mockSvc)
|
||||
//
|
||||
// // Verify myFunc's functionality
|
||||
// }
|
||||
//
|
||||
// It is important to note that this interface will have breaking changes
|
||||
// when the service model is updated and adds new API operations, paginators,
|
||||
// and waiters. Its suggested to use the pattern above for testing, or using
|
||||
// tooling to generate mocks to satisfy the interfaces.
|
||||
type SecretsManagerAPI interface {
|
||||
CancelRotateSecret(*secretsmanager.CancelRotateSecretInput) (*secretsmanager.CancelRotateSecretOutput, error)
|
||||
CancelRotateSecretWithContext(aws.Context, *secretsmanager.CancelRotateSecretInput, ...request.Option) (*secretsmanager.CancelRotateSecretOutput, error)
|
||||
CancelRotateSecretRequest(*secretsmanager.CancelRotateSecretInput) (*request.Request, *secretsmanager.CancelRotateSecretOutput)
|
||||
|
||||
CreateSecret(*secretsmanager.CreateSecretInput) (*secretsmanager.CreateSecretOutput, error)
|
||||
CreateSecretWithContext(aws.Context, *secretsmanager.CreateSecretInput, ...request.Option) (*secretsmanager.CreateSecretOutput, error)
|
||||
CreateSecretRequest(*secretsmanager.CreateSecretInput) (*request.Request, *secretsmanager.CreateSecretOutput)
|
||||
|
||||
DeleteSecret(*secretsmanager.DeleteSecretInput) (*secretsmanager.DeleteSecretOutput, error)
|
||||
DeleteSecretWithContext(aws.Context, *secretsmanager.DeleteSecretInput, ...request.Option) (*secretsmanager.DeleteSecretOutput, error)
|
||||
DeleteSecretRequest(*secretsmanager.DeleteSecretInput) (*request.Request, *secretsmanager.DeleteSecretOutput)
|
||||
|
||||
DescribeSecret(*secretsmanager.DescribeSecretInput) (*secretsmanager.DescribeSecretOutput, error)
|
||||
DescribeSecretWithContext(aws.Context, *secretsmanager.DescribeSecretInput, ...request.Option) (*secretsmanager.DescribeSecretOutput, error)
|
||||
DescribeSecretRequest(*secretsmanager.DescribeSecretInput) (*request.Request, *secretsmanager.DescribeSecretOutput)
|
||||
|
||||
GetRandomPassword(*secretsmanager.GetRandomPasswordInput) (*secretsmanager.GetRandomPasswordOutput, error)
|
||||
GetRandomPasswordWithContext(aws.Context, *secretsmanager.GetRandomPasswordInput, ...request.Option) (*secretsmanager.GetRandomPasswordOutput, error)
|
||||
GetRandomPasswordRequest(*secretsmanager.GetRandomPasswordInput) (*request.Request, *secretsmanager.GetRandomPasswordOutput)
|
||||
|
||||
GetSecretValue(*secretsmanager.GetSecretValueInput) (*secretsmanager.GetSecretValueOutput, error)
|
||||
GetSecretValueWithContext(aws.Context, *secretsmanager.GetSecretValueInput, ...request.Option) (*secretsmanager.GetSecretValueOutput, error)
|
||||
GetSecretValueRequest(*secretsmanager.GetSecretValueInput) (*request.Request, *secretsmanager.GetSecretValueOutput)
|
||||
|
||||
ListSecretVersionIds(*secretsmanager.ListSecretVersionIdsInput) (*secretsmanager.ListSecretVersionIdsOutput, error)
|
||||
ListSecretVersionIdsWithContext(aws.Context, *secretsmanager.ListSecretVersionIdsInput, ...request.Option) (*secretsmanager.ListSecretVersionIdsOutput, error)
|
||||
ListSecretVersionIdsRequest(*secretsmanager.ListSecretVersionIdsInput) (*request.Request, *secretsmanager.ListSecretVersionIdsOutput)
|
||||
|
||||
ListSecretVersionIdsPages(*secretsmanager.ListSecretVersionIdsInput, func(*secretsmanager.ListSecretVersionIdsOutput, bool) bool) error
|
||||
ListSecretVersionIdsPagesWithContext(aws.Context, *secretsmanager.ListSecretVersionIdsInput, func(*secretsmanager.ListSecretVersionIdsOutput, bool) bool, ...request.Option) error
|
||||
|
||||
ListSecrets(*secretsmanager.ListSecretsInput) (*secretsmanager.ListSecretsOutput, error)
|
||||
ListSecretsWithContext(aws.Context, *secretsmanager.ListSecretsInput, ...request.Option) (*secretsmanager.ListSecretsOutput, error)
|
||||
ListSecretsRequest(*secretsmanager.ListSecretsInput) (*request.Request, *secretsmanager.ListSecretsOutput)
|
||||
|
||||
ListSecretsPages(*secretsmanager.ListSecretsInput, func(*secretsmanager.ListSecretsOutput, bool) bool) error
|
||||
ListSecretsPagesWithContext(aws.Context, *secretsmanager.ListSecretsInput, func(*secretsmanager.ListSecretsOutput, bool) bool, ...request.Option) error
|
||||
|
||||
PutSecretValue(*secretsmanager.PutSecretValueInput) (*secretsmanager.PutSecretValueOutput, error)
|
||||
PutSecretValueWithContext(aws.Context, *secretsmanager.PutSecretValueInput, ...request.Option) (*secretsmanager.PutSecretValueOutput, error)
|
||||
PutSecretValueRequest(*secretsmanager.PutSecretValueInput) (*request.Request, *secretsmanager.PutSecretValueOutput)
|
||||
|
||||
RestoreSecret(*secretsmanager.RestoreSecretInput) (*secretsmanager.RestoreSecretOutput, error)
|
||||
RestoreSecretWithContext(aws.Context, *secretsmanager.RestoreSecretInput, ...request.Option) (*secretsmanager.RestoreSecretOutput, error)
|
||||
RestoreSecretRequest(*secretsmanager.RestoreSecretInput) (*request.Request, *secretsmanager.RestoreSecretOutput)
|
||||
|
||||
RotateSecret(*secretsmanager.RotateSecretInput) (*secretsmanager.RotateSecretOutput, error)
|
||||
RotateSecretWithContext(aws.Context, *secretsmanager.RotateSecretInput, ...request.Option) (*secretsmanager.RotateSecretOutput, error)
|
||||
RotateSecretRequest(*secretsmanager.RotateSecretInput) (*request.Request, *secretsmanager.RotateSecretOutput)
|
||||
|
||||
TagResource(*secretsmanager.TagResourceInput) (*secretsmanager.TagResourceOutput, error)
|
||||
TagResourceWithContext(aws.Context, *secretsmanager.TagResourceInput, ...request.Option) (*secretsmanager.TagResourceOutput, error)
|
||||
TagResourceRequest(*secretsmanager.TagResourceInput) (*request.Request, *secretsmanager.TagResourceOutput)
|
||||
|
||||
UntagResource(*secretsmanager.UntagResourceInput) (*secretsmanager.UntagResourceOutput, error)
|
||||
UntagResourceWithContext(aws.Context, *secretsmanager.UntagResourceInput, ...request.Option) (*secretsmanager.UntagResourceOutput, error)
|
||||
UntagResourceRequest(*secretsmanager.UntagResourceInput) (*request.Request, *secretsmanager.UntagResourceOutput)
|
||||
|
||||
UpdateSecret(*secretsmanager.UpdateSecretInput) (*secretsmanager.UpdateSecretOutput, error)
|
||||
UpdateSecretWithContext(aws.Context, *secretsmanager.UpdateSecretInput, ...request.Option) (*secretsmanager.UpdateSecretOutput, error)
|
||||
UpdateSecretRequest(*secretsmanager.UpdateSecretInput) (*request.Request, *secretsmanager.UpdateSecretOutput)
|
||||
|
||||
UpdateSecretVersionStage(*secretsmanager.UpdateSecretVersionStageInput) (*secretsmanager.UpdateSecretVersionStageOutput, error)
|
||||
UpdateSecretVersionStageWithContext(aws.Context, *secretsmanager.UpdateSecretVersionStageInput, ...request.Option) (*secretsmanager.UpdateSecretVersionStageOutput, error)
|
||||
UpdateSecretVersionStageRequest(*secretsmanager.UpdateSecretVersionStageInput) (*request.Request, *secretsmanager.UpdateSecretVersionStageOutput)
|
||||
}
|
||||
|
||||
var _ SecretsManagerAPI = (*secretsmanager.SecretsManager)(nil)
|
||||
98
vendor/github.com/aws/aws-sdk-go/service/secretsmanager/service.go
generated
vendored
Normal file
98
vendor/github.com/aws/aws-sdk-go/service/secretsmanager/service.go
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
||||
|
||||
package secretsmanager
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/client"
|
||||
"github.com/aws/aws-sdk-go/aws/client/metadata"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/aws/signer/v4"
|
||||
"github.com/aws/aws-sdk-go/private/protocol/jsonrpc"
|
||||
)
|
||||
|
||||
// SecretsManager provides the API operation methods for making requests to
|
||||
// AWS Secrets Manager. See this package's package overview docs
|
||||
// for details on the service.
|
||||
//
|
||||
// SecretsManager methods are safe to use concurrently. It is not safe to
|
||||
// modify mutate any of the struct's properties though.
|
||||
type SecretsManager struct {
|
||||
*client.Client
|
||||
}
|
||||
|
||||
// Used for custom client initialization logic
|
||||
var initClient func(*client.Client)
|
||||
|
||||
// Used for custom request initialization logic
|
||||
var initRequest func(*request.Request)
|
||||
|
||||
// Service information constants
|
||||
const (
|
||||
ServiceName = "secretsmanager" // Service endpoint prefix API calls made to.
|
||||
EndpointsID = ServiceName // Service ID for Regions and Endpoints metadata.
|
||||
)
|
||||
|
||||
// New creates a new instance of the SecretsManager client with a session.
|
||||
// If additional configuration is needed for the client instance use the optional
|
||||
// aws.Config parameter to add your extra config.
|
||||
//
|
||||
// Example:
|
||||
// // Create a SecretsManager client from just a session.
|
||||
// svc := secretsmanager.New(mySession)
|
||||
//
|
||||
// // Create a SecretsManager client with additional configuration
|
||||
// svc := secretsmanager.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
|
||||
func New(p client.ConfigProvider, cfgs ...*aws.Config) *SecretsManager {
|
||||
c := p.ClientConfig(EndpointsID, cfgs...)
|
||||
if c.SigningNameDerived || len(c.SigningName) == 0 {
|
||||
c.SigningName = "secretsmanager"
|
||||
}
|
||||
return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
|
||||
}
|
||||
|
||||
// newClient creates, initializes and returns a new service client instance.
|
||||
func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *SecretsManager {
|
||||
svc := &SecretsManager{
|
||||
Client: client.New(
|
||||
cfg,
|
||||
metadata.ClientInfo{
|
||||
ServiceName: ServiceName,
|
||||
SigningName: signingName,
|
||||
SigningRegion: signingRegion,
|
||||
Endpoint: endpoint,
|
||||
APIVersion: "2017-10-17",
|
||||
JSONVersion: "1.1",
|
||||
TargetPrefix: "secretsmanager",
|
||||
},
|
||||
handlers,
|
||||
),
|
||||
}
|
||||
|
||||
// Handlers
|
||||
svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
|
||||
svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
|
||||
svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
|
||||
svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
|
||||
svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
|
||||
|
||||
// Run custom client initialization if present
|
||||
if initClient != nil {
|
||||
initClient(svc.Client)
|
||||
}
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
// newRequest creates a new request for a SecretsManager operation and runs any
|
||||
// custom request initialization.
|
||||
func (c *SecretsManager) newRequest(op *request.Operation, params, data interface{}) *request.Request {
|
||||
req := c.NewRequest(op, params, data)
|
||||
|
||||
// Run custom request initialization if present
|
||||
if initRequest != nil {
|
||||
initRequest(req)
|
||||
}
|
||||
|
||||
return req
|
||||
}
|
||||
Reference in New Issue
Block a user