-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TimestreamInfluxDB DB instance add more updatable arguments #7
Changes from 6 commits
0175e89
5ec3fb9
9a2f3b6
05ddc93
87e603d
4507de5
83b735e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -105,11 +105,8 @@ func (r *resourceDBInstance) Schema(ctx context.Context, req resource.SchemaRequ | |||||
that each data point persists). A bucket belongs to an organization.`, | ||||||
}, | ||||||
"db_instance_type": schema.StringAttribute{ | ||||||
CustomType: fwtypes.StringEnumType[awstypes.DbInstanceType](), | ||||||
Required: true, | ||||||
PlanModifiers: []planmodifier.String{ | ||||||
stringplanmodifier.RequiresReplace(), | ||||||
}, | ||||||
CustomType: fwtypes.StringEnumType[awstypes.DbInstanceType](), | ||||||
Required: true, | ||||||
Description: `The Timestream for InfluxDB DB instance type to run InfluxDB on.`, | ||||||
}, | ||||||
"db_parameter_group_identifier": schema.StringAttribute{ | ||||||
|
@@ -146,7 +143,6 @@ func (r *resourceDBInstance) Schema(ctx context.Context, req resource.SchemaRequ | |||||
Optional: true, | ||||||
Computed: true, | ||||||
PlanModifiers: []planmodifier.String{ | ||||||
stringplanmodifier.RequiresReplace(), | ||||||
stringplanmodifier.UseStateForUnknown(), | ||||||
}, | ||||||
Description: `Specifies whether the DB instance will be deployed as a standalone instance or | ||||||
|
@@ -215,6 +211,18 @@ func (r *resourceDBInstance) Schema(ctx context.Context, req resource.SchemaRequ | |||||
also use the InfluxDB CLI to create an operator token. These attributes will be | ||||||
stored in a Secret created in AWS SecretManager in your account.`, | ||||||
}, | ||||||
names.AttrPort: schema.Int64Attribute{ | ||||||
Optional: true, | ||||||
Computed: true, | ||||||
PlanModifiers: []planmodifier.Int64{ | ||||||
int64planmodifier.UseStateForUnknown(), | ||||||
}, | ||||||
Validators: []validator.Int64{ | ||||||
int64validator.Between(1024, 65535), | ||||||
int64validator.NoneOf(2375, 2376, 7788, 7789, 7790, 7791, 7792, 7793, 7794, 7795, 7796, 7797, 7798, 7799, 8090, 51678, 51679, 51680), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (jk)
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that a leetspeak reference? |
||||||
}, | ||||||
Description: `The port number on which InfluxDB accepts connections.`, | ||||||
}, | ||||||
names.AttrPubliclyAccessible: schema.BoolAttribute{ | ||||||
Optional: true, | ||||||
Computed: true, | ||||||
|
@@ -226,9 +234,7 @@ func (r *resourceDBInstance) Schema(ctx context.Context, req resource.SchemaRequ | |||||
}, | ||||||
"secondary_availability_zone": schema.StringAttribute{ | ||||||
Computed: true, | ||||||
PlanModifiers: []planmodifier.String{ | ||||||
stringplanmodifier.UseStateForUnknown(), | ||||||
}, | ||||||
Default: nil, | ||||||
Description: `The Availability Zone in which the standby instance is located when deploying | ||||||
with a MultiAZ standby instance.`, | ||||||
}, | ||||||
|
@@ -454,15 +460,34 @@ func (r *resourceDBInstance) Update(ctx context.Context, req resource.UpdateRequ | |||||
} | ||||||
|
||||||
if !plan.DBParameterGroupIdentifier.Equal(state.DBParameterGroupIdentifier) || | ||||||
!plan.LogDeliveryConfiguration.Equal(state.LogDeliveryConfiguration) { | ||||||
!plan.LogDeliveryConfiguration.Equal(state.LogDeliveryConfiguration) || | ||||||
!plan.DBInstanceType.Equal(state.DBInstanceType) || | ||||||
!plan.DeploymentType.Equal(state.DeploymentType) || | ||||||
!plan.Port.Equal(state.Port) { | ||||||
in := timestreaminfluxdb.UpdateDbInstanceInput{ | ||||||
Identifier: plan.ID.ValueStringPointer(), | ||||||
} | ||||||
|
||||||
resp.Diagnostics.Append(flex.Expand(ctx, plan, &in)...) | ||||||
// If any argument is updated with the same value, a ValidationException will occur. Arguments should only | ||||||
// be updated if they have changed. For this reason, flex.Expand cannot be used for all arguments. | ||||||
if !plan.DBParameterGroupIdentifier.Equal(state.DBParameterGroupIdentifier) { | ||||||
in.DbParameterGroupIdentifier = plan.DBParameterGroupIdentifier.ValueStringPointer() | ||||||
} | ||||||
|
||||||
if resp.Diagnostics.HasError() { | ||||||
return | ||||||
if !plan.LogDeliveryConfiguration.Equal(state.LogDeliveryConfiguration) { | ||||||
flex.Expand(ctx, plan.LogDeliveryConfiguration, &in.LogDeliveryConfiguration) | ||||||
} | ||||||
|
||||||
if !plan.DBInstanceType.Equal(state.DBInstanceType) { | ||||||
in.DbInstanceType = awstypes.DbInstanceType(plan.DBInstanceType.ValueString()) | ||||||
} | ||||||
|
||||||
if !plan.DeploymentType.Equal(state.DeploymentType) { | ||||||
in.DeploymentType = awstypes.DeploymentType(plan.DeploymentType.ValueString()) | ||||||
} | ||||||
|
||||||
if !plan.Port.Equal(state.Port) { | ||||||
in.Port = aws.Int32(int32(plan.Port.ValueInt64())) | ||||||
forestmvey marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
} | ||||||
|
||||||
_, err := conn.UpdateDbInstance(ctx, &in) | ||||||
|
@@ -494,6 +519,12 @@ func (r *resourceDBInstance) Update(ctx context.Context, req resource.UpdateRequ | |||||
plan.SecondaryAvailabilityZone = flex.StringToFrameworkLegacy(ctx, output.SecondaryAvailabilityZone) | ||||||
} | ||||||
|
||||||
// Updating tags can leave SecondaryAvailabilityZone unknown, as tags cannot be included in UpdateDbInstanceInput above. | ||||||
// To get around this, if SecondaryAvailabilityZone is unknown after an update, set it to its previous value. | ||||||
if plan.SecondaryAvailabilityZone.IsUnknown() { | ||||||
plan.SecondaryAvailabilityZone = state.SecondaryAvailabilityZone | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the fix for From what I can determine, the problem is that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might be good to add a small comment regarding this in the code 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. |
||||||
} | ||||||
|
||||||
resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) | ||||||
} | ||||||
|
||||||
|
@@ -557,7 +588,7 @@ func waitDBInstanceCreated(ctx context.Context, conn *timestreaminfluxdb.Client, | |||||
|
||||||
func waitDBInstanceUpdated(ctx context.Context, conn *timestreaminfluxdb.Client, id string, timeout time.Duration) (*timestreaminfluxdb.GetDbInstanceOutput, error) { | ||||||
stateConf := &retry.StateChangeConf{ | ||||||
Pending: enum.Slice(awstypes.StatusModifying, awstypes.StatusUpdating), | ||||||
Pending: enum.Slice(awstypes.StatusModifying, awstypes.StatusUpdating, awstypes.StatusUpdatingInstanceType, awstypes.StatusUpdatingDeploymentType), | ||||||
Target: enum.Slice(awstypes.StatusAvailable), | ||||||
Refresh: statusDBInstance(ctx, conn, id), | ||||||
Timeout: timeout, | ||||||
|
@@ -575,7 +606,7 @@ func waitDBInstanceUpdated(ctx context.Context, conn *timestreaminfluxdb.Client, | |||||
|
||||||
func waitDBInstanceDeleted(ctx context.Context, conn *timestreaminfluxdb.Client, id string, timeout time.Duration) (*timestreaminfluxdb.GetDbInstanceOutput, error) { | ||||||
stateConf := &retry.StateChangeConf{ | ||||||
Pending: enum.Slice(awstypes.StatusDeleting), | ||||||
Pending: enum.Slice(awstypes.StatusDeleting, awstypes.StatusDeleted), | ||||||
Target: []string{}, | ||||||
Refresh: statusDBInstance(ctx, conn, id), | ||||||
Timeout: timeout, | ||||||
|
@@ -645,6 +676,7 @@ type resourceDBInstanceData struct { | |||||
Name types.String `tfsdk:"name"` | ||||||
Organization types.String `tfsdk:"organization"` | ||||||
Password types.String `tfsdk:"password"` | ||||||
Port types.Int64 `tfsdk:"port"` | ||||||
PubliclyAccessible types.Bool `tfsdk:"publicly_accessible"` | ||||||
SecondaryAvailabilityZone types.String `tfsdk:"secondary_availability_zone"` | ||||||
Tags tftags.Map `tfsdk:"tags"` | ||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be redundant to add default here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be redundant, the port defaults to
8086
anyways when creating an instance.