Skip to content

Commit

Permalink
Add backup_retention_period to docdbelastic resource
Browse files Browse the repository at this point in the history
  • Loading branch information
ayumitamai97 committed Jun 24, 2024
1 parent f81ecdb commit 95568ca
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions internal/service/docdbelastic/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ func (r *resourceCluster) Schema(ctx context.Context, _ resource.SchemaRequest,
enum.FrameworkValidate[awstypes.Auth](),
},
},
"backup_retention_period": schema.Int64Attribute{
Optional: true,
Computed: true,
Validators: []validator.Int64{
int64validator.Between(1, 35),
},
},
names.AttrEndpoint: schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
Expand Down Expand Up @@ -162,14 +169,15 @@ func (r *resourceCluster) Create(ctx context.Context, request resource.CreateReq
}

input := &docdbelastic.CreateClusterInput{
ClientToken: aws.String(id.UniqueId()),
AdminUserName: flex.StringFromFramework(ctx, plan.AdminUserName),
AdminUserPassword: flex.StringFromFramework(ctx, plan.AdminUserPassword),
AuthType: awstypes.Auth(plan.AuthType.ValueString()),
ClusterName: flex.StringFromFramework(ctx, plan.Name),
ShardCapacity: flex.Int32FromFramework(ctx, plan.ShardCapacity),
ShardCount: flex.Int32FromFramework(ctx, plan.ShardCount),
Tags: getTagsIn(ctx),
ClientToken: aws.String(id.UniqueId()),
AdminUserName: flex.StringFromFramework(ctx, plan.AdminUserName),
AdminUserPassword: flex.StringFromFramework(ctx, plan.AdminUserPassword),
AuthType: awstypes.Auth(plan.AuthType.ValueString()),
BackupRetentionPeriod: flex.Int32FromFramework(ctx, plan.BackupRetentionPeriod),
ClusterName: flex.StringFromFramework(ctx, plan.Name),
ShardCapacity: flex.Int32FromFramework(ctx, plan.ShardCapacity),
ShardCount: flex.Int32FromFramework(ctx, plan.ShardCount),
Tags: getTagsIn(ctx),
}

if !plan.KmsKeyID.IsNull() || !plan.KmsKeyID.IsUnknown() {
Expand Down Expand Up @@ -276,6 +284,10 @@ func (r *resourceCluster) Update(ctx context.Context, request resource.UpdateReq
input.AuthType = awstypes.Auth(plan.AuthType.ValueString())
}

if !plan.BackupRetentionPeriod.Equal(state.BackupRetentionPeriod) {
input.BackupRetentionPeriod = flex.Int32FromFramework(ctx, plan.BackupRetentionPeriod)
}

if !plan.PreferredMaintenanceWindow.Equal(state.PreferredMaintenanceWindow) {
input.PreferredMaintenanceWindow = flex.StringFromFramework(ctx, plan.PreferredMaintenanceWindow)
}
Expand Down Expand Up @@ -381,6 +393,7 @@ type resourceClusterData struct {
AdminUserPassword types.String `tfsdk:"admin_user_password"`
ARN types.String `tfsdk:"arn"`
AuthType types.String `tfsdk:"auth_type"`
BackupRetentionPeriod types.Int64 `tfsdk:"backup_retention_period"`
Endpoint types.String `tfsdk:"endpoint"`
ID types.String `tfsdk:"id"`
KmsKeyID types.String `tfsdk:"kms_key_id"`
Expand Down

0 comments on commit 95568ca

Please sign in to comment.