hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.76k stars 9.11k forks source link

[Bug]: When `terraform import` is used the absolute path is generated for `path.module` #35055

Closed EugenKon closed 8 months ago

EugenKon commented 9 months ago

Terraform Core Version

Terraform v1.6.4

AWS Provider Version

registry.terraform.io/hashicorp/aws v4.67.0

Affected Resource(s)

data "archive_file" "dnsUrlRedirects" resource "aws_lambda_function" "dnsUrlRedirects"

Expected Behavior

The path should be relative

Actual Behavior

The path is absolute

Relevant Error/Panic Output Snippet

image

Terraform Configuration Files

data "archive_file" "dnsUrlRedirects" {
  type        = "zip"
  source_file = "${path.module}/lambda-function/index.js"
  output_path = "${path.module}/lambda-function/urlRedirects.zip"
}

Steps to Reproduce

terraform plan -generate-config-out=billing_policy.tf.import
terraform import aws_iam_group_policy_attachment.billing_s3_read_only Billing/arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
...

I also did many other imports, but this one cause issue.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 9 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 8 months ago

Hey @EugenKon 👋 Thanks for taking the time to raise this! We don't recommend path.module because it can have different results, much like you're seeing here. The document I linked has a couple of other suggestions, but since this is related to Terraform Core rather than the AWS Provider itself, I'll be closing this issue.

github-actions[bot] commented 7 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.