Genesys Cloud - Developer Community!

 View Only

Sign Up

Expand all | Collapse all

Best source(s) of info on how to get started with CI/CD if orgs already exist?

  • 1.  Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 07-09-2025 04:58

    I've spent DAYS (literally) trying to digest every article, forum post, video, etc. I can get my hands on and am left with a sense of frustration that I'm hoping I can get some help with.

    Background: we started creating our first GC org/implementation roughly a year ago. At that time, we had only the one org, but had the idea that we wanted two orgs: one for "dev" and one for "prod." Due to timing requirements, the "first" org has ended up being the Prod org and the 2nd org we had set up (this was set up late last year or earlier this year) is now "Dev." I spent ~100 hours trying to basically export the majority of the objects in what is now the Prod org (the "original"/first org we had) and get them over to the "fresh" Dev org using Terraform. Long story short, some of it worked out, some of it I gave up on and manually recreated the objects.

    So at least for a minute, the two orgs were basically "in sync" but I got there via a combo of Terraform and manual work (like literally have two browser windows open - one logged into Dev and one logged into Prod, and manually use the UI to create the required objects in Dev using the displayed object in Prod. What I did not/do not have is some set of Terraform files that I can use going forward for what I guess I'd call "traditional CI/CD pipeline" approach going forward.

    Fast forward to today: we've been making some changes to existing flows, added a couple of new queues, added a couple of new flows, etc. in the DEV org (the "second" org that got created). Since I was not able to make Terraform do all I was hoping it would do initially, I have nothing to use in terms of Terraform files to now try to use CI/CD to "promote"/"merge" the changes made in the Dev org (manually using the UI, NOT using YAML or a code editor, etc.) and I'm entirely lost on how to get things set up in Terraform such that Terraform "understands" the relationship between a given object in the Dev org and it's "related" object in the Prod org (for example, a queue that has the exact same name in both orgs but obviously different GUID'S).

    Outside of a PS engagement (it would take longer than I have to get approvals, generate PO's, etc.), I'm looking for some help on how to now get a proper set of Terraform files (.tf, state file(s) where needed, etc., tfvars, etc.) built out for both Dev and Prod such that I can then use Terraform to take the changes made manually in Dev using the UI and "push" those changes to the associated objects in Prod.

    Is there a video, resource, article, etc. that walks through how to get this all set up initially given both orgs exist (I realize that is not ideal), most objects exist in both orgs, usually with the exact same name, and in general, the properties of the objects I want to manage are identical at the moment I want to get this set up?

    I'm lost where it comes to the end-to-end process of setting Terraform up when both orgs and essentially all the objects already exist in both orgs and I want Terraform to understand that "Customer Service Queue" in Dev with an ID of XYZ is the "same" object as "Customer Service Queue" in Prod but with an ID of PDQ and if it detects that the properties of the Dev object (at ID = XYZ) have changed from "the initial captured state" at the point when I finish this initial setup of Terraform, it understands that it needs to apply those changes to the Prod org's object (at ID = PDQ).

    I suspect this is via a combination of substitution and reference, but there's just not enough specific documentation on this specific use case (which seems to be one a LOT of people are interested in since in most cases, we'll be starting to use CX as Code with org(s) that already exist) related to how to get things set up initially assuming both orgs have been manually mangled into having a synchronized set of objects. 

    I believe the initial setup of all of this is going to require me to do exports from BOTH orgs (I assume into separate directories), but I don't know what Terraform files need to be copied from one directory to the other, what files I need to manually make changes to in order to be able to move forward and keep things in sync with Terraform detecting changes in the Dev org and applying those changes to the associated Prod org objects, and getting object "lookups" to properly resolve (in one case, I was trying to export a flow from one org and import it into the other. The flow had a Transfer to Group action that contained a literal with the Group name which was identical in both orgs, but after the flow got updated/imported to the destination org, I had to manually fix the transfer action literals and re-select the groups with the exact same names as what was being displayed already in Architect in the destination org.

    I think there are MANY of us that would benefit from a very explicit guide on how to get the initial states captured (assuming the initial states are already in sync) and how to keep things in sync going forward.

    I also want to know this: assuming I get all this set up and working, is it "allowed" to continue to use the UI (such as the Architect UI) to make changes in Dev and then use Terraform to apply those changes to Prod, or do I have to make all of my changes using a code editor and raw YAML once the initial setup is complete?

    One other thing: when I did the initial export from Prod to Dev (remember, the first org we had eventually became "Prod" and the 2nd org we got created became Dev, so opposite of what you'd expect) I used ChatGPT extensively (like literally over 7 full days/100 hours). It screwed A LOT of stuff up and then would correct itself but I have to say that I would have never gotten anything to work at all without ChatGPT - the documentation that's available is just insufficient for someone new to Terraform.

    I'm going to try to make my way through the Terraform in Action materials from Scott Winkler per a recommendation I saw amongst the various Genesys-created documentation elements but I can't remember where that recommendation was. I'm hoping that by gaining a deeper understanding of how Terraform handles this sort of thing overall, I'll be in a better position to understand what needs to happen related to the various Terraform files, substitutions/variables, references, dependencies, etc. 

    If I ever get to the point that I have it all sorted out, I absolutely will write my own guide on how I did it, so anyone who is willing to help me, please know that I'm committing to "giving back" when I've got it all sorted.

    Thank you for taking the time to read all of this and also thank you in advance for (hopefully) helping me. I will be journaling/cataloging every step I take with the goal of having a final document that captures all the steps and all the gritty details of how to do this so those coming after me won't have this frustration.

    Kind regards,

    Greg


    #CXasCode

    ------------------------------
    Greg Palen
    Principal Genesys Cloud Consultant
    Verizon Business
    ------------------------------


  • 2.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 07-14-2025 04:40

    Hi Greg, I don't believe there is a comprehensive guide on how to do this. We were in the same position as you however with 4 Orgs in total. It took a lot of effort and a lot of trial and error but we got there in the end and we now have a complete CI\CD pipeline to deploy our GC resources across the 4 Orgs using a combination of Terraform and GitHub. We had to learn as we went along as there was not much help or guidance available as you know.

    Your best bet would be to export your configuration as you mentioned. You can use the export utility to create the required .tf files but I would suggest you spend some time structuring your files and modules once exported to your needs.

    In terms of keeping things in sync. As I mentioned we use a combination of Terraform and GitHub, each Org has it's own Git branch. We also have a Terraform Workspace for each Org. When Terraform detects a change in the GitHub branch, it triggers a Plan. Once we're happy with those changes we move the code to the next Branch/Org and repeat the process up to Prod.

    With regards to making changes to Architect flows, you can make changes in the UI and then export the YAML and apply it to your working directory and apply the changes with Terraform.

    I know I haven't answered all your questions but happy to assist further.



    ------------------------------
    Savino Ricci
    Technical Consultant
    ------------------------------



  • 3.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 07-14-2025 10:10

    Hi Savino,

    Thanks for your reply and the overview you provided. I'm glad to know somebody got this working all the way through. My goal for both myself and ultimately the entire community is an EXHAUSTIVE guide on how to do this from the point of view of someone who is learning enough Terraform to get the job done at the same time.

    If you have the time and interest to either get on a call with me and let me ask some specific questions or perhaps we just keep going here back and forth with all the questions I have going forward, that's fine too. And if you just don't have time for anything further than what you posted, please feel free to say so. I know we're ALL busy so I get it if you don't have (or want) the time to spend on this.

    I'm also in communication with Genesys on this so hopefully between you and them, I can pull together everything I need to do the exhaustive guide.

    Let me know if you want to help further and if you prefer we set up a call or just continue trading questions and answers here.

    Again, thank you so much for taking the time to reply!

    Deepest regards,

    Greg



    ------------------------------
    Greg Palen
    Principal Genesys Cloud Consultant
    Verizon Business
    ------------------------------



  • 4.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 07-14-2025 16:34

    📝 Summary of Key Points:

    • Terraform is designed for forward CICD pipelines, not reverse migrations.

    • Reverse-engineering from production to development is complex and context-specific.

    • There's no one-size-fits-all guide, but targeted exports and overlays can help.

    • Start small, iterate, and consider involving Professional Services for complex cases.

    • Developer forums are a great place to surface and troubleshoot specific challenges.


    Hi, this is John Carnell.

    Sorry I didn't get back to this thread sooner-I was traveling last week and spent Friday catching up on email. I wanted to respond because I completely understand the frustration of trying to work backward from a production environment to a development one using Terraform. That's a tough scenario, and here's why.

    🚧 Why This is Hard

    Terraform is fundamentally designed to support a forward-moving CI/CD pipeline: from dev → test → prod. It's not naturally suited to going in reverse (i.e., pulling prod configurations back into dev). This isn't just a tooling issue-it's about how Terraform was designed: as a set of primitives for DevOps, not a high-level abstraction with universal migration tooling.

    And because every contact center implementation is a little different, it's difficult to provide clean, step-by-step guidance that works for everyone.

    🛠️ A General Approach

    That said, there are some patterns that can help. Here's a rough outline of what I'd recommend when trying to rebuild dev using what's in prod:

    1. Export from Dev First
      Export your development environment using the export tool. This includes generating the Terraform state (.tfstate) and HCL files. Start small-pick a key object like an Architect flow.

    2. Resolve Dependencies
      Use the export functionality to resolve and include all dependencies for that object. This will give you a clean export without GUIDs embedded in the Terraform state.

    3. Export from Prod (HCL Only)
      Go to your production environment and export just the HCL definitions for the same object(s). Don't include the prod state file-you don't want to overwrite your dev state.

    4. Overlay and Apply
      Overlay the production HCL files onto your dev environment and apply them. This lets you simulate how that object would look in dev using production definitions.

    5. Iterate
      Build incrementally. Once you've done one object successfully, move on to others. Don't try to export and re-import everything at once-it's almost guaranteed to cause problems.

    🤝 Why I Recommend Professional Services

    I always advise teams to consider engaging Professional Services (PS)-not as a sales pitch, but because these folks have done a lot of these implementations. They can help shortcut a lot of the pain by tailoring the process to your exact use case. PS even has internal tools for cloning environments, which aren't publicly documented or generalized for all customers.

    🧭 Final Advice

    If you're hitting specific errors or edge cases (e.g., exports not working, dependencies missing, conflicts on import), please post them here in the developer forum. A lot of other teams have dealt with similar issues, and you're likely to get helpful input.

    Also, if I'm not mistaken, one of our product managers will be reaching out to follow up on this topic.


    Thanks again for raising the question. It's not an easy path, but with the right strategy-and patience-it can be done. And remember:
    Start small. Understand the process. Then iterate. Trying to do everything at once, especially in one giant repo, usually leads to overwhelm and failure.

    Looking forward to hearing how it goes-and feel free to post follow-ups.

    - John Carnell



    ------------------------------
    John Carnell
    Director, Developer Engagement
    ------------------------------



  • 5.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 07-14-2025 16:50
    Edited by Greg Palen 07-14-2025 16:53

    Hi John and thanks for writing back.

    I think I must have done a poor job of writing my original post if your impression was that I was looking for help with the reverse migration. That's all done. I have both orgs "in sync" now and did most of that manually by literally sitting there and re-creating anything I could not get copied over using Terraform.

    I'm trying to set it up "the way it's meant to be done" (forward) and that's where I've hit wall after wall. The problem is that everything is "general" and with no meaningful Terraform experience, that's like me telling you that the general approach to flying an airplane is to have the proper amount of velocity to maintain flight and when you're ready to land, you reduce the velocity such that flight can no longer be maintained at the same altitude (I'm a private pilot and I chose this analogy very deliberately because I think it makes my point, as long as you're not also a pilot and/or have previous experience behind the controls). Unless you spend the time understanding the rotation speed of the aircraft, etc., you're just guessing at pretty much everything.

    Now on to specific questions - the 5 steps you laid out feel like you gave me the instructions for going from Prod to Dev. I don't need that - I need exactly the opposite. Also, your step #1 seems to include a contradiction: you say to include generating the state file but doesn't that create the GUID's that in #2 you say won't be there?

    If you (and Savino) are willing to answer my questions as I pose them, I'll give this a shot and as I indicated earlier, will produce that detailed guide myself once I work through it all.

    Before I do anything more at all, I would like to confirm that the instructions you provided above (#1 - #5) are in fact for going from Prod to Dev and NOT Dev to Prod. To restate, I am at the point where my goal is to set this up as a normal, forward CI/CD pipeline. Both orgs are in sync right now so I do not have to do anything at all in that regard. I now need to get everything set up such that if I make a change to a flow for example (in DEV, not Prod), I can use what I put together with Terraform to then "push" that change to Prod "properly."

    Can you let me know if the instructions you provided are meant to go from Dev to Prod or Prod to Dev please? As I mentioned before, it feels like you're helping me with the reverse migration from Prod to Dev and that's not what I need help with - that's long since been done and now I'm trying to do all of this the right way.

    PS: if the instructions you gave are in fact for the reverse migration, which I do not need, can you please post a new set of instructions for the normal, forward CI/CD setup (Dev -> Test -> Prod, except we only have Dev & Prod, so Dev -> Prod).

    Thanks,

    Greg



    ------------------------------
    Greg Palen
    Principal Genesys Cloud Consultant
    Verizon Business
    ------------------------------



  • 6.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 07-15-2025 07:30
    Hey,
     
    I don't want to step on the toes of John or Savino, but I'm also happy answer questions. Many moons ago I wrote an article about a CI/CD flow I created, which talks to the high-level CI/CD process, but not so much to your specific situation:
     
    Can I just check I understand your setup please?
    • You have two environments (Dev and Prod) that you have manually made the same
    • You want to create the TF so you can promote changes in Dev to Prod
    • You have flows/resources in your dev org that reference other resources in your dev org (i.e. a flow that references a queue), and you want to promote such flows into your Prod org
    • You want TF to take control of resources you already have in Dev and Prod



    ------------------------------
    Lucas Woodward
    OVO Energy Ltd

    https://www.linkedin.com/in/lucas-woodward-the-dev
    ------------------------------



  • 7.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 07-15-2025 08:07

    Hi Lucas,

    You will never step on my toes :). Your input is always welcome.

    Thanks,
        John



    ------------------------------
    John Carnell
    Director, Developer Engagement
    ------------------------------



  • 8.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 07-18-2025 14:42

    Hi John,

    Can you see my reply to your instructions (which were for going from Prod -> Dev; I don't need that - already done) and reply back to me with updated instructions just like what you provided initially, but for going from Dev -> Prod "as intended?"

    Thanks!

    Greg



    ------------------------------
    Greg Palen
    Principal Genesys Cloud Consultant
    Verizon Business
    ------------------------------



  • 9.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 07-16-2025 02:17

    Hi Lucas,

    Agree with John, the more the merrier! 

    @Greg Palen Definitely happy to help further and contribute



    ------------------------------
    Savino Ricci
    Technical Consultant
    ------------------------------



  • 10.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 07-18-2025 14:47

    Hi Lucas,

    Your understanding of what my current setup is (and what I'm trying to accomplish) is exactly spot-on (all 4 bullets).

    Sorry I didn't reply sooner - I was without power the majority of yesterday. All is good now thankfully.

    I haven't had a chance to read your post yet but I definitely will.

    I'm literally at Square 0. I know I need to do some Terraform "stuff" related to both orgs but not sure about things like whether or not a state file is needed, etc. Per John's instructions, I like the idea of starting very, very small on this. I'm thinking one flow and its related dependencies.

    If any of you guys can give me the details of what needs to be in the initial Terraform "configuration" file, I can get started. I know I need an export block, credentials, etc. You can skip telling me that stuff. Focus on what options/properties I need in the Export block.

    Also, let me know about any specifics in terms of how I should structure my file/folder system. Assume I have a "top-level" folder called terra_home. I'd like your input on what should be within that folder. I imagine I need a subfolder for each of the two orgs, etc.

    Looking forward to working through all this and I really appreciate everyone's help!

    Regards,

    Greg



    ------------------------------
    Greg Palen
    Principal Genesys Cloud Consultant
    Verizon Business
    ------------------------------



  • 11.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 07-18-2025 14:49

    Side note: I just went and read your other posting related to the Chatbots automation. That's a great overview for me and helps me understand at a high level what I'm working towards! Thank you!

    Now it's "nuts and bolts" time :).



    ------------------------------
    Greg Palen
    Principal Genesys Cloud Consultant
    Verizon Business
    ------------------------------



  • 12.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 07-31-2025 18:25

    Sorry for the slow response, and if you already know most of this. However, I thought I'd start from the high-level and work down.

    Terraform at the high-level

    The following diagram shows the high-level of Terraform being used to maintain the infrastructure of two organisations, Dev and Prod.
     
    It shows two things:
    • Each environment has its own state file - this records the state of the resources TF manages in the environment, which in this diagram is the book_refund queue.
    • Ideally both environments are made to represent the same resource definitions (.tf files)
      • Although attributes/quantities of resources can differ between environments as the tfvars files show

    The separation of state files has interesting consequences for each organisation, namely:

    • If you want to import a resource you created manually in an Org into TF then you'd have to do it for each environment
      • This is because TF will import the resource into your environment specific state file.
    • Each environment's state file will associate the TF resource's ID (resource type + resource name) with the ID of the resource in Genesys. In the diagram this means there will be an entry in the state files linking genesyscloud_routing_queue.book_refund to the ID of a resource in Genesys Cloud.
      • If you manually rename the ID of a resource in the TF file (e.g from .book_refund to .book_refunds) then TF destroy the resource with the old name and create a new one with the new name.

    Taking control of resources you already have in Dev and Prod

    If you have resources in your organisations that you want to control via Terraform then you need to import them into your Terraform's state file, and either into a TF JSON file via Genesys Cloud's Export resource or into the TF file using TF's import command.

    Once the resource is managed by TF then ideally you would no longer be making changes to it directly in the UI since this can cause the resource to drift - meaning it becomes unaligned to what TF is expecting. The consequences being that TF with likely overwrite your manually set config.

    This is an example of using Terraform's import functionality:

    # file: queue.tf
    
    # 1. Define the import with the ID of the element and the
    #    resource below you want it associated with in the state file
    import {
      to = genesyscloud_routing_queue.book_purchase
      id = "d3fc76d9-ff56-434a-a546-6054ca2ac8c5"
    }
    
    # 2. Only you run apply it will have imported the state against this resource
    #     You can then delete the import statement above.       
    resource "genesyscloud_routing_queue" "book_purchase" {
      name = "Book Purchase"
    }

    You would have to perform this against each environment to ensure the resource in each is stored in the respective state file. In each environment the common identifier for the book_purchase queue is the ID genesyscloud_roouting_queue.book_purchase.

    Referencing existing resources in your flows

    You mentioned that you have flows/resources in your dev org that reference other resources in your dev org (i.e. a flow that references a queue), and you want to promote such flows into your Prod org.

    Presuming the resources you've mentioned aren't managed in TF then you'll need to use a Data Source resource. These resources allow you to reference an existing resource and extract out information about it that can be used as a reference:

    An example of this:

    data "genesyscloud_user" "user_lucas" {
      name = "Lucas Woodward"
    }
    
    resource "genesyscloud_flow" "inbound_message_flow" {
      filepath = "${path.module}/book_refund_inbound_message_flow.yaml"
      file_content_hash = filesha256("${path.module}/book_refund_inbound_message_flow.yaml")
      # These reference placeholders in the flow file e.g. {{direct_agent_id}}
      substitutions = {
        direct_agent_id = data.genesyscloud_user.user_lucas.id
      }
    }

    In this example I am using the data resource to 'lookup' a user with my name, which I am passing as a substitution in an Inbound Message flow.

    As I promote this between Dev and Prod the Data Source will be retrieving the ID unique to that environment and passing it as a substitution.

    ---

    Hopefully this is a good start to answering your questions?

    Also, I hope you don't mind but I plan on creating a walkthrough of using TF for CX as Code in my newsletter, since I enjoyed reminding myself of all of this again.



    ------------------------------
    Lucas Woodward
    Orchestrator of the Year Finalist (2025)

    LinkedIn - https://www.linkedin.com/in/lucas-woodward-the-dev
    Newsletter - https://makingchatbots.com
    ------------------------------



  • 13.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?
    Best Answer

    Posted 10-01-2025 10:50

    I finally finished writing the article that hopefully answers your questions: https://makingchatbots.com/p/cx-as-code-with-genesys-cloud



    ------------------------------
    Lucas Woodward
    Winner of Orchestrator of the Year, Developer (2025)

    LinkedIn - https://www.linkedin.com/in/lucas-woodward-the-dev
    Newsletter - https://makingchatbots.com
    ------------------------------



  • 14.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 10-01-2025 11:15
    Edited by Greg Palen 10-03-2025 10:35

    Ignore this post - see below.



  • 15.  RE: Best source(s) of info on how to get started with CI/CD if orgs already exist?

    Posted 10-03-2025 10:30
    Edited by Greg Palen 10-03-2025 10:36

    Hi Lucas,

    Before I throw a bunch of questions at you, I wanted to ask you if you prefer we go back and forth here, or would you prefer we use the Comments under your article?

    Once I hear back from you on this preference, I'll post my questions accordingly.

    The article and your post above both definitely helped me understand some things, particularly around how variables are used to deal with different ID's, potentially different names, etc. between dev and prod. It has, however, spawned a decent number of questions...

    Looking forward to hearing back,

    Greg



    ------------------------------
    Greg Palen
    Principal Genesys Cloud Consultant
    Verizon Business
    ------------------------------