Skip to content

Commit fa60993

Browse files
authored
Preserve null tags if not configured to prevent apply errors (#8)
1 parent e012f19 commit fa60993

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

internal/provider/resource_app.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -635,16 +635,20 @@ func (r *AppResource) mapAppToModel(data *AppResourceModel, app *client.App) {
635635
data.ProductionBranch = types.StringNull()
636636
}
637637

638-
// Map tags
639-
if len(app.Tags) > 0 {
640-
tagElements := make(map[string]attr.Value)
641-
for k, v := range app.Tags {
642-
tagElements[k] = types.StringValue(v)
638+
// Map tags - only update if tags were configured by the user
639+
// If tags is null in config, preserve null to avoid "inconsistent result after apply" error
640+
if !data.Tags.IsNull() {
641+
if len(app.Tags) > 0 {
642+
tagElements := make(map[string]attr.Value)
643+
for k, v := range app.Tags {
644+
tagElements[k] = types.StringValue(v)
645+
}
646+
data.Tags = types.MapValueMust(types.StringType, tagElements)
647+
} else {
648+
data.Tags = types.MapNull(types.StringType)
643649
}
644-
data.Tags = types.MapValueMust(types.StringType, tagElements)
645-
} else {
646-
data.Tags = types.MapNull(types.StringType)
647650
}
651+
// If data.Tags is null (not configured), leave it as null
648652

649653
// Region can be at top level or inside config
650654
if app.Region != "" {

0 commit comments

Comments
 (0)