Closed careb2b closed 4 years ago
There are two cicd/
directories, one is at the root of your output directory (i.e. tfengine/generated/cicd
) and the other one is under live
(tfengine/generated/live/cicd
). The difference is tfengine/generated/cicd
should be run once manually, and tfengine/generated/live/cicd
is managed by CICD itself.
Can you let me know what's the directory structure of your generated configs after running tfengine
? The Cloud Build Triggers work together with the Terraform configs and directory structure configured by tfengine
and it assumes there is a /live
folder and also a live/cicd
folder inside. If you use tfengine
to generated configs, the directory structure should be set up for you.
Thanks. I had TERRAFORM_ROOT as "live" in the trigger which was wrong and now changed it to ".". This fixed the issue of not being able to run. I ran into another issue.
1) docs tell you to download and install terraform which is used to create the initial state file, but Google Cloud Build has a slightly older version of terraform so the run fails because you manually created the state with a newer version.
Error loading state: state snapshot was created by Terraform v0.12.28, which is newer than current v0.12.26; upgrade to Terraform v0.12.28 or greater to work with this state
2) And then the READMe in cicd... Should it mention to copy cicd/confgs/* to live/cicd/configs so triggers can see those files?
Thanks. I had TERRAFORM_ROOT as "live" in the trigger which was wrong and now changed it to ".". This fixed the issue of not being able to run. I ran into another issue.
- docs tell you to download and install terraform which is used to create the initial state file, but Google Cloud Build has a slightly older version of terraform so the run fails because you manually created the state with a newer version.
Error loading state: state snapshot was created by Terraform v0.12.28, which is newer than current v0.12.26; upgrade to Terraform v0.12.28 or greater to work with this state
Let me update the Docker image used in CICD so it's using the up-to-date Terraform.
- And then the READMe in cicd... Should it mention to copy cicd/confgs/* to live/cicd/configs so triggers can see those files?
You don't need to copy/paste any cicd/ directories. They are two separate cicd/ directories. Cloud Build triggers are configured to look for Cloud Build configs at {TERRAFORM_ROOT}/cicd/configs/, not in {TERRAFORM_ROOT}/live/cicd/configs/
@xingao267 it seems like when there is a new Terraform binary release it will cause this version discrepancy. Can we update the devops instructions to use the same docker container when running from local machine?
@umairidris deploying bootstrap
and cicd
dirs locally from a container is not difficult but might make the process a little bit more complicated. docker
will need to be installed. And to run it, users will need to mount their gcloud credentials, source configs and output local terraform state files to the container. Sent https://github.com/GoogleCloudPlatform/healthcare-data-protection-suite/pull/477 instead to pin the terraform version in the readme files.
@xingao267 makes sense, let's pin the versions so they are consistent throughout.
@careb2b FYI we're working on simplifying the cicd directory layout as part of #397.
@xingao267 Yes, it was due to be having TERRAFORM_ROOT set to live incorrectly. After reapplying it was ok and I did not need the config files in live/cicd.
I noticed the triggers were updated for later terraform version and I was able to apply now.
I will close this.
I am going through the steps in file
tfengine/generated/cicd/README.md.
I am not able to call terraform successfully through google cloud build trigger.In cicd directory, I ran
terraform apply
which ran successfully.It generated files:
I committed those configs into my github repo, but the triggers were looking for the config files in
live/cicd/configs
and notcicd/configs
. Did I miss something in the README or is a step needed to copy/move those files?After moving the files to
live/cicd/configs.
I was then able to execute the triggers on pull request or manually.They fail due following error:
My live directory does not have any terraform files.