polite-engineer-31217
09/12/2022, 6:56 AMError: Failed to parse the Terragrunt code using the Terragrunt library:
1 error occurred:
* error downloading '<https://github.com/aws-ia/terraform-aws-control_tower_account_factory.git?ref=1.6.2>': /usr/bin/git exited with 1: error: pathspec 'master' did not match any file(s) known to git
I don’t know why it’s looking for the master branch
I’m using terragrunt and calling the module like this
terraform {
source = "<http://github.com/aws-ia/terraform-aws-control_tower_account_factory//.?ref=1.6.2|github.com/aws-ia/terraform-aws-control_tower_account_factory//.?ref=1.6.2>"
}
Any idea what’s wrong ? Thank you# Remove the '!${{ env.TF_ROOT }}...' path below if you're using Terragrunt and seeing
# issues downloading from remote git sources.
path: |
${{ env.TF_ROOT }}/**/.infracost/terraform_modules/**
!${{ env.TF_ROOT }}/**/.infracost/terraform_modules/**/.git/**
the git folders were commented and I fixed the issue with re-enabling them. So doing the opposite of the comment fix my issue for the first time and when I rerun my action, it failed again.
I think the error comes from this
# If there's no cached record for this commit, pull in the latest cached record anyway
# Internally infracost will downloaded any additional required modules if required
restore-keys: infracost-terraform-modules-${{ runner.os }}-
I updated my module from 1.6.1 to 1.6.2, so the cache should contains my previous versionlittle-author-61621
09/12/2022, 9:12 AMpolite-engineer-31217
09/12/2022, 9:13 AMError: Failed to parse the Terragrunt code using the Terragrunt library:
1 error occurred:
* error downloading '<https://github.com/aws-ia/terraform-aws-control_tower_account_factory.git?ref=1.6.2>': /usr/bin/git exited with 1: error: pathspec 'master' did not match any file(s) known to git
little-author-61621
09/12/2022, 9:21 AMpolite-engineer-31217
09/12/2022, 9:35 AMlittle-author-61621
09/12/2022, 9:41 AMpolite-engineer-31217
09/12/2022, 9:44 AM!${{ env.TF_ROOT }}/**/.terragrunt-cache/**
little-author-61621
09/12/2022, 9:46 AMpolite-engineer-31217
09/12/2022, 9:47 AMlittle-author-61621
09/12/2022, 9:49 AMpolite-engineer-31217
09/12/2022, 9:49 AMlittle-author-61621
09/12/2022, 9:50 AMpolite-engineer-31217
09/12/2022, 9:52 AMkey: infracost-terraform-modules-${{ runner.os }}-${{ github.event.pull_request.base.sha || github.sha }}
Actually we never can reuse this key so we always end up with
infracost-terraform-modules-${{ runner.os }}-
little-author-61621
09/12/2022, 9:57 AMkey: infracost-terraform-modules-${{ runner.os }}-${{ github.event.pull_request.head.ref }}-${{ github.event.pull_request.base.sha || github.sha }}
and then setting the restore key to restore-keys: infracost-terraform-modules-${{ runner.os }}-${{ github.event.pull_request.head.ref }}-
could help.
What do you think?polite-engineer-31217
09/12/2022, 10:01 AMkey: infracost-terraform-modules-${{ runner.os }}-${{ github.ref }}
- name: Cache the Infracost baseline JSON result
id: cache-infracost-base-json
uses: actions/cache@v3
with:
path: '/tmp/infracost-base.json'
key: infracost-base-json-${{ runner.os }}-${{ github.base_ref || github.ref }}
if it’s a pull request we create the key with the target branch “main”, if it’s a push we use the current branch.
That way every PR targetting “main” will be able to reuse the cacherestore-keys
- An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note cache-hit
returns false in this case.
by using the commit sha we can never have a cache hitlittle-author-61621
09/12/2022, 10:20 AMpolite-engineer-31217
09/12/2022, 10:22 AMCache not found for input keys: infracost-base-json-Linux-main
So yes we want to hit the cache build from the main branch for every subsequent run. This cache will alway be up to date with the last build, which is fine I guess. I can add commits on my PR, I will reuse the same cache, or I can create another PR it will also use this cache for the base jsonlittle-author-61621
09/12/2022, 10:28 AMpolite-engineer-31217
09/12/2022, 10:33 AM- name: Cache the Infracost baseline JSON result
id: cache-infracost-base-json
uses: actions/cache@v3
with:
path: '/tmp/infracost-base.json'
key: infracost-base-json-${{ runner.os }}-${{ github.base_ref || github.ref }}
# Checkout the base branch of the pull request (e.g. main/master).
- name: Checkout base branch
uses: actions/checkout@v3
with:
ref: '${{ github.event.pull_request.base.ref }}'
# Downloading remote Terraform modules can be slow, so we add them to the GitHub cache.
# We skip this for pushes to the main/master branch that already have the baseline generated.
- name: Cache .infracost/terraform_modules for target branch
uses: actions/cache@v3
with:
# Remove the '!${{ env.TF_ROOT }}...' path below if you're using Terragrunt and seeing
# issues downloading from remote git sources.
path: |
${{ env.TF_ROOT }}/**/.infracost/terraform_modules/**
!${{ env.TF_ROOT }}/**/.infracost/terraform_modules/**/.git/**
key: infracost-terraform-modules-${{ runner.os }}-${{ github.head_ref || github.ref }}
# If there's no cached record for this commit, pull in the latest cached record anyway
# Internally infracost will downloaded any additional required modules if required
# restore-keys: infracost-terraform-modules-${{ runner.os }}-
if: github.event_name == 'pull_request' || steps.cache-infracost-base-json.outputs.cache-hit != 'true'
little-author-61621
09/12/2022, 10:52 AM