Skip to content

Terragrunt Provider Cache not working properly when using it with Atlantis #3076

Description

@amontalban

Describe the bug

As described in #2920 (comment) we are having mixed results while using Terragrunt Provider Cache running 0.57.2 inside Atlantis, in the same PR some plans succeed and some don't.

We use Atlantis in ECS with EFS for storage, we run multiple instances of it with Redis as backend.

Recently we upgraded to Terragrunt 0.57.2 and Atlantis 0.27.2 to use the Terragrunt Provider Cache so we can speed up the PR planning/applying because we have over 700 terragrunt.hcl files in our code.

When doing a PR that includes an upgrade for Terraform AWS Provider it will trigger a huge number of plans and given we have Atlantis configured with --parallel-plan and --parallel-apply it starts multiple terragrunt plan processes at the same time.

To Reproduce
I do not have a step by step to reproduce but this is our env vars when running inside Atlantis:

TERRAGRUNT_DOWNLOAD="$HOME/.cache/terragrunt/modules"
TERRAGRUNT_FETCH_DEPENDENCY_OUTPUT_FROM_STATE="true"
TERRAGRUNT_PROVIDER_CACHE=1
TERRAGRUNT_NON_INTERACTIVE="true"
TERRAGRUNT_INCLUDE_EXTERNAL_DEPENDENCIES="true"

Atlantis server args:

--enable-diff-markdown-format  --hide-prev-plan-comments --automerge --hide-unchanged-plan-comments --parallel-apply --parallel-plan

Atlantis env vars:

ATLANTIS_PARALLEL_POOL_SIZE=10
ATLANTIS_ALLOW_REPO_CONFIG=true

Expected behavior
Be able to use Terragrunt Provider Cache on Atlantis using parallel plan and apply.

Nice to have

  • Terminal output
time=2024-04-18T23:16:12Z level=info msg=Terragrunt Cache server is listening on 127.0.0.1:39541
time=2024-04-18T23:16:12Z level=info msg=Start Terragrunt Cache server
time=2024-04-18T23:16:16Z level=info msg=Downloading Terraform configurations from git::ssh://git@github.com/terraform-aws-modules/terraform-aws-iam.git?ref=v5.37.1 into /home/atlantis/.cache/terragrunt/modules/CZJOkESJyj2a2n17Ph1lBtPy7p8/Z_nexO2qqCg5RPmJa_gkAX4ynAY prefix=[/home/atlantis/.atlantis/repos/ACME/terraform/838/provider_aws_dev__global_iam_roles_sre-role/provider/aws/security/_global/iam/policies/sre-assume-role] 
time=2024-04-18T23:16:16Z level=info msg=Downloading Terraform configurations from git::ssh://git@github.com/ACME/tf-aws-iam-saml-provider.git?ref=v1.0.1 into /home/atlantis/.cache/terragrunt/modules/1-d3ZTASqfksjn_orsKPDUGD7ks/lPrDQ0wT1dtsjgNOnzZoq0oCtyE prefix=[/home/atlantis/.atlantis/repos/ACME/terraform/838/provider_aws_dev__global_iam_roles_sre-role/provider/aws/security/_global/iam/identity_providers/X] 
╷
│ Error: Failed to query available provider packages
│ 
│ Could not retrieve the list of available versions for provider
│ hashicorp/aws: host registry.terraform.io rejected the given authentication
│ credentials
time=2024-04-18T22:43:57Z level=info msg=Terragrunt Cache server is listening on 127.0.0.1:38393
time=2024-04-18T22:43:57Z level=info msg=Start Terragrunt Cache server
time=2024-04-18T22:43:58Z level=info msg=Downloading Terraform configurations from git::ssh://git@github.com/terraform-aws-modules/terraform-aws-iam.git?ref=v5.30.0 into /home/atlantis/.cache/terragrunt/modules/BBCsdcAtPBWyKxcKxrWGSmPnyMI/Z_nexO2qqCg5RPmJa_gkAX4ynAY

Error: Could not retrieve providers for locking

Terraform failed to fetch the requested providers for cache_provider in order
to calculate their checksums: some providers could not be installed:
- registry.terraform.io/hashicorp/aws: host registry.terraform.io rejected
the given authentication credentials.

Versions

  • Terragrunt version: 0.57.2
  • Terraform version: 1.4.6
  • Environment details (Ubuntu 20.04, Windows 10, etc.): ghcr.io/runatlantis/atlantis:v0.27.2

Additional context
Atlantis configuration: https://gist.github.com/amontalban/dcd106a55390203bd30cb706e96698e6

We do not have any CLI Configuration or credentials configured.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions