Skip to content

Commit 9728505

Browse files
committed
ci: Add caching for terraform initialization.
1 parent 7ac014a commit 9728505

File tree

5 files changed

+31
-62
lines changed

5 files changed

+31
-62
lines changed

.github/actions/setup-opentofu/action.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ inputs:
88
runs:
99
using: composite
1010
steps:
11+
- name: Cache OpenTofu
12+
uses: actions/cache@v4
13+
with:
14+
path: ./tofu/config/${{ inputs.config }}/.terraform
15+
key: ${{ runner.os }}-tofu-${{ hashFiles('./tofu/config/${{ inputs.config }}/.terraform.lock.hcl') }}
16+
restore-keys: |
17+
${{ runner.os }}-tofu-
1118
- name: Setup OpenTofu
1219
uses: opentofu/setup-opentofu@v1
1320
with:

.github/workflows/launch-tools.yaml

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -40,50 +40,6 @@ jobs:
4040
aws-region: ${{ secrets.AWS_REGION || 'us-west-1' }}
4141
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
4242
role-session-name: GitHub_to_AWS_via_FederatedOIDC
43-
# - name: Setup OpenTofu
44-
# uses: opentofu/setup-opentofu@v1
45-
# with:
46-
# tofu_wrapper: false
47-
# - name: Display OpenTofu version
48-
# run: tofu version
49-
# - name: Set optional variables
50-
# env:
51-
# # For any of these that have a value, the corresponding TF_VAR_*
52-
# # environment variable will be set.
53-
# APPLY_DATABASE_UPDATES_IMMEDIATELY: ${{ secrets.TF_VAR_APPLY_DATABASE_UPDATES_IMMEDIATELY }}
54-
# TF_VAR_CONSUMER_CONTAINER_COUNT: ${{ secrets.TF_VAR_CONSUMER_CONTAINER_COUNT }}
55-
# CONSUMER_CPU: ${{ secrets.TF_VAR_CONSUMER_CPU }}
56-
# CONSUMER_MEMORY: ${{ secrets.TF_VAR_CONSUMER_MEMORY }}
57-
# DATABASE_SKIP_FINAL_SNAPSHOT: ${{ secrets.TF_VAR_DATABASE_SKIP_FINAL_SNAPSHOT }}
58-
# DELETION_PROTECTION: ${{ secrets.TF_VAR_DELETION_PROTECTION }}
59-
# DEPLOYMENT_ENVIRONMENTS: ${{ secrets.TF_VAR_DEPLOYMENT_ENVIRONMENTS }}
60-
# ENVIRONMENT: ${{ secrets.TF_VAR_ENVIRONMENT }}
61-
# EXPORT_EXPIRATION: ${{ secrets.TF_VAR_EXPORT_EXPIRATION }}
62-
# IMAGE_TAGS_MUTABLE: ${{ secrets.TF_VAR_IMAGE_TAGS_MUTABLE }}
63-
# KEY_RECOVERY_PERIOD: ${{ secrets.TF_VAR_KEY_RECOVERY_PERIOD }}
64-
# PROGRAM: ${{ secrets.TF_VAR_PROGRAM }}
65-
# PROJECT: ${{ secrets.TF_VAR_PROJECT }}
66-
# REPOSITORY: ${{ secrets.TF_VAR_REPOSITORY }}
67-
# run: |
68-
# variables=(
69-
# "apply_database_updates_immediately" "consumer_container_count"
70-
# "consumer_cpu" "consumer_memory" "database_skip_final_snapshot"
71-
# "deletion_protection" "deployment_environments" "environment"
72-
# "export_expiration" "image_tags_mutable" "key_recovery_period"
73-
# "program" "project" "repository"
74-
# )
75-
# for var in ${variables[@]}; do
76-
# name="$(echo $var | tr '[:lower:]' '[:upper:]')"
77-
# if [ -n "${!name}" ]; then
78-
# echo "Setting TF_VAR_$var"
79-
# echo "TF_VAR_$var=${!name}" >> $GITHUB_ENV
80-
# else
81-
# echo "$name is not set"
82-
# fi
83-
# done
84-
# - name: Initialize OpenTofu
85-
# working-directory: ./tofu/config/service
86-
# run: tofu init
8743
- name: Setup OpenTofu
8844
uses: ./.github/actions/setup-opentofu
8945
env:

tofu/config/service/.terraform.lock.hcl

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tofu/modules/ephemeral_service/docker.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ resource "docker_image" "container" {
99
"${local.prefix}:${var.image_tag}",
1010
"${module.ecr.repository_url}:${var.image_tag}"
1111
]
12+
13+
auth_config {
14+
host_name = data.aws_ecr_authorization_token.token.proxy_endpoint
15+
password = data.aws_ecr_authorization_token.token.password
16+
user_name = data.aws_ecr_authorization_token.token.user_name
17+
}
1218
}
1319

1420
triggers = {
@@ -28,8 +34,8 @@ resource "docker_registry_image" "container" {
2834

2935
auth_config {
3036
address = data.aws_ecr_authorization_token.token.proxy_endpoint
31-
username = data.aws_ecr_authorization_token.token.user_name
3237
password = data.aws_ecr_authorization_token.token.password
38+
username = data.aws_ecr_authorization_token.token.user_name
3339
}
3440

3541
triggers = {

tofu/modules/ephemeral_service/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ terraform {
99

1010
docker = {
1111
source = "kreuzwerker/docker"
12-
version = "~> 3.6"
12+
version = "~> 3.7"
1313
}
1414
}
1515
}

0 commit comments

Comments
 (0)