Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use relative paths for archives #11

Merged
merged 3 commits into from
Jul 20, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use relative path to module for archive files
This removes the assumption about Terraform making a .terraform directory in the current working directory, and removes the need to use md5 to handle multiple module versions in the same project as Terraform deals with that itself. It now assumes that the module is located within the current working directory.
raymondbutcher committed Jul 20, 2018

Verified

This commit was signed with the committer’s verified signature.
TheSpiritXIII Daniel Hrabovcak
commit f0ba1b90348b86970bd51216283078a96ce9c6cd
12 changes: 8 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
locals {
module_relpath = "${substr(path.module, length(path.cwd) + 1, -1)}"
}

data "aws_iam_policy_document" "default" {
statement {
sid = ""
@@ -46,14 +50,14 @@ data "aws_iam_policy_document" "ami_backup" {

data "archive_file" "ami_backup" {
type = "zip"
source_file = "${path.module}/ami_backup.py"
output_path = ".terraform/terraform-aws-ec2-ami-backup/backup-${md5(file("${path.module}/ami_backup.py"))}.zip"
source_file = "${local.module_relpath}/ami_backup.py"
output_path = "${local.module_relpath}/ami_backup.zip"
}

data "archive_file" "ami_cleanup" {
type = "zip"
source_file = "${path.module}/ami_cleanup.py"
output_path = ".terraform/terraform-aws-ec2-ami-backup/cleanup-${md5(file("${path.module}/ami_cleanup.py"))}.zip"
source_file = "${local.module_relpath}/ami_cleanup.py"
output_path = "${local.module_relpath}/ami_cleanup.zip"
}

module "label" {