Skip to content

Conversation

@its2shar
Copy link
Member

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

% make t K=connect T=TestAccConnect_serial/RoutingProfile/crossChannelBehavior
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
make: Running acceptance tests on branch: 🌿 r/aws_connect_routing_profile 🌿...
TF_ACC=1 go1.24.8 test ./internal/service/connect/... -v -count 1 -parallel 20 -run='TestAccConnect_serial/RoutingProfile/crossChannelBehavior'  -timeout 360m -vet=off
2025/10/21 19:08:59 Creating Terraform AWS Provider (SDKv2-style)...
2025/10/21 19:08:59 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN   TestAccConnect_serial
=== PAUSE TestAccConnect_serial
=== CONT  TestAccConnect_serial
=== RUN   TestAccConnect_serial/RoutingProfile
=== RUN   TestAccConnect_serial/RoutingProfile/crossChannelBehavior
--- PASS: TestAccConnect_serial (186.41s)
    --- PASS: TestAccConnect_serial/RoutingProfile (186.41s)
        --- PASS: TestAccConnect_serial/RoutingProfile/crossChannelBehavior (186.41s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/connect    191.755s

@its2shar its2shar requested a review from a team as a code owner October 21, 2025 13:49
@github-actions
Copy link
Contributor

Community Guidelines

This 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

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/connect Issues and PRs that pertain to the connect service. size/L Managed by automation to categorize the size of a PR. labels Oct 21, 2025
"behaviour": {
Type: schema.TypeString,
Optional: true,
Default: string(awstypes.BehaviorTypeRouteAnyChannel),
Copy link
Member

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": {
Copy link
Member

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": {
Copy link
Member

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.

@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_connect_routing_profile: Add behaviour support to media_concurrencies block
Copy link
Member

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:

Suggested change
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
Copy link
Member

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.

@jar-b jar-b added the rnd-ind-provider rnd-ind-provider label Oct 27, 2025
Comment on lines +496 to +501
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)),
}
}
Copy link
Member

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.

Comment on lines +529 to +538
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),
},
}
}
}
Copy link
Member

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 {
Copy link
Member

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.

Comment on lines +357 to +360
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "media_concurrencies.*", map[string]string{
"channel": string(awstypes.ChannelVoice),
"concurrency": "1",
}),
Copy link
Member

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.

Comment on lines +52 to +59
### 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.
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Introduces or discusses updates to documentation. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. rnd-ind-provider rnd-ind-provider service/connect Issues and PRs that pertain to the connect service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: Add support for concurrency cross channel behaviour to aws_connect_routing_profile

2 participants