1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package rds 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/rds/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// The DeleteDBInstance action deletes a previously provisioned DB instance. When 15// you delete a DB instance, all automated backups for that instance are deleted 16// and can't be recovered. Manual DB snapshots of the DB instance to be deleted by 17// DeleteDBInstance are not deleted. If you request a final DB snapshot the status 18// of the Amazon RDS DB instance is deleting until the DB snapshot is created. The 19// API action DescribeDBInstance is used to monitor the status of this operation. 20// The action can't be canceled or reverted once submitted. When a DB instance is 21// in a failure state and has a status of failed, incompatible-restore, or 22// incompatible-network, you can only delete it when you skip creation of the final 23// snapshot with the SkipFinalSnapshot parameter. If the specified DB instance is 24// part of an Amazon Aurora DB cluster, you can't delete the DB instance if both of 25// the following conditions are true: 26// 27// * The DB cluster is a read replica of 28// another Amazon Aurora DB cluster. 29// 30// * The DB instance is the only instance in the 31// DB cluster. 32// 33// To delete a DB instance in this case, first call the 34// PromoteReadReplicaDBCluster API action to promote the DB cluster so it's no 35// longer a read replica. After the promotion completes, then call the 36// DeleteDBInstance API action to delete the final instance in the DB cluster. 37func (c *Client) DeleteDBInstance(ctx context.Context, params *DeleteDBInstanceInput, optFns ...func(*Options)) (*DeleteDBInstanceOutput, error) { 38 if params == nil { 39 params = &DeleteDBInstanceInput{} 40 } 41 42 result, metadata, err := c.invokeOperation(ctx, "DeleteDBInstance", params, optFns, c.addOperationDeleteDBInstanceMiddlewares) 43 if err != nil { 44 return nil, err 45 } 46 47 out := result.(*DeleteDBInstanceOutput) 48 out.ResultMetadata = metadata 49 return out, nil 50} 51 52// 53type DeleteDBInstanceInput struct { 54 55 // The DB instance identifier for the DB instance to be deleted. This parameter 56 // isn't case-sensitive. Constraints: 57 // 58 // * Must match the name of an existing DB 59 // instance. 60 // 61 // This member is required. 62 DBInstanceIdentifier *string 63 64 // A value that indicates whether to remove automated backups immediately after the 65 // DB instance is deleted. This parameter isn't case-sensitive. The default is to 66 // remove automated backups immediately after the DB instance is deleted. 67 DeleteAutomatedBackups *bool 68 69 // The DBSnapshotIdentifier of the new DBSnapshot created when the 70 // SkipFinalSnapshot parameter is disabled. Specifying this parameter and also 71 // specifying to skip final DB snapshot creation in SkipFinalShapshot results in an 72 // error. Constraints: 73 // 74 // * Must be 1 to 255 letters or numbers. 75 // 76 // * First character 77 // must be a letter. 78 // 79 // * Can't end with a hyphen or contain two consecutive 80 // hyphens. 81 // 82 // * Can't be specified when deleting a read replica. 83 FinalDBSnapshotIdentifier *string 84 85 // A value that indicates whether to skip the creation of a final DB snapshot 86 // before the DB instance is deleted. If skip is specified, no DB snapshot is 87 // created. If skip isn't specified, a DB snapshot is created before the DB 88 // instance is deleted. By default, skip isn't specified, and the DB snapshot is 89 // created. When a DB instance is in a failure state and has a status of 'failed', 90 // 'incompatible-restore', or 'incompatible-network', it can only be deleted when 91 // skip is specified. Specify skip when deleting a read replica. The 92 // FinalDBSnapshotIdentifier parameter must be specified if skip isn't specified. 93 SkipFinalSnapshot bool 94 95 noSmithyDocumentSerde 96} 97 98type DeleteDBInstanceOutput struct { 99 100 // Contains the details of an Amazon RDS DB instance. This data type is used as a 101 // response element in the DescribeDBInstances action. 102 DBInstance *types.DBInstance 103 104 // Metadata pertaining to the operation's result. 105 ResultMetadata middleware.Metadata 106 107 noSmithyDocumentSerde 108} 109 110func (c *Client) addOperationDeleteDBInstanceMiddlewares(stack *middleware.Stack, options Options) (err error) { 111 err = stack.Serialize.Add(&awsAwsquery_serializeOpDeleteDBInstance{}, middleware.After) 112 if err != nil { 113 return err 114 } 115 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDeleteDBInstance{}, middleware.After) 116 if err != nil { 117 return err 118 } 119 if err = addSetLoggerMiddleware(stack, options); err != nil { 120 return err 121 } 122 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 123 return err 124 } 125 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 126 return err 127 } 128 if err = addResolveEndpointMiddleware(stack, options); err != nil { 129 return err 130 } 131 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 132 return err 133 } 134 if err = addRetryMiddlewares(stack, options); err != nil { 135 return err 136 } 137 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 138 return err 139 } 140 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 141 return err 142 } 143 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 144 return err 145 } 146 if err = addClientUserAgent(stack); err != nil { 147 return err 148 } 149 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 150 return err 151 } 152 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 153 return err 154 } 155 if err = addOpDeleteDBInstanceValidationMiddleware(stack); err != nil { 156 return err 157 } 158 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDeleteDBInstance(options.Region), middleware.Before); err != nil { 159 return err 160 } 161 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 162 return err 163 } 164 if err = addResponseErrorMiddleware(stack); err != nil { 165 return err 166 } 167 if err = addRequestResponseLogging(stack, options); err != nil { 168 return err 169 } 170 return nil 171} 172 173func newServiceMetadataMiddleware_opDeleteDBInstance(region string) *awsmiddleware.RegisterServiceMetadata { 174 return &awsmiddleware.RegisterServiceMetadata{ 175 Region: region, 176 ServiceID: ServiceID, 177 SigningName: "rds", 178 OperationName: "DeleteDBInstance", 179 } 180} 181