-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Remove readonly properties from DMS ReplicationTaskSettings #13476
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bc9c2be
Suppress readonly properties from DMS ReplicationTaskSettings
aburgel 35b33af
Move logic from diff suppression to state
aburgel 1229f9a
Improve DMS acceptance test
aburgel f02b209
Run terrafmt
aburgel 13820ec
AWS partition linter
aburgel 2cf0ea5
r/dms_replication_task: Avoid hardcoded DNS suffix
YakDriver 531f9ef
r/dms_replication_task: Remove errant rebase fodder
YakDriver 9030219
r/dms_replication_task: Simplify, cleanup names
YakDriver 6474fe8
tests/dms_replication_task: Reduce duplication of HCL
YakDriver 32d5501
tests/dms_replication_task: Lint
YakDriver d281a50
tests/dms_replication_task: Remove quotes
YakDriver af2c65c
r/dms_replication_task: Add changelog
YakDriver 58f2525
r/dms_replication_task: Minor cleanups
YakDriver File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
resource/aws_dms_replication_task: Handle read-only attributes in `replication_task_settings` to avoid unnecessary diffs. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package aws | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"log" | ||
"strconv" | ||
|
@@ -288,11 +289,16 @@ func resourceAwsDmsReplicationTaskSetState(d *schema.ResourceData, task *dms.Rep | |
d.Set("replication_instance_arn", task.ReplicationInstanceArn) | ||
d.Set("replication_task_arn", task.ReplicationTaskArn) | ||
d.Set("replication_task_id", task.ReplicationTaskIdentifier) | ||
d.Set("replication_task_settings", task.ReplicationTaskSettings) | ||
d.Set("source_endpoint_arn", task.SourceEndpointArn) | ||
d.Set("table_mappings", task.TableMappings) | ||
d.Set("target_endpoint_arn", task.TargetEndpointArn) | ||
|
||
settings, err := dmsReplicationTaskRemoveReadOnlySettings(*task.ReplicationTaskSettings) | ||
if err != nil { | ||
return err | ||
} | ||
d.Set("replication_task_settings", settings) | ||
|
||
return nil | ||
} | ||
|
||
|
@@ -328,3 +334,29 @@ func resourceAwsDmsReplicationTaskStateRefreshFunc( | |
return v, *v.ReplicationTasks[0].Status, nil | ||
} | ||
} | ||
|
||
func dmsReplicationTaskRemoveReadOnlySettings(settings string) (*string, error) { | ||
var settingsData map[string]interface{} | ||
if err := json.Unmarshal([]byte(settings), &settingsData); err != nil { | ||
return nil, err | ||
} | ||
|
||
controlTablesSettings, ok := settingsData["ControlTablesSettings"].(map[string]interface{}) | ||
if ok { | ||
delete(controlTablesSettings, "historyTimeslotInMinutes") | ||
} | ||
|
||
logging, ok := settingsData["Logging"].(map[string]interface{}) | ||
if ok { | ||
delete(logging, "CloudWatchLogGroup") | ||
delete(logging, "CloudWatchLogStream") | ||
Comment on lines
+351
to
+352
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. If you define these in your task settings, DMS API will return an error that they are read only. |
||
} | ||
|
||
cleanedSettings, err := json.Marshal(settingsData) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
cleanedSettingsString := string(cleanedSettings) | ||
return &cleanedSettingsString, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
There is another property
HistoryTimeslotInMinutes
(with a capital H) that is the real property. I don't know why this one exists, but I'm cleaning it out since leaving it in when we set state would cause a difference to show.