@@ -211,6 +211,19 @@ inputs:
211
211
description : " allows overriding of the terraform cache dir which defaults to ${github.workspace}/cache"
212
212
required : false
213
213
default : ' '
214
+ cache-dependencies-s3 :
215
+ description : " Use S3 for caching terraform/terragrunt dependencies"
216
+ required : false
217
+ default : ' false'
218
+ cache-dependencies-s3-bucket :
219
+ description : " S3 bucket URL for caching (e.g., s3://mybucket/cache)"
220
+ required : false
221
+ default : ' '
222
+ cache-dependencies-s3-region :
223
+ description : " AWS region for S3 cache bucket"
224
+ required : false
225
+ default : ' us-east-1'
226
+
214
227
215
228
digger-spec :
216
229
description : " (orchestrator only) the spec to pass onto digger cli"
@@ -316,6 +329,24 @@ runs:
316
329
digger-cache
317
330
if : ${{ inputs.cache-dependencies == 'true' }}
318
331
332
+ - name : restore-s3-cache
333
+ shell : bash
334
+ run : |
335
+ BUCKET=$(echo "${{ inputs.cache-dependencies-s3-bucket }}" | sed 's|^s3://||')
336
+ REGION="${{ inputs.cache-dependencies-s3-region }}"
337
+
338
+ SCRIPT_PATH="${{ github.action_path }}/scripts/s3-cache-download.bash"
339
+ if [ ! -f "$SCRIPT_PATH" ]; then
340
+ echo "::error::S3 cache download script not found at $SCRIPT_PATH"
341
+ echo "Please make sure the script exists and is properly installed."
342
+ exit 1
343
+ fi
344
+
345
+ chmod +x "$SCRIPT_PATH"
346
+ "$SCRIPT_PATH" "$BUCKET" "$REGION" "$TF_PLUGIN_CACHE_DIR"
347
+ if : ${{ inputs.cache-dependencies-s3 == 'true' }}
348
+
349
+ # Then terraform setup happens...
319
350
- name : Setup Terraform
320
351
uses : hashicorp/setup-terraform@v3
321
352
with :
@@ -429,8 +460,11 @@ runs:
429
460
430
461
NO_BACKEND : ${{ inputs.no-backend }}
431
462
DEBUG : ' true'
432
- TG_PROVIDER_CACHE : ${{ inputs.cache-dependencies == 'true' && 1 || 0 }}
433
- TERRAGRUNT_PROVIDER_CACHE : ${{ inputs.cache-dependencies == 'true' && 1 || 0 }}
463
+ TG_PROVIDER_CACHE : ${{ (inputs.cache-dependencies == 'true' || inputs.cache-dependencies-s3 == 'true') && 1 || 0 }}
464
+ TERRAGRUNT_PROVIDER_CACHE : ${{ (inputs.cache-dependencies == 'true' || inputs.cache-dependencies-s3 == 'true') && 1 || 0 }}
465
+ TF_PLUGIN_CACHE_DIR : ${{ env.TF_PLUGIN_CACHE_DIR }}
466
+ TG_PROVIDER_CACHE_DIR : ${{ env.TF_PLUGIN_CACHE_DIR }}
467
+ TERRAGRUNT_PROVIDER_CACHE_DIR : ${{ env.TF_PLUGIN_CACHE_DIR }}
434
468
DIGGER_RUN_SPEC : ${{inputs.digger-spec}}
435
469
run : |
436
470
if [[ ${{ inputs.ee }} == "true" ]]; then
@@ -476,8 +510,11 @@ runs:
476
510
INPUT_DRIFT_DETECTION_SLACK_NOTIFICATION_URL : ${{ inputs.drift-detection-slack-notification-url }}
477
511
INPUT_DRIFT_DETECTION_ADVANCED_SLACK_NOTIFICATION_URL : ${{ inputs.drift-detection-advanced-slack-notification-url }}
478
512
NO_BACKEND : ${{ inputs.no-backend }}
479
- TG_PROVIDER_CACHE : ${{ inputs.cache-dependencies == 'true' && 1 || 0 }}
480
- TERRAGRUNT_PROVIDER_CACHE : ${{ inputs.cache-dependencies == 'true' && 1 || 0 }}
513
+ TG_PROVIDER_CACHE : ${{ (inputs.cache-dependencies == 'true' || inputs.cache-dependencies-s3 == 'true') && 1 || 0 }}
514
+ TERRAGRUNT_PROVIDER_CACHE : ${{ (inputs.cache-dependencies == 'true' || inputs.cache-dependencies-s3 == 'true') && 1 || 0 }}
515
+ TF_PLUGIN_CACHE_DIR : ${{ env.TF_PLUGIN_CACHE_DIR }}
516
+ TG_PROVIDER_CACHE_DIR : ${{ env.TF_PLUGIN_CACHE_DIR }}
517
+ TERRAGRUNT_PROVIDER_CACHE_DIR : ${{ env.TF_PLUGIN_CACHE_DIR }}
481
518
DIGGER_RUN_SPEC : ${{inputs.digger-spec}}
482
519
id : digger
483
520
shell : bash
@@ -524,8 +561,11 @@ runs:
524
561
INPUT_DRIFT_DETECTION_SLACK_NOTIFICATION_URL : ${{ inputs.drift-detection-slack-notification-url }}
525
562
INPUT_DRIFT_DETECTION_ADVANCED_SLACK_NOTIFICATION_URL : ${{ inputs.drift-detection-advanced-slack-notification-url }}
526
563
NO_BACKEND : ${{ inputs.no-backend }}
527
- TG_PROVIDER_CACHE : ${{ inputs.cache-dependencies == 'true' && 1 || 0 }}
528
- TERRAGRUNT_PROVIDER_CACHE : ${{ inputs.cache-dependencies == 'true' && 1 || 0 }}
564
+ TG_PROVIDER_CACHE : ${{ (inputs.cache-dependencies == 'true' || inputs.cache-dependencies-s3 == 'true') && 1 || 0 }}
565
+ TERRAGRUNT_PROVIDER_CACHE : ${{ (inputs.cache-dependencies == 'true' || inputs.cache-dependencies-s3 == 'true') && 1 || 0 }}
566
+ TF_PLUGIN_CACHE_DIR : ${{ env.TF_PLUGIN_CACHE_DIR }}
567
+ TG_PROVIDER_CACHE_DIR : ${{ env.TF_PLUGIN_CACHE_DIR }}
568
+ TERRAGRUNT_PROVIDER_CACHE_DIR : ${{ env.TF_PLUGIN_CACHE_DIR }}
529
569
DIGGER_RUN_SPEC : ${{inputs.digger-spec}}
530
570
id : digger-local-run
531
571
shell : bash
@@ -567,6 +607,23 @@ runs:
567
607
path : ${{ env.TF_PLUGIN_CACHE_DIR }}
568
608
key : digger-cache-${{ hashFiles('**/cache') }}
569
609
610
+ - name : save-s3-cache
611
+ shell : bash
612
+ run : |
613
+ BUCKET=$(echo "${{ inputs.cache-dependencies-s3-bucket }}" | sed 's|^s3://||')
614
+ REGION="${{ inputs.cache-dependencies-s3-region }}"
615
+
616
+ SCRIPT_PATH="${{ github.action_path }}/scripts/s3-cache-upload.bash"
617
+ if [ ! -f "$SCRIPT_PATH" ]; then
618
+ echo "::error::S3 cache upload script not found at $SCRIPT_PATH"
619
+ echo "Please make sure the script exists and is properly installed."
620
+ exit 1
621
+ fi
622
+
623
+ chmod +x "$SCRIPT_PATH"
624
+ "$SCRIPT_PATH" "$BUCKET" "$REGION" "$TF_PLUGIN_CACHE_DIR"
625
+ if : ${{ always() && inputs.cache-dependencies-s3 == 'true' }}
626
+
570
627
branding :
571
628
icon : globe
572
629
color : purple
0 commit comments