'How can I access a folder outside of the terraform root module?
I am trying to deploy a lambda using terraform. One of the steps in the lambda module zips up the source folder for the lambda. However, when I run the following code I am met with this error:Error: error archiving directory: could not archive missing directory: ./../hello-world
This is my current folder structure
Here is my lambda terraform for the zip step:
data "archive_file" "lambda_hello_world" {
type = "zip"
source_dir = "${path.root}/../hello-world"
output_path = "${path.root}/../hello-world.zip"
}
Pipeline code:
name: Deploy Infrastructure
on:
push:
branches:
- master
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
defaults:
run:
working-directory: './terraform/'
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
# terraform_version: 0.13.0
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Terraform Format
id: fmt
run: terraform fmt -check
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Validate
id: validate
run: terraform validate -no-color
- name: Terraform Plan
id: plan
run: terraform plan -no-color
continue-on-error: true
- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1
- name: Terraform Apply
run: terraform apply -auto-approve
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

