hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.8k stars 9.15k forks source link

[Enhancement]: Connect : add a aws_connect_contact_flow_action resource #33697

Open psantus opened 1 year ago

psantus commented 1 year ago

Description

Currently aws_connect_contact_flow consists of a huge "content" JSON.

Having resources for action would give a much easier "object-oriented" approach to designing flows using Terraform.

I have designed a module to be able to have actions as pseudo-resources, but since modules can't take weakly typed inputs as variable, it is limited. Indeed, action parameters are complex objects which can't be described as variables.

Affected Resource(s) and/or Data Source(s)

Potential Terraform Configuration

resource "aws_connect_contact_flow" "contact_flow" {
  instance_id = aws_connect_instance.instance.id
  name        = "Chat contact flow"
  ## other metadata
}

resource "aws_connect_contact_flow_action" "action_one" {
  contact_flow_id = aws_connect_contact_flow.contact_flow.id
  type   = "MessageParticipant"
  parameters = {
    Text = "Some text"
  }
  next_action_id = aws_connect_contact_flow_action.action_two.id

  metadata = {
    position = {
      x = 273.75
      y = 20
    }
  }
}

resource "aws_connect_contact_flow_action" "action_two" {
  contact_flow_id = aws_connect_contact_flow.contact_flow.id

  type   = "MessageParticipant"

  parameters = {
    Text = "Some text"
  }

  next_action_id = aws_connect_contact_flow_action.action_two.id

  conditions = [
    {
      NextAction = aws_connect_contact_flow_action.action_two.id,
      Condition = {
        Operator = "Equals"
        Operands = ["True"]
      }
    },
    {
      NextAction = aws_connect_contact_flow_action.action_three.id,
      Condition = {
        Operator = "Equals"
        Operands = ["False"]
      }
    }
  ]

  errors = [
    {
      ErrorType  = "NoMatchingError"
      NextAction = aws_connect_contact_flow_action.action_three.id
    }
  ]

  metadata = {
    position = {
      x = 273.75
      y = 20
    }
  }
}

References

https://docs.aws.amazon.com/connect/latest/APIReference/flow-language-actions.html

Can't do it myself, but would be happy to discuss with whoever would implement this.

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue