-
Couldn't load subscription status.
- Fork 9.8k
Add support for concurrency cross channel behaviour #44750
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
base: main
Are you sure you want to change the base?
Conversation
Community GuidelinesThis comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀 Voting for Prioritization
Pull Request Authors
|
| "behaviour": { | ||
| Type: schema.TypeString, | ||
| Optional: true, | ||
| Default: string(awstypes.BehaviorTypeRouteAnyChannel), |
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.
Rather than set a provider-side default, we can set this as optional and computed and inherit the AWS default as a read-only value.
https://hashicorp.github.io/terraform-provider-aws/data-handling-and-conversion/#default-values
| Required: true, | ||
| ValidateFunc: validation.IntBetween(1, 10), | ||
| }, | ||
| "behaviour": { |
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.
To match the AWS API, this should be a list nested block (MaxItems: 1) with a single string attribute inside.
cross_channel_behavior {
behavior_type = ""
}| Type: schema.TypeInt, | ||
| Computed: true, | ||
| }, | ||
| "behaviour": { |
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.
Same as above - the shape of this attribute should match the AWS API.
.changelog/44750.txt
Outdated
| @@ -0,0 +1,3 @@ | |||
| ```release-note:enhancement | |||
| resource/aws_connect_routing_profile: Add behaviour support to media_concurrencies block | |||
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.
New argument additions typically use the following pattern:
| resource/aws_connect_routing_profile: Add behaviour support to media_concurrencies block | |
| resource/aws_connect_routing_profile: Add `media_concurrencies.cross_channel_behavior` argument |
Also, there should be a corresponding changelog entry for the data source.
| default_outbound_queue_id = aws_connect_queue.default_outbound_queue.queue_id | ||
| description = "Test cross-channel behavior - %[2]s" | ||
| %[3]s |
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.
Embedding variable blocks of HCL like this can make the configuration difficult to reason about when debugging. Although more text is required, explicitly writing out the media_concurrencies blocks in separate config helpers makes the comparison between steps easier to understand.
| if v, ok := tfMap["cross_channel_behavior"].([]any); ok && len(v) > 0 { | ||
| crossChannelBehaviorMap := v[0].(map[string]any) | ||
| apiObject.CrossChannelBehavior = &awstypes.CrossChannelBehavior{ | ||
| BehaviorType: awstypes.BehaviorType(crossChannelBehaviorMap["behavior_type"].(string)), | ||
| } | ||
| } |
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.
This can be moved into it's own, distinct expander expandCrossChannelBehavior.
Each flatten/expander is typically only responsible for one level of attributes. Because cross_channel_behavior is a nested list, we can split that out into it's own expand function which gets called from here. This helps keep the function body of each individual flex function compact, even for large nested structures.
| channel := string(apiObject.Channel) | ||
| if apiObject.CrossChannelBehavior != nil { | ||
| if len(configList) == 0 || configuredBehaviors[channel] { | ||
| tfMap["cross_channel_behavior"] = []map[string]any{ | ||
| { | ||
| "behavior_type": string(apiObject.CrossChannelBehavior.BehaviorType), | ||
| }, | ||
| } | ||
| } | ||
| } |
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.
This can be a separate flattener.
| } | ||
|
|
||
| func flattenMediaConcurrencies(apiObjects []awstypes.MediaConcurrency) []any { | ||
| func flattenMediaConcurrencies(apiObjects []awstypes.MediaConcurrency, configList ...[]any) []any { |
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.
Is there a reason the configured values are now passed in here? I'm not quite following why it is being used below.
| resource.TestCheckTypeSetElemNestedAttrs(resourceName, "media_concurrencies.*", map[string]string{ | ||
| "channel": string(awstypes.ChannelVoice), | ||
| "concurrency": "1", | ||
| }), |
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.
This check should also verify the AWS server-side default for cross_channel_behavior is being written to state as expected.
| ### Cross-Channel Behavior | ||
|
|
||
| The `cross_channel_behavior` block in `media_concurrencies` controls how Amazon Connect routes contacts across different channels: | ||
|
|
||
| - `ROUTE_ANY_CHANNEL` (default): Allows agents to receive contacts from any channel, regardless of the channel they are currently handling. | ||
| - `ROUTE_CURRENT_CHANNEL_ONLY`: Restricts agents to receive contacts only from the channel they are currently handling. | ||
|
|
||
| This feature enables fine-grained control over agent workload distribution and helps optimize contact center operations. |
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.
This block seems redundant with the argument reference below. If any of the additional details are necessary they can be included in the argument descriptions instead.
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the library.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
Description
Add cross-channel behavior support to aws_connect_routing_profile resource and data source
Relations
Closes #35018
References
https://docs.aws.amazon.com/connect/latest/APIReference/API_CreateRoutingProfile.html
https://docs.aws.amazon.com/connect/latest/APIReference/API_UpdateRoutingProfileConcurrency.html
Output from Acceptance Testing