// 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.
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.
// 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())
			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_shared01 ( ) { svc := secretsmanager . New ( session . New ( ) ) input := & secretsmanager . UpdateSecretInput { KmsKeyId : aws . String ( " " ) , SecretId : 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 update the KMS key associated with a secret
To update the KMS key associated with a secret
// Print the error, cast err to awserr.Error to get the Code and // Message from an error.