// 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.
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.
// 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())
			case secretsmanager.ErrCodePreconditionNotMetException:
				fmt.Println(secretsmanager.ErrCodePreconditionNotMetException, aerr.Error())
			default:
				fmt.Println(aerr.Error())
			}
		} else {
			fmt.Println(err.Error())
		}
		return
	}
	fmt.Println(result)
}
func ExampleSecretsManager_UpdateSecret_shared02 ( ) { svc := secretsmanager . New ( session . New ( ) ) input := & secretsmanager . UpdateSecretInput { SecretId : aws . String ( " " ) , SecretString : aws . String ( " " ) , } 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 ( ) ) case secretsmanager . ErrCodePreconditionNotMetException : fmt . Println ( secretsmanager . ErrCodePreconditionNotMetException , aerr . Error ( ) ) default : fmt . Println ( aerr . Error ( ) ) } } else { fmt . Println ( err . Error ( ) ) } return } fmt . Println ( result ) }
To create a new version of the encrypted secret value
To create a new version of the encrypted secret value
// Print the error, cast err to awserr.Error to get the Code and // Message from an error.