Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Provide example of Terraform provider caching #2

Open
rocky-foreflight opened this issue Nov 16, 2022 · 1 comment
Open

Provide example of Terraform provider caching #2

rocky-foreflight opened this issue Nov 16, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@rocky-foreflight
Copy link
Collaborator

When @aaron-foreflight and I were reviewing #1, we ran into an issue where state had accumulated from his native version of Terraform in the project working directory, which prevented the testing instructions from succeeding.

To rule out any issues with accumulated state, I suggested we clear the .terraform directory and re-run terraform init before each invocation of terraform plan.

However, @aaron-foreflight made a good point about the extra ~30s we'd spend fetching providers before each Terraform operation.

We discovered that Terraform supports caching plugin providers. And we were able to wire things up via the following service definition:

services:
  terraform:
    image: ghcr.io/foreflight/terraform:1.3.4
    environment:
      - TF_PLUGIN_CACHE_DIR=/root/.terraform.d/plugin-cache
    volumes:
      - ./:/usr/local/src
      - $HOME/.terraform.d/plugin-cache:/root/.terraform.d/plugin-cache
      - $HOME/.aws:/root/.aws:ro
    working_dir: /usr/local/src
    entrypoint: bash

We should consider talking about this in the README.

@rocky-foreflight rocky-foreflight added the enhancement New feature or request label Nov 16, 2022
@aaron-foreflight
Copy link

@ahuckabee-foreflight ^

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants