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

Unable to use imported keypair with aws_launch_configuration #8529

Closed
mrjfox opened this issue May 5, 2019 · 3 comments · May be fixed by #40075
Closed

Unable to use imported keypair with aws_launch_configuration #8529

mrjfox opened this issue May 5, 2019 · 3 comments · May be fixed by #40075
Labels
service/autoscaling Issues and PRs that pertain to the autoscaling service.

Comments

@mrjfox
Copy link

mrjfox commented May 5, 2019

Hi

It appears that i am unable to use aws_launch_configuration (aka ALC) with an imported aws keypair and i have no issue importing the key only using it with ALC.

1) Successful import

terraform import aws_key_pair.imported_key imported_key
aws_key_pair.imported_key: Importing from ID "imported_key"...
aws_key_pair.imported_key: Import complete!
  Imported aws_key_pair (ID: imported_key)
aws_key_pair.imported_key: Refreshing state... (ID: imported_key)

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

2) It then fails on terraform plan

terraform plan

Error: aws_key_pair.imported_key: "public_key": required field is not set

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Affected Resource(s)

  • aws 2.8.0
  • terraform 0.11.13

Terraform Configuration Files

Have excluded the rest of the terraform manifest, only included the parts used.

terraform {
  backend "local" {
      path = "./terraform.tfstate"
    }
}

resource "aws_key_pair" "imported_key" {
  key_name   = "imported_key"
}

resource "aws_launch_configuration" "master-ap-southeast-2c-masters-example-com" {
  name_prefix                 = "master-ap-southeast-2c.masters.example-com-"
  image_id                    = "ami-04481c741a0311bbb"
  instance_type               = "t2.medium"
  key_name                    = "${aws_key_pair.imported_key.id}"
  iam_instance_profile        = "${aws_iam_instance_profile.masters-example-com.id}"
  security_groups             = ["${aws_security_group.masters-example-com.id}"]
  associate_public_ip_address = true
  user_data                   = "${file("${path.module}/data/aws_launch_configuration_master-ap-southeast-2c.masters.example-com_user_data")}"

  root_block_device = {
    volume_type           = "gp2"
    volume_size           = 64
    delete_on_termination = true
  }

  lifecycle = {
    create_before_destroy = true
  }

  enable_monitoring = false
}

Debug Output

Panic Output

Expected Behavior

I expect to be able to use the import keypair

When importing, terraform asks to define the keypair meaning:

resource "aws_key_pair" "imported_key" {
  key_name   = "jareds-eks-test"
}

Actual Behavior

I complaints due to the lack of public key.

Steps to Reproduce

  1. terraform init
  2. `terraform import #See above
  3. terraform plan

Important Factoids

References

  • #0000
@eramirez51
Copy link

+1

@aeschright aeschright added the needs-triage Waiting for first response or review from a maintainer. label Jun 19, 2019
@aeschright aeschright added the service/autoscaling Issues and PRs that pertain to the autoscaling service. label Jul 3, 2019
@bflad
Copy link
Contributor

bflad commented Aug 2, 2019

Hi folks 👋 Sorry for this frustrating issue. We are tracking this problem in the earlier #1092, which you can follow for updates. As a workaround for imported key pairs you can setup your configuration similar to the below:

resource "aws_key_pair" "example" {
  key_name   = "example"
  public_key = ""

  lifecycle {
    ignore_changes = ["public_key"]
  }
}

@bflad bflad closed this as completed Aug 2, 2019
@ghost
Copy link

ghost commented Nov 2, 2019

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 2, 2019
@breathingdust breathingdust removed the needs-triage Waiting for first response or review from a maintainer. label Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/autoscaling Issues and PRs that pertain to the autoscaling service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants