// 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.
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.
// 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 {
			fmt.Println(err.Error())
		}
		return
	}
	fmt.Println(result)
}
func ExampleSecretsManager_RotateSecret_shared00 ( ) { svc := secretsmanager . New ( session . New ( ) ) input := & secretsmanager . RotateSecretInput { RotationLambdaARN : aws . String ( " " ) , RotationRules : & secretsmanager . RotationRulesType { AutomaticallyAfterDays : aws . Int64 ( 30 ) , } , SecretId : aws . String ( " " ) , } 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 { fmt . Println ( err . Error ( ) ) } return } fmt . Println ( result ) }
To configure rotation for a secret
To configure rotation for a secret
// Print the error, cast err to awserr.Error to get the Code and // Message from an error.