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

Issue passing public key using file $("${path.module}/<path of the public key>" )} for resource aws_iam_user_ssh_key #15563

Closed
Manoj2087 opened this issue Jul 16, 2017 · 2 comments

Comments

@Manoj2087
Copy link

PROVIDER ISSUES

PLEASE NOTE: Terraform has split out the builtin Providers into their own repositories. For any Provider issues, please open all issues and pull requests in the corresponding repository. An index of supported Providers can be found here:

All other issues (that appear to affect multiple or all providers) may be an issue with Terraform's core, and should be opened here.


Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.
Terraform v0.9.11

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.

#Create IAM User for readonly access the Code commit repo
resource "aws_iam_user" "apigwccm-iam-codecommit-readonly" {
name = "${format("%s-codecommit-readonly",var.APIGWCCM_PROJECT_NAME)}"
path = "${format("/%s/",var.APIGWCCM_PROJECT_NAME)}"
force_destroy = true
}
resource "aws_iam_user_ssh_key" "user" {
username = "${aws_iam_user.apigwccm-iam-codecommit-readonly.name}"
encoding = "SSH"
public_key = "${file("${path.module}/keypair/keypair.pub")}"
}

Debug Output

Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.
1 error(s) occurred:

  • module.apigwccm-codecommit.aws_iam_user_ssh_key.user: 1 error(s) occurred:

  • module.apigwccm-codecommit.aws_iam_user_ssh_key.user: file: open C:\Users\alag\git\GITSoftwareAG\software-ag-cloud.wm-apigw-cloud\terraform\apigw-cmm.terraform\modules\068b1ba3c31927074d5747be94ff52df/keypair/keypair.pub: The system cannot find the path specified. in:

${file("${path.module}/keypair/keypair.pub")}

Expected Behavior

What should have happened?
Should read the file content and pass it into public_key of aws_iam_user_ssh_key . Instead gives an error. This works for the below configuration for aws_key_pair. Why doesn't this work for the resource aws_iam_user_ssh_key.

resource "aws_key_pair" "apigwccm-ec2-keypair" {
key_name = "${format("%s-ec2-keypair",var.APIGWCCM_PROJECT_NAME)}"
public_key = "${file("${path.module}/keypair/keypair.pub")}"
}

Actual Behavior

What actually happened?
Gives the error
1 error(s) occurred:

  • module.apigwccm-codecommit.aws_iam_user_ssh_key.user: 1 error(s) occurred:

  • module.apigwccm-codecommit.aws_iam_user_ssh_key.user: file: open C:\Users\alag\git\GITSoftwareAG\software-ag-cloud.wm-apigw-cloud\terraform\apigw-cmm.terraform\modules\068b1ba3c31927074d5747be94ff52df/keypair/keypair.pub: The system cannot find the path specified. in:

${file("${path.module}/keypair/keypair.pub")}

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

@Manoj2087
Copy link
Author

I think the issue issue was due to the modules. A terraform get -update seems to have fixed the issue. Closing the issue

@ghost
Copy link

ghost commented Apr 8, 2020

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.

@ghost ghost locked and limited conversation to collaborators Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant