Skip to content

Commit

Permalink
feat(DocDB): implement restorefrom for docdb
Browse files Browse the repository at this point in the history
  • Loading branch information
safboukhari committed May 23, 2023
1 parent fd8d9ab commit 56b371c
Show file tree
Hide file tree
Showing 5 changed files with 704 additions and 4 deletions.
167 changes: 167 additions & 0 deletions apis/docdb/v1alpha1/custom_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha1

import (
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// RDS instance states.
Expand Down Expand Up @@ -56,6 +57,23 @@ type CustomDBInstanceParameters struct {
DBClusterIdentifier *string `json:"dbClusterIdentifier,omitempty"`
DBClusterIdentifierRef *xpv1.Reference `json:"dbClusterIdentifierRef,omitempty"`
DBClusterIdentifierSelector *xpv1.Selector `json:"dbClusterIdentifierSelector,omitempty"`

// RestoreFrom specifies the details of the backup to restore when creating a new DBInstance.
// +optional
RestoreFrom *RestoreDBInstanceBackupConfiguration `json:"restoreFrom,omitempty"`

// A list of Amazon EC2 VPC security groups to authorize on this DB instance.
// This change is asynchronously applied as soon as possible.
//
// This setting doesn't apply to RDS Custom.
//
// Amazon Aurora
// Not applicable. The associated list of EC2 VPC security groups is managed
// by the DB cluster. For more information, see ModifyDBCluster.
//
// Constraints:
// * If supplied, must match existing VpcSecurityGroupIds.
VPCSecurityGroupIDs []string `json:"vpcSecurityGroupIDs,omitempty"`
}

// CustomDBSubnetGroupParameters for DBSubnetGroupParameters
Expand Down Expand Up @@ -156,6 +174,155 @@ type CustomDBClusterParameters struct {
VPCSecurityGroupIDsRefs []xpv1.Reference `json:"vpcSecurityGroupIDsRefs,omitempty"`
// TODO(haarchri): when resource is bumped to beta we will convert this field to vpcSecurityGroupIdSelector
VPCSecurityGroupIDsSelector *xpv1.Selector `json:"vpcSecurityGroupIDsSelector,omitempty"`

// RestoreFrom specifies the details of the backup to restore when creating a new DBCluster.
// +optional
RestoreFrom *RestoreDBClusterBackupConfiguration `json:"restoreFrom,omitempty"`
}

// S3RestoreBackupConfiguration defines the details of the S3 backup to restore from.
type S3RestoreBackupConfiguration struct {
// BucketName is the name of the S3 bucket containing the backup to restore.
BucketName *string `json:"bucketName"`

// IngestionRoleARN is the IAM role RDS can assume that will allow it to access the contents of the S3 bucket.
IngestionRoleARN *string `json:"ingestionRoleARN"`

// Prefix is the path prefix of the S3 bucket within which the backup to restore is located.
// +optional
Prefix *string `json:"prefix,omitempty"`

// SourceEngine is the engine used to create the backup.
// Must be "mysql".
SourceEngine *string `json:"sourceEngine"`

// SourceEngineVersion is the version of the engine used to create the backup.
// Example: "5.7.30"
SourceEngineVersion *string `json:"sourceEngineVersion"`
}

// SnapshotRestoreBackupConfiguration defines the details of the snapshot to restore from.
type SnapshotRestoreBackupConfiguration struct {
// SnapshotIdentifier is the identifier of the snapshot to restore.
SnapshotIdentifier *string `json:"snapshotIdentifier"`
}

// PointInTimeRestoreBackupConfiguration defines the details of the time to restore from
type PointInTimeRestoreBackupConfiguration struct {
// RestoreTime is the date and time (UTC) to restore from.
// Must be before the latest restorable time for the DB instance.
// Can't be specified if the useLatestRestorableTime parameter is enabled.
// Example: 2011-09-07T23:45:00Z
// +optional
RestoreTime *metav1.Time `json:"restoreTime"`

// UseLatestRestorableTime indicates that the DB instance is restored from the latest backup
// Can't be specified if the restoreTime parameter is provided.
// +optional
UseLatestRestorableTime bool `json:"useLatestRestorableTime"`

// SourceDBInstanceAutomatedBackupsArn specifies the Amazon Resource Name (ARN) of the replicated automated backups
// from which to restore. Example: arn:aws:rds:useast-1:123456789012:auto-backup:ab-L2IJCEXJP7XQ7HOJ4SIEXAMPLE
// +optional
SourceDBInstanceAutomatedBackupsArn *string `json:"sourceDBInstanceAutomatedBackupsArn"`

// SourceDBInstanceIdentifier specifies the identifier of the source DB instance from which to restore. Constraints:
// Must match the identifier of an existing DB instance.
// +optional
SourceDBInstanceIdentifier *string `json:"sourceDBInstanceIdentifier"`

// SourceDbiResourceID specifies the resource ID of the source DB instance from which to restore.
// +optional
SourceDbiResourceID *string `json:"sourceDbiResourceId"`
}

// PointInTimeRestoreDBClusterBackupConfiguration defines the details of the time to restore from
type PointInTimeRestoreDBClusterBackupConfiguration struct {
// RestoreTime is the date and time (UTC) to restore from.
// Must be before the latest restorable time for the DB instance.
// Can't be specified if the useLatestRestorableTime parameter is enabled.
// Example: 2011-09-07T23:45:00Z
// +optional
RestoreTime *metav1.Time `json:"restoreTime"`

// UseLatestRestorableTime indicates that the DB instance is restored from the latest backup
// Can't be specified if the restoreTime parameter is provided.
// +optional
UseLatestRestorableTime bool `json:"useLatestRestorableTime"`

// SourceDBInstanceAutomatedBackupsArn specifies the Amazon Resource Name (ARN) of the replicated automated backups
// from which to restore. Example: arn:aws:rds:useast-1:123456789012:auto-backup:ab-L2IJCEXJP7XQ7HOJ4SIEXAMPLE
// +optional
SourceDBInstanceAutomatedBackupsArn *string `json:"sourceDBInstanceAutomatedBackupsArn"`

// SourceDBClusterIdentifier specifies the identifier of the source DB cluster from which to restore. Constraints:
// Must match the identifier of an existing DB instance.
// +optional
SourceDBClusterIdentifier *string `json:"sourceDBClusterIdentifier"`

// SourceDbiResourceID specifies the resource ID of the source DB instance from which to restore.
// +optional
SourceDbiResourceID *string `json:"sourceDbiResourceId"`

// The type of restore to be performed. You can specify one of the following
// values:
//
// * full-copy - The new DB cluster is restored as a full copy of the source
// DB cluster.
//
// * copy-on-write - The new DB cluster is restored as a clone of the source
// DB cluster.
//
// Constraints: You can't specify copy-on-write if the engine version of the
// source DB cluster is earlier than 1.11.
//
// If you don't specify a RestoreType value, then the new DB cluster is restored
// as a full copy of the source DB cluster.
//
// Valid for: Aurora DB clusters and Multi-AZ DB clusters
// +optional
// +kubebuilder:validation:Enum=full-copy;copy-on-write
RestoreType *string `json:"restoreType"`
}

// RestoreDBInstanceBackupConfiguration defines the backup to restore a new DBCluster from.
type RestoreDBInstanceBackupConfiguration struct {
// S3 specifies the details of the S3 backup to restore from.
// +optional
S3 *S3RestoreBackupConfiguration `json:"s3,omitempty"`

// Snapshot specifies the details of the snapshot to restore from.
// +optional
Snapshot *SnapshotRestoreBackupConfiguration `json:"snapshot,omitempty"`

// PointInTime specifies the details of the point in time restore.
// +optional
PointInTime *PointInTimeRestoreBackupConfiguration `json:"pointInTime,omitempty"`

// Source is the type of the backup to restore when creating a new DBCluster or DBInstance.
// S3, Snapshot and PointInTime are supported.
// +kubebuilder:validation:Enum=S3;Snapshot;PointInTime
Source *string `json:"source"`
}

// RestoreDBClusterBackupConfiguration defines the backup to restore a new DBCluster from.
type RestoreDBClusterBackupConfiguration struct {
// S3 specifies the details of the S3 backup to restore from.
// +optional
S3 *S3RestoreBackupConfiguration `json:"s3,omitempty"`

// Snapshot specifies the details of the snapshot to restore from.
// +optional
Snapshot *SnapshotRestoreBackupConfiguration `json:"snapshot,omitempty"`

// PointInTime specifies the details of the point in time restore.
// +optional
PointInTime *PointInTimeRestoreDBClusterBackupConfiguration `json:"pointInTime,omitempty"`

// Source is the type of the backup to restore when creating a new DBCluster or DBInstance.
// S3, Snapshot and PointInTime are supported.
// +kubebuilder:validation:Enum=S3;Snapshot;PointInTime
Source *string `json:"source"`
}

// CustomParameter are custom parameters for the Parameter
Expand Down
Loading

0 comments on commit 56b371c

Please sign in to comment.