You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to dynamically build go code from source code, zip it and create a lambda out of it. Problem starts because we do not want to keep binaries with IAC code and hence build and archive has to happen in terraform dynamically but terraform data resource causes issues as described below.
Terraform Version
Terraform v0.12.24
provider.archive v1.3.0
provider.aws v2.67.0
provider.helm v1.2.3
provider.kubernetes v1.11.3
provider.local v1.4.0
provider.null v2.1.2
provider.random v2.2.1
provider.template v2.1.2
Affected Resource(s)
Please list the resources as a list, for example:
null_resource.builder
null_data_resource.wait_for_builder
data.archive_file.zip_file
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
Terraform Configuration Files
resource"null_resource""builder" {
count=var.enabled==true?1:0triggers={
generated_hash =filemd5("${path.module}/lambda/eks-monitor/main.go")
}
provisioner"local-exec" {
working_dir="${path.module}/lambda/eks-monitor"command="go build main.go"
}
}
data"null_data_source""wait_for_builder" {
count=var.enabled==true?1:0inputs={
# This ensures that this data resource will not be evaluated until# after the null_resource has been created.
builder_id = null_resource.builder.0.id
# This value gives us something to implicitly depend on# in the archive_file below.
source_file ="${path.module}/lambda/eks-monitor/main"
}
}
data"archive_file""zip_file" {
count=var.enabled==true?1:0type="zip"source_file=data.null_data_source.wait_for_builder.0.outputs["source_file"]
output_path="${path.module}/lambda/eks-monitor/main.zip"
}
Expected Behavior
Ideally data should know that it's archive_file and should not try to run it during refresh.
Actual Behavior
During the refresh it runs again and causes an issue because null_resource has built the file once and during second run binary doesn't exist ( we use Jenkins to deploy and worker nodes underneath keep changing and binary file is not there during the seond run.
So I get this error
Error: error archiving file: could not archive missing file: ../modules/aws-eks-add-on/aws-eks-monitor/lambda/eks-monitor/main
on ../modules/aws-eks-add-on/aws-eks-monitor/lambda.tf line 58, in data "archive_file" "zip_file":
58: data "archive_file" "zip_file" {
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform apply
Make sure main and main.zip is deleted because that's where the issue starts ( build and deploy environments are dynamic container and do not store dynamically build artifacts )
terraform apply again
The text was updated successfully, but these errors were encountered:
Hi there,
I am trying to dynamically build go code from source code, zip it and create a lambda out of it. Problem starts because we do not want to keep binaries with IAC code and hence build and archive has to happen in terraform dynamically but terraform data resource causes issues as described below.
Terraform Version
Terraform v0.12.24
Affected Resource(s)
Please list the resources as a list, for example:
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
Terraform Configuration Files
Expected Behavior
Ideally data should know that it's archive_file and should not try to run it during refresh.
Actual Behavior
During the refresh it runs again and causes an issue because null_resource has built the file once and during second run binary doesn't exist ( we use Jenkins to deploy and worker nodes underneath keep changing and binary file is not there during the seond run.
So I get this error
Error: error archiving file: could not archive missing file: ../modules/aws-eks-add-on/aws-eks-monitor/lambda/eks-monitor/main
on ../modules/aws-eks-add-on/aws-eks-monitor/lambda.tf line 58, in data "archive_file" "zip_file":
58: data "archive_file" "zip_file" {
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform apply
terraform apply
againThe text was updated successfully, but these errors were encountered: